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.
This commit is contained in:
Adrien Destugues 2014-12-11 17:17:55 +01:00
parent bf57c148f7
commit 042bb68ed6
3 changed files with 14 additions and 7 deletions

View File

@ -343,7 +343,7 @@ GameSoundBuffer::UpdateMods()
}
void
void
GameSoundBuffer::Reset()
{
fGain = 1.0;

View File

@ -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();
}

View File

@ -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));
}