diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-11-17 18:54:41 +0100 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-11-17 22:49:35 +0000 |
commit | 0fef9d752f801986a81b7c294143eae21cd0de97 (patch) | |
tree | d1528b47b44fd5ca9f459ba8374618f6ce6a19d1 /ui/qt/rtp_audio_stream.cpp | |
parent | e3eb9f32081dafd97e058bf292e130e511f33748 (diff) | |
download | wireshark-0fef9d752f801986a81b7c294143eae21cd0de97.tar.gz |
Fix crash in RTP Player on stop and close
When dragging the UI, this somehow causes a great lag. Then by
spam-clicking on the Stop button, a double free seems to occur.
Fix this by moving the audio cleanup to the outputStateChanged callback
as documented at https://doc.qt.io/qt-5/qaudiooutput.html. Note that
calling stop() in the IdleState also triggers a change event, resulting
in the desired cleanup.
Stop streams before the dialog is closed (via accept/reject). This
*cannot* be done in the destrutor of RtpPlayerDialog because destructing
QAudioOutput processes events from the event queue, resulting in
preature destruction of other objects... crash.
Change-Id: I6bfb33c9396e9bc1ffd346519d22390a97b6bdaf
Reviewed-on: https://code.wireshark.org/review/11894
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/rtp_audio_stream.cpp')
-rw-r--r-- | ui/qt/rtp_audio_stream.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ui/qt/rtp_audio_stream.cpp b/ui/qt/rtp_audio_stream.cpp index 94149fe3ca..c16eca903c 100644 --- a/ui/qt/rtp_audio_stream.cpp +++ b/ui/qt/rtp_audio_stream.cpp @@ -539,10 +539,7 @@ void RtpAudioStream::stopPlaying() { if (audio_output_) { audio_output_->stop(); - delete audio_output_; - audio_output_ = NULL; } - emit finishedPlaying(); } void RtpAudioStream::writeSilence(int samples) @@ -564,20 +561,23 @@ void RtpAudioStream::writeSilence(int samples) void RtpAudioStream::outputStateChanged() { - if (!audio_output_) return; - - if (audio_output_->state() == QAudio::IdleState) { + switch (audio_output_->state()) { + case QAudio::StoppedState: // RTP_STREAM_DEBUG("stopped %f", audio_output_->processedUSecs() / 100000.0); delete audio_output_; audio_output_ = NULL; - emit finishedPlaying(); + break; + case QAudio::IdleState: + audio_output_->stop(); + break; + default: + break; } } void RtpAudioStream::outputNotify() { - if (!audio_output_) return; emit processedSecs(audio_output_->processedUSecs() / 1000000.0); } |