Android: use the headers to have the audio pause/resume definitions

and make SDL_PriveAudioData more private
main
Sylvain 2023-05-10 09:31:29 +02:00 committed by Sylvain Becker
parent 28f891ad0a
commit 6d9ccbb3c7
7 changed files with 73 additions and 81 deletions

View File

@ -22,10 +22,27 @@
#ifdef SDL_AUDIO_DRIVER_AAUDIO #ifdef SDL_AUDIO_DRIVER_AAUDIO
#include "../SDL_sysaudio.h"
#include "../SDL_audio_c.h" #include "../SDL_audio_c.h"
#include "../../core/android/SDL_android.h"
#include "SDL_aaudio.h" #include "SDL_aaudio.h"
#include "../../core/android/SDL_android.h"
#include <stdbool.h>
#include <aaudio/AAudio.h>
struct SDL_PrivateAudioData
{
AAudioStream *stream;
/* Raw mixing buffer */
Uint8 *mixbuf;
int mixlen;
int frame_size;
/* Resume device if it was paused automatically */
int resume;
};
/* Debug */ /* Debug */
#if 0 #if 0
#define LOGI(...) SDL_Log(__VA_ARGS__); #define LOGI(...) SDL_Log(__VA_ARGS__);

View File

@ -20,28 +20,21 @@
*/ */
#include "SDL_internal.h" #include "SDL_internal.h"
#ifndef SDL_aaudio_h #ifndef SDL_aaudio_h_
#define SDL_aaudio_h #define SDL_aaudio_h_
#include "../SDL_sysaudio.h" #ifdef SDL_AUDIO_DRIVER_AAUDIO
#include <stdbool.h>
#include <aaudio/AAudio.h>
struct SDL_PrivateAudioData
{
AAudioStream *stream;
/* Raw mixing buffer */
Uint8 *mixbuf;
int mixlen;
int frame_size;
/* Resume device if it was paused automatically */
int resume;
};
void aaudio_ResumeDevices(void); void aaudio_ResumeDevices(void);
void aaudio_PauseDevices(void); void aaudio_PauseDevices(void);
SDL_bool aaudio_DetectBrokenPlayState(void); SDL_bool aaudio_DetectBrokenPlayState(void);
#endif /* SDL_aaudio_h */ #else
static void aaudio_ResumeDevices(void) {}
static void aaudio_PauseDevices(void) {}
static SDL_bool aaudio_DetectBrokenPlayState(void) { return SDL_FALSE; }
#endif
#endif /* SDL_aaudio_h_ */

View File

@ -24,13 +24,20 @@
/* Output audio to Android */ /* Output audio to Android */
#include "../SDL_sysaudio.h"
#include "../SDL_audio_c.h" #include "../SDL_audio_c.h"
#include "SDL_androidaudio.h" #include "SDL_androidaudio.h"
#include "../../core/android/SDL_android.h" #include "../../core/android/SDL_android.h"
#include <android/log.h> #include <android/log.h>
struct SDL_PrivateAudioData
{
/* Resume device if it was paused automatically */
int resume;
};
static SDL_AudioDevice *audioDevice = NULL; static SDL_AudioDevice *audioDevice = NULL;
static SDL_AudioDevice *captureDevice = NULL; static SDL_AudioDevice *captureDevice = NULL;
@ -208,9 +215,4 @@ void ANDROIDAUDIO_ResumeDevices(void)
} }
} }
#else
void ANDROIDAUDIO_ResumeDevices(void) {}
void ANDROIDAUDIO_PauseDevices(void) {}
#endif /* SDL_AUDIO_DRIVER_ANDROID */ #endif /* SDL_AUDIO_DRIVER_ANDROID */

View File

@ -23,15 +23,16 @@
#ifndef SDL_androidaudio_h_ #ifndef SDL_androidaudio_h_
#define SDL_androidaudio_h_ #define SDL_androidaudio_h_
#include "../SDL_sysaudio.h" #ifdef SDL_AUDIO_DRIVER_ANDROID
struct SDL_PrivateAudioData
{
/* Resume device if it was paused automatically */
int resume;
};
void ANDROIDAUDIO_ResumeDevices(void); void ANDROIDAUDIO_ResumeDevices(void);
void ANDROIDAUDIO_PauseDevices(void); void ANDROIDAUDIO_PauseDevices(void);
#else
static void ANDROIDAUDIO_ResumeDevices(void) {}
static void ANDROIDAUDIO_PauseDevices(void) {}
#endif
#endif /* SDL_androidaudio_h_ */ #endif /* SDL_androidaudio_h_ */

