summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@gmail.com>2023-04-13 12:22:33 +1000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-17 02:38:11 +0000
commit5c4a9e10a20da14d082cef00b2a29ff5ccdacbfd (patch)
tree3c7b421e1a2a2c11fb8461833303ce35389f9a45
parentf53f31d9b9c5b9f21de392cc8b155e6ee2eec3fd (diff)
downloadqtmultimedia-5c4a9e10a20da14d082cef00b2a29ff5ccdacbfd.tar.gz
wasm: use double as duration data type
Fixes a crash in certain circumstances. Change-Id: Ia4c9e9c7a5fb94863f48f32eca13bb6832a3eefc Reviewed-by: MikoĊ‚aj Boc <Mikolaj.Boc@qt.io> (cherry picked from commit 51b0aa48169a2db839368b9785600fb802756b1b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/multimedia/wasm/common/qwasmvideooutput.cpp20
1 files changed, 10 insertions, 10 deletions
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<int>() < 1)
return;
if (positionToSetInSeconds
- >= seekableTimeRange.call<emscripten::val>("start", 0).as<int>()
+ >= seekableTimeRange.call<emscripten::val>("start", 0).as<double>()
&& positionToSetInSeconds
- <= seekableTimeRange.call<emscripten::val>("end", 0).as<int>()) {
+ <= seekableTimeRange.call<emscripten::val>("end", 0).as<double>()) {
m_requestedPosition = positionToSetInSeconds;
m_video.set("currentTime", m_requestedPosition);
@@ -399,8 +399,8 @@ bool QWasmVideoOutput::isVideoSeekable()
if (seekableTimeRange["length"].as<int>() < 1)
return false;
if (!seekableTimeRange.isNull() || !seekableTimeRange.isUndefined()) {
- bool isit = !qFuzzyCompare(seekableTimeRange.call<emscripten::val>("start", 0).as<float>(),
- seekableTimeRange.call<emscripten::val>("end", 0).as<float>());
+ bool isit = !qFuzzyCompare(seekableTimeRange.call<emscripten::val>("start", 0).as<double>(),
+ seekableTimeRange.call<emscripten::val>("end", 0).as<double>());
return isit;
}
return false;
@@ -616,7 +616,7 @@ void QWasmVideoOutput::doElementCallbacks()
if ((!timeRanges.isNull() || !timeRanges.isUndefined())
&& timeRanges["length"].as<int>() == 1) {
double buffered = m_video["buffered"].call<emscripten::val>("end", 0).as<double>();
- float duration = m_video["duration"].as<float>();
+ const double duration = m_video["duration"].as<double>();
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<int>();
+ const double duration = event["target"]["duration"].as<double>();
if (duration < 0) // track not exactly ready yet
return;
@@ -715,7 +715,7 @@ void QWasmVideoOutput::doElementCallbacks()
double bufferedEnd = dVal.as<double>();
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<int>(); // in seconds
- int duration = m_video["duration"].as<int>(); // in seconds
+ const double currentTime = m_video["currentTime"].as<double>(); // in seconds
+ const double duration = m_video["duration"].as<double>(); // 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<int>() * 1000;
+ return m_video["duration"].as<double>() * 1000;
}
void QWasmVideoOutput::newFrame(const QVideoFrame &frame)