summarylogtreecommitdiffstats
path: root/guayadeque_01c_rev1893.patch
blob: e4b557d6e1e7d25485cf37b86e75e53cc9a7022c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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 );