Android/openslES: register and use CloseDevice function.
authorSylvain Becker <sylvain.becker@gmail.com>
Mon, 14 Jan 2019 10:16:26 +0100
changeset 12539e7282e21da92
parent 12538 fad97a498ffb
child 12540 2660c01ff7da
Android/openslES: register and use CloseDevice function.
src/audio/openslES/SDL_openslES.c
     1.1 --- a/src/audio/openslES/SDL_openslES.c	Mon Jan 14 10:04:54 2019 +0100
     1.2 +++ b/src/audio/openslES/SDL_openslES.c	Mon Jan 14 10:16:26 2019 +0100
     1.3 @@ -235,8 +235,7 @@
     1.4  }
     1.5  
     1.6  static int
     1.7 -openslES_CreatePCMPlayer(
     1.8 -      _THIS)
     1.9 +openslES_CreatePCMPlayer(_THIS)
    1.10  {
    1.11      SLDataFormat_PCM format_pcm;
    1.12  
    1.13 @@ -463,6 +462,11 @@
    1.14  static int
    1.15  openslES_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
    1.16  {
    1.17 +    this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *this->hidden));
    1.18 +    if (this->hidden == NULL) {
    1.19 +        return SDL_OutOfMemory();
    1.20 +    }
    1.21 +
    1.22      if (iscapture) {
    1.23          LOGI("openslES_OpenDevice( ) %s for capture", devname);
    1.24          return openslES_CreatePCMRecorder(this);
    1.25 @@ -480,9 +484,12 @@
    1.26          openslES_DestroyPCMRecorder();
    1.27      } else {
    1.28          LOGI("openslES_CloseDevice( ) for playing");
    1.29 +        SDL_Log("openslES_CloseDevice( ) for playing");
    1.30          openslES_DestroyPCMPlayer();
    1.31      }
    1.32  
    1.33 +    SDL_free(this->hidden);
    1.34 +
    1.35      return;
    1.36  }
    1.37  
    1.38 @@ -553,6 +560,7 @@
    1.39      /* Set the function pointers */
    1.40      // impl->DetectDevices = openslES_DetectDevices;
    1.41      impl->OpenDevice    = openslES_OpenDevice;
    1.42 +    impl->CloseDevice   = openslES_CloseDevice;
    1.43      impl->PlayDevice    = openslES_PlayDevice;
    1.44      impl->GetDeviceBuf  = openslES_GetDeviceBuf;
    1.45      impl->Deinitialize  = openslES_DestroyEngine;