mardi 3 février 2015

Android OpenSL: voice stream leads to artifacts in recorded sound

I am trying to record and play sound using android's OpenSL. I choosed Victor Lazzarini's Guide as a starting point.


When I change output sound stream type to SL_ANDROID_STREAM_VOICE I hear severe artifacts: crackles, sizzlings, etc. I've modified the lines in original solution:



const SLInterfaceID ids1[] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_ANDROIDCONFIGURATION};
const SLboolean req1[] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
result = (*p->engineEngine)->CreateAudioPlayer(p->engineEngine, &(p->bqPlayerObject), &audioSrc, &audioSnk, 2, ids1, req1);
if(result != SL_RESULT_SUCCESS) goto end_openaudio;

SLAndroidConfigurationItf playerConfig;
result = (*p->bqPlayerObject)->GetInterface(p->bqPlayerObject, SL_IID_ANDROIDCONFIGURATION, &playerConfig);
if(result != SL_RESULT_SUCCESS) goto end_openaudio;
SLint32 streamType = SL_ANDROID_STREAM_VOICE;
result = (*playerConfig)->SetConfiguration(playerConfig, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
if(result != SL_RESULT_SUCCESS) goto end_openaudio;


But when I use



SLint32 streamType = SL_ANDROID_STREAM_MEDIA


Everything is fine.


The issue does not repeat in android 4.4+.


Aucun commentaire:

Enregistrer un commentaire