[pulseaudio-discuss] [PATCH v2 1/2] direction: Add a couple of direction helper functions

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Thu Mar 27 00:52:44 PDT 2014


On Thu, 2014-03-27 at 05:14 +0100, David Henningsson wrote:
> On 03/26/2014 10:52 AM, Tanu Kaskinen wrote:
> > ---
> >  doxygen/doxygen.conf.in |  1 +
> >  src/Makefile.am         |  2 ++
> >  src/map-file            |  2 ++
> >  src/pulse/direction.c   | 46 ++++++++++++++++++++++++++++++++++++++++++++++
> >  src/pulse/direction.h   | 37 +++++++++++++++++++++++++++++++++++++
> >  src/pulse/pulseaudio.h  |  5 +++--
> >  6 files changed, 91 insertions(+), 2 deletions(-)
> >  create mode 100644 src/pulse/direction.c
> >  create mode 100644 src/pulse/direction.h
> > 
> > diff --git a/doxygen/doxygen.conf.in b/doxygen/doxygen.conf.in
> > index fc6850d..43380e9 100644
> > --- a/doxygen/doxygen.conf.in
> > +++ b/doxygen/doxygen.conf.in
> > @@ -671,6 +671,7 @@ WARN_LOGFILE           =
> >  INPUT                  = @srcdir@/../src/pulse/channelmap.h \
> >                           @srcdir@/../src/pulse/context.h \
> >                           @srcdir@/../src/pulse/def.h \
> > +                         @srcdir@/../src/pulse/direction.h \
> >                           @srcdir@/../src/pulse/error.h \
> >                           @srcdir@/../src/pulse/ext-stream-restore.h \
> >                           @srcdir@/../src/pulse/ext-device-manager.h \
> > diff --git a/src/Makefile.am b/src/Makefile.am
> > index 99d76ce..5c2d5bc 100644
> > --- a/src/Makefile.am
> > +++ b/src/Makefile.am
> > @@ -746,6 +746,7 @@ pulseinclude_HEADERS = \
> >  		pulse/channelmap.h \
> >  		pulse/context.h \
> >  		pulse/def.h \
> > +		pulse/direction.h \
> >  		pulse/error.h \
> >  		pulse/ext-device-manager.h \
> >  		pulse/ext-device-restore.h \
> > @@ -791,6 +792,7 @@ libpulse_la_SOURCES = \
> >  		pulse/channelmap.c pulse/channelmap.h \
> >  		pulse/context.c pulse/context.h \
> >  		pulse/def.h \
> > +		pulse/direction.c pulse/direction.h \
> >  		pulse/error.c pulse/error.h \
> >  		pulse/ext-device-manager.c pulse/ext-device-manager.h \
> >  		pulse/ext-device-restore.c pulse/ext-device-restore.h \
> > diff --git a/src/map-file b/src/map-file
> > index fbad1a4..dc36fdc 100644
> > --- a/src/map-file
> > +++ b/src/map-file
> > @@ -146,6 +146,8 @@ pa_cvolume_set_position;
> >  pa_cvolume_snprint;
> >  pa_cvolume_snprint_verbose;
> >  pa_cvolume_valid;
> > +pa_direction_to_string;
> > +pa_direction_valid;
> >  pa_encoding_to_string;
> >  pa_ext_device_manager_delete;
> >  pa_ext_device_manager_enable_role_device_priority_routing;
> > diff --git a/src/pulse/direction.c b/src/pulse/direction.c
> > new file mode 100644
> > index 0000000..95f5e00
> > --- /dev/null
> > +++ b/src/pulse/direction.c
> > @@ -0,0 +1,46 @@
> > +/***
> > +  This file is part of PulseAudio.
> > +
> > +  Copyright 2014 Intel Corporation
> > +
> > +  PulseAudio is free software; you can redistribute it and/or modify
> > +  it under the terms of the GNU Lesser General Public License as published
> > +  by the Free Software Foundation; either version 2.1 of the License,
> > +  or (at your option) any later version.
> > +
> > +  PulseAudio is distributed in the hope that it will be useful, but
> > +  WITHOUT ANY WARRANTY; without even the implied warranty of
> > +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > +  General Public License for more details.
> > +
> > +  You should have received a copy of the GNU Lesser General Public License
> > +  along with PulseAudio; if not, write to the Free Software
> > +  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
> > +  USA.
> > +***/
> > +
> > +#include "direction.h"
> > +
> > +#include <pulsecore/i18n.h>
> > +
> > +int pa_direction_valid(pa_direction_t direction) {
> > +    if (direction != PA_DIRECTION_INPUT
> > +            && direction != PA_DIRECTION_OUTPUT
> > +            && direction != (PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT))
> > +        return 0;
> > +
> > +    return 1;
> > +}
> > +
> > +const char *pa_direction_to_string(pa_direction_t direction) {
> > +    pa_init_i18n();
> 
> Are pa_init_i18n and _() both declared with PA_GCC_PURE (or equivalent)?
> No side effects?

No they aren't, good catch. I probably added PA_GCC_PURE without
remembering that the function calls the i18n functions. I'll remove the
attribute.

> Both acked otherwise. I would probably not have started a separate file
> just for two functions, but it does not matter much.

I tried to find a place for them in the existing files, but pulse/util.h
was the best candidate, and the direction functions felt somehow out of
place there.

-- 
Tanu



More information about the pulseaudio-discuss mailing list