Changeset 4226
- Timestamp:
- Aug 10, 2012 2:52:34 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/android/pjmedia/src/pjmedia-audiodev/opensl_dev.c
r4215 r4226 34 34 35 35 #include <SLES/OpenSLES.h> 36 #include <SLES/OpenSLES_Android.h> 37 #include <sys/system_properties.h> 38 #include <android/api-level.h> 36 37 #ifdef __ANDROID__ 38 #include <SLES/OpenSLES_Android.h> 39 #include <SLES/OpenSLES_AndroidConfiguration.h> 40 #include <sys/system_properties.h> 41 #include <android/api-level.h> 42 43 #define W_SLBufferQueueItf SLAndroidSimpleBufferQueueItf 44 #define W_SLBufferQueueState SLAndroidSimpleBufferQueueState 45 #define W_SL_IID_BUFFERQUEUE SL_IID_ANDROIDSIMPLEBUFFERQUEUE 46 #else 47 #define W_SLBufferQueueItf SLBufferQueueItf 48 #define W_SLBufferQueueState SLBufferQueueState 49 #define W_SL_IID_BUFFERQUEUE SL_IID_BUFFERQUEUE 50 #endif 39 51 40 52 #define THIS_FILE "opensl_dev.c" … … 98 110 int recordBufIdx; 99 111 100 SLAndroidSimpleBufferQueueItfplayerBufQ;101 SLAndroidSimpleBufferQueueItfrecordBufQ;112 W_SLBufferQueueItf playerBufQ; 113 W_SLBufferQueueItf recordBufQ; 102 114 }; 103 115 … … 155 167 156 168 /* This callback is called every time a buffer finishes playing. */ 157 void bqPlayerCallback( SLAndroidSimpleBufferQueueItf bq, void *context)169 void bqPlayerCallback(W_SLBufferQueueItf bq, void *context) 158 170 { 159 171 struct opensl_aud_stream *stream = (struct opensl_aud_stream*) context; … … 201 213 202 214 /* This callback handler is called every time a buffer finishes recording */ 203 void bqRecorderCallback( SLAndroidSimpleBufferQueueItf bq, void *context)215 void bqRecorderCallback(W_SLBufferQueueItf bq, void *context) 204 216 { 205 217 struct opensl_aud_stream *stream = (struct opensl_aud_stream*) context; … … 449 461 { 450 462 /* Audio sink for recorder and audio source for player */ 463 #ifdef __ANDROID__ 451 464 SLDataLocator_AndroidSimpleBufferQueue loc_bq = 452 465 { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, NUM_BUFFERS }; 466 #else 467 SLDataLocator_BufferQueue loc_bq = 468 { SL_DATALOCATOR_BUFFERQUEUE, NUM_BUFFERS }; 469 #endif 453 470 struct opensl_aud_factory *pa = (struct opensl_aud_factory*)f; 454 471 pj_pool_t *pool; … … 497 514 SLDataSink audioSnk = {&loc_outmix, NULL}; 498 515 /* Audio interface */ 516 #ifdef __ANDROID__ 517 int numIface = 3; 499 518 const SLInterfaceID ids[3] = {SL_IID_BUFFERQUEUE, 500 519 SL_IID_VOLUME, … … 504 523 SLAndroidConfigurationItf playerConfig; 505 524 SLint32 streamType = SL_ANDROID_STREAM_VOICE; 525 #else 526 int numIface = 2; 527 const SLInterfaceID ids[2] = {SL_IID_BUFFERQUEUE, 528 SL_IID_VOLUME}; 529 const SLboolean req[2] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE}; 530 #endif 506 531 507 532 /* Create audio player */ … … 509 534 &stream->playerObj, 510 535 &audioSrc, &audioSnk, 511 3, ids, req);536 numIface, ids, req); 512 537 if (result != SL_RESULT_SUCCESS) { 513 538 PJ_LOG(3, (THIS_FILE, "Cannot create audio player: %d", result)); … … 515 540 } 516 541 542 #ifdef __ANDROID__ 517 543 /* Set Android configuration */ 518 544 result = (*stream->playerObj)->GetInterface(stream->playerObj, … … 528 554 "player configuration")); 529 555 } 530 556 #endif 557 531 558 /* Realize the player */ 532 559 result = (*stream->playerObj)->Realize(stream->playerObj, … … 587 614 SLDataSink audioSnk = {&loc_bq, &format_pcm}; 588 615 /* Audio interface */ 589 const SLInterfaceID ids[2] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE, 616 #ifdef __ANDROID__ 617 int numIface = 2; 618 const SLInterfaceID ids[2] = {W_SL_IID_BUFFERQUEUE, 590 619 SL_IID_ANDROIDCONFIGURATION}; 591 620 const SLboolean req[2] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_FALSE}; 592 621 SLAndroidConfigurationItf recorderConfig; 622 #else 623 int numIface = 1; 624 const SLInterfaceID ids[1] = {W_SL_IID_BUFFERQUEUE}; 625 const SLboolean req[1] = {SL_BOOLEAN_TRUE}; 626 #endif 593 627 594 628 /* Create audio recorder … … 598 632 &stream->recordObj, 599 633 &audioSrc, &audioSnk, 600 2, ids, req);634 numIface, ids, req); 601 635 if (result != SL_RESULT_SUCCESS) { 602 636 PJ_LOG(3, (THIS_FILE, "Cannot create recorder: %d", result)); … … 604 638 } 605 639 640 #ifdef __ANDROID__ 606 641 /* Set Android configuration */ 607 642 result = (*stream->recordObj)->GetInterface(stream->recordObj, … … 631 666 "recorder configuration")); 632 667 } 668 #endif 633 669 634 670 /* Realize the recorder */ … … 651 687 /* Get the buffer queue interface */ 652 688 result = (*stream->recordObj)->GetInterface( 653 stream->recordObj, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,689 stream->recordObj, W_SL_IID_BUFFERQUEUE, 654 690 &stream->recordBufQ); 655 691 if (result != SL_RESULT_SUCCESS) { … … 861 897 /* 862 898 SLresult result; 863 SLAndroidSimpleBufferQueueState state;899 W_SLBufferQueueState state; 864 900 865 901 result = (*stream->playerBufQ)->GetState(stream->playerBufQ, &state);
Note: See TracChangeset
for help on using the changeset viewer.