help needed: Cannot set stream type: audio player already realized

190 views
Skip to first unread message

余曦文

unread,
Feb 25, 2015, 11:15:55 PM2/25/15
to andro...@googlegroups.com
opensl es work with earspeaker , make this mistake,please help me

result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_ANDROIDCONFIGURATION, &configItf);
assert(SL_RESULT_SUCCESS == result);
(void) result;
SLint32 streamType = SL_ANDROID_STREAM_VOICE;
result = (*configItf)->SetConfiguration(configItf, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
assert(SL_RESULT_SUCCESS == result);
(void) result;

Glenn Kasten

unread,
Feb 26, 2015, 3:24:02 PM2/26/15
to andro...@googlegroups.com
I don't have the full context.  Can you give the other APIs you called before this?
And which API returned status "already realized"?

余曦文

unread,
Mar 1, 2015, 7:14:09 PM3/1/15
to andro...@googlegroups.com
thank you first, I mean I want to change speaker to earpiece in opensl,so I need to  SetConfiguration,like this:
       result = (*configItf)->SetConfiguration(configItf, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
assert(SL_RESULT_SUCCESS == result);
(void) result;
but it must set before   this:
// realize the player
result = (*bqPlayerObject)->Realize(bqPlayerObject, SL_BOOLEAN_FALSE );
assert(SL_RESULT_SUCCESS == result);
(void) result;
so when i  change earpiece to speaker again, it  tells me "already realized"   
do you understand?

Glenn Kasten於 2015年2月27日星期五 UTC+8上午4時24分02秒寫道:

Glenn Kasten

unread,
Mar 1, 2015, 10:26:28 PM3/1/15
to andro...@googlegroups.com
SL_ANDROID_KEY_STREAM_TYPE is a configuration (creation) parameter,
not a runtime parameter. If you want to change SL_ANDROID_KEY_STREAM_TYPE after creation,
you will need to destroy the player and re-create it.

余曦文

unread,
Mar 2, 2015, 1:15:13 AM3/2/15
to andro...@googlegroups.com
yes,i did it as you said,and it worked ok, but i feel the code is too long, i look up the user guide,it says this configuration is the same as android API,so i decide change speaker to earpiece by android's API, anyway thank you Glenn.

Glenn Kasten於 2015年3月2日星期一 UTC+8上午11時26分28秒寫道:
Reply all
Reply to author
Forward
0 new messages