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/polypsrc.c | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) (limited to 'src/polypsrc.c') diff --git a/src/polypsrc.c b/src/polypsrc.c index b396e3d..a790e6d 100644 --- a/src/polypsrc.c +++ b/src/polypsrc.c @@ -30,6 +30,7 @@ #include #include "polypsrc.h" +#include "polyputil.h" GST_DEBUG_CATEGORY_EXTERN(polyp_debug); #define GST_CAT_DEFAULT polyp_debug @@ -298,10 +299,11 @@ static void gst_polypsrc_stream_request_cb(pa_stream *s, size_t length, void *us static gboolean gst_polypsrc_open(GstAudioSrc *asrc) { GstPolypSrc *polypsrc = GST_POLYPSRC(asrc); + gchar *name = gst_polyp_client_name(); pa_threaded_mainloop_lock(polypsrc->mainloop); - if (!(polypsrc->context = pa_context_new(pa_threaded_mainloop_get_api(polypsrc->mainloop), "gstreamer"))) { + if (!(polypsrc->context = pa_context_new(pa_threaded_mainloop_get_api(polypsrc->mainloop), name))) { GST_ELEMENT_ERROR(polypsrc, RESOURCE, FAILED, ("Failed to create context"), (NULL)); goto unlock_and_fail; } @@ -322,11 +324,15 @@ static gboolean gst_polypsrc_open(GstAudioSrc *asrc) { } pa_threaded_mainloop_unlock(polypsrc->mainloop); + + g_free(name); return TRUE; unlock_and_fail: pa_threaded_mainloop_unlock(polypsrc->mainloop); + + g_free(name); return FALSE; } @@ -339,41 +345,12 @@ static gboolean gst_polypsrc_close(GstAudioSrc *asrc) { return TRUE; } - -static gboolean gst_polypsrc_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_polypsrc_prepare(GstAudioSrc *asrc, GstRingBufferSpec *spec) { pa_buffer_attr buf_attr; GstPolypSrc *polypsrc = GST_POLYPSRC(asrc); - if (!gst_polypsrc_fill_sample_spec(spec, &polypsrc->sample_spec)) { + if (!gst_polyp_fill_sample_spec(spec, &polypsrc->sample_spec)) { GST_ELEMENT_ERROR(polypsrc, RESOURCE, SETTINGS, ("Invalid sample specification."), (NULL)); goto unlock_and_fail; } -- cgit