[pulseaudio-commits] 2 commits - doxygen/doxygen.conf.in src/Makefile.am src/map-file src/pulse

Tanu Kaskinen tanuk at kemper.freedesktop.org
Thu Mar 27 01:02:50 PDT 2014


 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/introspect.c  |    6 +++---
 src/pulse/pulseaudio.h  |    5 +++--
 7 files changed, 94 insertions(+), 5 deletions(-)

New commits:
commit 633bc529e2643adbcd09a211887e0b788a69e6c2
Author: Tanu Kaskinen <tanu.kaskinen at linux.intel.com>
Date:   Wed Mar 26 11:52:34 2014 +0200

    introspect: Use pa_direction_valid() to validate port direction
    
    There's no behavioral change, just nicer code.

diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c
index 2d54fdb..d7696df 100644
--- a/src/pulse/introspect.c
+++ b/src/pulse/introspect.c
@@ -25,6 +25,7 @@
 #endif
 
 #include <pulse/context.h>
+#include <pulse/direction.h>
 #include <pulse/xmalloc.h>
 #include <pulse/fork-detect.h>
 
@@ -823,15 +824,14 @@ static int fill_card_port_info(pa_context *context, pa_tagstruct* t, pa_card_inf
             pa_tagstruct_getu32(t, &port->priority) < 0 ||
             pa_tagstruct_getu32(t, &available) < 0 ||
             pa_tagstruct_getu8(t, &direction) < 0 ||
+            !pa_direction_valid(direction) ||
             pa_tagstruct_get_proplist(t, port->proplist) < 0 ||
             pa_tagstruct_getu32(t, &port->n_profiles) < 0) {
 
             return -PA_ERR_PROTOCOL;
         }
 
-        if (available > PA_PORT_AVAILABLE_YES ||
-            direction > PA_DIRECTION_OUTPUT + PA_DIRECTION_INPUT) {
-
+        if (available > PA_PORT_AVAILABLE_YES ) {
             return -PA_ERR_PROTOCOL;
         }
 

commit b9147fad0fc33acf8c90a8c05f49cbae427fd33a
Author: Tanu Kaskinen <tanu.kaskinen at linux.intel.com>
Date:   Wed Mar 26 11:52:33 2014 +0200

    direction: Add a couple of direction helper functions

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();
+
+    if (direction == PA_DIRECTION_INPUT)
+        return _("input");
+    if (direction == PA_DIRECTION_OUTPUT)
+        return _("output");
+    if (direction == (PA_DIRECTION_INPUT | PA_DIRECTION_OUTPUT))
+        return _("bidirectional");
+
+    return _("invalid");
+}
diff --git a/src/pulse/direction.h b/src/pulse/direction.h
new file mode 100644
index 0000000..127f07a
--- /dev/null
+++ b/src/pulse/direction.h
@@ -0,0 +1,37 @@
+#ifndef foodirectionhfoo
+#define foodirectionhfoo
+
+/***
+  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 <pulse/def.h>
+
+/** \file
+ * Utility functions for \ref pa_direction_t. */
+
+/** Return non-zero if the given value is a valid direction (either input,
+ * output or bidirectional). \since 6.0 */
+int pa_direction_valid(pa_direction_t direction) PA_GCC_CONST;
+
+/** Return a textual representation of the direction. \since 6.0 */
+const char *pa_direction_to_string(pa_direction_t direction);
+
+#endif
diff --git a/src/pulse/pulseaudio.h b/src/pulse/pulseaudio.h
index 21b7213..2e270dd 100644
--- a/src/pulse/pulseaudio.h
+++ b/src/pulse/pulseaudio.h
@@ -23,6 +23,7 @@
   USA.
 ***/
 
+#include <pulse/direction.h>
 #include <pulse/mainloop-api.h>
 #include <pulse/sample.h>
 #include <pulse/format.h>
@@ -49,8 +50,8 @@
 
 /** \file
  * Include all libpulse header files at once. The following files are
- * included: \ref mainloop-api.h, \ref sample.h, \ref def.h, \ref
- * context.h, \ref stream.h, \ref introspect.h, \ref subscribe.h, \ref
+ * included: \ref direction.h, \ref mainloop-api.h, \ref sample.h, \ref def.h,
+ * \ref context.h, \ref stream.h, \ref introspect.h, \ref subscribe.h, \ref
  * scache.h, \ref version.h, \ref error.h, \ref channelmap.h, \ref
  * operation.h,\ref volume.h, \ref xmalloc.h, \ref utf8.h, \ref
  * thread-mainloop.h, \ref mainloop.h, \ref util.h, \ref proplist.h,



More information about the pulseaudio-commits mailing list