the_naive
11th May 2016, 14:19
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::LittleEndia n);
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);
I tried to use GDB for finding out why this crash happens, but I only get the result in call stack of QtCreator as shown in the image.
11937
Could anyone please tell me how to prevent the aforementioned crash?
Thanks.
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::LittleEndia n);
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);
I tried to use GDB for finding out why this crash happens, but I only get the result in call stack of QtCreator as shown in the image.
11937
Could anyone please tell me how to prevent the aforementioned crash?
Thanks.