mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
gst-libs/gst/audio/: Only start playback if we are playing. should fix #330748.
Original commit message from CVS: * gst-libs/gst/audio/gstbaseaudiosink.c: (gst_base_audio_sink_change_state): * gst-libs/gst/audio/gstringbuffer.c: (wait_segment), (gst_ring_buffer_may_start): * gst-libs/gst/audio/gstringbuffer.h: Only start playback if we are playing. should fix #330748.
This commit is contained in:
parent
17b06edc28
commit
82fd38fbcf
4 changed files with 49 additions and 1 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2006-03-17 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst-libs/gst/audio/gstbaseaudiosink.c:
|
||||||
|
(gst_base_audio_sink_change_state):
|
||||||
|
* gst-libs/gst/audio/gstringbuffer.c: (wait_segment),
|
||||||
|
(gst_ring_buffer_may_start):
|
||||||
|
* gst-libs/gst/audio/gstringbuffer.h:
|
||||||
|
Only start playback if we are playing.
|
||||||
|
should fix #330748.
|
||||||
|
|
||||||
2006-03-17 Jan Schmidt <thaytan@mad.scientist.com>
|
2006-03-17 Jan Schmidt <thaytan@mad.scientist.com>
|
||||||
|
|
||||||
* ext/alsa/gstalsasink.c: (gst_alsasink_getcaps):
|
* ext/alsa/gstalsasink.c: (gst_alsasink_getcaps):
|
||||||
|
|
|
@ -707,14 +707,17 @@ gst_base_audio_sink_change_state (GstElement * element,
|
||||||
goto open_failed;
|
goto open_failed;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||||
gst_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
|
|
||||||
sink->next_sample = -1;
|
sink->next_sample = -1;
|
||||||
|
gst_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
|
||||||
|
gst_ring_buffer_may_start (sink->ringbuffer, FALSE);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||||
{
|
{
|
||||||
GstClock *clock;
|
GstClock *clock;
|
||||||
GstClockTime time, base;
|
GstClockTime time, base;
|
||||||
|
|
||||||
|
gst_ring_buffer_may_start (sink->ringbuffer, TRUE);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (sink);
|
GST_OBJECT_LOCK (sink);
|
||||||
clock = GST_ELEMENT_CLOCK (sink);
|
clock = GST_ELEMENT_CLOCK (sink);
|
||||||
if (clock == NULL)
|
if (clock == NULL)
|
||||||
|
@ -746,6 +749,8 @@ gst_base_audio_sink_change_state (GstElement * element,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||||
|
/* ringbuffer cannot start anymore */
|
||||||
|
gst_ring_buffer_may_start (sink->ringbuffer, FALSE);
|
||||||
gst_ring_buffer_pause (sink->ringbuffer);
|
gst_ring_buffer_pause (sink->ringbuffer);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
|
|
|
@ -1077,6 +1077,10 @@ wait_segment (GstRingBuffer * buf)
|
||||||
/* buffer must be started now or we deadlock since nobody is reading */
|
/* buffer must be started now or we deadlock since nobody is reading */
|
||||||
if (G_UNLIKELY (g_atomic_int_get (&buf->state) !=
|
if (G_UNLIKELY (g_atomic_int_get (&buf->state) !=
|
||||||
GST_RING_BUFFER_STATE_STARTED)) {
|
GST_RING_BUFFER_STATE_STARTED)) {
|
||||||
|
/* see if we are allowed to start it */
|
||||||
|
if (G_UNLIKELY (g_atomic_int_get (&buf->abidata.ABI.may_start) == FALSE))
|
||||||
|
goto no_start;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (buf, "start!");
|
GST_DEBUG_OBJECT (buf, "start!");
|
||||||
gst_ring_buffer_start (buf);
|
gst_ring_buffer_start (buf);
|
||||||
}
|
}
|
||||||
|
@ -1120,6 +1124,11 @@ flushing:
|
||||||
GST_OBJECT_UNLOCK (buf);
|
GST_OBJECT_UNLOCK (buf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
no_start:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (buf, "not allowed to start");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1455,3 +1464,22 @@ gst_ring_buffer_clear (GstRingBuffer * buf, gint segment)
|
||||||
|
|
||||||
memcpy (data, buf->empty_seg, buf->spec.segsize);
|
memcpy (data, buf->empty_seg, buf->spec.segsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_ring_buffer_may_start:
|
||||||
|
* @buf: the #GstRingBuffer
|
||||||
|
* @allowed: the new value
|
||||||
|
*
|
||||||
|
* Tell the ringbuffer that it is allowed to start playback when
|
||||||
|
* the ringbuffer is filled with samples.
|
||||||
|
*
|
||||||
|
* Since: 0.10.6
|
||||||
|
*
|
||||||
|
* MT safe.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_ring_buffer_may_start (GstRingBuffer * buf, gboolean allowed)
|
||||||
|
{
|
||||||
|
GST_LOG_OBJECT (buf, "may start: %d", allowed);
|
||||||
|
gst_atomic_int_set (&buf->abidata.ABI.may_start, allowed);
|
||||||
|
}
|
||||||
|
|
|
@ -243,6 +243,8 @@ struct _GstRingBuffer {
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
gboolean flushing;
|
gboolean flushing;
|
||||||
|
/* ATOMIC */
|
||||||
|
gint may_start;
|
||||||
} ABI;
|
} ABI;
|
||||||
/* adding + 0 to mark ABI change to be undone later */
|
/* adding + 0 to mark ABI change to be undone later */
|
||||||
gpointer _gst_reserved[GST_PADDING + 0];
|
gpointer _gst_reserved[GST_PADDING + 0];
|
||||||
|
@ -335,6 +337,9 @@ gboolean gst_ring_buffer_prepare_read (GstRingBuffer *buf, gint *segme
|
||||||
void gst_ring_buffer_clear (GstRingBuffer *buf, gint segment);
|
void gst_ring_buffer_clear (GstRingBuffer *buf, gint segment);
|
||||||
void gst_ring_buffer_advance (GstRingBuffer *buf, guint advance);
|
void gst_ring_buffer_advance (GstRingBuffer *buf, guint advance);
|
||||||
|
|
||||||
|
void gst_ring_buffer_may_start (GstRingBuffer *buf, gboolean allowed);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_RING_BUFFER_H__ */
|
#endif /* __GST_RING_BUFFER_H__ */
|
||||||
|
|
Loading…
Reference in a new issue