summaryrefslogtreecommitdiffstats
path: root/src/polypsink.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/polypsink.c')
-rw-r--r--src/polypsink.c36
1 files changed, 6 insertions, 30 deletions
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 <gst/gsttaglist.h>
#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;
}