Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Assertion 's' failed at pulse/stream.c while stopping and starting QAudioInput and QAudioOutput in quick succession?
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtmultimediapulseaudioaudioc++ qt
5 Posts 3 Posters 3.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    faisal.tum
    wrote on 11 May 2016, 12:59 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 11 May 2016, 14:03 last edited by
      #2
      This post is deleted!
      F 1 Reply Last reply 11 May 2016, 14:23
      0
      • V VRonin
        11 May 2016, 14:03

        This post is deleted!

        F Offline
        F Offline
        faisal.tum
        wrote on 11 May 2016, 14:23 last edited by faisal.tum 5 Nov 2016, 14:31
        #3

        @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

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VRonin
          wrote on 11 May 2016, 15:25 last edited by
          #4

          Sorry, ignore me, post deleted

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 11 May 2016, 21:20 last edited by
            #5

            Hi,

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            2/5

            11 May 2016, 14:03

            • Login

            • Login or register to search.
            2 out of 5
            • First post
              2/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved