Skip to content

Display and control your Android device

Add app name SDL hint

Colin Kinlochd2cc930975a8
diff --git a/app/src/compat.h b/app/src/compat.h
index 1995d384..296d1a9f 100644
--- a/app/src/compat.h
+++ b/app/src/compat.h
@@ -75,6 +75,14 @@
# define SCRCPY_SDL_HAS_THREAD_PRIORITY_TIME_CRITICAL
#endif
+#if SDL_VERSION_ATLEAST(2, 0, 18)
+# define SCRCPY_SDL_HAS_HINT_APP_NAME
+#endif
+
+#if SDL_VERSION_ATLEAST(2, 0, 14)
+# define SCRCPY_SDL_HAS_HINT_AUDIO_DEVICE_APP_NAME
+#endif
+
#ifndef HAVE_STRDUP
char *strdup(const char *s);
#endif
diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c
index 4d08e667..a4c8c340 100644
--- a/app/src/scrcpy.c
+++ b/app/src/scrcpy.c
@@ -107,6 +107,17 @@ sdl_set_hints(const char *render_driver) {
LOGW("Could not set render driver");
}
+ // App name used in various contexts (such as PulseAudio)
+#if defined(SCRCPY_SDL_HAS_HINT_APP_NAME)
+ if (!SDL_SetHint(SDL_HINT_APP_NAME, "scrcpy")) {
+ LOGW("Could not set app name");
+ }
+#elif defined(SCRCPY_SDL_HAS_HINT_AUDIO_DEVICE_APP_NAME)
+ if (!SDL_SetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME, "scrcpy")) {
+ LOGW("Could not set audio device app name");
+ }
+#endif
+
// Linear filtering
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1")) {
LOGW("Could not enable linear filtering");