From 042bb68ed612cca921a3bc119e56f303f7e11899 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Thu, 11 Dec 2014 17:17:55 +0100 Subject: [PATCH] BGameSound: make Worms Armageddon sounds work * When the endianness is not intialized, assume B_MEDIA_HOST_ENDIAN. This is probably what was meant (and this is what Worms Armageddon means). * Move creation of the media nodes back to the initialisation instead of StartPlaying, otherwise an extra node is created each time the sound is played. --- src/kits/game/GameSoundBuffer.cpp | 2 +- src/kits/game/GameSoundDevice.cpp | 13 ++++++++----- src/kits/game/SimpleGameSound.cpp | 6 +++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/kits/game/GameSoundBuffer.cpp b/src/kits/game/GameSoundBuffer.cpp index 58bfcfbd23..f52cde622d 100644 --- a/src/kits/game/GameSoundBuffer.cpp +++ b/src/kits/game/GameSoundBuffer.cpp @@ -343,7 +343,7 @@ GameSoundBuffer::UpdateMods() } - void +void GameSoundBuffer::Reset() { fGain = 1.0; diff --git a/src/kits/game/GameSoundDevice.cpp b/src/kits/game/GameSoundDevice.cpp index 9202677f5f..d295d5cbfb 100644 --- a/src/kits/game/GameSoundDevice.cpp +++ b/src/kits/game/GameSoundDevice.cpp @@ -151,7 +151,10 @@ BGameSoundDevice::CreateBuffer(gs_id* sound, const gs_audio_format* format, if (position >= 0) { fSounds[position] = new SimpleSoundBuffer(format, data, frames); - err = B_OK; + + media_node systemMixer; + BMediaRoster::Roster()->GetAudioMixer(&systemMixer); + err = fSounds[position]->Connect(&systemMixer); } if (err == B_OK) @@ -174,7 +177,10 @@ BGameSoundDevice::CreateBuffer(gs_id* sound, const void* object, if (position >= 0) { fSounds[position] = new StreamingSoundBuffer(format, object, inBufferFrameCount, inBufferCount); - err = B_OK; + + media_node systemMixer; + BMediaRoster::Roster()->GetAudioMixer(&systemMixer); + err = fSounds[position]->Connect(&systemMixer); } if (err == B_OK) @@ -224,9 +230,6 @@ BGameSoundDevice::StartPlaying(gs_id sound) return B_BAD_VALUE; if (!fSounds[sound - 1]->IsPlaying()) { - media_node systemMixer; - BMediaRoster::Roster()->GetAudioMixer(&systemMixer); - fSounds[sound - 1]->Connect(&systemMixer); // tell the producer to start playing the sound return fSounds[sound - 1]->StartPlaying(); } diff --git a/src/kits/game/SimpleGameSound.cpp b/src/kits/game/SimpleGameSound.cpp index 065dcc521c..9cfdbe5a53 100644 --- a/src/kits/game/SimpleGameSound.cpp +++ b/src/kits/game/SimpleGameSound.cpp @@ -54,12 +54,16 @@ BSimpleGameSound::BSimpleGameSound(const void *inData, size_t inFrameCount, if (InitCheck() != B_OK) return; + gs_audio_format actual = *format; + if (actual.byte_order == 0) + actual.byte_order = B_MEDIA_HOST_ENDIAN; + size_t frameSize = get_sample_size(format->format) * format->channel_count; uchar * data = new uchar[inFrameCount * frameSize]; memcpy(data, inData, inFrameCount * frameSize); - SetInitError(Init(data, inFrameCount, format)); + SetInitError(Init(data, inFrameCount, &actual)); }