diff --git src/MediaCtrl.cpp src/MediaCtrl.cpp index d0f9912..27fcdf5 100644 --- src/MediaCtrl.cpp +++ src/MediaCtrl.cpp @@ -1372,6 +1372,7 @@ guFaderPlayBin::guFaderPlayBin( guMediaCtrl * mediactrl, const wxString &uri, co m_LastFadeVolume = -1; m_StartOffset = startpos; m_SeekTimerId = 0; + m_AddedRecord = false; guLogDebug( wxT( "guFaderPlayBin::guFaderPlayBin (%i) %i" ), m_Id, playtype ); @@ -2485,39 +2486,53 @@ bool guFaderPlayBin::SetRecordFileName( const wxString &filename ) // -------------------------------------------------------------------------------- // void guFaderPlayBin::AddRecordElement( GstPad * pad, bool isblocked ) { - gst_bin_add( GST_BIN( m_Playbackbin ), m_RecordBin ); - m_RecordPad = gst_element_get_request_pad( m_Tee, "src%d" ); + Lock(); + guLogMessage( wxT( "AddRecordElement %d %d\n" ), m_AddedRecord, isblocked ); + if( !m_AddedRecord ) + { + m_AddedRecord = true; + gst_bin_add( GST_BIN( m_Playbackbin ), m_RecordBin ); + m_RecordPad = gst_element_get_request_pad( m_Tee, "src%d" ); - gst_pad_link( m_RecordPad, m_RecordGhostPad ); + gst_pad_link( m_RecordPad, m_RecordGhostPad ); - // if we're supposed to be playing, unblock the sink */ - if( isblocked ) - { - gst_element_set_state( m_Playbackbin, GST_STATE_PLAYING ); - gst_object_ref( m_RecordGhostPad ); - gst_pad_set_blocked_async( pad, false, GstPadBlockCallback( record_unlocked ), m_RecordGhostPad ); - } - else - { - gst_element_set_state( m_Playbackbin, GST_STATE_PAUSED ); - gst_object_ref( m_RecordGhostPad ); - record_unlocked( NULL, false, m_RecordGhostPad ); - } + } + Unlock(); + // if we're supposed to be playing, unblock the sink */ + if( isblocked ) + { + gst_element_set_state( m_Playbackbin, GST_STATE_PLAYING ); + gst_object_ref( m_RecordGhostPad ); + gst_pad_set_blocked_async( pad, false, GstPadBlockCallback( record_unlocked ), m_RecordGhostPad ); + } + else + { + gst_element_set_state( m_Playbackbin, GST_STATE_PAUSED ); + gst_object_ref( m_RecordGhostPad ); + record_unlocked( NULL, false, m_RecordGhostPad ); + } } // -------------------------------------------------------------------------------- // void guFaderPlayBin::RemoveRecordElement( GstPad * pad, bool isblocked ) { - g_object_ref( m_RecordBin ); - gst_bin_remove( GST_BIN( m_Playbackbin ), m_RecordBin ); - - gst_element_set_state( m_RecordBin, GST_STATE_NULL ); - g_object_unref( m_RecordBin ); - SetRecordBin( NULL ); - if( isblocked ) + Lock(); + guLogMessage( wxT( "RemoveRecordElement %d %d\n" ), m_AddedRecord, isblocked ); + if( m_AddedRecord ) { - gst_pad_set_blocked_async( pad, false, GstPadBlockCallback( record_unlocked ), NULL ); + m_AddedRecord = false; + g_object_ref( m_RecordBin ); + gst_bin_remove( GST_BIN( m_Playbackbin ), m_RecordBin ); + + gst_element_set_state( m_RecordBin, GST_STATE_NULL ); + g_object_unref( m_RecordBin ); + SetRecordBin( NULL ); } + Unlock(); + if( isblocked ) + { + gst_pad_set_blocked_async( pad, false, GstPadBlockCallback( record_unlocked ), NULL ); + } } diff --git src/MediaCtrl.h src/MediaCtrl.h index d9409ba..0d92ac3 100644 --- src/MediaCtrl.h +++ src/MediaCtrl.h @@ -253,6 +253,7 @@ class guFaderPlayBin int m_StartOffset; int m_SeekTimerId; + bool m_AddedRecord; bool BuildPlaybackBin( void ); bool BuildOutputBin( void );