src/audio/openslES/SDL_openslES.c
changeset 12541 f0b89ca0ad7d
parent 12540 2660c01ff7da
child 12542 c86d239a58f0
     1.1 --- a/src/audio/openslES/SDL_openslES.c	Mon Jan 14 10:58:57 2019 +0100
     1.2 +++ b/src/audio/openslES/SDL_openslES.c	Mon Jan 14 12:33:29 2019 +0100
     1.3 @@ -34,12 +34,15 @@
     1.4  
     1.5  #define LOG_TAG "SDL_openslES"
     1.6  
     1.7 -/*#define LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) */
     1.8 -/*#define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) */
     1.9 -/*#define LOGI(...) do {} while (0) */
    1.10 -/*#define LOGE(...) do {} while (0) */
    1.11 +#if 0
    1.12 +#define LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
    1.13 +#define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
    1.14 +// #define LOGI(...) do {} while (0)
    1.15 +// #define LOGE(...) do {} while (0)
    1.16 +#else
    1.17  #define LOGI(...)
    1.18  #define LOGE(...)
    1.19 +#endif
    1.20  
    1.21  /* engine interfaces */
    1.22  static SLObjectItf engineObject = NULL;
    1.23 @@ -54,7 +57,7 @@
    1.24  
    1.25  /* buffer queue player interfaces */
    1.26  static SLObjectItf                   bqPlayerObject = NULL;
    1.27 -static SLPlayItf                     bqPlayerPlay;
    1.28 +static SLPlayItf                     bqPlayerItf;
    1.29  static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
    1.30  /*static SLEffectSendItf          bqPlayerEffectSend; */
    1.31  static SLMuteSoloItf                 bqPlayerMuteSolo;
    1.32 @@ -162,7 +165,7 @@
    1.33  static void openslES_DestroyEngine()
    1.34  {
    1.35      LOGI("openslES_DestroyEngine()");
    1.36 -   
    1.37 +
    1.38  //        openslES_DestroyPCMPlayer(this);
    1.39  //    openslES_DestroyPCMRecorder(this);
    1.40  
    1.41 @@ -236,11 +239,12 @@
    1.42  
    1.43      SLDataFormat_PCM format_pcm;
    1.44  
    1.45 +    SDL_AudioFormat test_format = 0;
    1.46      SLresult result;
    1.47      int i;
    1.48  
    1.49  #if 0
    1.50 -      SDL_AudioFormat test_format;
    1.51 +
    1.52        test_format = SDL_FirstAudioFormat( this->spec.format );
    1.53  
    1.54        while (test_format != 0) {
    1.55 @@ -349,7 +353,7 @@
    1.56      }
    1.57  
    1.58      /* get the play interface */
    1.59 -    result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAY, &bqPlayerPlay);
    1.60 +    result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAY, &bqPlayerItf);
    1.61      if (SL_RESULT_SUCCESS != result) {
    1.62          LOGE("SL_IID_PLAY interface get failed");
    1.63          goto failed;
    1.64 @@ -396,7 +400,7 @@
    1.65      }
    1.66  
    1.67      /* set the player's state to playing */
    1.68 -    result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
    1.69 +    result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_PLAYING);
    1.70      if (SL_RESULT_SUCCESS != result) {
    1.71          LOGE("Play set state failed");
    1.72          goto failed;
    1.73 @@ -433,6 +437,13 @@
    1.74  openslES_DestroyPCMPlayer(_THIS)
    1.75  {
    1.76      struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *) this->hidden;
    1.77 +    SLresult result;
    1.78 +
    1.79 +    /* set the player's state to 'stopped' */
    1.80 +    result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_STOPPED);
    1.81 +    if (SL_RESULT_SUCCESS != result) {
    1.82 +        SDL_SetError("Stopped set state failed");
    1.83 +    }
    1.84  
    1.85      /* destroy buffer queue audio player object, and invalidate all associated interfaces */
    1.86      if (bqPlayerObject != NULL) {
    1.87 @@ -440,7 +451,7 @@
    1.88          (*bqPlayerObject)->Destroy(bqPlayerObject);
    1.89  
    1.90          bqPlayerObject = NULL;
    1.91 -        bqPlayerPlay = NULL;
    1.92 +        bqPlayerItf = NULL;
    1.93          bqPlayerBufferQueue = NULL;
    1.94          /* bqPlayerEffectSend = NULL; */
    1.95          bqPlayerMuteSolo = NULL;
    1.96 @@ -488,7 +499,7 @@
    1.97          LOGI("openslES_CloseDevice( ) for playing");
    1.98          openslES_DestroyPCMPlayer(this);
    1.99      }
   1.100 -    
   1.101 +
   1.102      SDL_free(this->hidden);
   1.103  
   1.104      return;
   1.105 @@ -587,6 +598,28 @@
   1.106      "openslES", "opensl ES audio driver", openslES_Init, 0
   1.107  };
   1.108  
   1.109 +void openslES_ResumeDevices()
   1.110 +{
   1.111 +    SLresult result;
   1.112 +
   1.113 +    /* set the player's state to 'playing' */
   1.114 +    result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_PLAYING);
   1.115 +    if (SL_RESULT_SUCCESS != result) {
   1.116 +        SDL_SetError("Play set state failed");
   1.117 +    }
   1.118 +}
   1.119 +
   1.120 +void openslES_PauseDevices()
   1.121 +{
   1.122 +    SLresult result;
   1.123 +
   1.124 +    /* set the player's state to 'paused' */
   1.125 +    result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_PAUSED);
   1.126 +    if (SL_RESULT_SUCCESS != result) {
   1.127 +        SDL_SetError("Playe set state failed");
   1.128 +    }
   1.129 +}
   1.130 +
   1.131  #endif /* SDL_AUDIO_DRIVER_OPENSLES */
   1.132  
   1.133  /* vi: set ts=4 sw=4 expandtab: */