Skip to content

Commit

Permalink
Fixed|Audio: Playing a music file
Browse files Browse the repository at this point in the history
When playing a music file (e.g., OGG), prioritize the audio plugin's
PlayFile function. Apparently FMOD is having problems playing an OGG
stream from memory (or there's another bug in Doomsday's music code).
  • Loading branch information
skyjake committed Aug 7, 2016
1 parent 5a14b24 commit 7b9aa18
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions doomsday/apps/client/src/audio/base/system.cpp
Expand Up @@ -679,30 +679,31 @@ DENG2_PIMPL(System)
{
std::unique_ptr<FileHandle> hndl(&App_FileSystem().openFile(path, "rb"));

auto didPlay = forAllInterfaces(AUDIO_IMUSIC, [this, &hndl, &looped] (void *ifs)
auto didPlay = forAllInterfaces(AUDIO_IMUSIC, [this, &path, &hndl, &looped] (void *ifs)
{
auto *iMusic = (audiointerface_music_t *) ifs;

// Does this interface offer buffered playback?
if(iMusic->Play && iMusic->SongBuffer)
{
// Buffer the data using the driver's own facility.
dsize const len = hndl->length();
hndl->read((duint8 *) iMusic->SongBuffer(len), len);

return iMusic->Play(looped);
}
// Does this interface offer playback from a native file?
else if(iMusic->PlayFile)
if(iMusic->PlayFile)
{
// Write the data to disk and play from there.
File &file = App::rootFolder().replaceFile(composeMusicBufferFilename());
File &file = App::rootFolder().replaceFile(composeMusicBufferFilename(path.fileNameExtension()));
Block buf(hndl->length());
hndl->read(buf.data(), buf.size());
file << buf;
file.flush();
return iMusic->PlayFile(file.as<NativeFile>().nativePath().toUtf8(), looped);
}
else if(iMusic->Play && iMusic->SongBuffer)
{
// Buffer the data using the driver's own facility.
dsize const len = hndl->length();
hndl->read((duint8 *) iMusic->SongBuffer(len), len);

return iMusic->Play(looped);
}
// Does this interface offer playback from a native file?
else
return 0; // Continue.
});

Expand Down

0 comments on commit 7b9aa18

Please sign in to comment.