opens the OpenSL ES device for output
| 678 | |
| 679 | // opens the OpenSL ES device for output |
| 680 | SLresult openSLPlayOpen(opensl_stream2 *p) { |
| 681 | SLresult result; |
| 682 | SLuint32 sr = p->sr; |
| 683 | SLuint32 channels = p->outchannels; |
| 684 | if (channels){ |
| 685 | // configure audio source |
| 686 | SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2}; |
| 687 | switch(sr){ |
| 688 | case 8000: |
| 689 | sr = SL_SAMPLINGRATE_8; |
| 690 | break; |
| 691 | case 11025: |
| 692 | sr = SL_SAMPLINGRATE_11_025; |
| 693 | break; |
| 694 | case 16000: |
| 695 | sr = SL_SAMPLINGRATE_16; |
| 696 | break; |
| 697 | case 22050: |
| 698 | sr = SL_SAMPLINGRATE_22_05; |
| 699 | break; |
| 700 | case 24000: |
| 701 | sr = SL_SAMPLINGRATE_24; |
| 702 | break; |
| 703 | case 32000: |
| 704 | sr = SL_SAMPLINGRATE_32; |
| 705 | break; |
| 706 | case 44100: |
| 707 | sr = SL_SAMPLINGRATE_44_1; |
| 708 | break; |
| 709 | case 48000: |
| 710 | sr = SL_SAMPLINGRATE_48; |
| 711 | break; |
| 712 | case 64000: |
| 713 | sr = SL_SAMPLINGRATE_64; |
| 714 | break; |
| 715 | case 88200: |
| 716 | sr = SL_SAMPLINGRATE_88_2; |
| 717 | break; |
| 718 | case 96000: |
| 719 | sr = SL_SAMPLINGRATE_96; |
| 720 | break; |
| 721 | case 192000: |
| 722 | sr = SL_SAMPLINGRATE_192; |
| 723 | break; |
| 724 | default: |
| 725 | return -1; |
| 726 | } |
| 727 | const SLInterfaceID ids[] = {SL_IID_VOLUME}; |
| 728 | const SLboolean req[] = {SL_BOOLEAN_FALSE}; |
| 729 | result = (*p->engineEngine)->CreateOutputMix(p->engineEngine, |
| 730 | &(p->outputMixObject), 1, ids, req); |
| 731 | // realize the output mix |
| 732 | result = (*p->outputMixObject)->Realize(p->outputMixObject, SL_BOOLEAN_FALSE); |
| 733 | SLuint32 speakers = SL_SPEAKER_FRONT_CENTER; |
| 734 | if(channels > 1) |
| 735 | speakers = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT; |
| 736 | SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM,channels, sr, |
| 737 | SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16, |
no outgoing calls
no test coverage detected