From 218ba9bee9f7a1cee34e1963f6d0b2d75499e58e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 9 May 2006 15:29:27 +0000 Subject: * use the same gst_polyp_fill_sample_spec() implementation by both the sink and the source * pass a sensible client name to Polypaudio git-svn-id: file:///home/lennart/svn/public/gst-pulse/trunk@18 bb39ca4e-bce3-0310-b5d4-eea78a553289 --- src/polypsink.c | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) (limited to 'src/polypsink.c') diff --git a/src/polypsink.c b/src/polypsink.c index 8859edb..e154e37 100644 --- a/src/polypsink.c +++ b/src/polypsink.c @@ -30,6 +30,7 @@ #include #include "polypsink.h" +#include "polyputil.h" GST_DEBUG_CATEGORY_EXTERN(polyp_debug); #define GST_CAT_DEFAULT polyp_debug @@ -306,10 +307,11 @@ static void gst_polypsink_stream_request_cb(pa_stream *s, size_t length, void *u static gboolean gst_polypsink_open(GstAudioSink *asink) { GstPolypSink *polypsink = GST_POLYPSINK(asink); + gchar *name = gst_polyp_client_name(); pa_threaded_mainloop_lock(polypsink->mainloop); - if (!(polypsink->context = pa_context_new(pa_threaded_mainloop_get_api(polypsink->mainloop), "gstreamer"))) { + if (!(polypsink->context = pa_context_new(pa_threaded_mainloop_get_api(polypsink->mainloop), name))) { GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Failed to create context"), (NULL)); goto unlock_and_fail; } @@ -330,11 +332,13 @@ static gboolean gst_polypsink_open(GstAudioSink *asink) { } pa_threaded_mainloop_unlock(polypsink->mainloop); + g_free(name); return TRUE; unlock_and_fail: pa_threaded_mainloop_unlock(polypsink->mainloop); + g_free(name); return FALSE; } @@ -348,40 +352,12 @@ static gboolean gst_polypsink_close(GstAudioSink *asink) { return TRUE; } -static gboolean gst_polypsink_fill_sample_spec(GstRingBufferSpec *spec, pa_sample_spec *ss) { - - if (spec->format == GST_MU_LAW && spec->width == 8) - ss->format = PA_SAMPLE_ULAW; - else if (spec->format == GST_A_LAW && spec->width == 8) - ss->format = PA_SAMPLE_ALAW; - else if (spec->format == GST_U8 && spec->width == 8) - ss->format = PA_SAMPLE_U8; - else if (spec->format == GST_S16_LE && spec->width == 16) - ss->format = PA_SAMPLE_S16LE; - else if (spec->format == GST_S16_BE && spec->width == 16) - ss->format = PA_SAMPLE_S16BE; - else if (spec->format == GST_FLOAT32_LE && spec->width == 32) - ss->format = PA_SAMPLE_FLOAT32LE; - else if (spec->format == GST_FLOAT32_BE && spec->width == 32) - ss->format = PA_SAMPLE_FLOAT32BE; - else - return FALSE; - - ss->channels = spec->channels; - ss->rate = spec->rate; - - if (!pa_sample_spec_valid(ss)) - return FALSE; - - return TRUE; -} - static gboolean gst_polypsink_prepare(GstAudioSink *asink, GstRingBufferSpec *spec) { pa_buffer_attr buf_attr; GstPolypSink *polypsink = GST_POLYPSINK(asink); - if (!gst_polypsink_fill_sample_spec(spec, &polypsink->sample_spec)) { + if (!gst_polyp_fill_sample_spec(spec, &polypsink->sample_spec)) { GST_ELEMENT_ERROR(polypsink, RESOURCE, SETTINGS, ("Invalid sample specification."), (NULL)); goto unlock_and_fail; } -- cgit