Problem with playing audio in real time using OpenSL ES, Crash APP
$30-250 USD
Đã hủy
Đã đăng vào hơn 3 năm trước
$30-250 USD
Thanh toán khi bàn giao
I'm trying to record audio and play it in real time using OpenSL ES, I can send the audio packet to the server, and the server is sending the packet to users correctly. However, there is a problem that I don't know why. The user who is recording can hear himself (the audio goes through the server and goes back to him), but when another user is speaking, the audio packages arrive and when I will queue the application closes.
Here is the part where I play the audio packets that arrive from the server.
void setBuffer(int playerid, uint8_t* buffer, size_t bufferSize)
{
if (buffer != NULL && playerBufferQueueItf != NULL && playerPlay != NULL && engineEngine != NULL)
{
(*playerBufferQueueItf)->Enqueue(playerBufferQueueItf, buffer, bufferSize);
}
}
Below starts the listen
createEngine();
// Create a mixer
SLresult result;
result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObjext, 0, 0, 0);
assert(SL_RESULT_SUCCESS == result);
(void)result;
result = (*outputMixObjext)->Realize(outputMixObjext, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// Create a player
createAudioPlayer(engineEngine, outputMixObjext, playerObject);
result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
(void)result;
result = (*playerObject)->GetInterface(playerObject, SL_IID_BUFFERQUEUE, &playerBufferQueueItf);
assert(SL_RESULT_SUCCESS == result);
(void)result;
result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAY, &playerPlay);
assert(SL_RESULT_SUCCESS == result);
(void)result;
result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
assert(SL_RESULT_SUCCESS == result);
I took this link as a base [login to view URL], it writes to a file and reproduces, my record sends to the server and reproduces in real time. (does not store anything in the file)