View File

@ -26,16 +26,26 @@
https://googlesamples.github.io/android-audio-high-performance/guides/opensl_es.html https://googlesamples.github.io/android-audio-high-performance/guides/opensl_es.html
*/ */
#include "../SDL_sysaudio.h"
#include "../SDL_audio_c.h" #include "../SDL_audio_c.h"
#include "../../core/android/SDL_android.h"
#include "SDL_openslES.h" #include "SDL_openslES.h"
/* for native audio */ #include "../../core/android/SDL_android.h"
#include <SLES/OpenSLES.h> #include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h> #include <SLES/OpenSLES_Android.h>
#include <android/log.h> #include <android/log.h>
#define NUM_BUFFERS 2 /* -- Don't lower this! */
struct SDL_PrivateAudioData
{
Uint8 *mixbuff;
int next_buffer;
Uint8 *pmixbuff[NUM_BUFFERS];
SDL_Semaphore *playsem;
};
#if 0 #if 0
#define LOG_TAG "SDL_openslES" #define LOG_TAG "SDL_openslES"
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)

View File

@ -20,22 +20,19 @@
*/ */
#include "SDL_internal.h" #include "SDL_internal.h"
#ifndef SDL_openslesaudio_h #ifndef SDL_openslesaudio_h_
#define SDL_openslesaudio_h #define SDL_openslesaudio_h_
#include "../SDL_sysaudio.h" #ifdef SDL_AUDIO_DRIVER_OPENSLES
#define NUM_BUFFERS 2 /* -- Don't lower this! */
struct SDL_PrivateAudioData
{
Uint8 *mixbuff;
int next_buffer;
Uint8 *pmixbuff[NUM_BUFFERS];
SDL_Semaphore *playsem;
};
void openslES_ResumeDevices(void); void openslES_ResumeDevices(void);
void openslES_PauseDevices(void); void openslES_PauseDevices(void);
#endif /* SDL_openslesaudio_h */ #else
static void openslES_ResumeDevices(void) {}
static void openslES_PauseDevices(void) {}
#endif
#endif /* SDL_openslesaudio_h_ */

View File

@ -28,38 +28,10 @@
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
#include "../../events/SDL_events_c.h" #include "../../events/SDL_events_c.h"
/* Can't include sysaudio "../../audio/android/SDL_androidaudio.h"
* because of THIS redefinition */
#if !defined(SDL_AUDIO_DISABLED) && defined(SDL_AUDIO_DRIVER_ANDROID) #include "../../audio/android/SDL_androidaudio.h"
extern void ANDROIDAUDIO_ResumeDevices(void); #include "../../audio/aaudio/SDL_aaudio.h"
extern void ANDROIDAUDIO_PauseDevices(void); #include "../../audio/openslES/SDL_openslES.h"
#else
static void ANDROIDAUDIO_ResumeDevices(void) {}
static void ANDROIDAUDIO_PauseDevices(void) {}
#endif
#if !defined(SDL_AUDIO_DISABLED) && defined(SDL_AUDIO_DRIVER_OPENSLES)
extern void openslES_ResumeDevices(void);
extern void openslES_PauseDevices(void);
#else
static void openslES_ResumeDevices(void)
{
}
static void openslES_PauseDevices(void) {}
#endif
#if !defined(SDL_AUDIO_DISABLED) && defined(SDL_AUDIO_DRIVER_AAUDIO)
extern void aaudio_ResumeDevices(void);
extern void aaudio_PauseDevices(void);
SDL_bool aaudio_DetectBrokenPlayState(void);
#else
static void aaudio_ResumeDevices(void)
{
}
static void aaudio_PauseDevices(void) {}
static SDL_bool aaudio_DetectBrokenPlayState(void) { return SDL_FALSE; }
#endif
/* Number of 'type' events in the event queue */ /* Number of 'type' events in the event queue */
static int SDL_NumberOfEvents(Uint32 type) static int SDL_NumberOfEvents(Uint32 type)