From patchwork Sat Feb 13 18:47:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 8300671 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B5139C02AA for ; Sat, 13 Feb 2016 18:48:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B6A762042B for ; Sat, 13 Feb 2016 18:48:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 98FCE2041F for ; Sat, 13 Feb 2016 18:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751255AbcBMSsE (ORCPT ); Sat, 13 Feb 2016 13:48:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36560 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751083AbcBMSsD (ORCPT ); Sat, 13 Feb 2016 13:48:03 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id F2F7DC00124C for ; Sat, 13 Feb 2016 18:48:02 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-4-73.ams2.redhat.com [10.36.4.73]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1DIlejV011443; Sat, 13 Feb 2016 13:48:01 -0500 From: Hans de Goede To: Linux Media Mailing List Cc: Hans de Goede Subject: [PATCH tvtime 10/17] mixer: Silence mixer probe errors Date: Sat, 13 Feb 2016 19:47:31 +0100 Message-Id: <1455389258-13470-10-git-send-email-hdegoede@redhat.com> In-Reply-To: <1455389258-13470-1-git-send-email-hdegoede@redhat.com> References: <1455389258-13470-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On most systems now a days we end up using digital loopback and do not have a valid mixer config, silence mixer error spew on startup. Signed-off-by: Hans de Goede --- src/mixer-alsa.c | 34 ++++++++++++++++++++++------------ src/mixer-oss.c | 12 ++++++++---- src/mixer.c | 4 ++-- src/mixer.h | 2 +- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/mixer-alsa.c b/src/mixer-alsa.c index a549899..e84a3d0 100644 --- a/src/mixer-alsa.c +++ b/src/mixer-alsa.c @@ -33,24 +33,28 @@ static snd_mixer_elem_t *elem = NULL; static long alsa_min, alsa_max, alsa_vol; -static void alsa_open_mixer( void ) +static void alsa_open_mixer( int verbose ) { int err; static snd_mixer_selem_id_t *sid = NULL; if ((err = snd_mixer_open (&handle, 0)) < 0) { - fprintf(stderr, "mixer: open error: %s\n", snd_strerror(err)); + if (verbose) + fprintf(stderr, "mixer: open error: %s\n", snd_strerror(err)); return; } if ((err = snd_mixer_attach (handle, card)) < 0) { - fprintf(stderr, "mixer: attach error: %s\n", snd_strerror(err)); + if (verbose) + fprintf(stderr, "mixer: attach error: %s\n", snd_strerror(err)); goto error; } if ((err = snd_mixer_selem_register (handle, NULL, NULL)) < 0) { - fprintf(stderr, "mixer: register error: %s\n", snd_strerror(err)); + if (verbose) + fprintf(stderr, "mixer: register error: %s\n", snd_strerror(err)); goto error; } if ((err = snd_mixer_load (handle)) < 0) { - fprintf(stderr, "mixer: load error: %s\n", snd_strerror(err)); + if (verbose) + fprintf(stderr, "mixer: load error: %s\n", snd_strerror(err)); goto error; } snd_mixer_selem_id_malloc(&sid); @@ -58,16 +62,20 @@ static void alsa_open_mixer( void ) goto error; snd_mixer_selem_id_set_name(sid, channel); if (!(elem = snd_mixer_find_selem(handle, sid))) { - fprintf(stderr, "mixer: unable to find mixer for channel %s\n", channel); + if (verbose) + fprintf(stderr, "mixer: unable to find mixer for channel %s\n", + channel); goto error; } if (!snd_mixer_selem_has_playback_volume(elem)) { - fprintf(stderr, "mixer: no playback\n"); + if (verbose) + fprintf(stderr, "mixer: no playback\n"); goto error; } snd_mixer_selem_get_playback_volume_range(elem, &alsa_min, &alsa_max); if ((alsa_max - alsa_min) <= 0) { - fprintf(stderr, "mixer: no valid playback range\n"); + if (verbose) + fprintf(stderr, "mixer: no valid playback range\n"); goto error; } snd_mixer_selem_id_free(sid); @@ -174,7 +182,7 @@ static int alsa_ismute( void ) return muted; } -static int alsa_set_device( const char *devname ) +static int alsa_set_device( const char *devname, int verbose ) { int i; @@ -189,10 +197,12 @@ static int alsa_set_device( const char *devname ) card[i] = 0; channel = card + i + 1; } - alsa_open_mixer(); + alsa_open_mixer( verbose ); if (!handle) { - fprintf( stderr, "mixer: Can't open mixer %s (channel %s), " - "mixer volume and mute unavailable.\n", card, channel ); + if( verbose ) { + fprintf( stderr, "mixer: Can't open mixer %s (channel %s), " + "mixer volume and mute unavailable.\n", card, channel ); + } return -1; } return 0; diff --git a/src/mixer-oss.c b/src/mixer-oss.c index 08aa0ca..f2441fe 100644 --- a/src/mixer-oss.c +++ b/src/mixer-oss.c @@ -181,7 +181,7 @@ static int oss_ismute( void ) static char *oss_core_devnames[] = SOUND_DEVICE_NAMES; -static int oss_set_device( const char *devname ) +static int oss_set_device( const char *devname, int verbose ) { const char *channame; int found = 0; @@ -198,8 +198,10 @@ static int oss_set_device( const char *devname ) channame = mixer_device + i + 1; } if( !file_is_openable_for_read( mixer_device ) ) { - fprintf( stderr, "mixer: Can't open device %s, " - "mixer volume and mute unavailable.\n", mixer_device ); + if( verbose ) { + fprintf( stderr, "mixer: Can't open device %s, " + "mixer volume and mute unavailable.\n", mixer_device ); + } return -1; } @@ -212,7 +214,9 @@ static int oss_set_device( const char *devname ) } } if( !found ) { - fprintf( stderr, "mixer: No such mixer channel '%s', using channel 'line'.\n", channame ); + if( verbose ) { + fprintf( stderr, "mixer: No such mixer channel '%s'.\n", channame ); + } return -1; } mixer_dev_mask = 1 << mixer_channel; diff --git a/src/mixer.c b/src/mixer.c index 5356d2b..c87df3a 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -29,7 +29,7 @@ /** * Sets the mixer device and channel. */ -static int null_set_device( const char *devname ) +static int null_set_device( const char *devname, int verbose ) { return 0; } @@ -159,7 +159,7 @@ void mixer_init( config_t *cfg, const char *v4ldev ) mixer = mixers[i]; if (!mixer) continue; - if (mixer->set_device(devname) == 0) + if( mixer->set_device( devname, config_get_verbose( cfg ) ) == 0 ) break; } diff --git a/src/mixer.h b/src/mixer.h index f51f481..9b6f67b 100644 --- a/src/mixer.h +++ b/src/mixer.h @@ -40,7 +40,7 @@ struct mixer { /** * Sets the mixer device and channel. */ -int (* set_device)( const char *devname ); +int (* set_device)( const char *devname, int verbose ); /** * Sets the initial state of the mixer device.