From 4a9586e991cdec7564585070b90e1c6acbcecab1 Mon Sep 17 00:00:00 2001 From: ka Date: Wed, 9 Jun 2010 21:15:24 +0200 Subject: [PATCH] avmedia101: adjustments for new GStreamer build baseline --- avmedia/source/gstreamer/gstplayer.cxx | 26 ++++++++------- avmedia/source/gstreamer/gstplayer.hxx | 44 +++++++++++++++++--------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx index e1a7ef566ee2..e9fe02594b66 100644 --- a/avmedia/source/gstreamer/gstplayer.cxx +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -326,7 +326,10 @@ double SAL_CALL Player::getRate() void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) throw( uno::RuntimeException ) { - g_atomic_int_set( &mnLooping, bSet ? 1 : 0 ); + if( bSet && !isPlaybackLoop() ) + g_atomic_int_inc( &mnLooping ); + else if( !bSet && isPlaybackLoop() ) + g_atomic_int_dec_and_test( &mnLooping ); } // ------------------------------------------------------------------------------ @@ -371,10 +374,12 @@ sal_Bool SAL_CALL Player::isMute() void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB ) throw( uno::RuntimeException ) { - g_atomic_int_set( &mnVolumeDB, nVolumeDB ); - if( implInitPlayer() ) { + g_mutex_lock( mpMutex ); + mnVolumeDB = nVolumeDB; + g_mutex_unlock( mpMutex ); + // maximum gain for gstreamer volume is 10 double fGstVolume = pow( 10.0, static_cast< double >( ::std::min( nVolumeDB, static_cast< sal_Int16 >( 20 ) ) / 20.0 ) ); @@ -528,7 +533,7 @@ void Player::implQuitThread() { // set quit flag to 1 so that the main loop will be quit in idle // handler the next time it is called from the thread's main loop - g_atomic_int_add( &mnQuit, 1 ); + g_atomic_int_inc( &mnQuit ); // wait until loop and as such the thread has quit g_thread_join( mpThread ); @@ -758,7 +763,7 @@ void Player::implHandleNewPadFunc( GstElement* pElement, // just look for structures having 'video' in their names if( ::std::string( pStructName ).find( "video" ) != ::std::string::npos ) { - g_atomic_int_set( &pPlayer->mnIsVideoSource, 1 ); + g_atomic_int_inc( &pPlayer->mnIsVideoSource ); for( gint n = 0, nFields = gst_structure_n_fields( pStruct ); n < nFields; ++n ) { @@ -768,15 +773,14 @@ void Player::implHandleNewPadFunc( GstElement* pElement, if( ( ::std::string( pFieldName ).find( "width" ) != ::std::string::npos ) && gst_structure_get_int( pStruct, pFieldName, &nValue ) ) { - g_atomic_int_set( &pPlayer->mnVideoWidth, - ::std::max( (gint) g_atomic_int_get( - &pPlayer->mnVideoWidth ), nValue ) ); + const gint nDiff = nValue - g_atomic_int_get( &pPlayer->mnVideoWidth ); + g_atomic_int_add( &pPlayer->mnVideoWidth, ::std::max( nDiff, 0 ) ); } else if( ( ::std::string( pFieldName ).find( "height" ) != ::std::string::npos ) && gst_structure_get_int( pStruct, pFieldName, &nValue ) ) { - g_atomic_int_set( &pPlayer->mnVideoHeight, - ::std::max( g_atomic_int_get( &pPlayer->mnVideoHeight ), nValue ) ); + const gint nDiff = nValue - g_atomic_int_get( &pPlayer->mnVideoHeight ); + g_atomic_int_add( &pPlayer->mnVideoHeight, ::std::max( nDiff, 0 ) ); } } } @@ -800,7 +804,7 @@ gboolean Player::idle() // in case Player::idle() is called again later; // the flag should have been set only once within Ctor called from // the application thread - g_atomic_int_add( &mnQuit, -1 ); + g_atomic_int_dec_and_test( &mnQuit ); g_main_loop_quit( mpLoop ); } diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx index c8cf6d558994..b4e437c89a8c 100644 --- a/avmedia/source/gstreamer/gstplayer.hxx +++ b/avmedia/source/gstreamer/gstplayer.hxx @@ -33,8 +33,21 @@ #include "gstcommon.hxx" #include -#include +#include +// necessary for older GLib versions +#ifndef G_GNUC_NULL_TERMINATED +#if __GNUC__ >= 4 +#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) +#else +#define G_GNUC_NULL_TERMINATED +#endif +#endif + +// necessary for older GLib versions +struct GOptionGroup; + +#include #include "com/sun/star/media/XPlayer.hdl" namespace avmedia @@ -140,7 +153,9 @@ public: throw( ::com::sun::star::uno::RuntimeException ); -protected: Player( GString* pURI = NULL ); +protected: + + Player( GString* pURI = NULL ); virtual gboolean busCallback( GstBus* pBus, GstMessage* pMsg ); @@ -162,12 +177,11 @@ protected: Player( GString* pURI = NULL ); } -private: Player( const Player& ) {} +private: - Player & operator=( const Player& ) - { - return( *this ); - } + Player( const Player& ); + + Player& operator=( const Player& ); static gboolean implBusPrepare( GSource* pSource, gint* pTimeout ); @@ -209,14 +223,14 @@ protected: private: ::avmedia::gst::Window* mpPlayerWindow; - volatile gint mnIsVideoSource; - volatile gint mnVideoWidth; - volatile gint mnVideoHeight; - volatile gint mnInitialized; - volatile gint mnVolumeDB; - volatile gint mnLooping; - volatile gint mnQuit; - volatile gint mnVideoWindowSet; + gint mnIsVideoSource; + gint mnVideoWidth; + gint mnVideoHeight; + gint mnInitialized; + gint mnVolumeDB; + gint mnLooping; + gint mnQuit; + gint mnVideoWindowSet; }; } // namespace gst } // namespace avmedia