From 51b0aa48169a2db839368b9785600fb802756b1b Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Thu, 13 Apr 2023 12:22:33 +1000 Subject: wasm: use double as duration data type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes a crash in certain circumstances. Pick-to: 6.5 Change-Id: Ia4c9e9c7a5fb94863f48f32eca13bb6832a3eefc Reviewed-by: MikoĊ‚aj Boc --- .../multimedia/wasm/common/qwasmvideooutput.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/plugins/multimedia/wasm/common/qwasmvideooutput.cpp b/src/plugins/multimedia/wasm/common/qwasmvideooutput.cpp index 4aa133ef9..91264172f 100644 --- a/src/plugins/multimedia/wasm/common/qwasmvideooutput.cpp +++ b/src/plugins/multimedia/wasm/common/qwasmvideooutput.cpp @@ -375,9 +375,9 @@ void QWasmVideoOutput::seekTo(qint64 positionMSecs) if (seekableTimeRange["length"].as() < 1) return; if (positionToSetInSeconds - >= seekableTimeRange.call("start", 0).as() + >= seekableTimeRange.call("start", 0).as() && positionToSetInSeconds - <= seekableTimeRange.call("end", 0).as()) { + <= seekableTimeRange.call("end", 0).as()) { m_requestedPosition = positionToSetInSeconds; m_video.set("currentTime", m_requestedPosition); @@ -399,8 +399,8 @@ bool QWasmVideoOutput::isVideoSeekable() if (seekableTimeRange["length"].as() < 1) return false; if (!seekableTimeRange.isNull() || !seekableTimeRange.isUndefined()) { - bool isit = !qFuzzyCompare(seekableTimeRange.call("start", 0).as(), - seekableTimeRange.call("end", 0).as()); + bool isit = !qFuzzyCompare(seekableTimeRange.call("start", 0).as(), + seekableTimeRange.call("end", 0).as()); return isit; } return false; @@ -616,7 +616,7 @@ void QWasmVideoOutput::doElementCallbacks() if ((!timeRanges.isNull() || !timeRanges.isUndefined()) && timeRanges["length"].as() == 1) { double buffered = m_video["buffered"].call("end", 0).as(); - float duration = m_video["duration"].as(); + const double duration = m_video["duration"].as(); if (duration == buffered) { m_currentBufferedValue = 100; @@ -702,7 +702,7 @@ void QWasmVideoOutput::doElementCallbacks() if (event.isUndefined() || event.isNull()) return; - float duration = event["target"]["duration"].as(); + const double duration = event["target"]["duration"].as(); if (duration < 0) // track not exactly ready yet return; @@ -715,7 +715,7 @@ void QWasmVideoOutput::doElementCallbacks() double bufferedEnd = dVal.as(); if (duration > 0 && bufferedEnd > 0) { - float bufferedValue = (bufferedEnd / duration * 100); + const double bufferedValue = (bufferedEnd / duration * 100); qCDebug(qWasmMediaVideoOutput) << "progress buffered"; m_currentBufferedValue = bufferedValue; emit bufferingChanged(m_currentBufferedValue); @@ -735,8 +735,8 @@ void QWasmVideoOutput::doElementCallbacks() Q_UNUSED(event) qCDebug(qWasmMediaVideoOutput) << "pause"; - int currentTime = m_video["currentTime"].as(); // in seconds - int duration = m_video["duration"].as(); // in seconds + const double currentTime = m_video["currentTime"].as(); // in seconds + const double duration = m_video["duration"].as(); // in seconds if ((currentTime > 0 && currentTime < duration) && (!m_shouldStop && m_toBePaused)) { emit stateChanged(QWasmMediaPlayer::Paused); } else { @@ -778,7 +778,7 @@ qint64 QWasmVideoOutput::getDuration() if (m_video.isUndefined() || m_video.isNull()) return 0; - return m_video["duration"].as() * 1000; + return m_video["duration"].as() * 1000; } void QWasmVideoOutput::newFrame(const QVideoFrame &frame) -- cgit v1.2.1