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@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-04-18 15:06:23 +02:00
parent 7fa4f64098
commit 0034fba36b
3 changed files with 147 additions and 146 deletions

View File

@@ -38,20 +38,20 @@ MediaControlBase::MediaControlBase()
void MediaControlBase::UpdateTimeField( MediaItem const & aMediaItem, double fTime ) void MediaControlBase::UpdateTimeField( MediaItem const & aMediaItem, double fTime )
{ {
if( !aMediaItem.getURL().isEmpty()) if( aMediaItem.getURL().isEmpty())
{ return;
OUString aTimeString;
SvtSysLocale aSysLocale; OUString aTimeString;
const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
aTimeString += rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( fTime ) ) ) ) + SvtSysLocale aSysLocale;
" / " + const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( aMediaItem.getDuration() ) )) );
if( mxTimeEdit->get_text() != aTimeString ) aTimeString += rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( fTime ) ) ) ) +
mxTimeEdit->set_text( aTimeString ); " / " +
} 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 ) void MediaControlBase::UpdateVolumeSlider( MediaItem const & aMediaItem )

View File

@@ -674,19 +674,20 @@ void SAL_CALL Player::setMediaTime( double fTime )
{ {
::osl::MutexGuard aGuard(m_aMutex); ::osl::MutexGuard aGuard(m_aMutex);
if( mpPlaybin ) { if( !mpPlaybin )
gint64 gst_position = llround (fTime * GST_SECOND); return;
gst_element_seek( mpPlaybin, 1.0, gint64 gst_position = llround (fTime * GST_SECOND);
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" ); 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" );
} }

View File

@@ -224,38 +224,38 @@ void MediaWindowImpl::setURL( const OUString& rURL,
OUString const& rTempURL, OUString const& rReferer) OUString const& rTempURL, OUString const& rReferer)
{ {
maReferer = rReferer; maReferer = rReferer;
if( rURL != getURL() ) if( rURL == getURL() )
return;
if( mxPlayer.is() )
mxPlayer->stop();
if( mxPlayerWindow.is() )
{ {
if( mxPlayer.is() ) mxPlayerWindow->setVisible( false );
mxPlayer->stop(); mxPlayerWindow.clear();
if( mxPlayerWindow.is() )
{
mxPlayerWindow->setVisible( false );
mxPlayerWindow.clear();
}
mxPlayer.clear();
mTempFileURL.clear();
if (!rTempURL.isEmpty())
{
maFileURL = rURL;
mTempFileURL = rTempURL;
}
else
{
INetURLObject aURL( rURL );
if (aURL.GetProtocol() != INetProtocol::NotValid)
maFileURL = aURL.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
else
maFileURL = rURL;
}
mxPlayer = createPlayer((!mTempFileURL.isEmpty()) ? mTempFileURL : maFileURL, rReferer, &m_sMimeType );
onURLChanged();
} }
mxPlayer.clear();
mTempFileURL.clear();
if (!rTempURL.isEmpty())
{
maFileURL = rURL;
mTempFileURL = rTempURL;
}
else
{
INetURLObject aURL( rURL );
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 const OUString& MediaWindowImpl::getURL() const
@@ -332,35 +332,35 @@ void MediaWindowImpl::executeMediaItem( const MediaItem& rItem )
mxPlayerWindow->setZoomLevel( rItem.getZoom() ); mxPlayerWindow->setZoomLevel( rItem.getZoom() );
// set play state at last // 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();
if (!isPlaying())
start();
}
break;
case MediaState::Pause:
{
if (isPlaying())
stop();
}
break;
case MediaState::Stop:
{
if (isPlaying())
{
setMediaTime( 0.0 );
stop();
setMediaTime( 0.0 );
}
}
break;
} }
break;
case MediaState::Pause:
{
if (isPlaying())
stop();
}
break;
case MediaState::Stop:
{
if (isPlaying())
{
setMediaTime( 0.0 );
stop();
setMediaTime( 0.0 );
}
}
break;
} }
} }
@@ -472,31 +472,31 @@ void MediaWindowImpl::setPointer(PointerStyle aPointer)
if (mpChildWindow) if (mpChildWindow)
mpChildWindow->SetPointer(aPointer); mpChildWindow->SetPointer(aPointer);
if (mxPlayerWindow.is()) if (!mxPlayerWindow.is())
return;
long nPointer;
switch (aPointer)
{ {
long nPointer; case PointerStyle::Cross:
nPointer = awt::SystemPointer::CROSS;
switch (aPointer) break;
{ case PointerStyle::Hand:
case PointerStyle::Cross: nPointer = awt::SystemPointer::HAND;
nPointer = awt::SystemPointer::CROSS; break;
break; case PointerStyle::Move:
case PointerStyle::Hand: nPointer = awt::SystemPointer::MOVE;
nPointer = awt::SystemPointer::HAND; break;
break; case PointerStyle::Wait:
case PointerStyle::Move: nPointer = awt::SystemPointer::WAIT;
nPointer = awt::SystemPointer::MOVE; break;
break; default:
case PointerStyle::Wait: nPointer = awt::SystemPointer::ARROW;
nPointer = awt::SystemPointer::WAIT; break;
break;
default:
nPointer = awt::SystemPointer::ARROW;
break;
}
mxPlayerWindow->setPointerType(nPointer);
} }
mxPlayerWindow->setPointerType(nPointer);
} }
void MediaWindowImpl::Resize() void MediaWindowImpl::Resize()
@@ -524,28 +524,28 @@ void MediaWindowImpl::Resize()
void MediaWindowImpl::StateChanged(StateChangedType eType) 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 case StateChangedType::Visible:
switch (eType)
{ {
case StateChangedType::Visible: stopPlayingInternal(!IsVisible());
{ mxPlayerWindow->setVisible(IsVisible());
stopPlayingInternal(!IsVisible());
mxPlayerWindow->setVisible(IsVisible());
}
break;
case StateChangedType::Enable:
{
stopPlayingInternal(!IsEnabled());
mxPlayerWindow->setEnable(IsEnabled());
}
break;
default:
break;
} }
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 Point aBasePos(mpChildWindow->GetPosPixel());
const tools::Rectangle aVideoRect(aBasePos, mpChildWindow->GetSizePixel()); const tools::Rectangle aVideoRect(aBasePos, mpChildWindow->GetSizePixel());
if (pLogo && !pLogo->IsEmpty() && !aVideoRect.IsEmpty()) if (!(pLogo && !pLogo->IsEmpty() && !aVideoRect.IsEmpty()))
return;
Size aLogoSize(pLogo->GetSizePixel());
const Color aBackgroundColor(67, 67, 67);
rRenderContext.SetLineColor(aBackgroundColor);
rRenderContext.SetFillColor(aBackgroundColor);
rRenderContext.DrawRect(aVideoRect);
if ((aLogoSize.Width() > aVideoRect.GetWidth() || aLogoSize.Height() > aVideoRect.GetHeight() ) &&
(aLogoSize.Height() > 0))
{ {
Size aLogoSize(pLogo->GetSizePixel()); const double fLogoWH = double(aLogoSize.Width()) / aLogoSize.Height();
const Color aBackgroundColor(67, 67, 67);
rRenderContext.SetLineColor(aBackgroundColor); if (fLogoWH < (double(aVideoRect.GetWidth()) / aVideoRect.GetHeight()))
rRenderContext.SetFillColor(aBackgroundColor);
rRenderContext.DrawRect(aVideoRect);
if ((aLogoSize.Width() > aVideoRect.GetWidth() || aLogoSize.Height() > aVideoRect.GetHeight() ) &&
(aLogoSize.Height() > 0))
{ {
const double fLogoWH = double(aLogoSize.Width()) / aLogoSize.Height(); aLogoSize.setWidth( long(aVideoRect.GetHeight() * fLogoWH) );
aLogoSize.setHeight( aVideoRect.GetHeight() );
if (fLogoWH < (double(aVideoRect.GetWidth()) / aVideoRect.GetHeight())) }
{ else
aLogoSize.setWidth( long(aVideoRect.GetHeight() * fLogoWH) ); {
aLogoSize.setHeight( aVideoRect.GetHeight() ); aLogoSize.setWidth( aVideoRect.GetWidth() );
} aLogoSize.setHeight( long(aVideoRect.GetWidth() / fLogoWH) );
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));
rRenderContext.DrawBitmapEx(aPoint, aLogoSize, *pLogo);
} }
Point aPoint(aBasePos.X() + ((aVideoRect.GetWidth() - aLogoSize.Width()) >> 1),
aBasePos.Y() + ((aVideoRect.GetHeight() - aLogoSize.Height()) >> 1));
rRenderContext.DrawBitmapEx(aPoint, aLogoSize, *pLogo);
} }
void MediaWindowImpl::GetFocus() void MediaWindowImpl::GetFocus()