瀏覽代碼

Android/openslES: register and use CloseDevice function.

Sylvain Becker 6 年之前
父節點
當前提交
5aeeaaab70
共有 1 個文件被更改,包括 10 次插入2 次删除
  1. 10 2
      src/audio/openslES/SDL_openslES.c

+ 10 - 2
src/audio/openslES/SDL_openslES.c

@@ -235,8 +235,7 @@ openslES_DestroyPCMRecorder(void)
 }
 }
 
 
 static int
 static int
-openslES_CreatePCMPlayer(
-      _THIS)
+openslES_CreatePCMPlayer(_THIS)
 {
 {
     SLDataFormat_PCM format_pcm;
     SLDataFormat_PCM format_pcm;
 
 
@@ -463,6 +462,11 @@ openslES_DestroyPCMPlayer(void)
 static int
 static int
 openslES_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
 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) {
     if (iscapture) {
         LOGI("openslES_OpenDevice( ) %s for capture", devname);
         LOGI("openslES_OpenDevice( ) %s for capture", devname);
         return openslES_CreatePCMRecorder(this);
         return openslES_CreatePCMRecorder(this);
@@ -480,9 +484,12 @@ openslES_CloseDevice(_THIS)
         openslES_DestroyPCMRecorder();
         openslES_DestroyPCMRecorder();
     } else {
     } else {
         LOGI("openslES_CloseDevice( ) for playing");
         LOGI("openslES_CloseDevice( ) for playing");
+        SDL_Log("openslES_CloseDevice( ) for playing");
         openslES_DestroyPCMPlayer();
         openslES_DestroyPCMPlayer();
     }
     }
 
 
+    SDL_free(this->hidden);
+
     return;
     return;
 }
 }
 
 
@@ -553,6 +560,7 @@ openslES_Init(SDL_AudioDriverImpl * impl)
     /* Set the function pointers */
     /* Set the function pointers */
     // impl->DetectDevices = openslES_DetectDevices;
     // impl->DetectDevices = openslES_DetectDevices;
     impl->OpenDevice    = openslES_OpenDevice;
     impl->OpenDevice    = openslES_OpenDevice;
+    impl->CloseDevice   = openslES_CloseDevice;
     impl->PlayDevice    = openslES_PlayDevice;
     impl->PlayDevice    = openslES_PlayDevice;
     impl->GetDeviceBuf  = openslES_GetDeviceBuf;
     impl->GetDeviceBuf  = openslES_GetDeviceBuf;
     impl->Deinitialize  = openslES_DestroyEngine;
     impl->Deinitialize  = openslES_DestroyEngine;