Skip to content

Commit

Permalink
Audio|Client: Try other music sources if playback fails
Browse files Browse the repository at this point in the history
Although the preferred source may be available playback may still
fail for some reason (e.g., the preferred source is CD audio yet
the specified track number does not exist).

If playback does fail, then continue to try all sources according
to the user's preferred order.
  • Loading branch information
danij-deng committed Nov 23, 2014
1 parent 360e4e2 commit 33e7f2b
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions doomsday/client/src/audio/s_mus.cpp
Expand Up @@ -362,7 +362,8 @@ int Mus_Start(Record const *rec, bool looped)
case MUSP_CD:
if(Mus_GetCD(rec))
{
return AudioDriver_Music_PlayCDTrack(Mus_GetCD(rec), looped);
if(AudioDriver_Music_PlayCDTrack(Mus_GetCD(rec), looped))
return true;
}
break;

Expand All @@ -374,7 +375,8 @@ int Mus_Start(Record const *rec, bool looped)
<< rec->gets("id") << NativePath(Str_Text(&path)).pretty();

// Its an external file.
return AudioDriver_Music_PlayFile(Str_Text(&path), looped);
if(AudioDriver_Music_PlayFile(Str_Text(&path), looped))
return true;
}

// Next, try non-MUS lumps.
Expand All @@ -385,18 +387,13 @@ int Mus_Start(Record const *rec, bool looped)
case MUSP_MUS:
if(AudioDriver_Music_Available())
{
String const lumpName = rec->gets("lumpName");
lumpnum_t lumpNum = App_FileSystem().lumpNumForName(lumpName);
if(lumpNum >= 0)
{
int result = Mus_StartLump(lumpNum, looped, canPlayMUS);
if(result < 0) break;
return result;
}
lumpnum_t const lumpNum = App_FileSystem().lumpNumForName(rec->gets("lumpName"));
if(Mus_StartLump(lumpNum, looped, canPlayMUS) == 1)
return true;
}
break;

default: DENG_ASSERT(!"Mus_Start: Invalid value for order[i]"); break;
default: DENG2_ASSERT(!"Mus_Start: Invalid value for order[i]"); break;
}
}

Expand Down

0 comments on commit 33e7f2b

Please sign in to comment.