[Bug 692953] alsasink does not work at all with default value "sync=true"
GStreamer (bugzilla.gnome.org)
bugzilla at gnome.org
Wed Sep 11 10:30:38 PDT 2013
https://bugzilla.gnome.org/show_bug.cgi?id=692953
GStreamer | gst-plugins-base | 1.0.9
--- Comment #146 from Robert Krakora <rob.krakora at messagenetsystems.com> 2013-09-11 17:30:30 UTC ---
I am thinking that gst_alsasink_write() should look something like this:
static gint
gst_alsasink_write (GstAudioSink * asink, gpointer data, guint length)
{
GstAlsaSink *alsa;
gint err;
gint cptr;
gint16 *ptr = data;
cptr = length / alsa->bpf;
GST_ALSA_SINK_LOCK (asink);
while (cptr > 0) {
/* start by doing a blocking wait for free space. Set the timeout
* to 4 times the period time */
err = snd_pcm_wait (alsa->handle, (4 * alsa->period_time / 1000));
if (err < 0) {
GST_DEBUG_OBJECT (asink, "wait error, %d", err);
if (xrun_recovery (alsa, alsa->handle, err) < 0) {
goto write_error;
}
]
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);
if (err < 0) {
GST_DEBUG_OBJECT (asink, "Write error: %s", snd_strerror (err));
if (err == -EAGAIN) {
}
}
GST_LOG_OBJECT (asink, "received audio samples buffer of %u bytes", length);
cptr = length / alsa->bpf;
GST_ALSA_SINK_LOCK (asink);
while (cptr > 0) {
/* start by doing a blocking wait for free space. Set the timeout
* to 4 times the period time */
err = snd_pcm_wait (alsa->handle, (4 * alsa->period_time / 1000));
if (err == -EPIPE) {
GST_DEBUG_OBJECT (asink, "wait error, %d", err);
if (xrun_recovery (alsa, alsa->handle, err) < 0) {
goto write_error;
}
}
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);
if (err < 0) {
GST_DEBUG_OBJECT (asink, "Write error: %s", snd_strerror (err));
cptr = length / alsa->bpf;
GST_ALSA_SINK_LOCK (asink);
while (cptr > 0) {
/* start by doing a blocking wait for free space. Set the timeout
* to 4 times the period time */
err = snd_pcm_wait (alsa->handle, (4 * alsa->period_time / 1000));
if (err == -EPIPE) {
GST_DEBUG_OBJECT (asink, "wait error, %d", err);
if (xrun_recovery (alsa, alsa->handle, err) < 0) {
goto write_error;
}
}
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);
if (err < 0) {
GST_DEBUG_OBJECT (asink, "Write error: %s", snd_strerror (err));
if (err == -EAGAIN) {
continue;
} else if (err == -ENODEV) {
goto device_disappeared;
} else if (xrun_recovery (alsa, alsa->handle, err) < 0) {
goto write_error;
}
continue;
}
ptr += snd_pcm_frames_to_bytes (alsa->handle, err);
cptr -= err;
}
GST_ALSA_SINK_UNLOCK (asink);
return length - (cptr * alsa->bpf);
write_error:
{
GST_ALSA_SINK_UNLOCK (asink);
return length; /* skip one period */
}
device_disappeared:
{
GST_ELEMENT_ERROR (asink, RESOURCE, WRITE,
(_("Error outputting to audio device. "
"The device has been disconnected.")), (NULL));
goto write_error;
}
}
--
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the gstreamer-bugs
mailing list