[Libreoffice-commits] core.git: avmedia/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Apr 18 20:00:55 UTC 2020


 avmedia/source/framework/MediaControlBase.cxx |   22 +-
 avmedia/source/gstreamer/gstplayer.cxx        |   23 +-
 avmedia/source/viewer/mediawindow_impl.cxx    |  226 +++++++++++++-------------
 3 files changed, 136 insertions(+), 135 deletions(-)

New commits:
commit 0034fba36bdfe876c57014382ce77ea3aed55c91
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sat Apr 18 15:06:23 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Apr 18 22:00:13 2020 +0200

    loplugin:flatten in avmedia
    
    Change-Id: Ie066ee15833a58db4a9a18006629c015d50a56b6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92486
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/avmedia/source/framework/MediaControlBase.cxx b/avmedia/source/framework/MediaControlBase.cxx
index 2d6b8d05b7a1..e84586d76809 100644
--- a/avmedia/source/framework/MediaControlBase.cxx
+++ b/avmedia/source/framework/MediaControlBase.cxx
@@ -38,20 +38,20 @@ MediaControlBase::MediaControlBase()
 
 void MediaControlBase::UpdateTimeField( MediaItem const & aMediaItem, double fTime )
 {
-    if( !aMediaItem.getURL().isEmpty())
-    {
-        OUString aTimeString;
+    if( aMediaItem.getURL().isEmpty())
+        return;
 
-        SvtSysLocale aSysLocale;
-        const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
+    OUString aTimeString;
 
-        aTimeString += rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( fTime ) ) ) ) +
-            " / " +
-            rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( aMediaItem.getDuration() ) )) );
+    SvtSysLocale aSysLocale;
+    const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
 
-        if( mxTimeEdit->get_text() != aTimeString )
-            mxTimeEdit->set_text( aTimeString );
-    }
+    aTimeString += rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( fTime ) ) ) ) +
+        " / " +
+        rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( aMediaItem.getDuration() ) )) );
+
+    if( mxTimeEdit->get_text() != aTimeString )
+        mxTimeEdit->set_text( aTimeString );
 }
 
 void MediaControlBase::UpdateVolumeSlider( MediaItem const & aMediaItem )
diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx
index 2c8dbc085ee9..9511be54b5ae 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -674,19 +674,20 @@ void SAL_CALL Player::setMediaTime( double fTime )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
 
