From 0398365fafa23bd9d8f8548654b7b068ad561ea5 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 28 Mar 2011 10:34:17 +0000 Subject: solaris11: #i117566#: gstreamer: Sun C++ complains: C callbacks not extern "C" --- avmedia/source/gstreamer/gstframegrabber.cxx | 3 + avmedia/source/gstreamer/gstplayer.cxx | 176 ++++++++++++++------------- avmedia/source/gstreamer/gstplayer.hxx | 29 +---- 3 files changed, 101 insertions(+), 107 deletions(-) (limited to 'avmedia') diff --git a/avmedia/source/gstreamer/gstframegrabber.cxx b/avmedia/source/gstreamer/gstframegrabber.cxx index bd55e11f8afe..49a6d9695fbc 100644 --- a/avmedia/source/gstreamer/gstframegrabber.cxx +++ b/avmedia/source/gstreamer/gstframegrabber.cxx @@ -31,6 +31,9 @@ #include #include +#include + + using namespace ::com::sun::star; namespace avmedia { namespace gst { diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx index f082cfc5c513..ba354fe5f274 100644 --- a/avmedia/source/gstreamer/gstplayer.cxx +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -66,6 +66,92 @@ struct GstBusSource : public GSource {} }; + +// ----------------------------------------------------------------------- +extern "C" +{ + +static gpointer +lcl_implThreadFunc( gpointer pData ) +{ + return( pData ? static_cast< Player* >( pData )->run() : NULL ); +} + +static gboolean +lcl_implBusCheck( GSource* pSource ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + + return( pBusSource && + GST_IS_BUS( pBusSource->mpBus ) && + gst_bus_have_pending( GST_BUS_CAST( pBusSource->mpBus ) ) ); +} + + +static gboolean +lcl_implBusPrepare( GSource* pSource, gint* pTimeout ) +{ + if (pTimeout) + { + *pTimeout = 0; + } + + return lcl_implBusCheck(pSource); +} + +static gboolean +lcl_implBusDispatch( GSource* pSource, + GSourceFunc /*aCallback*/, + gpointer pData ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + gboolean bRet = false; + + if( pData && pBusSource && GST_IS_BUS( pBusSource->mpBus ) ) + { + GstMessage* pMsg = gst_bus_pop( pBusSource->mpBus ); + + if( pMsg ) + { + bRet = static_cast< Player* >( pData )->busCallback( + pBusSource->mpBus, pMsg ); + gst_message_unref( pMsg ); + } + } + + return( bRet ); +} + +static void +lcl_implBusFinalize( GSource* pSource ) +{ + GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); + + if( pBusSource && pBusSource->mpBus ) + { + gst_object_unref( pBusSource->mpBus ); + pBusSource->mpBus = NULL; + } +} + +static gboolean +lcl_implIdleFunc( gpointer pData ) +{ + return( pData ? static_cast< Player* >( pData )->idle() : true ); +} + +static GstBusSyncReply +lcl_implHandleCreateWindowFunc( GstBus* pBus, GstMessage* pMsg, gpointer pData ) +{ + return (pData) + ? static_cast< Player* >( pData )->handleCreateWindow( pBus, pMsg ) + : GST_BUS_PASS; +} + +} // extern "C" + + + // --------------- // - Player - // --------------- @@ -102,7 +188,7 @@ Player::Player( GString* pURI ) : OSL_TRACE( ">>> --------------------------------" ); OSL_TRACE( ">>> Creating Player object with URL: %s", pURI->str ); - mpThread = g_thread_create( Player::implThreadFunc, this, true, NULL ); + mpThread = g_thread_create( &lcl_implThreadFunc, this, true, NULL ); } } @@ -572,62 +658,6 @@ bool Player::implInitPlayer() return( bRet ); } -// ------------------------------------------------------------------------------ -gboolean Player::implBusPrepare( GSource* pSource, - gint* pTimeout ) -{ - if( pTimeout ) - { - *pTimeout = 0; - } - - return( implBusCheck( pSource ) ); -} - -// ------------------------------------------------------------------------------ -gboolean Player::implBusCheck( GSource* pSource ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - - return( pBusSource && - GST_IS_BUS( pBusSource->mpBus ) && - gst_bus_have_pending( GST_BUS_CAST( pBusSource->mpBus ) ) ); -} - -// ------------------------------------------------------------------------------ -gboolean Player::implBusDispatch( GSource* pSource, - GSourceFunc /*aCallback*/, - gpointer pData ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - gboolean bRet = false; - - if( pData && pBusSource && GST_IS_BUS( pBusSource->mpBus ) ) - { - GstMessage* pMsg = gst_bus_pop( pBusSource->mpBus ); - - if( pMsg ) - { - bRet = static_cast< Player* >( pData )->busCallback( pBusSource->mpBus, pMsg ); - gst_message_unref( pMsg ); - } - } - - return( bRet ); -} - -// ------------------------------------------------------------------------------ -void Player::implBusFinalize( GSource* pSource ) -{ - GstBusSource* pBusSource = static_cast< GstBusSource* >( pSource ); - - if( pBusSource && pBusSource->mpBus ) - { - gst_object_unref( pBusSource->mpBus ); - pBusSource->mpBus = NULL; - } -} - // ------------------------------------------------------------------------------ gboolean Player::busCallback( GstBus* /*pBus*/, GstMessage* pMsg ) @@ -673,26 +703,6 @@ gboolean Player::busCallback( GstBus* /*pBus*/, return( true ); } -// ------------------------------------------------------------------------------ -gboolean Player::implIdleFunc( gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->idle() : true ); -} - -// ------------------------------------------------------------------------------ -gpointer Player::implThreadFunc( gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->run() : NULL ); -} - -// ------------------------------------------------------------------------------ -GstBusSyncReply Player::implHandleCreateWindowFunc( GstBus* pBus, - GstMessage* pMsg, - gpointer pData ) -{ - return( pData ? static_cast< Player* >( pData )->handleCreateWindow( pBus, pMsg ) : GST_BUS_PASS ); -} - // ------------------------------------------------------------------------------ void Player::implHandleNewElementFunc( GstBin* /* pBin */, GstElement* pElement, @@ -824,10 +834,10 @@ gpointer Player::run() { static GSourceFuncs aSourceFuncs = { - Player::implBusPrepare, - Player::implBusCheck, - Player::implBusDispatch, - Player::implBusFinalize, + &lcl_implBusPrepare, + &lcl_implBusCheck, + &lcl_implBusDispatch, + &lcl_implBusFinalize, NULL, NULL }; @@ -842,7 +852,7 @@ gpointer Player::run() // add idle callback GSource* pIdleSource = g_idle_source_new(); - g_source_set_callback( pIdleSource, Player::implIdleFunc, this, NULL ); + g_source_set_callback( pIdleSource, &lcl_implIdleFunc, this, NULL ); g_source_attach( pIdleSource, mpContext ); // add bus callback @@ -853,7 +863,7 @@ gpointer Player::run() // add bus sync handler to intercept video window creation for setting our own window gst_bus_set_sync_handler( static_cast< GstBusSource* >( pBusSource )->mpBus, - Player::implHandleCreateWindowFunc, this ); + &lcl_implHandleCreateWindowFunc, this ); // watch for all elements (and pads) that will be added to the playbin, // in order to retrieve properties like video width and height diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx index d751e381258d..0793eaf8caf2 100644 --- a/avmedia/source/gstreamer/gstplayer.hxx +++ b/avmedia/source/gstreamer/gstplayer.hxx @@ -149,11 +149,7 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); - -protected: - - Player( GString* pURI = NULL ); - +// these are public because the C callbacks call them virtual gboolean busCallback( GstBus* pBus, GstMessage* pMsg ); @@ -164,6 +160,10 @@ protected: virtual GstBusSyncReply handleCreateWindow( GstBus* pBus, GstMessage* pMsg ); +protected: + + Player( GString* pURI = NULL ); + void implQuitThread(); bool implInitPlayer(); @@ -180,25 +180,6 @@ private: Player& operator=( const Player& ); - static gboolean implBusPrepare( GSource* pSource, - gint* pTimeout ); - - static gboolean implBusCheck( GSource* pSource ); - - static gboolean implBusDispatch( GSource* pSource, - GSourceFunc aCallback, - gpointer pData ); - - static void implBusFinalize( GSource* pSource ); - - static gboolean implIdleFunc( gpointer pData ); - - static gpointer implThreadFunc( gpointer pData ); - - static GstBusSyncReply implHandleCreateWindowFunc( GstBus* pBus, - GstMessage* pMsg, - gpointer pDData ); - static void implHandleNewElementFunc( GstBin* pBin, GstElement* pElement, gpointer pData ); -- cgit From b33afb6c8b7410bf299941f9d52f5cc558df3fd4 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 28 Mar 2011 10:34:17 +0000 Subject: solaris11: #i117566#: gstreamer: Sun C++ complains about bogus atomic int abuse --- avmedia/source/gstreamer/gstplayer.cxx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'avmedia') diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx index ba354fe5f274..614ff80ce352 100644 --- a/avmedia/source/gstreamer/gstplayer.cxx +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -415,10 +415,14 @@ double SAL_CALL Player::getRate() void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) throw( uno::RuntimeException ) { - if( bSet && !isPlaybackLoop() ) - g_atomic_int_inc( &mnLooping ); - else if( !bSet && isPlaybackLoop() ) - g_atomic_int_dec_and_test( &mnLooping ); + if (bSet) + { + g_atomic_int_compare_and_exchange(&mnLooping, 0, 1); + } + else + { + g_atomic_int_compare_and_exchange(&mnLooping, 1, 0); + } } // ------------------------------------------------------------------------------ @@ -810,16 +814,12 @@ void Player::implHandleNewPadFunc( GstElement* pElement, // ------------------------------------------------------------------------------ gboolean Player::idle() { - // test if main loop should quit and set flag mnQuit to 1 - bool bQuit = g_atomic_int_compare_and_exchange( &mnQuit, 1, 1 ); + // test if main loop should quit by comparing with 1 + // and set flag mnQuit to 0 so we call g_main_loop_quit exactly once + bool const bQuit = g_atomic_int_compare_and_exchange( &mnQuit, 1, 0 ); if( bQuit ) { - // set mnQuit back to 0 to avoid mutiple g_main_loop_quit calls - // 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_dec_and_test( &mnQuit ); g_main_loop_quit( mpLoop ); } -- cgit From c4de82c9a636e4c8e91cab392e5a1a17e6ee8677 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 28 Mar 2011 10:34:17 +0000 Subject: solaris11: #i117566#: gstreamer: checkdll does not work for libavmedia_gst.so --- avmedia/source/gstreamer/makefile.mk | 2 ++ 1 file changed, 2 insertions(+) (limited to 'avmedia') diff --git a/avmedia/source/gstreamer/makefile.mk b/avmedia/source/gstreamer/makefile.mk index c648fcc77f89..857c5914b094 100644 --- a/avmedia/source/gstreamer/makefile.mk +++ b/avmedia/source/gstreamer/makefile.mk @@ -62,6 +62,8 @@ SHL1STDLIBS+=$(PKGCONFIG_LIBS) SHL1IMPLIB=i$(TARGET) SHL1LIBS=$(SLB)$/$(TARGET).lib SHL1DEF=$(MISC)$/$(SHL1TARGET).def +# on Solaris checkdll does not work: LD_LIBRARY_PATH breaks the 2 libxml2.so.2 +SHL1NOCHECK=t DEF1NAME=$(SHL1TARGET) DEF1EXPORTFILE=exports.dxp -- cgit