From 03f8528315fa46c95991a34f3325d7b33ae5538c Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Sat, 02 May 2020 21:48:36 +0000
Subject: [PATCH] Update source to SDL2 2.0.12
---
source/src/audio/SDL_audio.c | 73 +++++++++++++++++++++++-------------
1 files changed, 46 insertions(+), 27 deletions(-)
diff --git a/source/src/audio/SDL_audio.c b/source/src/audio/SDL_audio.c
index f4999f1..3137493 100644
--- a/source/src/audio/SDL_audio.c
+++ b/source/src/audio/SDL_audio.c
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
- Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -88,6 +88,9 @@
#endif
#if SDL_AUDIO_DRIVER_FUSIONSOUND
&FUSIONSOUND_bootstrap,
+#endif
+#if SDL_AUDIO_DRIVER_OPENSLES
+ &openslES_bootstrap,
#endif
#if SDL_AUDIO_DRIVER_ANDROID
&ANDROIDAUDIO_bootstrap,
@@ -245,12 +248,6 @@
{ /* no-op. */
}
-static int
-SDL_AudioGetPendingBytes_Default(_THIS)
-{
- return 0;
-}
-
static Uint8 *
SDL_AudioGetDeviceBuf_Default(_THIS)
{
@@ -358,7 +355,6 @@
FILL_STUB(BeginLoopIteration);
FILL_STUB(WaitDevice);
FILL_STUB(PlayDevice);
- FILL_STUB(GetPendingBytes);
FILL_STUB(GetDeviceBuf);
FILL_STUB(CaptureFromDevice);
FILL_STUB(FlushCapture);
@@ -651,11 +647,9 @@
}
/* Nothing to do unless we're set up for queueing. */
- if (device->callbackspec.callback == SDL_BufferQueueDrainCallback) {
- current_audio.impl.LockDevice(device);
- retval = ((Uint32) SDL_CountDataQueue(device->buffer_queue)) + current_audio.impl.GetPendingBytes(device);
- current_audio.impl.UnlockDevice(device);
- } else if (device->callbackspec.callback == SDL_BufferQueueFillCallback) {
+ if (device->callbackspec.callback == SDL_BufferQueueDrainCallback ||
+ device->callbackspec.callback == SDL_BufferQueueFillCallback)
+ {
current_audio.impl.LockDevice(device);
retval = (Uint32) SDL_CountDataQueue(device->buffer_queue);
current_audio.impl.UnlockDevice(device);
@@ -695,8 +689,16 @@
SDL_assert(!device->iscapture);
+#if SDL_AUDIO_DRIVER_ANDROID
+ {
+ /* Set thread priority to THREAD_PRIORITY_AUDIO */
+ extern void Android_JNI_AudioSetThreadPriority(int, int);
+ Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
+ }
+#else
/* The audio mixing is always a high priority thread */
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_TIME_CRITICAL);
+#endif
/* Perform any thread setup */
device->threadid = SDL_ThreadID();
@@ -792,8 +794,16 @@
SDL_assert(device->iscapture);
+#if SDL_AUDIO_DRIVER_ANDROID
+ {
+ /* Set thread priority to THREAD_PRIORITY_AUDIO */
+ extern void Android_JNI_AudioSetThreadPriority(int, int);
+ Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
+ }
+#else
/* The audio mixing is always a high priority thread */
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
+#endif
/* Perform any thread setup */
device->threadid = SDL_ThreadID();
@@ -877,8 +887,6 @@
}
}
- current_audio.impl.PrepareToClose(device);
-
current_audio.impl.FlushCapture(device);
current_audio.impl.ThreadDeinit(device);
@@ -940,7 +948,7 @@
}
SDL_zero(current_audio);
- SDL_zero(open_devices);
+ SDL_zeroa(open_devices);
/* Select the proper audio driver */
if (driver_name == NULL) {
@@ -1068,7 +1076,7 @@
return NULL;
}
- if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
+ if (iscapture && !current_audio.impl.HasCaptureSupport) {
SDL_SetError("No capture support");
return NULL;
}
@@ -1222,7 +1230,7 @@
return 0;
}
- if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
+ if (iscapture && !current_audio.impl.HasCaptureSupport) {
SDL_SetError("No capture support");
return 0;
}
@@ -1600,7 +1608,7 @@
SDL_DestroyMutex(current_audio.detectionLock);
SDL_zero(current_audio);
- SDL_zero(open_devices);
+ SDL_zeroa(open_devices);
#ifdef HAVE_LIBSAMPLERATE_H
UnloadLibSampleRate();
@@ -1656,17 +1664,28 @@
return format_list[format_idx][format_idx_sub++];
}
+Uint8
+SDL_SilenceValueForFormat(const SDL_AudioFormat format)
+{
+ switch (format) {
+ /* !!! FIXME: 0x80 isn't perfect for U16, but we can't fit 0x8000 in a
+ !!! FIXME: byte for memset() use. This is actually 0.1953 percent
+ !!! FIXME: off from silence. Maybe just don't use U16. */
+ case AUDIO_U16LSB:
+ case AUDIO_U16MSB:
+ case AUDIO_U8:
+ return 0x80;
+
+ default: break;
+ }
+
+ return 0x00;
+}
+
void
SDL_CalculateAudioSpec(SDL_AudioSpec * spec)
{
- switch (spec->format) {
- case AUDIO_U8:
- spec->silence = 0x80;
- break;
- default:
- spec->silence = 0x00;
- break;
- }
+ spec->silence = SDL_SilenceValueForFormat(spec->format);
spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8;
spec->size *= spec->channels;
spec->size *= spec->samples;
--
Gitblit v1.9.3