CVSROOT: /sources/gnash Module name: gnash Changes by: Tomas Groth <tgc> 07/08/01 10:09:23
Modified files: . : ChangeLog backend : sound_handler_gst.cpp sound_handler_gst.h Log message: * backend/sound_handler_gst.{h,cpp}: Switch to try_mutex, and in callback_handoff only try to lock, and return if unsuccesfull to avoid a potential deadlock, fixes bug #20596. Warning fixes CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3893&r2=1.3894 http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_gst.cpp?cvsroot=gnash&r1=1.56&r2=1.57 http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_gst.h?cvsroot=gnash&r1=1.13&r2=1.14 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.3893 retrieving revision 1.3894 diff -u -b -r1.3893 -r1.3894 --- ChangeLog 1 Aug 2007 04:02:13 -0000 1.3893 +++ ChangeLog 1 Aug 2007 10:09:22 -0000 1.3894 @@ -1,3 +1,9 @@ +2007-08-01 Tomas Groth Christensen <[EMAIL PROTECTED]> + + * backend/sound_handler_gst.{h,cpp}: Switch to try_mutex, and in + callback_handoff only try to lock, and return if unsuccesfull + to avoid a potential deadlock, fixes bug #20596. Warning fixes. + 2007-08-01 Sandro Santilli <[EMAIL PROTECTED]> * plugin/plugin.cpp: run 'gtk-gnash' by default. @@ -125,7 +131,7 @@ * testsuite/actionscript.all/TextField.as: expect one failure less. -2007-07-30 Sergio Costas +2007-07-30 Sergio Costas <raster (at) rastersoft.com> * backend/sound_handler_gst.cpp: Use the audioconverter element to get the current position, to avoid delay. Index: backend/sound_handler_gst.cpp =================================================================== RCS file: /sources/gnash/gnash/backend/sound_handler_gst.cpp,v retrieving revision 1.56 retrieving revision 1.57 diff -u -b -r1.56 -r1.57 --- backend/sound_handler_gst.cpp 30 Jul 2007 09:05:51 -0000 1.56 +++ backend/sound_handler_gst.cpp 1 Aug 2007 10:09:23 -0000 1.57 @@ -20,7 +20,7 @@ // Based on sound_handler_sdl.cpp by Thatcher Ulrich http://tulrich.com 2003 // which has been donated to the Public Domain. -/* $Id: sound_handler_gst.cpp,v 1.56 2007/07/30 09:05:51 tgc Exp $ */ +/* $Id: sound_handler_gst.cpp,v 1.57 2007/08/01 10:09:23 tgc Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -80,7 +80,7 @@ // can be use for playing it. { - mutex::scoped_lock lock(_mutex); + try_mutex::scoped_lock lock(_mutex); sound_data *sounddata = new sound_data; if (!sounddata) { @@ -144,7 +144,7 @@ // this gets called when a stream gets more data long GST_sound_handler::fill_stream_data(void* data, int data_bytes, int /*sample_count*/, int handle_id) { - mutex::scoped_lock lock(_mutex); + try_mutex::scoped_lock lock(_mutex); // @@ does a negative handle_id have any meaning ? // should we change it to unsigned instead ? @@ -186,9 +186,20 @@ { gst_elements *gstelements = static_cast<gst_elements*>(user_data); - mutex::scoped_lock lock(gstelements->handler->_mutex); + try_mutex::scoped_try_lock lock(gstelements->handler->_mutex); - // First callback + // If we couldn't obtain a lock return to avoid a deadlock + if (!lock.locked()) { + + // We return nothing in this case to avoid noise being decoded and played + if (GST_BUFFER_SIZE(buffer) != 0 && GST_BUFFER_DATA(buffer)) { + GST_BUFFER_DATA(buffer) = 0; + GST_BUFFER_SIZE(buffer) = 0; + } + return; + } + + // First callback or after a couldn't-get-lock-return if (GST_BUFFER_SIZE(buffer) == 0) { if (gstelements->data_size > BUFFER_SIZE) { GST_BUFFER_SIZE(buffer) = BUFFER_SIZE; @@ -252,7 +263,7 @@ void GST_sound_handler::play_sound(int sound_handle, int loop_count, int /*offset*/, long start_position, const std::vector<sound_envelope>* /*envelopes*/) // Play the index'd sample. { - mutex::scoped_lock lock(_mutex); + try_mutex::scoped_lock lock(_mutex); // Check if the sound exists, or if audio is muted if (sound_handle < 0 || (unsigned int) sound_handle >= m_sound_data.size() || muted) @@ -459,7 +470,7 @@ void GST_sound_handler::stop_sound(int sound_handle) { - mutex::scoped_lock lock(_mutex); + try_mutex::scoped_lock lock(_mutex); // Check if the sound exists. if (sound_handle < 0 || (unsigned int) sound_handle >= m_sound_data.size()) @@ -499,7 +510,7 @@ void GST_sound_handler::delete_sound(int sound_handle) // this gets called when it's done with a sample. { - mutex::scoped_lock lock(_mutex); + try_mutex::scoped_lock lock(_mutex); if (sound_handle >= 0 && (unsigned int) sound_handle < m_sound_data.size()) { @@ -524,7 +535,7 @@ // where 0 is off and 100 is full volume. The default setting is 100. int GST_sound_handler::get_volume(int sound_handle) { - mutex::scoped_lock lock(_mutex); + try_mutex::scoped_lock lock(_mutex); // Check if the sound exists. if (sound_handle >= 0 && (unsigned int) sound_handle < m_sound_data.size()) @@ -540,7 +551,7 @@ // 100 is full volume and 0 is no volume. The default setting is 100. void GST_sound_handler::set_volume(int sound_handle, int volume) { - mutex::scoped_lock lock(_mutex); + try_mutex::scoped_lock lock(_mutex); // Check if the sound exists. if (sound_handle < 0 || (unsigned int) sound_handle >= m_sound_data.size()) @@ -568,7 +579,7 @@ void GST_sound_handler::get_info(int sound_handle, int* format, bool* stereo) { - mutex::scoped_lock lock(_mutex); + try_mutex::scoped_lock lock(_mutex); // Check if the sound exists. if (sound_handle >= 0 && (unsigned int) sound_handle < m_sound_data.size()) @@ -606,7 +617,7 @@ unsigned int GST_sound_handler::get_duration(int sound_handle) { - mutex::scoped_lock lock(_mutex); + try_mutex::scoped_lock lock(_mutex); // Check if the sound exists. if (sound_handle < 0 || (unsigned int) sound_handle >= m_sound_data.size()) @@ -629,7 +640,7 @@ unsigned int GST_sound_handler::get_position(int sound_handle) { - mutex::scoped_lock lock(_mutex); + try_mutex::scoped_lock lock(_mutex); // Check if the sound exists. if (sound_handle < 0 || (unsigned int) sound_handle >= m_sound_data.size()) @@ -659,6 +670,7 @@ return 0; } } + return 0; } // Pointer handling and checking functions Index: backend/sound_handler_gst.h =================================================================== RCS file: /sources/gnash/gnash/backend/sound_handler_gst.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -b -r1.13 -r1.14 --- backend/sound_handler_gst.h 27 Jul 2007 15:09:41 -0000 1.13 +++ backend/sound_handler_gst.h 1 Aug 2007 10:09:23 -0000 1.14 @@ -55,10 +55,10 @@ GstPad *addersinkpad; // position in the stream - long position; + unsigned long position; // data size - long data_size; + unsigned long data_size; long loop_count; @@ -127,7 +127,7 @@ bool muted; /// Mutex for making sure threads doesn't mess things up - boost::mutex _mutex; + boost::try_mutex _mutex; public: _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit