opensles: Fixed capitalization to match other SDL backends.

This commit is contained in:
Ryan C. Gordon
2023-10-18 13:57:32 -04:00
parent 34914bfb49
commit 442e84916a
3 changed files with 50 additions and 50 deletions

View File

@@ -55,7 +55,7 @@ static const AudioBootStrap *const bootstrap[] = {
&AAUDIO_bootstrap, &AAUDIO_bootstrap,
#endif #endif
#ifdef SDL_AUDIO_DRIVER_OPENSLES #ifdef SDL_AUDIO_DRIVER_OPENSLES
&openslES_bootstrap, &OPENSLES_bootstrap,
#endif #endif
#ifdef SDL_AUDIO_DRIVER_ANDROID #ifdef SDL_AUDIO_DRIVER_ANDROID
&ANDROIDAUDIO_bootstrap, &ANDROIDAUDIO_bootstrap,

View File

@@ -338,7 +338,7 @@ extern AudioBootStrap COREAUDIO_bootstrap;
extern AudioBootStrap DISKAUDIO_bootstrap; extern AudioBootStrap DISKAUDIO_bootstrap;
extern AudioBootStrap DUMMYAUDIO_bootstrap; extern AudioBootStrap DUMMYAUDIO_bootstrap;
extern AudioBootStrap AAUDIO_bootstrap; extern AudioBootStrap AAUDIO_bootstrap;
extern AudioBootStrap openslES_bootstrap; // !!! FIXME: capitalize this to match the others extern AudioBootStrap OPENSLES_bootstrap;
extern AudioBootStrap ANDROIDAUDIO_bootstrap; extern AudioBootStrap ANDROIDAUDIO_bootstrap;
extern AudioBootStrap PS2AUDIO_bootstrap; extern AudioBootStrap PS2AUDIO_bootstrap;
extern AudioBootStrap PSPAUDIO_bootstrap; extern AudioBootStrap PSPAUDIO_bootstrap;

View File

@@ -108,7 +108,7 @@ static const char *sldevaudioplayerstr = "SLES Audio Player";
#define SLES_DEV_AUDIO_RECORDER sldevaudiorecorderstr #define SLES_DEV_AUDIO_RECORDER sldevaudiorecorderstr
#define SLES_DEV_AUDIO_PLAYER sldevaudioplayerstr #define SLES_DEV_AUDIO_PLAYER sldevaudioplayerstr
static void openslES_DetectDevices( int iscapture ) static void OPENSLES_DetectDevices( int iscapture )
{ {
LOGI( "openSLES_DetectDevices()" ); LOGI( "openSLES_DetectDevices()" );
if ( iscapture ) if ( iscapture )
@@ -118,9 +118,9 @@ static void openslES_DetectDevices( int iscapture )
} }
#endif #endif
static void openslES_DestroyEngine(void) static void OPENSLES_DestroyEngine(void)
{ {
LOGI("openslES_DestroyEngine()"); LOGI("OPENSLES_DestroyEngine()");
// destroy output mix object, and invalidate all associated interfaces // destroy output mix object, and invalidate all associated interfaces
if (outputMixObject != NULL) { if (outputMixObject != NULL) {
@@ -136,7 +136,7 @@ static void openslES_DestroyEngine(void)
} }
} }
static int openslES_CreateEngine(void) static int OPENSLES_CreateEngine(void)
{ {
const SLInterfaceID ids[1] = { SL_IID_VOLUME }; const SLInterfaceID ids[1] = { SL_IID_VOLUME };
const SLboolean req[1] = { SL_BOOLEAN_FALSE }; const SLboolean req[1] = { SL_BOOLEAN_FALSE };
@@ -185,7 +185,7 @@ static int openslES_CreateEngine(void)
return 1; return 1;
error: error:
openslES_DestroyEngine(); OPENSLES_DestroyEngine();
return 0; return 0;
} }
@@ -198,7 +198,7 @@ static void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
SDL_PostSemaphore(audiodata->playsem); SDL_PostSemaphore(audiodata->playsem);
} }
static void openslES_DestroyPCMRecorder(SDL_AudioDevice *device) static void OPENSLES_DestroyPCMRecorder(SDL_AudioDevice *device)
{ {
struct SDL_PrivateAudioData *audiodata = device->hidden; struct SDL_PrivateAudioData *audiodata = device->hidden;
SLresult result; SLresult result;
@@ -229,7 +229,7 @@ static void openslES_DestroyPCMRecorder(SDL_AudioDevice *device)
} }
} }
static int openslES_CreatePCMRecorder(SDL_AudioDevice *device) static int OPENSLES_CreatePCMRecorder(SDL_AudioDevice *device)
{ {
struct SDL_PrivateAudioData *audiodata = device->hidden; struct SDL_PrivateAudioData *audiodata = device->hidden;
SLDataFormat_PCM format_pcm; SLDataFormat_PCM format_pcm;
@@ -375,7 +375,7 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
SDL_PostSemaphore(audiodata->playsem); SDL_PostSemaphore(audiodata->playsem);
} }
static void openslES_DestroyPCMPlayer(SDL_AudioDevice *device) static void OPENSLES_DestroyPCMPlayer(SDL_AudioDevice *device)
{ {
struct SDL_PrivateAudioData *audiodata = device->hidden; struct SDL_PrivateAudioData *audiodata = device->hidden;
@@ -406,7 +406,7 @@ static void openslES_DestroyPCMPlayer(SDL_AudioDevice *device)
} }
} }
static int openslES_CreatePCMPlayer(SDL_AudioDevice *device) static int OPENSLES_CreatePCMPlayer(SDL_AudioDevice *device)
{ {
/* If we want to add floating point audio support (requires API level 21) /* If we want to add floating point audio support (requires API level 21)
it can be done as described here: it can be done as described here:
@@ -597,7 +597,7 @@ failed:
return -1; return -1;
} }
static int openslES_OpenDevice(SDL_AudioDevice *device) static int OPENSLES_OpenDevice(SDL_AudioDevice *device)
{ {
device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
if (device->hidden == NULL) { if (device->hidden == NULL) {
@@ -605,18 +605,18 @@ static int openslES_OpenDevice(SDL_AudioDevice *device)
} }
if (device->iscapture) { if (device->iscapture) {
LOGI("openslES_OpenDevice() for capture"); LOGI("OPENSLES_OpenDevice() for capture");
return openslES_CreatePCMRecorder(device); return OPENSLES_CreatePCMRecorder(device);
} else { } else {
int ret; int ret;
LOGI("openslES_OpenDevice() for playing"); LOGI("OPENSLES_OpenDevice() for playing");
ret = openslES_CreatePCMPlayer(device); ret = OPENSLES_CreatePCMPlayer(device);
if (ret < 0) { if (ret < 0) {
// Another attempt to open the device with a lower frequency // Another attempt to open the device with a lower frequency
if (device->spec.freq > 48000) { if (device->spec.freq > 48000) {
openslES_DestroyPCMPlayer(device); OPENSLES_DestroyPCMPlayer(device);
device->spec.freq = 48000; device->spec.freq = 48000;
ret = openslES_CreatePCMPlayer(device); ret = OPENSLES_CreatePCMPlayer(device);
} }
} }
@@ -628,21 +628,21 @@ static int openslES_OpenDevice(SDL_AudioDevice *device)
return 0; return 0;
} }
static int openslES_WaitDevice(SDL_AudioDevice *device) static int OPENSLES_WaitDevice(SDL_AudioDevice *device)
{ {
struct SDL_PrivateAudioData *audiodata = device->hidden; struct SDL_PrivateAudioData *audiodata = device->hidden;
LOGV("openslES_WaitDevice()"); LOGV("OPENSLES_WaitDevice()");
// Wait for an audio chunk to finish // Wait for an audio chunk to finish
return SDL_WaitSemaphore(audiodata->playsem); return SDL_WaitSemaphore(audiodata->playsem);
} }
static int openslES_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen) static int OPENSLES_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
{ {
struct SDL_PrivateAudioData *audiodata = device->hidden; struct SDL_PrivateAudioData *audiodata = device->hidden;
LOGV("======openslES_PlayDevice()======"); LOGV("======OPENSLES_PlayDevice()======");
// Queue it up // Queue it up
const SLresult result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer, buflen); const SLresult result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer, buflen);
@@ -673,15 +673,15 @@ static int openslES_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int
// //
// okay.. // okay..
static Uint8 *openslES_GetDeviceBuf(SDL_AudioDevice *device, int *bufsize) static Uint8 *OPENSLES_GetDeviceBuf(SDL_AudioDevice *device, int *bufsize)
{ {
struct SDL_PrivateAudioData *audiodata = device->hidden; struct SDL_PrivateAudioData *audiodata = device->hidden;
LOGV("openslES_GetDeviceBuf()"); LOGV("OPENSLES_GetDeviceBuf()");
return audiodata->pmixbuff[audiodata->next_buffer]; return audiodata->pmixbuff[audiodata->next_buffer];
} }
static int openslES_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, int buflen) static int OPENSLES_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, int buflen)
{ {
struct SDL_PrivateAudioData *audiodata = device->hidden; struct SDL_PrivateAudioData *audiodata = device->hidden;
@@ -704,16 +704,16 @@ static int openslES_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, int
return device->buffer_size; return device->buffer_size;
} }
static void openslES_CloseDevice(SDL_AudioDevice *device) static void OPENSLES_CloseDevice(SDL_AudioDevice *device)
{ {
// struct SDL_PrivateAudioData *audiodata = device->hidden; // struct SDL_PrivateAudioData *audiodata = device->hidden;
if (device->hidden) { if (device->hidden) {
if (device->iscapture) { if (device->iscapture) {
LOGI("openslES_CloseDevice() for capture"); LOGI("OPENSLES_CloseDevice() for capture");
openslES_DestroyPCMRecorder(device); OPENSLES_DestroyPCMRecorder(device);
} else { } else {
LOGI("openslES_CloseDevice() for playing"); LOGI("OPENSLES_CloseDevice() for playing");
openslES_DestroyPCMPlayer(device); OPENSLES_DestroyPCMPlayer(device);
} }
SDL_free(device->hidden); SDL_free(device->hidden);
@@ -721,61 +721,61 @@ static void openslES_CloseDevice(SDL_AudioDevice *device)
} }
} }
static SDL_bool openslES_Init(SDL_AudioDriverImpl *impl) static SDL_bool OPENSLES_Init(SDL_AudioDriverImpl *impl)
{ {
LOGI("openslES_Init() called"); LOGI("OPENSLES_Init() called");
if (!openslES_CreateEngine()) { if (!OPENSLES_CreateEngine()) {
return SDL_FALSE; return SDL_FALSE;
} }
LOGI("openslES_Init() - set pointers"); LOGI("OPENSLES_Init() - set pointers");
// Set the function pointers // Set the function pointers
// impl->DetectDevices = openslES_DetectDevices; // impl->DetectDevices = OPENSLES_DetectDevices;
impl->ThreadInit = Android_AudioThreadInit; impl->ThreadInit = Android_AudioThreadInit;
impl->OpenDevice = openslES_OpenDevice; impl->OpenDevice = OPENSLES_OpenDevice;
impl->WaitDevice = openslES_WaitDevice; impl->WaitDevice = OPENSLES_WaitDevice;
impl->PlayDevice = openslES_PlayDevice; impl->PlayDevice = OPENSLES_PlayDevice;
impl->GetDeviceBuf = openslES_GetDeviceBuf; impl->GetDeviceBuf = OPENSLES_GetDeviceBuf;
impl->WaitCaptureDevice = openslES_WaitDevice; impl->WaitCaptureDevice = OPENSLES_WaitDevice;
impl->CaptureFromDevice = openslES_CaptureFromDevice; impl->CaptureFromDevice = OPENSLES_CaptureFromDevice;
impl->CloseDevice = openslES_CloseDevice; impl->CloseDevice = OPENSLES_CloseDevice;
impl->Deinitialize = openslES_DestroyEngine; impl->Deinitialize = OPENSLES_DestroyEngine;
// and the capabilities // and the capabilities
impl->HasCaptureSupport = SDL_TRUE; impl->HasCaptureSupport = SDL_TRUE;
impl->OnlyHasDefaultOutputDevice = SDL_TRUE; impl->OnlyHasDefaultOutputDevice = SDL_TRUE;
impl->OnlyHasDefaultCaptureDevice = SDL_TRUE; impl->OnlyHasDefaultCaptureDevice = SDL_TRUE;
LOGI("openslES_Init() - success"); LOGI("OPENSLES_Init() - success");
// this audio target is available. // this audio target is available.
return SDL_TRUE; return SDL_TRUE;
} }
AudioBootStrap openslES_bootstrap = { AudioBootStrap OPENSLES_bootstrap = {
"openslES", "opensl ES audio driver", openslES_Init, SDL_FALSE "openslES", "opensl ES audio driver", OPENSLES_Init, SDL_FALSE
}; };
void openslES_ResumeDevices(void) void OPENSLES_ResumeDevices(void)
{ {
if (bqPlayerPlay != NULL) { if (bqPlayerPlay != NULL) {
// set the player's state to 'playing' // set the player's state to 'playing'
SLresult result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING); SLresult result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
if (SL_RESULT_SUCCESS != result) { if (SL_RESULT_SUCCESS != result) {
LOGE("openslES_ResumeDevices failed: %d", result); LOGE("OPENSLES_ResumeDevices failed: %d", result);
} }
} }
} }
void openslES_PauseDevices(void) void OPENSLES_PauseDevices(void)
{ {
if (bqPlayerPlay != NULL) { if (bqPlayerPlay != NULL) {
// set the player's state to 'paused' // set the player's state to 'paused'
SLresult result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PAUSED); SLresult result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PAUSED);
if (SL_RESULT_SUCCESS != result) { if (SL_RESULT_SUCCESS != result) {
LOGE("openslES_PauseDevices failed: %d", result); LOGE("OPENSLES_PauseDevices failed: %d", result);
} }
} }
} }