summaryrefslogtreecommitdiffstats
path: root/src/pulse/format.c
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2011-03-08 20:15:36 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2011-05-02 11:55:38 +0530
commit8631f4e2c44b47db76795bebdbab54914a1f3ea0 (patch)
tree2f42ff9e46091f41b44864b1a4c512e75d6093ba /src/pulse/format.c
parenta3a004214404c6f91a82c1e2164444e5e08c26cf (diff)
format: Add some convenience functions for printing
Diffstat (limited to 'src/pulse/format.c')
-rw-r--r--src/pulse/format.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/pulse/format.c b/src/pulse/format.c
index 7ddfa7a1..0c5c24b1 100644
--- a/src/pulse/format.c
+++ b/src/pulse/format.c
@@ -27,12 +27,28 @@
#include <pulse/internal.h>
#include <pulse/xmalloc.h>
+#include <pulse/i18n.h>
#include <pulsecore/core-util.h>
#include <pulsecore/macro.h>
#include "format.h"
+const char *pa_encoding_to_string(pa_encoding_t e) {
+ static const char* const table[]= {
+ [PA_ENCODING_PCM] = "pcm",
+ [PA_ENCODING_AC3_IEC61937] = "ac3-iec61937",
+ [PA_ENCODING_EAC3_IEC61937] = "eac3-iec61937",
+ [PA_ENCODING_MPEG_IEC61937] = "mpeg-iec61937",
+ [PA_ENCODING_ANY] = "any",
+ };
+
+ if (e < 0 || e >= PA_ENCODING_MAX)
+ return NULL;
+
+ return table[e];
+}
+
pa_format_info* pa_format_info_new(void) {
pa_format_info *f = pa_xnew(pa_format_info, 1);
@@ -78,6 +94,26 @@ int pa_format_info_is_pcm(const pa_format_info *f) {
return f->encoding == PA_ENCODING_PCM;
}
+char *pa_format_info_snprint(char *s, size_t l, const pa_format_info *f) {
+ char *tmp;
+
+ pa_assert(s);
+ pa_assert(l > 0);
+ pa_assert(f);
+
+ pa_init_i18n();
+
+ if (!pa_format_info_valid(f))
+ pa_snprintf(s, l, _("(invalid)"));
+ else {
+ tmp = pa_proplist_to_string_sep(f->plist, ", ");
+ pa_snprintf(s, l, _("%s, %s"), pa_encoding_to_string(f->encoding), tmp[0] ? tmp : _("(no properties)"));
+ pa_xfree(tmp);
+ }
+
+ return s;
+}
+
pa_bool_t pa_format_info_is_compatible(pa_format_info *first, pa_format_info *second) {
const char *key;
void *state = NULL;