Skip to content

Commit

Permalink
Alt+Tab Keep Sound Playing (Windows)
Browse files Browse the repository at this point in the history
Added s_alttabmute CVAR with default value 1. Setting this CVAR to 0
will keep sound playing when game is minimized or out of focus. (Windows
only)
  • Loading branch information
p5yc0runn3r committed Jan 11, 2015
1 parent aa22beb commit 2971716
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions code/client/snd_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ cvar_t *s_dev;
cvar_t *s_show;
cvar_t *s_mixahead;
cvar_t *s_mixPreStep;
cvar_t *s_alttabmute;

loopSound_t loopSounds[MAX_GENTITIES];
static channel_t *freelist = NULL;
Expand Down Expand Up @@ -1484,6 +1485,7 @@ qboolean S_Base_Init( soundInterface_t *si ) {
s_show = Cvar_Get ("s_show", "0", CVAR_CHEAT);
s_testsound = Cvar_Get ("s_testsound", "0", CVAR_CHEAT);
s_dev = Cvar_Get ("s_dev", "", CVAR_ARCHIVE);
s_alttabmute = Cvar_Get ("s_alttabmute", "1", CVAR_ARCHIVE);

Cmd_AddCommand( "s_devlist", S_dmaHD_devlist );

Expand Down
3 changes: 3 additions & 0 deletions code/win32/win_snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static LPGUID g_dsguid = NULL;

extern cvar_t *s_khz;
extern cvar_t *s_dev;
extern cvar_t *s_alttabmute;

static const char *DSoundError( int error ) {
switch ( error ) {
Expand Down Expand Up @@ -293,6 +294,7 @@ int SNDDMA_InitDS ()

// Micah: take advantage of 2D hardware.if available.
dsbuf.dwFlags = DSBCAPS_LOCHARDWARE;
if (s_alttabmute->integer == 0) dsbuf.dwFlags |= DSBCAPS_STICKYFOCUS; // Keep playing when out of focus.
if (use8) {
dsbuf.dwFlags |= DSBCAPS_GETCURRENTPOSITION2;
}
Expand All @@ -312,6 +314,7 @@ int SNDDMA_InitDS ()
if (use8) {
dsbuf.dwFlags |= DSBCAPS_GETCURRENTPOSITION2;
}
if (s_alttabmute->integer == 0) dsbuf.dwFlags |= DSBCAPS_STICKYFOCUS; // Keep playing when out of focus.
if (DS_OK != pDS->lpVtbl->CreateSoundBuffer(pDS, &dsbuf, &pDSBuf, NULL)) {
Com_Printf( "failed\n" );
SNDDMA_Shutdown ();
Expand Down

0 comments on commit 2971716

Please sign in to comment.