Skip to content

Commit

Permalink
Allow setting SDL audiodriver with s_sdlDriver (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aciz authored Nov 10, 2023
1 parent 9a38daa commit 7771d16
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/client/snd_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ static cvar_t *s_mixOffset;
cvar_t *s_device;
#endif

#if defined(USE_SDL)
cvar_t *s_sdlDriver;
#endif

cvar_t *s_debugStreams;

// fretn
Expand Down Expand Up @@ -2453,6 +2457,11 @@ qboolean S_Base_Init( soundInterface_t *si ) {
"Use \"default\" to let system pick or choose one from \\s_devlist output." );
#endif

#if defined(USE_SDL)
s_sdlDriver = Cvar_Get( "s_sdlDriver", "", CVAR_ARCHIVE_ND | CVAR_LATCH | CVAR_UNSAFE );
Cvar_SetDescription( s_sdlDriver, "Set SDL audio driver, e.g. \"pulseaudio\" or \"pipewire\"" );
#endif

s_debugStreams = Cvar_Get("s_debugStreams", "0", CVAR_TEMP);

// fretn
Expand Down
4 changes: 4 additions & 0 deletions src/client/snd_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ extern cvar_t *s_muteWhenUnfocused;

extern cvar_t *s_testsound;

#if defined(USE_SDL)
extern cvar_t *s_sdlDriver;
#endif

extern float s_volCurrent;

qboolean S_LoadSound( sfx_t *sfx );
Expand Down
7 changes: 7 additions & 0 deletions src/sdl/sdl_snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ qboolean SNDDMA_Init( void )
s_sdlLevelSamps = Cvar_Get( "s_sdlLevelSamps", "0", CVAR_ARCHIVE_ND | CVAR_LATCH );
Cvar_CheckRange( s_sdlLevelSamps, "0", "2", CV_INTEGER );

#if defined(USE_SDL)
if ( s_sdlDriver->string )
{
SDL_setenv("SDL_AUDIODRIVER", s_sdlDriver->string, 0);
}
#endif

Com_Printf( "SDL_Init( SDL_INIT_AUDIO )... " );

if ( SDL_Init( SDL_INIT_AUDIO ) != 0 )
Expand Down

0 comments on commit 7771d16

Please sign in to comment.