mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-16 23:06:03 +00:00
android: Reworked audio backends for SDL3 audio API.
This involved moving an `#ifdef` out of SDL_audio.c for thread priority, so the default ThreadInit now does the usual stuff for non-Android platforms, the Android platforms provide an implementatin of ThreadInit with their side of the `#ifdef` and other platforms that implement ThreadInit incorporated the appropriate code...which is why WASAPI is touched in here. The Android bits compile, but have not been tested, and there was some reworkings in the Java bits, so this might need some further fixes still.
This commit is contained in:
@@ -25,8 +25,6 @@
|
||||
#include "../thread/SDL_systhread.h"
|
||||
#include "../SDL_utils_c.h"
|
||||
|
||||
extern void Android_JNI_AudioSetThreadPriority(int, int); // we need this on Android in the audio device threads.
|
||||
|
||||
// Available audio drivers
|
||||
static const AudioBootStrap *const bootstrap[] = {
|
||||
#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO
|
||||
@@ -412,7 +410,6 @@ void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device)
|
||||
|
||||
// stubs for audio drivers that don't need a specific entry point...
|
||||
|
||||
static void SDL_AudioThreadInit_Default(SDL_AudioDevice *device) { /* no-op. */ }
|
||||
static void SDL_AudioThreadDeinit_Default(SDL_AudioDevice *device) { /* no-op. */ }
|
||||
static void SDL_AudioWaitDevice_Default(SDL_AudioDevice *device) { /* no-op. */ }
|
||||
static void SDL_AudioPlayDevice_Default(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size) { /* no-op. */ }
|
||||
@@ -422,6 +419,11 @@ static void SDL_AudioCloseDevice_Default(SDL_AudioDevice *device) { /* no-op. */
|
||||
static void SDL_AudioDeinitialize_Default(void) { /* no-op. */ }
|
||||
static void SDL_AudioFreeDeviceHandle_Default(SDL_AudioDevice *device) { /* no-op. */ }
|
||||
|
||||
static void SDL_AudioThreadInit_Default(SDL_AudioDevice *device)
|
||||
{
|
||||
SDL_SetThreadPriority(device->iscapture ? SDL_THREAD_PRIORITY_HIGH : SDL_THREAD_PRIORITY_TIME_CRITICAL);
|
||||
}
|
||||
|
||||
static void SDL_AudioDetectDevices_Default(SDL_AudioDevice **default_output, SDL_AudioDevice **default_capture)
|
||||
{
|
||||
// you have to write your own implementation if these assertions fail.
|
||||
@@ -679,15 +681,6 @@ void SDL_AudioThreadFinalize(SDL_AudioDevice *device)
|
||||
void SDL_OutputAudioThreadSetup(SDL_AudioDevice *device)
|
||||
{
|
||||
SDL_assert(!device->iscapture);
|
||||
|
||||
// The audio mixing is always a high priority thread
|
||||
#ifdef SDL_AUDIO_DRIVER_ANDROID
|
||||
Android_JNI_AudioSetThreadPriority(SDL_FALSE, device->id);
|
||||
#else
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_TIME_CRITICAL);
|
||||
#endif
|
||||
|
||||
// Perform any thread setup
|
||||
current_audio.impl.ThreadInit(device);
|
||||
}
|
||||
|
||||
@@ -781,14 +774,6 @@ static int SDLCALL OutputAudioThread(void *devicep) // thread entry point
|
||||
void SDL_CaptureAudioThreadSetup(SDL_AudioDevice *device)
|
||||
{
|
||||
SDL_assert(device->iscapture);
|
||||
|
||||
// Audio capture is always a high priority thread (!!! FIXME: _should_ it be?)
|
||||
#ifdef SDL_AUDIO_DRIVER_ANDROID
|
||||
Android_JNI_AudioSetThreadPriority(SDL_TRUE, device->id);
|
||||
#else
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
||||
#endif
|
||||
|
||||
current_audio.impl.ThreadInit(device);
|
||||
}
|
||||
|
||||
@@ -1068,7 +1053,6 @@ int SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid, SDL_AudioSpec *spec)
|
||||
|
||||
if ((devid == 0) && is_default) {
|
||||
return SDL_SetError("No default audio device available");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_AudioDevice *device = ObtainPhysicalAudioDevice(devid);
|
||||
|
Reference in New Issue
Block a user