[pulseaudio-commits] src/map-file src/pulse src/pulsecore

Arun Raghavan arun at kemper.freedesktop.org
Mon Jul 23 14:00:28 UTC 2018


 src/map-file                |    4 +
 src/pulse/format.c          |   89 ++++++++++++++++++++++++++++++++++++++++++++
 src/pulse/format.h          |   20 +++++++++
 src/pulsecore/core-format.c |   89 --------------------------------------------
 src/pulsecore/core-format.h |   20 ---------
 5 files changed, 113 insertions(+), 109 deletions(-)

New commits:
commit 6d7a266e0e9969d4b227ab30c84377f819406bd3
Author: Arun Raghavan <arun at arunraghavan.net>
Date:   Sat May 26 08:52:52 2018 +0530

    format: Expose pa_format_info convenience getters in API
    
    We move over helper functions to get rate, channels, channel map and
    sample format (if PCM) in the public API, so users of the extended API
    are more easily able to pull out these values from pa_format_info.

diff --git a/src/map-file b/src/map-file
index 902ce2fd..aaa1a424 100644
--- a/src/map-file
+++ b/src/map-file
@@ -177,12 +177,16 @@ pa_format_info_copy;
 pa_format_info_free;
 pa_format_info_from_string;
 pa_format_info_from_sample_spec;
+pa_format_info_get_channel_map;
+pa_format_info_get_channels;
 pa_format_info_get_prop_type;
 pa_format_info_get_prop_int;
 pa_format_info_get_prop_int_range;
 pa_format_info_get_prop_int_array;
 pa_format_info_get_prop_string;
 pa_format_info_get_prop_string_array;
+pa_format_info_get_rate;
+pa_format_info_get_sample_format;
 pa_format_info_free_string_array;
 pa_format_info_is_compatible;
 pa_format_info_is_pcm;
diff --git a/src/pulse/format.c b/src/pulse/format.c
index 07b4420e..2e90821b 100644
--- a/src/pulse/format.c
+++ b/src/pulse/format.c
@@ -515,6 +515,95 @@ void pa_format_info_free_string_array(char **values, int n_values) {
     pa_xfree(values);
 }
 
+int pa_format_info_get_sample_format(const pa_format_info *f, pa_sample_format_t *sf) {
+    int r;
+    char *sf_str;
+    pa_sample_format_t sf_local;
+
+    pa_assert(f);
+    pa_assert(sf);
+
+    r = pa_format_info_get_prop_string(f, PA_PROP_FORMAT_SAMPLE_FORMAT, &sf_str);
+    if (r < 0)
+        return r;
+
+    sf_local = pa_parse_sample_format(sf_str);
+    pa_xfree(sf_str);
+
+    if (!pa_sample_format_valid(sf_local)) {
+        pa_log_debug("Invalid sample format.");
+        return -PA_ERR_INVALID;
+    }
+
+    *sf = sf_local;
+
+    return 0;
+}
+
+int pa_format_info_get_rate(const pa_format_info *f, uint32_t *rate) {
+    int r;
+    int rate_local;
+
+    pa_assert(f);
+    pa_assert(rate);
+
+    r = pa_format_info_get_prop_int(f, PA_PROP_FORMAT_RATE, &rate_local);
+    if (r < 0)
+        return r;
+
+    if (!pa_sample_rate_valid(rate_local)) {
+        pa_log_debug("Invalid sample rate: %i", rate_local);
+        return -PA_ERR_INVALID;
+    }
+
+    *rate = rate_local;
+
+    return 0;
+}
+
+int pa_format_info_get_channels(const pa_format_info *f, uint8_t *channels) {
+    int r;
+    int channels_local;
+
+    pa_assert(f);
+    pa_assert(channels);
+
+    r = pa_format_info_get_prop_int(f, PA_PROP_FORMAT_CHANNELS, &channels_local);
+    if (r < 0)
+        return r;
+
+    if (!pa_channels_valid(channels_local)) {
+        pa_log_debug("Invalid channel count: %i", channels_local);
+        return -PA_ERR_INVALID;
+    }
+
+    *channels = channels_local;
+
+    return 0;
+}
+
+int pa_format_info_get_channel_map(const pa_format_info *f, pa_channel_map *map) {
+    int r;
+    char *map_str;
+
+    pa_assert(f);
+    pa_assert(map);
+
+    r = pa_format_info_get_prop_string(f, PA_PROP_FORMAT_CHANNEL_MAP, &map_str);
+    if (r < 0)
+        return r;
+
+    map = pa_channel_map_parse(map, map_str);
+    pa_xfree(map_str);
+
+    if (!map) {
+        pa_log_debug("Failed to parse channel map.");
+        return -PA_ERR_INVALID;
+    }
+
+    return 0;
+}
+
 void pa_format_info_set_sample_format(pa_format_info *f, pa_sample_format_t sf) {
     pa_format_info_set_prop_string(f, PA_PROP_FORMAT_SAMPLE_FORMAT, pa_sample_format_to_string(sf));
 }
