audio: PlayDevice() should return an error code.

Higher level code treats errors as fatal and disconnects the device.
This commit is contained in:
Ryan C. Gordon
2023-08-30 19:16:39 -04:00
parent a94d724f17
commit 4e0c7c91fc
23 changed files with 73 additions and 52 deletions

View File

@@ -36,7 +36,7 @@ static Uint8 *EMSCRIPTENAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_
return device->hidden->mixbuf;
}
static void EMSCRIPTENAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
static int EMSCRIPTENAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
{
const int framelen = (SDL_AUDIO_BITSIZE(device->spec.format) / 8) * device->spec.channels;
MAIN_THREAD_EM_ASM({
@@ -53,6 +53,7 @@ static void EMSCRIPTENAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buf
}
}
}, buffer, buffer_size / framelen);
return 0;
}