-    if( mpPlaybin ) {
-        gint64 gst_position = llround (fTime * GST_SECOND);
+    if( !mpPlaybin )
+        return;
 
-        gst_element_seek( mpPlaybin, 1.0,
-                          GST_FORMAT_TIME,
-                          GST_SEEK_FLAG_FLUSH,
-                          GST_SEEK_TYPE_SET, gst_position,
-                          GST_SEEK_TYPE_NONE, 0 );
-        if( !isPlaying() )
-            gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
+    gint64 gst_position = llround (fTime * GST_SECOND);
 
-        SAL_INFO( "avmedia.gstreamer", AVVERSION "seek to: " << gst_position << " ns original: " << fTime << " s" );
-    }
+    gst_element_seek( mpPlaybin, 1.0,
+                      GST_FORMAT_TIME,
+                      GST_SEEK_FLAG_FLUSH,
+                      GST_SEEK_TYPE_SET, gst_position,
+                      GST_SEEK_TYPE_NONE, 0 );
+    if( !isPlaying() )
+        gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
+
+    SAL_INFO( "avmedia.gstreamer", AVVERSION "seek to: " << gst_position << " ns original: " << fTime << " s" );
 }
 
 
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx
index afb4a674cbb9..98f867e4e4e1 100644
--- a/avmedia/source/viewer/mediawindow_impl.cxx
+++ b/avmedia/source/viewer/mediawindow_impl.cxx
@@ -224,38 +224,38 @@ void MediaWindowImpl::setURL( const OUString& rURL,
         OUString const& rTempURL, OUString const& rReferer)
 {
     maReferer = rReferer;
-    if( rURL != getURL() )
-    {
-        if( mxPlayer.is() )
-            mxPlayer->stop();
+    if( rURL == getURL() )
+        return;
 
-        if( mxPlayerWindow.is() )
-        {
-            mxPlayerWindow->setVisible( false );
-            mxPlayerWindow.clear();
-        }
+    if( mxPlayer.is() )
+        mxPlayer->stop();
 
-        mxPlayer.clear();
-        mTempFileURL.clear();
+    if( mxPlayerWindow.is() )
+    {
+        mxPlayerWindow->setVisible( false );
+        mxPlayerWindow.clear();
+    }
 
-        if (!rTempURL.isEmpty())
-        {
-            maFileURL = rURL;
-            mTempFileURL = rTempURL;
-        }
-        else
-        {
-            INetURLObject aURL( rURL );
+    mxPlayer.clear();
+    mTempFileURL.clear();
 
-            if (aURL.GetProtocol() != INetProtocol::NotValid)
-                maFileURL = aURL.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
-            else
-                maFileURL = rURL;
-        }
+    if (!rTempURL.isEmpty())
+    {
+        maFileURL = rURL;
+        mTempFileURL = rTempURL;
+    }
+    else
+    {
+        INetURLObject aURL( rURL );
 
-        mxPlayer = createPlayer((!mTempFileURL.isEmpty()) ? mTempFileURL : maFileURL, rReferer, &m_sMimeType );
-        onURLChanged();
+        if (aURL.GetProtocol() != INetProtocol::NotValid)
+            maFileURL = aURL.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
+        else
+            maFileURL = rURL;
     }
+
+    mxPlayer = createPlayer((!mTempFileURL.isEmpty()) ? mTempFileURL : maFileURL, rReferer, &m_sMimeType );
+    onURLChanged();
 }
 
 const OUString& MediaWindowImpl::getURL() const
@@ -332,35 +332,35 @@ void MediaWindowImpl::executeMediaItem( const MediaItem& rItem )
         mxPlayerWindow->setZoomLevel( rItem.getZoom() );
 
     // set play state at last
-    if (nMaskSet & AVMediaSetMask::STATE)
+    if (!(nMaskSet & AVMediaSetMask::STATE))
+        return;
+
+    switch (rItem.getState())
     {
-        switch (rItem.getState())
+        case MediaState::Play:
         {
-            case MediaState::Play:
-            {
-                if (!isPlaying())
-                    start();
-            }
-            break;
+            if (!isPlaying())
+                start();
+        }
+        break;
 
-            case MediaState::Pause:
-            {
-                if (isPlaying())
-                    stop();
-            }
-            break;
+        case MediaState::Pause:
+        {
+            if (isPlaying())
+                stop();
+        }
+        break;
 
-            case MediaState::Stop:
+        case MediaState::Stop:
+        {
+            if (isPlaying())
             {
-                if (isPlaying())
-                {
-                    setMediaTime( 0.0 );
-                    stop();
-                    setMediaTime( 0.0 );
-                }
+                setMediaTime( 0.0 );
+                stop();
+                setMediaTime( 0.0 );
             }
-            break;
         }
+        break;
     }
 }
 
@@ -472,31 +472,31 @@ void MediaWindowImpl::setPointer(PointerStyle aPointer)
     if (mpChildWindow)
         mpChildWindow->SetPointer(aPointer);
 
-    if (mxPlayerWindow.is())
-    {
-        long nPointer;
+    if (!mxPlayerWindow.is())
+        return;
 
-        switch (aPointer)
-        {
-            case PointerStyle::Cross:
-                nPointer = awt::SystemPointer::CROSS;
-                break;
-            case PointerStyle::Hand:
-                nPointer = awt::SystemPointer::HAND;
-                break;
-            case PointerStyle::Move:
-                nPointer = awt::SystemPointer::MOVE;
-                break;
-            case PointerStyle::Wait:
-                nPointer = awt::SystemPointer::WAIT;
-                break;
-            default:
-                nPointer = awt::SystemPointer::ARROW;
-                break;
-        }
+    long nPointer;
 
-        mxPlayerWindow->setPointerType(nPointer);
+    switch (aPointer)
+    {
+        case PointerStyle::Cross:
+            nPointer = awt::SystemPointer::CROSS;
+            break;
+        case PointerStyle::Hand:
+            nPointer = awt::SystemPointer::HAND;
+            break;
+        case PointerStyle::Move:
+            nPointer = awt::SystemPointer::MOVE;
+            break;
+        case PointerStyle::Wait:
+            nPointer = awt::SystemPointer::WAIT;
+            break;
+        default:
+            nPointer = awt::SystemPointer::ARROW;
+            break;
     }
+
+    mxPlayerWindow->setPointerType(nPointer);
 }
 
 void MediaWindowImpl::Resize()