diff --git a/src/pulse/format.h b/src/pulse/format.h
index 584032fb..82a8be7b 100644
--- a/src/pulse/format.h
+++ b/src/pulse/format.h
@@ -213,6 +213,26 @@ int pa_format_info_get_prop_string_array(const pa_format_info *f, const char *ke
 /** Frees a string array returned by \ref pa_format_info_get_prop_string_array. \since 2.0 */
 void pa_format_info_free_string_array(char **values, int n_values);
 
+/** Gets the sample format stored in the format info. Returns a negative error
+ * code on failure. If the sample format property is not set at all, returns a
+ * negative integer. \since 13.0 */
+int pa_format_info_get_sample_format(const pa_format_info *f, pa_sample_format_t *sf);
+
+/** Gets the sample rate stored in the format info. Returns a negative error
+ * code on failure. If the sample rate property is not set at all, returns a
+ * negative integer. \since 13.0 */
+int pa_format_info_get_rate(const pa_format_info *f, uint32_t *rate);
+
+/** Gets the channel count stored in the format info. Returns a negative error
+ * code on failure. If the channels property is not set at all, returns a
+ * negative integer. \since 13.0 */
+int pa_format_info_get_channels(const pa_format_info *f, uint8_t *channels);
+
+/** Gets the channel map stored in the format info. Returns a negative error
+ * code on failure. If the channel map property is not
+ * set at all, returns a negative integer. \since 13.0 */
+int pa_format_info_get_channel_map(const pa_format_info *f, pa_channel_map *map);
+
 /** Sets an integer property on the given format info. \since 1.0 */
 void pa_format_info_set_prop_int(pa_format_info *f, const char *key, int value);
 /** Sets a property with a list of integer values on the given format info. \since 1.0 */
diff --git a/src/pulsecore/core-format.c b/src/pulsecore/core-format.c
index 862a74b5..1a218644 100644
--- a/src/pulsecore/core-format.c
+++ b/src/pulsecore/core-format.c
@@ -26,95 +26,6 @@
 
 #include <pulsecore/macro.h>
 
-int pa_format_info_get_sample_format(const pa_format_info *f, pa_sample_format_t *sf) {
-    int r;
-    char *sf_str;
-    pa_sample_format_t sf_local;
-
-    pa_assert(f);
-    pa_assert(sf);
-
-    r = pa_format_info_get_prop_string(f, PA_PROP_FORMAT_SAMPLE_FORMAT, &sf_str);
-    if (r < 0)
-        return r;
-
-    sf_local = pa_parse_sample_format(sf_str);
-    pa_xfree(sf_str);
-
-    if (!pa_sample_format_valid(sf_local)) {
-        pa_log_debug("Invalid sample format.");
-        return -PA_ERR_INVALID;
-    }
-
-    *sf = sf_local;
-
-    return 0;
-}
-
-int pa_format_info_get_rate(const pa_format_info *f, uint32_t *rate) {
-    int r;
-    int rate_local;
-
-    pa_assert(f);
-    pa_assert(rate);
-
-    r = pa_format_info_get_prop_int(f, PA_PROP_FORMAT_RATE, &rate_local);
-    if (r < 0)
-        return r;
-
-    if (!pa_sample_rate_valid(rate_local)) {
-        pa_log_debug("Invalid sample rate: %i", rate_local);
-        return -PA_ERR_INVALID;
-    }
-
-    *rate = rate_local;
-
-    return 0;
-}
-
-int pa_format_info_get_channels(const pa_format_info *f, uint8_t *channels) {
-    int r;
-    int channels_local;
-
-    pa_assert(f);
-    pa_assert(channels);
-
-    r = pa_format_info_get_prop_int(f, PA_PROP_FORMAT_CHANNELS, &channels_local);
-    if (r < 0)
-        return r;
-
-    if (!pa_channels_valid(channels_local)) {
-        pa_log_debug("Invalid channel count: %i", channels_local);
-        return -PA_ERR_INVALID;
-    }
-
-    *channels = channels_local;
-
-    return 0;
-}
-
-int pa_format_info_get_channel_map(const pa_format_info *f, pa_channel_map *map) {
-    int r;
-    char *map_str;
-
-    pa_assert(f);
-    pa_assert(map);
-
-    r = pa_format_info_get_prop_string(f, PA_PROP_FORMAT_CHANNEL_MAP, &map_str);
-    if (r < 0)
-        return r;
-
-    map = pa_channel_map_parse(map, map_str);
-    pa_xfree(map_str);
-
-    if (!map) {
-        pa_log_debug("Failed to parse channel map.");
-        return -PA_ERR_INVALID;
-    }
-
-    return 0;
-}
-
 pa_format_info *pa_format_info_from_sample_spec2(const pa_sample_spec *ss, const pa_channel_map *map, bool set_format,
                                                  bool set_rate, bool set_channels) {
     pa_format_info *format = NULL;
diff --git a/src/pulsecore/core-format.h b/src/pulsecore/core-format.h
index 37503041..e2e02fe7 100644
--- a/src/pulsecore/core-format.h
+++ b/src/pulsecore/core-format.h
@@ -22,26 +22,6 @@
 
 #include <stdbool.h>
 
-/* Gets the sample format stored in the format info. Returns a negative error
- * code on failure. If the sample format property is not set at all, returns
- * -PA_ERR_NOENTITY. */
-int pa_format_info_get_sample_format(const pa_format_info *f, pa_sample_format_t *sf);
-
-/* Gets the sample rate stored in the format info. Returns a negative error
- * code on failure. If the sample rate property is not set at all, returns
- * -PA_ERR_NOENTITY. */
-int pa_format_info_get_rate(const pa_format_info *f, uint32_t *rate);
-
-/* Gets the channel count stored in the format info. Returns a negative error
- * code on failure. If the channels property is not set at all, returns
- * -PA_ERR_NOENTITY. */
-int pa_format_info_get_channels(const pa_format_info *f, uint8_t *channels);
-
-/* Gets the channel map stored in the format info. Returns a negative error
- * code on failure. If the channel map property is not set at all, returns
- * -PA_ERR_NOENTITY. */
-int pa_format_info_get_channel_map(const pa_format_info *f, pa_channel_map *map);
-
 /* Convert a sample spec and an optional channel map to a new PCM format info
  * object (remember to free it). If map is NULL, then the channel map will be
  * left unspecified. If some fields of the sample spec should be ignored, pass



More information about the pulseaudio-commits mailing list