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

and make SDL_PriveAudioData more private
This commit is contained in:
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
#include "../SDL_sysaudio.h"
#include "../SDL_audio_c.h"
#include "../../core/android/SDL_android.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 */
#if 0
#define LOGI(...) SDL_Log(__VA_ARGS__);

View File

@ -20,28 +20,21 @@
*/
#include "SDL_internal.h"
#ifndef SDL_aaudio_h
#define SDL_aaudio_h
#ifndef SDL_aaudio_h_
#define SDL_aaudio_h_
#include "../SDL_sysaudio.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;
};
#ifdef SDL_AUDIO_DRIVER_AAUDIO
void aaudio_ResumeDevices(void);
void aaudio_PauseDevices(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 */
#include "../SDL_sysaudio.h"
#include "../SDL_audio_c.h"
#include "SDL_androidaudio.h"
#include "../../core/android/SDL_android.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 *captureDevice = NULL;
@ -208,9 +215,4 @@ void ANDROIDAUDIO_ResumeDevices(void)
}
}
#else
void ANDROIDAUDIO_ResumeDevices(void) {}
void ANDROIDAUDIO_PauseDevices(void) {}
#endif /* SDL_AUDIO_DRIVER_ANDROID */

View File

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

View File

@ -26,16 +26,26 @@
https://googlesamples.github.io/android-audio-high-performance/guides/opensl_es.html
*/
#include "../SDL_sysaudio.h"
#include "../SDL_audio_c.h"
#include "../../core/android/SDL_android.h"
#include "SDL_openslES.h"
/* for native audio */
#include "../../core/android/SDL_android.h"
#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.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
#define LOG_TAG "SDL_openslES"
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)

View File

@ -20,22 +20,19 @@
*/
#include "SDL_internal.h"
#ifndef SDL_openslesaudio_h
#define SDL_openslesaudio_h
#ifndef SDL_openslesaudio_h_
#define SDL_openslesaudio_h_
#include "../SDL_sysaudio.h"
#define NUM_BUFFERS 2 /* -- Don't lower this! */
struct SDL_PrivateAudioData
{
Uint8 *mixbuff;
int next_buffer;
Uint8 *pmixbuff[NUM_BUFFERS];
SDL_Semaphore *playsem;
};
#ifdef SDL_AUDIO_DRIVER_OPENSLES
void openslES_ResumeDevices(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 "../../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)
extern void ANDROIDAUDIO_ResumeDevices(void);
extern void ANDROIDAUDIO_PauseDevices(void);
#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
#include "../../audio/android/SDL_androidaudio.h"
#include "../../audio/aaudio/SDL_aaudio.h"
#include "../../audio/openslES/SDL_openslES.h"
/* Number of 'type' events in the event queue */
static int SDL_NumberOfEvents(Uint32 type)