Android/openslES: register and use CloseDevice function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c
index 99b9550..d3b0e39 100644
--- a/src/audio/openslES/SDL_openslES.c
+++ b/src/audio/openslES/SDL_openslES.c
@@ -235,8 +235,7 @@ openslES_DestroyPCMRecorder(void)
}
static int
-openslES_CreatePCMPlayer(
- _THIS)
+openslES_CreatePCMPlayer(_THIS)
{
SLDataFormat_PCM format_pcm;
@@ -463,6 +462,11 @@ openslES_DestroyPCMPlayer(void)
static int
openslES_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
{
+ this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *this->hidden));
+ if (this->hidden == NULL) {
+ return SDL_OutOfMemory();
+ }
+
if (iscapture) {
LOGI("openslES_OpenDevice( ) %s for capture", devname);
return openslES_CreatePCMRecorder(this);
@@ -480,9 +484,12 @@ openslES_CloseDevice(_THIS)
openslES_DestroyPCMRecorder();
} else {
LOGI("openslES_CloseDevice( ) for playing");
+ SDL_Log("openslES_CloseDevice( ) for playing");
openslES_DestroyPCMPlayer();
}
+ SDL_free(this->hidden);
+
return;
}
@@ -553,6 +560,7 @@ openslES_Init(SDL_AudioDriverImpl * impl)
/* Set the function pointers */
// impl->DetectDevices = openslES_DetectDevices;
impl->OpenDevice = openslES_OpenDevice;
+ impl->CloseDevice = openslES_CloseDevice;
impl->PlayDevice = openslES_PlayDevice;
impl->GetDeviceBuf = openslES_GetDeviceBuf;
impl->Deinitialize = openslES_DestroyEngine;