We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4801

Summary: Make pulseaudio stream description configurable
Product: SDL Reporter: bugzilla.libsdl.org
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2 Keywords: target-2.0.14
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   

Description bugzilla.libsdl.org 2019-09-11 17:24:04 UTC
Currently, SDL has a hard-coded description for its PulseAudio stream:

    h->stream = PULSEAUDIO_pa_stream_new(
        h->context,
        "Simple DirectMedia Layer", /* stream description */
        &paspec,    /* sample format spec */
        &pacmap     /* channel map */
    );

(from src/audio/pulseaudio/SDL_pulseaudio.c)

This stream description is user-visible. For example, it is how streams are identified in pavucontrol's "Playback" tab. So if a user currently wishes to adjust the playback volume of an SDL-based application using pavucontrol, then they need to know that the application's audio stream will be identified as "Simple DirectMedia Layer".

This is not a great user experience. It would be better if the application could tell SDL to use a specific name for the audio stream, one that has more meaning to the user than "Simple DirectMedia Layer".
Comment 1 Ryan C. Gordon 2020-03-23 03:36:36 UTC
I've wanted to do this for awhile! I'll try to plug this in for 2.0.14.

--ryan.
Comment 2 Ryan C. Gordon 2020-05-04 02:29:36 UTC
As of https://hg.libsdl.org/SDL/rev/4d04f91e1776, you can set hints before opening the audio device to pass this info to PulseAudio...

    SDL_SetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME, "My Game 2: The Revenge");

    // Set up the thing that plays all the game's sounds...
    SDL_SetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME, "Game audio");
    dev = SDL_OpenAudioDevice(...);

    // We also open a USB headset that is only used for multiplayer chat.
    SDL_SetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME, "Team VoIP chat");
    dev2 = SDL_OpenAudioDevice(...);


...this can also be used from the command line for apps that don't supply this information...

    SDL_AUDIO_DEVICE_STREAM_NAME="My Music Track" SDL_AUDIO_DEVICE_APP_NAME="My Media Player" ./playsound abc.mp3

...in SDL 2.1, we'll likely make this part of the formal API, but I think this as far as it will got for 2.0.

--ryan.
Comment 3 bugzilla.libsdl.org 2020-05-04 20:49:13 UTC
Awesome, thanks for this!