mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-08-26 16:41:36 +00:00
Added SDL_SetAppMetadata() (#10404)
Removed duplicate hints SDL_HINT_APP_NAME, SDL_HINT_APP_ID, and SDL_HINT_AUDIO_DEVICE_APP_NAME. Wired up a few things to use the metadata; more to come! Fixes https://github.com/libsdl-org/SDL/issues/4703
This commit is contained in:
@@ -261,18 +261,10 @@ static void JACK_CloseDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
// !!! FIXME: unify this (PulseAudio has a getAppName, Pipewire has a thing, etc
|
||||
// !!! FIXME: unify this (PulseAudio has a getAppName, Pipewire has a thing, etc)
|
||||
static const char *GetJackAppName(void)
|
||||
{
|
||||
const char *retval = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME);
|
||||
if (retval && *retval) {
|
||||
return retval;
|
||||
}
|
||||
retval = SDL_GetHint(SDL_HINT_APP_NAME);
|
||||
if (retval && *retval) {
|
||||
return retval;
|
||||
}
|
||||
return "SDL Application";
|
||||
return SDL_GetAppMetadataProperty(SDL_PROP_APP_METADATA_NAME_STRING);
|
||||
}
|
||||
|
||||
static int JACK_OpenDevice(SDL_AudioDevice *device)
|
||||
|
||||
@@ -1049,13 +1049,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device)
|
||||
const int min_period = PW_MIN_SAMPLES * SPA_MAX(device->spec.freq / PW_BASE_CLOCK_RATE, 1);
|
||||
|
||||
// Get the hints for the application name, icon name, stream name and role
|
||||
app_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME);
|
||||
if (!app_name || *app_name == '\0') {
|
||||
app_name = SDL_GetHint(SDL_HINT_APP_NAME);
|
||||
if (!app_name || *app_name == '\0') {
|
||||
app_name = "SDL Application";
|
||||
}
|
||||
}
|
||||
app_name = SDL_GetAppMetadataProperty(SDL_PROP_APP_METADATA_NAME_STRING);
|
||||
|
||||
icon_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_ICON_NAME);
|
||||
if (!icon_name || *icon_name == '\0') {
|
||||
@@ -1063,7 +1057,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device)
|
||||
}
|
||||
|
||||
// App ID. Default to NULL if not available.
|
||||
app_id = SDL_GetHint(SDL_HINT_APP_ID);
|
||||
app_id = SDL_GetAppMetadataProperty(SDL_PROP_APP_METADATA_IDENTIFIER_STRING);
|
||||
|
||||
stream_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME);
|
||||
if (!stream_name || *stream_name == '\0') {
|
||||
|
||||
@@ -264,34 +264,9 @@ static int load_pulseaudio_syms(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SDL_INLINE int squashVersion(const int major, const int minor, const int patch)
|
||||
{
|
||||
return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF);
|
||||
}
|
||||
|
||||
// Workaround for older pulse: pa_context_new() must have non-NULL appname
|
||||
static const char *getAppName(void)
|
||||
{
|
||||
const char *retval = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME);
|
||||
if (retval && *retval) {
|
||||
return retval;
|
||||
}
|
||||
retval = SDL_GetHint(SDL_HINT_APP_NAME);
|
||||
if (retval && *retval) {
|
||||
return retval;
|
||||
} else {
|
||||
const char *verstr = PULSEAUDIO_pa_get_library_version();
|
||||
retval = "SDL Application"; // the "oh well" default.
|
||||
if (verstr) {
|
||||
int maj, min, patch;
|
||||
if (SDL_sscanf(verstr, "%d.%d.%d", &maj, &min, &patch) == 3) {
|
||||
if (squashVersion(maj, min, patch) >= squashVersion(0, 9, 15)) {
|
||||
retval = NULL; // 0.9.15+ handles NULL correctly.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
return SDL_GetAppMetadataProperty(SDL_PROP_APP_METADATA_NAME_STRING);
|
||||
}
|
||||
|
||||
static void OperationStateChangeCallback(pa_operation *o, void *userdata)
|
||||
|
||||
Reference in New Issue
Block a user