diff options
author | Jirka Novak <j.novak@netsystem.cz> | 2021-08-20 22:39:01 +0200 |
---|---|---|
committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-08-21 07:20:33 +0000 |
commit | dd161ade12670c2b92105068527ae899a7e5afae (patch) | |
tree | 50b159baac97a85943b4d27d096078eb5bd143ec /ui/qt/rtp_audio_stream.cpp | |
parent | 2c556a0e90c99fb1de1eb60e82b35b99099c2b1a (diff) |
RTP Player: Fix of resampling for visual waveform
When capture was longer (e.g. 800s), audio was decoded correctly, but
visual waveform was shown incorrectly. Reason was exceeding range of
guint32 during calculation. Calculation is now made in guint64 and then
put back to guint32.
Diffstat (limited to 'ui/qt/rtp_audio_stream.cpp')
-rw-r--r-- | ui/qt/rtp_audio_stream.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ui/qt/rtp_audio_stream.cpp b/ui/qt/rtp_audio_stream.cpp index 27c973a06a..51e19e7b0f 100644 --- a/ui/qt/rtp_audio_stream.cpp +++ b/ui/qt/rtp_audio_stream.cpp @@ -412,7 +412,7 @@ void RtpAudioStream::decodeAudio(QAudioDeviceInfo out_device) // Buffer is in SAMPLEs spx_uint32_t in_len = (spx_uint32_t) (write_bytes / SAMPLE_BYTES); // Output is audio_out_rate_/sample_rate bigger than input - spx_uint32_t out_len = (spx_uint32_t) (in_len * audio_out_rate_ / sample_rate); + spx_uint32_t out_len = (spx_uint32_t) ((guint64)in_len * audio_out_rate_ / sample_rate); resample_buff = resizeBufferIfNeeded(resample_buff, &resample_buff_bytes, out_len * SAMPLE_BYTES); speex_resampler_process_int(audio_resampler_, 0, decode_buff, &in_len, resample_buff, &out_len); @@ -453,7 +453,7 @@ void RtpAudioStream::decodeVisual() // Loop over every frame record // readFrameSamples() maintains size of buffer for us while (audio_file_->readFrameSamples(&read_buff_bytes, &read_buff, &read_len, &frame_num, &type)) { - out_len = (spx_uint32_t)((read_len * visual_sample_rate_ ) / audio_out_rate_); + out_len = (spx_uint32_t)(((guint64)read_len * visual_sample_rate_ ) / audio_out_rate_); if (type == RTP_FRAME_AUDIO) { // We resample only audio samples |