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:
@@ -343,7 +343,7 @@ GameSoundBuffer::UpdateMods()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GameSoundBuffer::Reset()
|
GameSoundBuffer::Reset()
|
||||||
{
|
{
|
||||||
fGain = 1.0;
|
fGain = 1.0;
|
||||||
|
|||||||
@@ -151,7 +151,10 @@ BGameSoundDevice::CreateBuffer(gs_id* sound, const gs_audio_format* format,
|
|||||||
|
|
||||||
if (position >= 0) {
|
if (position >= 0) {
|
||||||
fSounds[position] = new SimpleSoundBuffer(format, data, frames);
|
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)
|
if (err == B_OK)
|
||||||
@@ -174,7 +177,10 @@ BGameSoundDevice::CreateBuffer(gs_id* sound, const void* object,
|
|||||||
if (position >= 0) {
|
if (position >= 0) {
|
||||||
fSounds[position] = new StreamingSoundBuffer(format, object,
|
fSounds[position] = new StreamingSoundBuffer(format, object,
|
||||||
inBufferFrameCount, inBufferCount);
|
inBufferFrameCount, inBufferCount);
|
||||||
err = B_OK;
|
|
||||||
|
media_node systemMixer;
|
||||||
|
BMediaRoster::Roster()->GetAudioMixer(&systemMixer);
|
||||||
|
err = fSounds[position]->Connect(&systemMixer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
@@ -224,9 +230,6 @@ BGameSoundDevice::StartPlaying(gs_id sound)
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
if (!fSounds[sound - 1]->IsPlaying()) {
|
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
|
// tell the producer to start playing the sound
|
||||||
return fSounds[sound - 1]->StartPlaying();
|
return fSounds[sound - 1]->StartPlaying();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,12 +54,16 @@ BSimpleGameSound::BSimpleGameSound(const void *inData, size_t inFrameCount,
|
|||||||
if (InitCheck() != B_OK)
|
if (InitCheck() != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
gs_audio_format actual = *format;
|
||||||
|
if (actual.byte_order == 0)
|
||||||
|
actual.byte_order = B_MEDIA_HOST_ENDIAN;
|
||||||
|
|
||||||
size_t frameSize
|
size_t frameSize
|
||||||
= get_sample_size(format->format) * format->channel_count;
|
= get_sample_size(format->format) * format->channel_count;
|
||||||
uchar * data = new uchar[inFrameCount * frameSize];
|
uchar * data = new uchar[inFrameCount * frameSize];
|
||||||
memcpy(data, inData, inFrameCount * frameSize);
|
memcpy(data, inData, inFrameCount * frameSize);
|
||||||
|
|
||||||
SetInitError(Init(data, inFrameCount, format));
|
SetInitError(Init(data, inFrameCount, &actual));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user