src/audio/openslES/SDL_openslES.c
changeset 12598 d3acc7299a95
parent 12597 b5ea5997cbf9
equal deleted inserted replaced
12597:b5ea5997cbf9 12598:d3acc7299a95
    44 #define LOGE(...)
    44 #define LOGE(...)
    45 #endif
    45 #endif
    46 
    46 
    47 /* engine interfaces */
    47 /* engine interfaces */
    48 static SLObjectItf engineObject = NULL;
    48 static SLObjectItf engineObject = NULL;
    49 static SLEngineItf engineEngine;
    49 static SLEngineItf engineEngine = NULL;
    50 
    50 
    51 /* output mix interfaces */
    51 /* output mix interfaces */
    52 static SLObjectItf outputMixObject = NULL;
    52 static SLObjectItf outputMixObject = NULL;
    53 // static SLEnvironmentalReverbItf outputMixEnvironmentalReverb = NULL;
    53 // static SLEnvironmentalReverbItf outputMixEnvironmentalReverb = NULL;
    54 
    54 
    57 
    57 
    58 /* buffer queue player interfaces */
    58 /* buffer queue player interfaces */
    59 static SLObjectItf                   bqPlayerObject      = NULL;
    59 static SLObjectItf                   bqPlayerObject      = NULL;
    60 static SLPlayItf                     bqPlayerPlay        = NULL;
    60 static SLPlayItf                     bqPlayerPlay        = NULL;
    61 static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue = NULL;
    61 static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue = NULL;
    62 /*static SLEffectSendItf          bqPlayerEffectSend = NULL; */
    62 #if 0
       
    63 static SLEffectSendItf               bqPlayerEffectSend  = NULL;
    63 static SLMuteSoloItf                 bqPlayerMuteSolo    = NULL;
    64 static SLMuteSoloItf                 bqPlayerMuteSolo    = NULL;
    64 static SLVolumeItf                   bqPlayerVolume      = NULL;
    65 static SLVolumeItf                   bqPlayerVolume      = NULL;
       
    66 #endif
    65 
    67 
    66 #if 0
    68 #if 0
    67 /* recorder interfaces TODO */
    69 /* recorder interfaces TODO */
    68 static SLObjectItf                   recorderObject = NULL;
    70 static SLObjectItf                   recorderObject = NULL;
    69 static SLRecordItf                   recorderRecord;
    71 static SLRecordItf                   recorderRecord;
   189 /* this callback handler is called every time a buffer finishes playing */
   191 /* this callback handler is called every time a buffer finishes playing */
   190 static void
   192 static void
   191 bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
   193 bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
   192 {
   194 {
   193     struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *) context;
   195     struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *) context;
   194     static int t = 0;
   196     LOGI("SLES: Playback Callmeback");
   195 
       
   196     /* assert(bq == bqPlayerBufferQueue); */
       
   197     /* assert(NULL == context); */
       
   198 
       
   199     /* for streaming playback, replace this test by logic to find and fill the next buffer */
       
   200 #if 0
       
   201     if (--nextCount > 0 && NULL != nextBuffer && 0 != nextSize)
       
   202     {
       
   203         SLresult result;
       
   204 
       
   205         /* enqueue another buffer */
       
   206         result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, nextBuffer, nextSize);
       
   207         /* the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT, */
       
   208         /* which for this code example would indicate a programming error */
       
   209         assert(SL_RESULT_SUCCESS == result);
       
   210         (void) result;
       
   211     }
       
   212 #endif
       
   213     LOGI("SLES: Playback Callmeback %u", t++);
       
   214     SDL_SemPost(audiodata->playsem);
   197     SDL_SemPost(audiodata->playsem);
   215     return;
   198     return;
   216 }
   199 }
   217 
   200 
   218 static int
   201 static int
   234 
   217 
   235 static int
   218 static int
   236 openslES_CreatePCMPlayer(_THIS)
   219 openslES_CreatePCMPlayer(_THIS)
   237 {
   220 {
   238     struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *) this->hidden;
   221     struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *) this->hidden;
   239 
       
   240     SLDataFormat_PCM format_pcm;
   222     SLDataFormat_PCM format_pcm;
   241 
       
   242     SDL_AudioFormat test_format = 0;
       
   243     SLresult result;
   223     SLresult result;
   244     int i;
   224     int i;
   245 
   225 
   246 #if 0
   226 #if 0
       
   227     SDL_AudioFormat test_format = 0;
   247 
   228 
   248       test_format = SDL_FirstAudioFormat( this->spec.format );
   229       test_format = SDL_FirstAudioFormat( this->spec.format );
   249 
   230 
   250       while (test_format != 0) {
   231       while (test_format != 0) {
   251 
   232 
   389     result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_MUTESOLO, &bqPlayerMuteSolo);
   370     result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_MUTESOLO, &bqPlayerMuteSolo);
   390     assert(SL_RESULT_SUCCESS == result);
   371     assert(SL_RESULT_SUCCESS == result);
   391     (void) result;
   372     (void) result;
   392 #endif
   373 #endif
   393 
   374 
       
   375 #if 0
   394     /* get the volume interface */
   376     /* get the volume interface */
   395     result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_VOLUME, &bqPlayerVolume);
   377     result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_VOLUME, &bqPlayerVolume);
   396     if (SL_RESULT_SUCCESS != result) {
   378     if (SL_RESULT_SUCCESS != result) {
   397         LOGE("SL_IID_VOLUME interface get failed");
   379         LOGE("SL_IID_VOLUME interface get failed");
   398         /* goto failed; */
   380         /* goto failed; */
   399     }
   381     }
       
   382 #endif
   400 
   383 
   401     /* Create the audio buffer semaphore */
   384     /* Create the audio buffer semaphore */
   402     audiodata->playsem = SDL_CreateSemaphore(NUM_BUFFERS - 1);
   385     audiodata->playsem = SDL_CreateSemaphore(NUM_BUFFERS - 1);
   403     if (!audiodata->playsem) {
   386     if (!audiodata->playsem) {
   404         LOGE("cannot create Semaphore!");
   387         LOGE("cannot create Semaphore!");
   452         (*bqPlayerObject)->Destroy(bqPlayerObject);
   435         (*bqPlayerObject)->Destroy(bqPlayerObject);
   453 
   436 
   454         bqPlayerObject = NULL;
   437         bqPlayerObject = NULL;
   455         bqPlayerPlay = NULL;
   438         bqPlayerPlay = NULL;
   456         bqPlayerBufferQueue = NULL;
   439         bqPlayerBufferQueue = NULL;
   457         /* bqPlayerEffectSend = NULL; */
   440 #if 0
       
   441         bqPlayerEffectSend = NULL;
   458         bqPlayerMuteSolo = NULL;
   442         bqPlayerMuteSolo = NULL;
   459         bqPlayerVolume = NULL;
   443         bqPlayerVolume = NULL;
       
   444 #endif
   460     }
   445     }
   461 
   446 
   462     if (audiodata->playsem) {
   447     if (audiodata->playsem) {
   463         SDL_DestroySemaphore(audiodata->playsem);
   448         SDL_DestroySemaphore(audiodata->playsem);
   464         audiodata->playsem = NULL;
   449         audiodata->playsem = NULL;