@@ -524,28 +524,28 @@ void MediaWindowImpl::Resize()
 
 void MediaWindowImpl::StateChanged(StateChangedType eType)
 {
-    if (mxPlayerWindow.is())
+    if (!mxPlayerWindow.is())
+        return;
+
+    // stop playing when going disabled or hidden
+    switch (eType)
     {
-        // stop playing when going disabled or hidden
-        switch (eType)
+        case StateChangedType::Visible:
         {
-            case StateChangedType::Visible:
-            {
-                stopPlayingInternal(!IsVisible());
-                mxPlayerWindow->setVisible(IsVisible());
-            }
-            break;
-
-            case StateChangedType::Enable:
-            {
-                stopPlayingInternal(!IsEnabled());
-                mxPlayerWindow->setEnable(IsEnabled());
-            }
-            break;
+            stopPlayingInternal(!IsVisible());
+            mxPlayerWindow->setVisible(IsVisible());
+        }
+        break;
 
-            default:
-            break;
+        case StateChangedType::Enable:
+        {
+            stopPlayingInternal(!IsEnabled());
+            mxPlayerWindow->setEnable(IsEnabled());
         }
+        break;
+
+        default:
+        break;
     }
 }
 
@@ -577,37 +577,37 @@ void MediaWindowImpl::Paint(vcl::RenderContext& rRenderContext, const tools::Rec
     const Point aBasePos(mpChildWindow->GetPosPixel());
     const tools::Rectangle aVideoRect(aBasePos, mpChildWindow->GetSizePixel());
 
-    if (pLogo && !pLogo->IsEmpty() && !aVideoRect.IsEmpty())
-    {
-        Size aLogoSize(pLogo->GetSizePixel());
-        const Color aBackgroundColor(67, 67, 67);
+    if (!(pLogo && !pLogo->IsEmpty() && !aVideoRect.IsEmpty()))
+        return;
 
-        rRenderContext.SetLineColor(aBackgroundColor);
-        rRenderContext.SetFillColor(aBackgroundColor);
-        rRenderContext.DrawRect(aVideoRect);
+    Size aLogoSize(pLogo->GetSizePixel());
+    const Color aBackgroundColor(67, 67, 67);
 
-        if ((aLogoSize.Width() > aVideoRect.GetWidth() || aLogoSize.Height() > aVideoRect.GetHeight() ) &&
-            (aLogoSize.Height() > 0))
-        {
-            const double fLogoWH = double(aLogoSize.Width()) / aLogoSize.Height();
+    rRenderContext.SetLineColor(aBackgroundColor);
+    rRenderContext.SetFillColor(aBackgroundColor);
+    rRenderContext.DrawRect(aVideoRect);
 
-            if (fLogoWH < (double(aVideoRect.GetWidth()) / aVideoRect.GetHeight()))
-            {
-                aLogoSize.setWidth( long(aVideoRect.GetHeight() * fLogoWH) );
-                aLogoSize.setHeight( aVideoRect.GetHeight() );
-            }
-            else
-            {
-                aLogoSize.setWidth( aVideoRect.GetWidth() );
-                aLogoSize.setHeight( long(aVideoRect.GetWidth() / fLogoWH) );
-            }
+    if ((aLogoSize.Width() > aVideoRect.GetWidth() || aLogoSize.Height() > aVideoRect.GetHeight() ) &&
+        (aLogoSize.Height() > 0))
+    {
+        const double fLogoWH = double(aLogoSize.Width()) / aLogoSize.Height();
+
+        if (fLogoWH < (double(aVideoRect.GetWidth()) / aVideoRect.GetHeight()))
+        {
+            aLogoSize.setWidth( long(aVideoRect.GetHeight() * fLogoWH) );
+            aLogoSize.setHeight( aVideoRect.GetHeight() );
         }
+        else
+        {
+            aLogoSize.setWidth( aVideoRect.GetWidth() );
+            aLogoSize.setHeight( long(aVideoRect.GetWidth() / fLogoWH) );
+        }
+    }
 
-        Point aPoint(aBasePos.X() + ((aVideoRect.GetWidth() - aLogoSize.Width()) >> 1),
-                     aBasePos.Y() + ((aVideoRect.GetHeight() - aLogoSize.Height()) >> 1));
+    Point aPoint(aBasePos.X() + ((aVideoRect.GetWidth() - aLogoSize.Width()) >> 1),
+                 aBasePos.Y() + ((aVideoRect.GetHeight() - aLogoSize.Height()) >> 1));
 
-        rRenderContext.DrawBitmapEx(aPoint, aLogoSize, *pLogo);
-    }
+    rRenderContext.DrawBitmapEx(aPoint, aLogoSize, *pLogo);
 }
 
 void MediaWindowImpl::GetFocus()


More information about the Libreoffice-commits mailing list