Assertion 's' failed at pulse/stream.c while stopping and starting QAudioInput and QAudioOutput in quick succession?



  • My application uses QAudioOutput and QAudioInput for audio communication between different audio devices. So, a user can speak through a microphone and that can be heard through a speaker using this app. It has a push-to-talk feature where the user can push a button on the app or a key on the keyboard to activate speaking through a microphone for the very moment when the button or the key is pressed.

    The problem is that when push-to-talk option is used in quick succession, like when the user presses and releases the button in very quick succession for several times, like 5-6 times, sometimes the application crashes with an error message that says:

    Assertion 's' failed at pulse/stream.c:1662, function pa_stream_writable_size(). Aborting.
    Aborted
    

    My OS is Ubuntu 14.04 LTS.

    The methods for starting and stopping the microphone and the speaker are as below:

    void AudioSettings::pushToTalk_pressed()
    {
        if(output->state() != QAudio::ActiveState && input->state() != QAudio::ActiveState)
        {
            output->start(input->start());
        }
    }
    
    void AudioSettings::pushToTalk_released()
    {   
        if(output->state() == QAudio::ActiveState && input->state() == QAudio::ActiveState)
        {
            output->stop();
            input->stop();
         }
    }
    

    Here input and output are respectively pointers to object of QAudioInput and QAudioOutput. They are initialized in the following way:

    QAudioFormat audioFormat;
    audioFormat.setChannelCount(2);
    audioFormat.setCodec("audio/pcm");
    audioFormat.setSampleRate(22050);
    audioFormat.setSampleSize(16);
    audioFormat.setByteOrder(QAudioFormat::LittleEndian);
    audioFormat.setSampleType(QAudioFormat::SignedInt);
    
    QAudioDeviceInfo outputDevinfo = ui->output2Box->itemData(ui->output2Box->currentIndex()).value<QAudioDeviceInfo>();
    
    if (!outputDevinfo.isFormatSupported(audioFormat))
    {
       //Default format not supported - trying to use nearest
       audioFormat = outputDevinfo.nearestFormat(audioFormat);
    }
    
    //Initializing output device        
    output = new QAudioOutput(outputDevinfo, audioFormat, this);
    
    QAudioDeviceInfo inputDevinfo = ui->input2Box->itemData(ui->input2Box->currentIndex()).value<QAudioDeviceInfo>();
    
    
    if (!inputDevinfo.isFormatSupported(audioFormat))
    {
       //Default format not supported - trying to use nearest
       audioFormat = inputDevinfo.nearestFormat(audioFormat);
    }
    
    //Initializing input device
    input = new QAudioInput(inputDevinfo, audioFormat, this);
    

    Could anyone please tell me how to prevent the aforementioned crash?

    Thanks.



  • This post is deleted!


  • @VRonin It's perfectly valid. I have seen others doing it in this forum itself. May be you are not aware. The application works perfectly in normal circumstance, the only situation it crashes is when the push-to-talk is key pressed and released furiously for several times. I want the application to be without crash, hence I it to cope with such furious usage.

    https://forum.qt.io/topic/19960/qaudioinput-redirect-to-qaudiooutput

    This is the post where they are doing the same as I am.

    In fact, from these links it's clear why they are valid.
    http://doc.qt.io/qt-5/qaudiooutput.html#start
    http://doc.qt.io/qt-4.8/qaudioinput.html#start-2



  • Sorry, ignore me, post deleted


  • Lifetime Qt Champion

    Hi,

    You should take a look at the bug report system to see if it something known.



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.