diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-02-14 10:31:17 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-02-14 13:50:35 +0100 |
commit | 21292d2bdc669ed379185c1e324727071cffc082 (patch) | |
tree | bb5fb92cf94167075e5668a33989ed4b6a183afd /avmedia/source/framework | |
parent | e37b9b21edccf2750816c18103b5b39d42779fac (diff) |
Related: tdf#100007 pause state not always updating "play" state to off
if I press pause then the UI gets stuck with both pause and stop
pressed in, the check against time here seems insufficient so
change merge and the setters to return true if there was a real
change and use that as the guard to update the UI
Change-Id: I550624fa3dcd5655d715a1f965bba9345b25ded7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129906
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'avmedia/source/framework')
-rw-r--r-- | avmedia/source/framework/mediacontrol.cxx | 11 | ||||
-rw-r--r-- | avmedia/source/framework/mediaitem.cxx | 124 |
2 files changed, 74 insertions, 61 deletions
diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx index bb1bca959a90..23d700595f95 100644 --- a/avmedia/source/framework/mediacontrol.cxx +++ b/avmedia/source/framework/mediacontrol.cxx @@ -39,8 +39,7 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl maChangeTimeIdle( "avmedia MediaControl Change Time Idle" ), maItem( 0, AVMediaSetMask::ALL ), mbLocked( false ), - meControlStyle( eControlStyle ), - mfTime(0.0) + meControlStyle( eControlStyle ) { mxPlayToolBox = m_xBuilder->weld_toolbar("playtoolbox"); mxTimeSlider = m_xBuilder->weld_scale("timeslider"); @@ -112,11 +111,11 @@ void MediaControl::UpdateURLField(MediaItem const & tempItem) void MediaControl::setState( const MediaItem& rItem ) { - double fTime = rItem.getTime(); - if( !mbLocked && fTime != mfTime) + if (mbLocked) + return; + bool bChanged = maItem.merge(rItem); + if (bChanged) { - mfTime = fTime; - maItem.merge( rItem ); if( rItem.getURL().isEmpty() && meControlStyle == MediaControlStyle::SingleLine ) mxPlayToolBox->set_sensitive(false); UpdateToolBoxes( maItem ); diff --git a/avmedia/source/framework/mediaitem.cxx b/avmedia/source/framework/mediaitem.cxx index 127ad8af243f..0a53cf5d4d39 100644 --- a/avmedia/source/framework/mediaitem.cxx +++ b/avmedia/source/framework/mediaitem.cxx @@ -178,187 +178,201 @@ bool MediaItem::PutValue( const css::uno::Any& rVal, sal_uInt8 ) return bRet; } - -void MediaItem::merge( const MediaItem& rMediaItem ) +bool MediaItem::merge(const MediaItem& rMediaItem) { + bool bChanged = false; + const AVMediaSetMask nMaskSet = rMediaItem.getMaskSet(); if( AVMediaSetMask::URL & nMaskSet ) - setURL( rMediaItem.getURL(), rMediaItem.getTempURL(), rMediaItem.getReferer() ); + bChanged |= setURL(rMediaItem.getURL(), rMediaItem.getTempURL(), rMediaItem.getReferer()); if( AVMediaSetMask::MIME_TYPE & nMaskSet ) - setMimeType( rMediaItem.getMimeType() ); + bChanged |= setMimeType(rMediaItem.getMimeType()); if (nMaskSet & AVMediaSetMask::GRAPHIC) - setGraphic(rMediaItem.getGraphic()); + bChanged |= setGraphic(rMediaItem.getGraphic()); if( AVMediaSetMask::STATE & nMaskSet ) - setState( rMediaItem.getState() ); + bChanged |= setState( rMediaItem.getState() ); if( AVMediaSetMask::DURATION & nMaskSet ) - setDuration( rMediaItem.getDuration() ); + bChanged |= setDuration(rMediaItem.getDuration()); if( AVMediaSetMask::TIME & nMaskSet ) - setTime( rMediaItem.getTime() ); + bChanged |= setTime(rMediaItem.getTime()); if( AVMediaSetMask::LOOP & nMaskSet ) - setLoop( rMediaItem.isLoop() ); + bChanged |= setLoop(rMediaItem.isLoop()); if( AVMediaSetMask::MUTE & nMaskSet ) - setMute( rMediaItem.isMute() ); + bChanged |= setMute(rMediaItem.isMute()); if( AVMediaSetMask::VOLUMEDB & nMaskSet ) - setVolumeDB( rMediaItem.getVolumeDB() ); + bChanged |= setVolumeDB(rMediaItem.getVolumeDB()); if( AVMediaSetMask::ZOOM & nMaskSet ) - setZoom( rMediaItem.getZoom() ); -} + bChanged |= setZoom(rMediaItem.getZoom()); + return bChanged; +} AVMediaSetMask MediaItem::getMaskSet() const { return m_pImpl->m_nMaskSet; } - -void MediaItem::setURL( const OUString& rURL, const OUString& rTempURL, const OUString& rReferer ) +bool MediaItem::setURL(const OUString& rURL, const OUString& rTempURL, const OUString& rReferer) { m_pImpl->m_nMaskSet |= AVMediaSetMask::URL; - m_pImpl->m_URL = rURL; - m_pImpl->m_TempFileURL = rTempURL; - m_pImpl->m_Referer = rReferer; + bool bChanged = rURL != m_pImpl->m_URL || rTempURL != m_pImpl->m_TempFileURL || rReferer != m_pImpl->m_Referer; + if (bChanged) + { + m_pImpl->m_URL = rURL; + m_pImpl->m_TempFileURL = rTempURL; + m_pImpl->m_Referer = rReferer; + } + return bChanged; } - const OUString& MediaItem::getURL() const { return m_pImpl->m_URL; } - const OUString& MediaItem::getTempURL() const { return m_pImpl->m_TempFileURL; } - const OUString& MediaItem::getReferer() const { return m_pImpl->m_Referer; } - -void MediaItem::setMimeType( const OUString& rMimeType ) +bool MediaItem::setMimeType(const OUString& rMimeType) { m_pImpl->m_nMaskSet |= AVMediaSetMask::MIME_TYPE; - m_pImpl->m_sMimeType = rMimeType; + bool bChanged = rMimeType != m_pImpl->m_sMimeType; + if (bChanged) + m_pImpl->m_sMimeType = rMimeType; + return bChanged; } - OUString MediaItem::getMimeType() const { return !m_pImpl->m_sMimeType.isEmpty() ? m_pImpl->m_sMimeType : AVMEDIA_MIMETYPE_COMMON; } -void MediaItem::setGraphic(const Graphic& rGraphic) +bool MediaItem::setGraphic(const Graphic& rGraphic) { m_pImpl->m_nMaskSet |= AVMediaSetMask::GRAPHIC; - m_pImpl->m_aGraphic = rGraphic; + bool bChanged = rGraphic != m_pImpl->m_aGraphic; + if (bChanged) + m_pImpl->m_aGraphic = rGraphic; + return bChanged; } const Graphic & MediaItem::getGraphic() const { return m_pImpl->m_aGraphic; } -void MediaItem::setState( MediaState eState ) +bool MediaItem::setState(MediaState eState) { - m_pImpl->m_eState = eState; m_pImpl->m_nMaskSet |= AVMediaSetMask::STATE; + bool bChanged = eState != m_pImpl->m_eState; + if (bChanged) + m_pImpl->m_eState = eState; + return bChanged; } - MediaState MediaItem::getState() const { return m_pImpl->m_eState; } - -void MediaItem::setDuration( double fDuration ) +bool MediaItem::setDuration(double fDuration) { - m_pImpl->m_fDuration = fDuration; m_pImpl->m_nMaskSet |= AVMediaSetMask::DURATION; + bool bChanged = fDuration != m_pImpl->m_fDuration; + if (bChanged) + m_pImpl->m_fDuration = fDuration; + return bChanged; } - double MediaItem::getDuration() const { return m_pImpl->m_fDuration; } - -void MediaItem::setTime( double fTime ) +bool MediaItem::setTime(double fTime) { - m_pImpl->m_fTime = fTime; m_pImpl->m_nMaskSet |= AVMediaSetMask::TIME; + bool bChanged = fTime != m_pImpl->m_fTime; + if (bChanged) + m_pImpl->m_fTime = fTime; + return bChanged; } - double MediaItem::getTime() const { return m_pImpl->m_fTime; } - -void MediaItem::setLoop( bool bLoop ) +bool MediaItem::setLoop(bool bLoop) { - m_pImpl->m_bLoop = bLoop; m_pImpl->m_nMaskSet |= AVMediaSetMask::LOOP; + bool bChanged = bLoop != m_pImpl->m_bLoop; + if (bChanged) + m_pImpl->m_bLoop = bLoop; + return bChanged; } - bool MediaItem::isLoop() const { return m_pImpl->m_bLoop; } - -void MediaItem::setMute( bool bMute ) +bool MediaItem::setMute(bool bMute) { - m_pImpl->m_bMute = bMute; m_pImpl->m_nMaskSet |= AVMediaSetMask::MUTE; + bool bChanged = bMute != m_pImpl->m_bMute; + if (bChanged) + m_pImpl->m_bMute = bMute; + return bChanged; } - bool MediaItem::isMute() const { return m_pImpl->m_bMute; } - -void MediaItem::setVolumeDB( sal_Int16 nDB ) +bool MediaItem::setVolumeDB(sal_Int16 nDB) { - m_pImpl->m_nVolumeDB = nDB; m_pImpl->m_nMaskSet |= AVMediaSetMask::VOLUMEDB; + bool bChanged = nDB != m_pImpl->m_nVolumeDB; + if (bChanged) + m_pImpl->m_nVolumeDB = nDB; + return bChanged; } - sal_Int16 MediaItem::getVolumeDB() const { return m_pImpl->m_nVolumeDB; } - -void MediaItem::setZoom( css::media::ZoomLevel eZoom ) +bool MediaItem::setZoom(css::media::ZoomLevel eZoom) { - m_pImpl->m_eZoom = eZoom; m_pImpl->m_nMaskSet |= AVMediaSetMask::ZOOM; + bool bChanged = eZoom != m_pImpl->m_eZoom; + if (bChanged) + m_pImpl->m_eZoom = eZoom; + return bChanged; } - css::media::ZoomLevel MediaItem::getZoom() const { return m_pImpl->m_eZoom; } - OUString GetFilename(OUString const& rSourceURL) { uno::Reference<uri::XUriReferenceFactory> const xUriFactory( |