Game Kit: do not allocate BBuffers before initializing the Media Kit

The port pool now being created in BMediaRoster init, we must make sure
the media roster is initialized before doing anything else.

Change-Id: I5a3cc61c993e9be4078772bbf341b637d951d239
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1734
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Adrien Destugues 2019-08-22 18:18:59 +02:00 committed by waddlesplash
parent 478ea25152
commit 759ee24c4c

View File

@ -146,6 +146,9 @@ BGameSoundDevice::CreateBuffer(gs_id* sound, const gs_audio_format* format,
if (frames <= 0 || !sound) if (frames <= 0 || !sound)
return B_BAD_VALUE; return B_BAD_VALUE;
// Make sure BMediaRoster is created before we AllocateSound()
BMediaRoster* roster = BMediaRoster::Roster();
status_t err = B_MEDIA_TOO_MANY_BUFFERS; status_t err = B_MEDIA_TOO_MANY_BUFFERS;
int32 position = AllocateSound(); int32 position = AllocateSound();
@ -153,7 +156,7 @@ BGameSoundDevice::CreateBuffer(gs_id* sound, const gs_audio_format* format,
fSounds[position] = new SimpleSoundBuffer(format, data, frames); fSounds[position] = new SimpleSoundBuffer(format, data, frames);
media_node systemMixer; media_node systemMixer;
BMediaRoster::Roster()->GetAudioMixer(&systemMixer); roster->GetAudioMixer(&systemMixer);
err = fSounds[position]->Connect(&systemMixer); err = fSounds[position]->Connect(&systemMixer);
} }
@ -171,6 +174,9 @@ BGameSoundDevice::CreateBuffer(gs_id* sound, const void* object,
if (!object || !sound) if (!object || !sound)
return B_BAD_VALUE; return B_BAD_VALUE;
// Make sure BMediaRoster is created before we AllocateSound()
BMediaRoster* roster = BMediaRoster::Roster();
status_t err = B_MEDIA_TOO_MANY_BUFFERS; status_t err = B_MEDIA_TOO_MANY_BUFFERS;
int32 position = AllocateSound(); int32 position = AllocateSound();
@ -179,7 +185,7 @@ BGameSoundDevice::CreateBuffer(gs_id* sound, const void* object,
inBufferFrameCount, inBufferCount); inBufferFrameCount, inBufferCount);
media_node systemMixer; media_node systemMixer;
BMediaRoster::Roster()->GetAudioMixer(&systemMixer); roster->GetAudioMixer(&systemMixer);
err = fSounds[position]->Connect(&systemMixer); err = fSounds[position]->Connect(&systemMixer);
} }