diff --git a/ChangeLog b/ChangeLog index 2edf8f8d68..484826db84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-11-13 Benjamin Otte + + * ext/alsa/gstalsa.c: (gst_alsa_pcm_wait): + add debugging + * ext/alsa/gstalsasink.c: (gst_alsa_sink_loop): + do a wait when we enter the loop func with no data available to + write instead of getting into an 100% CPU loop by just returning and + being called again by the scheduler + 2004-11-13 Jan Schmidt * configure.ac: diff --git a/ext/alsa/gstalsa.c b/ext/alsa/gstalsa.c index cfe94c4ed5..6ff7c0d0eb 100644 --- a/ext/alsa/gstalsa.c +++ b/ext/alsa/gstalsa.c @@ -1195,8 +1195,9 @@ inline gboolean gst_alsa_pcm_wait (GstAlsa * this) { int err; + snd_pcm_state_t state = snd_pcm_state (this->handle); - if (snd_pcm_state (this->handle) == SND_PCM_STATE_RUNNING) { + if (state == SND_PCM_STATE_RUNNING) { if ((err = snd_pcm_wait (this->handle, 1000)) < 0) { if (err == EINTR) { /* happens mostly when run under gdb, or when exiting due to a signal */ @@ -1213,6 +1214,9 @@ gst_alsa_pcm_wait (GstAlsa * this) return FALSE; } } + } else { + GST_INFO_OBJECT (this, "in state %s, not waiting", + snd_pcm_state_name (state)); } return TRUE; } diff --git a/ext/alsa/gstalsasink.c b/ext/alsa/gstalsasink.c index 49549753e8..09b8ac8b76 100644 --- a/ext/alsa/gstalsasink.c +++ b/ext/alsa/gstalsasink.c @@ -532,6 +532,9 @@ sink_restart: if (sink->behaviour[i] != 1) sink->buf_data[i] += bytes; } + } else if (avail == 0 && gst_element_get_state (element) == GST_STATE_PLAYING) { + if (gst_alsa_pcm_wait (this) == FALSE) + return; } if (snd_pcm_state (this->handle) != SND_PCM_STATE_RUNNING