From 38da64193bef3a3f7302c08018b94ba95276ed51 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Tue, 15 May 2007 15:29:17 +0000 Subject: [PATCH] ext/alsa/gstalsamixer.c (source, n_poll_fds, poll_fds, gst_alsa_mixer_check, gst_alsa_mixer_dispatch, gst_alsa_mixer_... Original commit message from CVS: * ext/alsa/gstalsamixer.c (source, n_poll_fds, poll_fds, gst_alsa_mixer_check, gst_alsa_mixer_dispatch, gst_alsa_mixer_finalize, gst_alsa_mixer_handle_source_callback, gst_alsa_mixer_handle_callback, gst_alsa_mixer_elem_handle_callback, gst_alsa_mixer_ensure_track_list, gst_alsa_mixer_update_option, gst_alsa_mixer_update_track): Apply some of the cleanup Tim suggested in #152864 afterwards. --- ChangeLog | 10 ++++++++++ ext/alsa/gstalsamixer.c | 29 ++++++++++++----------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac6c069..2bfb19c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2007-05-15 Stefan Kost + * ext/alsa/gstalsamixer.c (source, n_poll_fds, poll_fds, + gst_alsa_mixer_check, gst_alsa_mixer_dispatch, + gst_alsa_mixer_finalize, gst_alsa_mixer_handle_source_callback, + gst_alsa_mixer_handle_callback, gst_alsa_mixer_elem_handle_callback, + gst_alsa_mixer_ensure_track_list, gst_alsa_mixer_update_option, + gst_alsa_mixer_update_track): + Apply some of the cleanup Tim suggested in #152864 afterwards. + +2007-05-15 Stefan Kost + patch by: Marc-Andre Lureau * ext/alsa/gstalsamixer.c (main_context, GstAlsaMixerWatch, diff --git a/ext/alsa/gstalsamixer.c b/ext/alsa/gstalsamixer.c index d66bd9b..b6a1f09 100644 --- a/ext/alsa/gstalsamixer.c +++ b/ext/alsa/gstalsamixer.c @@ -91,7 +91,7 @@ gst_alsa_mixer_check (GSource * source) } if (revents & G_IO_ERR || revents & G_IO_HUP) { - GST_WARNING ("ALSA poll fds returned ERR or HUP"); + GST_DEBUG ("ALSA poll fds returned ERR or HUP"); return FALSE; } @@ -102,10 +102,7 @@ static gboolean gst_alsa_mixer_dispatch (GSource * source, GSourceFunc callback, gpointer user_data) { - if (!callback) { - GST_WARNING ("Cannot get callback from ALSA mixer watcher"); - } - + g_return_val_if_fail (callback, FALSE); return (*callback) (user_data); } @@ -253,7 +250,7 @@ gst_alsa_mixer_handle_source_callback (gpointer data) { GstAlsaMixer *mixer = (GstAlsaMixer *) data; - GST_WARNING ("Source cb"); + GST_LOG ("Source cb"); snd_mixer_handle_events (mixer->handle); return TRUE; @@ -267,7 +264,7 @@ gst_alsa_mixer_handle_callback (snd_mixer_t * handle, unsigned int mask, (GstAlsaMixer *) snd_mixer_get_callback_private (handle); GList *item; - GST_WARNING ("ALSA cb"); + GST_LOG ("ALSA cb"); snd_mixer_handle_events (mixer->handle); for (item = mixer->tracklist; item != NULL; item = item->next) { @@ -292,7 +289,7 @@ gst_alsa_mixer_elem_handle_callback (snd_mixer_elem_t * elem, unsigned int mask) (GstAlsaMixer *) snd_mixer_elem_get_callback_private (elem); GList *item; - GST_WARNING ("ALSA elem cb"); + GST_LOG ("ALSA elem cb"); for (item = mixer->tracklist; item != NULL; item = item->next) { if (GST_IS_ALSA_MIXER_TRACK (item->data)) { @@ -415,7 +412,6 @@ gst_alsa_mixer_ensure_track_list (GstAlsaMixer * mixer) } } - if (play_track && cap_track) { GST_ALSA_MIXER_TRACK (play_track)->shared_mute = GST_ALSA_MIXER_TRACK (cap_track); @@ -444,20 +440,19 @@ gst_alsa_mixer_ensure_track_list (GstAlsaMixer * mixer) g_source_new (&gst_alsa_mixer_watch_funcs, sizeof (GstAlsaMixerWatch)); g_return_if_fail (main_context != NULL && mixer->handle_source != NULL); - watch = (GstAlsaMixerWatch *) mixer->handle_source; - count = snd_mixer_poll_descriptors_count (mixer->handle); + if (count < 1) { + GST_WARNING ("Poll descriptors count < 0: %d", count); + g_source_destroy (mixer->handle_source); + mixer->handle_source = NULL; + return; + } pfds = g_newa (struct pollfd, count); + watch = (GstAlsaMixerWatch *) mixer->handle_source; watch->n_poll_fds = snd_mixer_poll_descriptors (mixer->handle, pfds, count);; watch->poll_fds = g_new0 (GPollFD, count); - if (watch->poll_fds == NULL) { - GST_WARNING ("Cannot allocate poll descriptors"); - g_source_destroy (mixer->handle_source); - mixer->handle_source = NULL; - return; - } for (i = 0; i < watch->n_poll_fds; ++i) { watch->poll_fds[i].fd = pfds[i].fd; -- 2.7.4