Commit 2763e2d7 authored by Erwan Croze's avatar Erwan Croze 👋🏻
Browse files

Fix opensles recorder init and destroy

parent ce2bfc11
...@@ -501,8 +501,16 @@ static void android_snd_read_preprocess(MSFilter *obj) { ...@@ -501,8 +501,16 @@ static void android_snd_read_preprocess(MSFilter *obj) {
OpenSLESInputContext *ictx = (OpenSLESInputContext*) obj->data; OpenSLESInputContext *ictx = (OpenSLESInputContext*) obj->data;
ictx->mFilter = obj; ictx->mFilter = obj;
ictx->read_samples = 0; ictx->read_samples = 0;
opensles_recorder_init(ictx);
opensles_recorder_callback_init(ictx); if (SL_RESULT_SUCCESS != opensles_recorder_init(ictx)) {
ms_error("Problem when initialization of opensles recorder");
return;
}
if (SL_RESULT_SUCCESS != opensles_recorder_callback_init(ictx)) {
ms_error("Problem when initialization of opensles recorder callback");
return;
}
if (ictx->opensles_context->builtin_aec) { if (ictx->opensles_context->builtin_aec) {
//android_snd_read_activate_hardware_aec(obj); //android_snd_read_activate_hardware_aec(obj);
} }
...@@ -538,22 +546,25 @@ static void android_snd_read_postprocess(MSFilter *obj) { ...@@ -538,22 +546,25 @@ static void android_snd_read_postprocess(MSFilter *obj) {
ictx->aec = NULL; ictx->aec = NULL;
} }
result = (*ictx->recorderRecord)->SetRecordState(ictx->recorderRecord, SL_RECORDSTATE_STOPPED); if (ictx->recorderRecord != NULL) {
if (SL_RESULT_SUCCESS != result) { result = (*ictx->recorderRecord)->SetRecordState(ictx->recorderRecord, SL_RECORDSTATE_STOPPED);
ms_error("OpenSLES Error %u while stopping the audio recorder", result); if (SL_RESULT_SUCCESS != result) {
} ms_error("OpenSLES Error %u while stopping the audio recorder", result);
}
}
result = (*ictx->recorderBufferQueue)->Clear(ictx->recorderBufferQueue); if (ictx->recorderBufferQueue != NULL) {
if (SL_RESULT_SUCCESS != result) { result = (*ictx->recorderBufferQueue)->Clear(ictx->recorderBufferQueue);
ms_error("OpenSLES Error %u while clearing the audio recorder buffer queue", result); if (SL_RESULT_SUCCESS != result) {
} ms_error("OpenSLES Error %u while clearing the audio recorder buffer queue", result);
}
}
if (ictx->recorderObject != NULL) if (ictx->recorderObject != NULL) {
{ (*ictx->recorderObject)->Destroy(ictx->recorderObject);
(*ictx->recorderObject)->Destroy(ictx->recorderObject); ictx->recorderObject = NULL;
ictx->recorderObject = NULL; ictx->recorderRecord = NULL;
ictx->recorderRecord = NULL; ictx->recorderBufferQueue = NULL;
ictx->recorderBufferQueue = NULL;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment