g_free (sink->device);
g_mutex_clear (&sink->alsa_lock);
+ g_mutex_clear (&sink->delay_lock);
g_mutex_lock (&output_mutex);
--output_ref;
alsasink->handle = NULL;
alsasink->cached_caps = NULL;
g_mutex_init (&alsasink->alsa_lock);
+ g_mutex_init (&alsasink->delay_lock);
g_mutex_lock (&output_mutex);
if (output_ref == 0) {
if (err < 0) {
GST_DEBUG_OBJECT (asink, "wait error, %d", err);
} else {
+ GST_DELAY_SINK_LOCK (asink);
err = snd_pcm_writei (alsa->handle, ptr, cptr);
+ GST_DELAY_SINK_UNLOCK (asink);
}
GST_DEBUG_OBJECT (asink, "written %d frames out of %d", err, cptr);
alsa = GST_ALSA_SINK (asink);
+ GST_DELAY_SINK_LOCK (asink);
res = snd_pcm_delay (alsa->handle, &delay);
+ GST_DELAY_SINK_UNLOCK (asink);
if (G_UNLIKELY (res < 0)) {
/* on errors, report 0 delay */
GST_DEBUG_OBJECT (alsa, "snd_pcm_delay returned %d", res);
#define GST_ALSA_SINK_LOCK(obj) (g_mutex_lock (GST_ALSA_SINK_GET_LOCK (obj)))
#define GST_ALSA_SINK_UNLOCK(obj) (g_mutex_unlock (GST_ALSA_SINK_GET_LOCK (obj)))
+#define GST_DELAY_SINK_GET_LOCK(obj) (&GST_ALSA_SINK_CAST (obj)->delay_lock)
+#define GST_DELAY_SINK_LOCK(obj) (g_mutex_lock (GST_DELAY_SINK_GET_LOCK (obj)))
+#define GST_DELAY_SINK_UNLOCK(obj) (g_mutex_unlock (GST_DELAY_SINK_GET_LOCK (obj)))
+
/**
* GstAlsaSink:
*
GstCaps *cached_caps;
GMutex alsa_lock;
+ GMutex delay_lock;
};
struct _GstAlsaSinkClass {