0

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.

    {
        (*playerBufferQueueItf)->Enqueue(playerBufferQueueItf, buffer, bufferSize); // Crash Here
    }

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); ```
Mateus
  • 1
  • 2
  • Are there multiple problems? Like the first one is that the audio is playing back to the one recording and the second one is that the application crashed when you try to enqueue audio in the buffer? Would be great if you could add a bit more structure so the different problems can be distinguished better. – Jan Oct 20 '20 at 07:32
  • I think it's just a problem, maybe I instantiated the wrong playobject, I don't know, maybe something that is in the record causes the application not to close because when I'm recording audio I hear normally, now when someone else the application closes – Mateus Oct 20 '20 at 15:26
  • I took this link as a base https://www.programmersought.com/article/8037536143/, 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) – Mateus Oct 20 '20 at 15:46

0 Answers0