summaryrefslogtreecommitdiffstats
path: root/src/polypsink.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/polypsink.c')
-rw-r--r--src/polypsink.c400
1 files changed, 200 insertions, 200 deletions
diff --git a/src/polypsink.c b/src/polypsink.c
index 8e8a0b2..a1f5990 100644
--- a/src/polypsink.c
+++ b/src/polypsink.c
@@ -1,20 +1,20 @@
/* $Id$ */
/***
- This file is part of gst-polyp.
+ This file is part of gst-pulse.
- gst-polyp is free software; you can redistribute it and/or modify
+ gst-pulse is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
- gst-polyp is distributed in the hope that it will be useful, but
+ gst-pulse is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with gst-polyp; if not, write to the Free Software
+ License along with gst-pulse; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
***/
@@ -29,11 +29,11 @@
#include <gst/base/gstbasesink.h>
#include <gst/gsttaglist.h>
-#include "polypsink.h"
-#include "polyputil.h"
+#include "pulsesink.h"
+#include "pulseutil.h"
-GST_DEBUG_CATEGORY_EXTERN(polyp_debug);
-#define GST_CAT_DEFAULT polyp_debug
+GST_DEBUG_CATEGORY_EXTERN(pulse_debug);
+#define GST_CAT_DEFAULT pulse_debug
enum {
PROP_SERVER = 1,
@@ -42,25 +42,25 @@ enum {
static GstAudioSinkClass *parent_class = NULL;
-static void gst_polypsink_destroy_stream(GstPolypSink *polypsink);
-static void gst_polypsink_destroy_context(GstPolypSink *polypsink);
+static void gst_pulsesink_destroy_stream(GstPolypSink *pulsesink);
+static void gst_pulsesink_destroy_context(GstPolypSink *pulsesink);
-static void gst_polypsink_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_polypsink_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static void gst_polypsink_finalize(GObject *object);
-static void gst_polypsink_dispose(GObject *object);
+static void gst_pulsesink_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void gst_pulsesink_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_pulsesink_finalize(GObject *object);
+static void gst_pulsesink_dispose(GObject *object);
-static gboolean gst_polypsink_open(GstAudioSink *asink);
-static gboolean gst_polypsink_close(GstAudioSink *asink);
+static gboolean gst_pulsesink_open(GstAudioSink *asink);
+static gboolean gst_pulsesink_close(GstAudioSink *asink);
-static gboolean gst_polypsink_prepare(GstAudioSink *asink, GstRingBufferSpec *spec);
-static gboolean gst_polypsink_unprepare(GstAudioSink *asink);
+static gboolean gst_pulsesink_prepare(GstAudioSink *asink, GstRingBufferSpec *spec);
+static gboolean gst_pulsesink_unprepare(GstAudioSink *asink);
-static guint gst_polypsink_write(GstAudioSink *asink, gpointer data, guint length);
-static guint gst_polypsink_delay(GstAudioSink *asink);
-static void gst_polypsink_reset(GstAudioSink *asink);
+static guint gst_pulsesink_write(GstAudioSink *asink, gpointer data, guint length);
+static guint gst_pulsesink_delay(GstAudioSink *asink);
+static void gst_pulsesink_reset(GstAudioSink *asink);
-static gboolean gst_polypsink_event(GstBaseSink *sink, GstEvent *event);
+static gboolean gst_pulsesink_event(GstBaseSink *sink, GstEvent *event);
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
# define ENDIANNESS "LITTLE_ENDIAN, BIG_ENDIAN"
@@ -68,7 +68,7 @@ static gboolean gst_polypsink_event(GstBaseSink *sink, GstEvent *event);
# define ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN"
#endif
-static void gst_polypsink_base_init(gpointer g_class) {
+static void gst_pulsesink_base_init(gpointer g_class) {
static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE(
"sink",
@@ -108,9 +108,9 @@ static void gst_polypsink_base_init(gpointer g_class) {
static const GstElementDetails details =
GST_ELEMENT_DETAILS(
- "Polypaudio Audio Sink",
+ "PulseAudio Audio Sink",
"Sink/Audio",
- "Plays audio to a Polypaudio server",
+ "Plays audio to a PulseAudio server",
"Lennart Poettering");
GstElementClass *element_class = GST_ELEMENT_CLASS(g_class);
@@ -119,7 +119,7 @@ static void gst_polypsink_base_init(gpointer g_class) {
gst_element_class_add_pad_template(element_class, gst_static_pad_template_get(&pad_template));
}
-static void gst_polypsink_class_init(
+static void gst_pulsesink_class_init(
gpointer g_class,
gpointer class_data) {
@@ -128,109 +128,109 @@ static void gst_polypsink_class_init(
GstAudioSinkClass *gstaudiosink_class = GST_AUDIO_SINK_CLASS(g_class);
parent_class = g_type_class_peek_parent(g_class);
- gobject_class->dispose = GST_DEBUG_FUNCPTR(gst_polypsink_dispose);
- gobject_class->finalize = GST_DEBUG_FUNCPTR(gst_polypsink_finalize);
- gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_polypsink_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_polypsink_get_property);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR(gst_pulsesink_dispose);
+ gobject_class->finalize = GST_DEBUG_FUNCPTR(gst_pulsesink_finalize);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_pulsesink_set_property);
+ gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_pulsesink_get_property);
- gstbasesink_class->event = GST_DEBUG_FUNCPTR(gst_polypsink_event);
+ gstbasesink_class->event = GST_DEBUG_FUNCPTR(gst_pulsesink_event);
- gstaudiosink_class->open = GST_DEBUG_FUNCPTR(gst_polypsink_open);
- gstaudiosink_class->close = GST_DEBUG_FUNCPTR(gst_polypsink_close);
- gstaudiosink_class->prepare = GST_DEBUG_FUNCPTR(gst_polypsink_prepare);
- gstaudiosink_class->unprepare = GST_DEBUG_FUNCPTR(gst_polypsink_unprepare);
- gstaudiosink_class->write = GST_DEBUG_FUNCPTR(gst_polypsink_write);
- gstaudiosink_class->delay = GST_DEBUG_FUNCPTR(gst_polypsink_delay);
- gstaudiosink_class->reset = GST_DEBUG_FUNCPTR(gst_polypsink_reset);
+ gstaudiosink_class->open = GST_DEBUG_FUNCPTR(gst_pulsesink_open);
+ gstaudiosink_class->close = GST_DEBUG_FUNCPTR(gst_pulsesink_close);
+ gstaudiosink_class->prepare = GST_DEBUG_FUNCPTR(gst_pulsesink_prepare);
+ gstaudiosink_class->unprepare = GST_DEBUG_FUNCPTR(gst_pulsesink_unprepare);
+ gstaudiosink_class->write = GST_DEBUG_FUNCPTR(gst_pulsesink_write);
+ gstaudiosink_class->delay = GST_DEBUG_FUNCPTR(gst_pulsesink_delay);
+ gstaudiosink_class->reset = GST_DEBUG_FUNCPTR(gst_pulsesink_reset);
/* Overwrite GObject fields */
g_object_class_install_property(
gobject_class,
PROP_SERVER,
- g_param_spec_string("server", "Server", "The Polypaudio server to connect to", NULL, G_PARAM_READWRITE));
+ g_param_spec_string("server", "Server", "The PulseAudio server to connect to", NULL, G_PARAM_READWRITE));
g_object_class_install_property(
gobject_class,
PROP_DEVICE,
- g_param_spec_string("device", "Sink", "The Polypaudio sink device to connect to", NULL, G_PARAM_READWRITE));
+ g_param_spec_string("device", "Sink", "The PulseAudio sink device to connect to", NULL, G_PARAM_READWRITE));
}
-static void gst_polypsink_init(
+static void gst_pulsesink_init(
GTypeInstance * instance,
gpointer g_class) {
- GstPolypSink *polypsink = GST_POLYPSINK(instance);
+ GstPolypSink *pulsesink = GST_PULSESINK(instance);
int e;
- polypsink->server = polypsink->device = polypsink->stream_name = NULL;
+ pulsesink->server = pulsesink->device = pulsesink->stream_name = NULL;
- polypsink->context = NULL;
- polypsink->stream = NULL;
+ pulsesink->context = NULL;
+ pulsesink->stream = NULL;
- polypsink->mainloop = pa_threaded_mainloop_new();
- g_assert(polypsink->mainloop);
+ pulsesink->mainloop = pa_threaded_mainloop_new();
+ g_assert(pulsesink->mainloop);
- e = pa_threaded_mainloop_start(polypsink->mainloop);
+ e = pa_threaded_mainloop_start(pulsesink->mainloop);
g_assert(e == 0);
}
-static void gst_polypsink_destroy_stream(GstPolypSink* polypsink) {
- if (polypsink->stream) {
- pa_stream_disconnect(polypsink->stream);
- pa_stream_unref(polypsink->stream);
- polypsink->stream = NULL;
+static void gst_pulsesink_destroy_stream(GstPolypSink* pulsesink) {
+ if (pulsesink->stream) {
+ pa_stream_disconnect(pulsesink->stream);
+ pa_stream_unref(pulsesink->stream);
+ pulsesink->stream = NULL;
}
- g_free(polypsink->stream_name);
- polypsink->stream_name = NULL;
+ g_free(pulsesink->stream_name);
+ pulsesink->stream_name = NULL;
}
-static void gst_polypsink_destroy_context(GstPolypSink* polypsink) {
+static void gst_pulsesink_destroy_context(GstPolypSink* pulsesink) {
- gst_polypsink_destroy_stream(polypsink);
+ gst_pulsesink_destroy_stream(pulsesink);
- if (polypsink->context) {
- pa_context_disconnect(polypsink->context);
- pa_context_unref(polypsink->context);
- polypsink->context = NULL;
+ if (pulsesink->context) {
+ pa_context_disconnect(pulsesink->context);
+ pa_context_unref(pulsesink->context);
+ pulsesink->context = NULL;
}
}
-static void gst_polypsink_finalize(GObject * object) {
- GstPolypSink *polypsink = GST_POLYPSINK(object);
+static void gst_pulsesink_finalize(GObject * object) {
+ GstPolypSink *pulsesink = GST_PULSESINK(object);
- pa_threaded_mainloop_stop(polypsink->mainloop);
+ pa_threaded_mainloop_stop(pulsesink->mainloop);
- gst_polypsink_destroy_context(polypsink);
+ gst_pulsesink_destroy_context(pulsesink);
- g_free(polypsink->server);
- g_free(polypsink->device);
- g_free(polypsink->stream_name);
+ g_free(pulsesink->server);
+ g_free(pulsesink->device);
+ g_free(pulsesink->stream_name);
- pa_threaded_mainloop_free(polypsink->mainloop);
+ pa_threaded_mainloop_free(pulsesink->mainloop);
G_OBJECT_CLASS(parent_class)->finalize(object);
}
-static void gst_polypsink_dispose(GObject * object) {
+static void gst_pulsesink_dispose(GObject * object) {
G_OBJECT_CLASS(parent_class)->dispose(object);
}
-static void gst_polypsink_set_property(
+static void gst_pulsesink_set_property(
GObject * object,
guint prop_id,
const GValue * value,
GParamSpec * pspec) {
- GstPolypSink *polypsink = GST_POLYPSINK(object);
+ GstPolypSink *pulsesink = GST_PULSESINK(object);
switch (prop_id) {
case PROP_SERVER:
- g_free(polypsink->server);
- polypsink->server = g_value_dup_string(value);
+ g_free(pulsesink->server);
+ pulsesink->server = g_value_dup_string(value);
break;
case PROP_DEVICE:
- g_free(polypsink->device);
- polypsink->device = g_value_dup_string(value);
+ g_free(pulsesink->device);
+ pulsesink->device = g_value_dup_string(value);
break;
default:
@@ -239,21 +239,21 @@ static void gst_polypsink_set_property(
}
}
-static void gst_polypsink_get_property(
+static void gst_pulsesink_get_property(
GObject * object,
guint prop_id,
GValue * value,
GParamSpec * pspec) {
- GstPolypSink *polypsink = GST_POLYPSINK(object);
+ GstPolypSink *pulsesink = GST_PULSESINK(object);
switch(prop_id) {
case PROP_SERVER:
- g_value_set_string(value, polypsink->server);
+ g_value_set_string(value, pulsesink->server);
break;
case PROP_DEVICE:
- g_value_set_string(value, polypsink->device);
+ g_value_set_string(value, pulsesink->device);
break;
default:
@@ -262,14 +262,14 @@ static void gst_polypsink_get_property(
}
}
-static void gst_polypsink_context_state_cb(pa_context *c, void *userdata) {
- GstPolypSink *polypsink = GST_POLYPSINK(userdata);
+static void gst_pulsesink_context_state_cb(pa_context *c, void *userdata) {
+ GstPolypSink *pulsesink = GST_PULSESINK(userdata);
switch (pa_context_get_state(c)) {
case PA_CONTEXT_READY:
case PA_CONTEXT_TERMINATED:
case PA_CONTEXT_FAILED:
- pa_threaded_mainloop_signal(polypsink->mainloop, 0);
+ pa_threaded_mainloop_signal(pulsesink->mainloop, 0);
break;
case PA_CONTEXT_UNCONNECTED:
@@ -280,15 +280,15 @@ static void gst_polypsink_context_state_cb(pa_context *c, void *userdata) {
}
}
-static void gst_polypsink_stream_state_cb(pa_stream *s, void * userdata) {
- GstPolypSink *polypsink = GST_POLYPSINK(userdata);
+static void gst_pulsesink_stream_state_cb(pa_stream *s, void * userdata) {
+ GstPolypSink *pulsesink = GST_PULSESINK(userdata);
switch (pa_stream_get_state(s)) {
case PA_STREAM_READY:
case PA_STREAM_FAILED:
case PA_STREAM_TERMINATED:
- pa_threaded_mainloop_signal(polypsink->mainloop, 0);
+ pa_threaded_mainloop_signal(pulsesink->mainloop, 0);
break;
case PA_STREAM_UNCONNECTED:
@@ -297,167 +297,167 @@ static void gst_polypsink_stream_state_cb(pa_stream *s, void * userdata) {
}
}
-static void gst_polypsink_stream_request_cb(pa_stream *s, size_t length, void *userdata) {
- GstPolypSink *polypsink = GST_POLYPSINK(userdata);
+static void gst_pulsesink_stream_request_cb(pa_stream *s, size_t length, void *userdata) {
+ GstPolypSink *pulsesink = GST_PULSESINK(userdata);
- pa_threaded_mainloop_signal(polypsink->mainloop, 0);
+ pa_threaded_mainloop_signal(pulsesink->mainloop, 0);
}
-static void gst_polypsink_stream_latency_update_cb(pa_stream *s, void *userdata) {
- GstPolypSink *polypsink = GST_POLYPSINK(userdata);
+static void gst_pulsesink_stream_latency_update_cb(pa_stream *s, void *userdata) {
+ GstPolypSink *pulsesink = GST_PULSESINK(userdata);
- pa_threaded_mainloop_signal(polypsink->mainloop, 0);
+ pa_threaded_mainloop_signal(pulsesink->mainloop, 0);
}
-static gboolean gst_polypsink_open(GstAudioSink *asink) {
- GstPolypSink *polypsink = GST_POLYPSINK(asink);
- gchar *name = gst_polyp_client_name();
+static gboolean gst_pulsesink_open(GstAudioSink *asink) {
+ GstPolypSink *pulsesink = GST_PULSESINK(asink);
+ gchar *name = gst_pulse_client_name();
- pa_threaded_mainloop_lock(polypsink->mainloop);
+ pa_threaded_mainloop_lock(pulsesink->mainloop);
- 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));
+ if (!(pulsesink->context = pa_context_new(pa_threaded_mainloop_get_api(pulsesink->mainloop), name))) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("Failed to create context"), (NULL));
goto unlock_and_fail;
}
- pa_context_set_state_callback(polypsink->context, gst_polypsink_context_state_cb, polypsink);
+ pa_context_set_state_callback(pulsesink->context, gst_pulsesink_context_state_cb, pulsesink);
- if (pa_context_connect(polypsink->context, polypsink->server, 0, NULL) < 0) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Failed to connect: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ if (pa_context_connect(pulsesink->context, pulsesink->server, 0, NULL) < 0) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("Failed to connect: %s", pa_strerror(pa_context_errno(pulsesink->context))), (NULL));
goto unlock_and_fail;
}
/* Wait until the context is ready */
- pa_threaded_mainloop_wait(polypsink->mainloop);
+ pa_threaded_mainloop_wait(pulsesink->mainloop);
- if (pa_context_get_state(polypsink->context) != PA_CONTEXT_READY) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Failed to connect: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ if (pa_context_get_state(pulsesink->context) != PA_CONTEXT_READY) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("Failed to connect: %s", pa_strerror(pa_context_errno(pulsesink->context))), (NULL));
goto unlock_and_fail;
}
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
g_free(name);
return TRUE;
unlock_and_fail:
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
g_free(name);
return FALSE;
}
-static gboolean gst_polypsink_close(GstAudioSink *asink) {
- GstPolypSink *polypsink = GST_POLYPSINK(asink);
+static gboolean gst_pulsesink_close(GstAudioSink *asink) {
+ GstPolypSink *pulsesink = GST_PULSESINK(asink);
- pa_threaded_mainloop_lock(polypsink->mainloop);
- gst_polypsink_destroy_context(polypsink);
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_lock(pulsesink->mainloop);
+ gst_pulsesink_destroy_context(pulsesink);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
return TRUE;
}
-static gboolean gst_polypsink_prepare(GstAudioSink *asink, GstRingBufferSpec *spec) {
+static gboolean gst_pulsesink_prepare(GstAudioSink *asink, GstRingBufferSpec *spec) {
pa_buffer_attr buf_attr;
- GstPolypSink *polypsink = GST_POLYPSINK(asink);
+ GstPolypSink *pulsesink = GST_PULSESINK(asink);
- if (!gst_polyp_fill_sample_spec(spec, &polypsink->sample_spec)) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, SETTINGS, ("Invalid sample specification."), (NULL));
+ if (!gst_pulse_fill_sample_spec(spec, &pulsesink->sample_spec)) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, SETTINGS, ("Invalid sample specification."), (NULL));
goto unlock_and_fail;
}
- pa_threaded_mainloop_lock(polypsink->mainloop);
+ pa_threaded_mainloop_lock(pulsesink->mainloop);
- if (!polypsink->context || pa_context_get_state(polypsink->context) != PA_CONTEXT_READY) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Bad context state: %s", polypsink->context ? pa_strerror(pa_context_errno(polypsink->context)) : NULL), (NULL));
+ if (!pulsesink->context || pa_context_get_state(pulsesink->context) != PA_CONTEXT_READY) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("Bad context state: %s", pulsesink->context ? pa_strerror(pa_context_errno(pulsesink->context)) : NULL), (NULL));
goto unlock_and_fail;
}
- if (!(polypsink->stream = pa_stream_new(polypsink->context, polypsink->stream_name ? polypsink->stream_name : "Playback Stream", &polypsink->sample_spec, NULL))) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Failed to create stream: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ if (!(pulsesink->stream = pa_stream_new(pulsesink->context, pulsesink->stream_name ? pulsesink->stream_name : "Playback Stream", &pulsesink->sample_spec, NULL))) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("Failed to create stream: %s", pa_strerror(pa_context_errno(pulsesink->context))), (NULL));
goto unlock_and_fail;
}
- pa_stream_set_state_callback(polypsink->stream, gst_polypsink_stream_state_cb, polypsink);
- pa_stream_set_write_callback(polypsink->stream, gst_polypsink_stream_request_cb, polypsink);
- pa_stream_set_latency_update_callback(polypsink->stream, gst_polypsink_stream_latency_update_cb, polypsink);
+ pa_stream_set_state_callback(pulsesink->stream, gst_pulsesink_stream_state_cb, pulsesink);
+ pa_stream_set_write_callback(pulsesink->stream, gst_pulsesink_stream_request_cb, pulsesink);
+ pa_stream_set_latency_update_callback(pulsesink->stream, gst_pulsesink_stream_latency_update_cb, pulsesink);
memset(&buf_attr, 0, sizeof(buf_attr));
buf_attr.tlength = spec->segtotal*spec->segsize;
buf_attr.maxlength = buf_attr.tlength*2;
buf_attr.prebuf = buf_attr.minreq = spec->segsize;
- if (pa_stream_connect_playback(polypsink->stream, polypsink->device, &buf_attr, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE|PA_STREAM_NOT_MONOTONOUS, NULL, NULL) < 0) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Failed to connect stream: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ if (pa_stream_connect_playback(pulsesink->stream, pulsesink->device, &buf_attr, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE|PA_STREAM_NOT_MONOTONOUS, NULL, NULL) < 0) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("Failed to connect stream: %s", pa_strerror(pa_context_errno(pulsesink->context))), (NULL));
goto unlock_and_fail;
}
/* Wait until the stream is ready */
- pa_threaded_mainloop_wait(polypsink->mainloop);
+ pa_threaded_mainloop_wait(pulsesink->mainloop);
- if (pa_stream_get_state(polypsink->stream) != PA_STREAM_READY) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Failed to connect stream: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ if (pa_stream_get_state(pulsesink->stream) != PA_STREAM_READY) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("Failed to connect stream: %s", pa_strerror(pa_context_errno(pulsesink->context))), (NULL));
goto unlock_and_fail;
}
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
- spec->bytes_per_sample = pa_frame_size(&polypsink->sample_spec);
+ spec->bytes_per_sample = pa_frame_size(&pulsesink->sample_spec);
memset(spec->silence_sample, 0, spec->bytes_per_sample);
return TRUE;
unlock_and_fail:
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
return FALSE;
}
-static gboolean gst_polypsink_unprepare(GstAudioSink * asink) {
- GstPolypSink *polypsink = GST_POLYPSINK(asink);
+static gboolean gst_pulsesink_unprepare(GstAudioSink * asink) {
+ GstPolypSink *pulsesink = GST_PULSESINK(asink);
- pa_threaded_mainloop_lock(polypsink->mainloop);
- gst_polypsink_destroy_stream(polypsink);
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_lock(pulsesink->mainloop);
+ gst_pulsesink_destroy_stream(pulsesink);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
return TRUE;
}
-#define CHECK_DEAD_GOTO(polypsink, label) \
-if (!(polypsink)->context || pa_context_get_state((polypsink)->context) != PA_CONTEXT_READY || \
- !(polypsink)->stream || pa_stream_get_state((polypsink)->stream) != PA_STREAM_READY) { \
- GST_ELEMENT_ERROR((polypsink), RESOURCE, FAILED, ("Disconnected: %s", (polypsink)->context ? pa_strerror(pa_context_errno((polypsink)->context)) : NULL), (NULL)); \
+#define CHECK_DEAD_GOTO(pulsesink, label) \
+if (!(pulsesink)->context || pa_context_get_state((pulsesink)->context) != PA_CONTEXT_READY || \
+ !(pulsesink)->stream || pa_stream_get_state((pulsesink)->stream) != PA_STREAM_READY) { \
+ GST_ELEMENT_ERROR((pulsesink), RESOURCE, FAILED, ("Disconnected: %s", (pulsesink)->context ? pa_strerror(pa_context_errno((pulsesink)->context)) : NULL), (NULL)); \
goto label; \
}
-static guint gst_polypsink_write(GstAudioSink *asink, gpointer data, guint length) {
- GstPolypSink *polypsink = GST_POLYPSINK(asink);
+static guint gst_pulsesink_write(GstAudioSink *asink, gpointer data, guint length) {
+ GstPolypSink *pulsesink = GST_PULSESINK(asink);
size_t sum = 0;
- pa_threaded_mainloop_lock(polypsink->mainloop);
+ pa_threaded_mainloop_lock(pulsesink->mainloop);
while (length > 0) {
size_t l;
for (;;) {
- CHECK_DEAD_GOTO(polypsink, unlock_and_fail);
+ CHECK_DEAD_GOTO(pulsesink, unlock_and_fail);
- if ((l = pa_stream_writable_size(polypsink->stream)) == (size_t) -1) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("pa_stream_writable_size() failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ if ((l = pa_stream_writable_size(pulsesink->stream)) == (size_t) -1) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("pa_stream_writable_size() failed: %s", pa_strerror(pa_context_errno(pulsesink->context))), (NULL));
goto unlock_and_fail;
}
if (l > 0)
break;
- pa_threaded_mainloop_wait(polypsink->mainloop);
+ pa_threaded_mainloop_wait(pulsesink->mainloop);
}
if (l > length)
l = length;
- if (pa_stream_write(polypsink->stream, data, l, NULL, 0, PA_SEEK_RELATIVE) < 0) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("pa_stream_write() failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ if (pa_stream_write(pulsesink->stream, data, l, NULL, 0, PA_SEEK_RELATIVE) < 0) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("pa_stream_write() failed: %s", pa_strerror(pa_context_errno(pulsesink->context))), (NULL));
goto unlock_and_fail;
}
@@ -467,75 +467,75 @@ static guint gst_polypsink_write(GstAudioSink *asink, gpointer data, guint lengt
sum += l;
}
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
return sum;
unlock_and_fail:
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
return 0;
}
-static guint gst_polypsink_delay(GstAudioSink *asink) {
- GstPolypSink *polypsink = GST_POLYPSINK(asink);
+static guint gst_pulsesink_delay(GstAudioSink *asink) {
+ GstPolypSink *pulsesink = GST_PULSESINK(asink);
pa_usec_t t;
- pa_threaded_mainloop_lock(polypsink->mainloop);
+ pa_threaded_mainloop_lock(pulsesink->mainloop);
for (;;) {
- CHECK_DEAD_GOTO(polypsink, unlock_and_fail);
+ CHECK_DEAD_GOTO(pulsesink, unlock_and_fail);
- if (pa_stream_get_latency(polypsink->stream, &t, NULL) >= 0)
+ if (pa_stream_get_latency(pulsesink->stream, &t, NULL) >= 0)
break;
- if (pa_context_errno(polypsink->context) != PA_ERR_NODATA) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("pa_stream_get_latency() failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ if (pa_context_errno(pulsesink->context) != PA_ERR_NODATA) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("pa_stream_get_latency() failed: %s", pa_strerror(pa_context_errno(pulsesink->context))), (NULL));
goto unlock_and_fail;
}
- pa_threaded_mainloop_wait(polypsink->mainloop);
+ pa_threaded_mainloop_wait(pulsesink->mainloop);
}
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
- return gst_util_uint64_scale_int (t, polypsink->sample_spec.rate, 1000000LL);
+ return gst_util_uint64_scale_int (t, pulsesink->sample_spec.rate, 1000000LL);
unlock_and_fail:
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
return 0;
}
-static void gst_polypsink_success_cb(pa_stream *s, int success, void *userdata) {
- GstPolypSink *polypsink = GST_POLYPSINK(userdata);
+static void gst_pulsesink_success_cb(pa_stream *s, int success, void *userdata) {
+ GstPolypSink *pulsesink = GST_PULSESINK(userdata);
- polypsink->operation_success = success;
- pa_threaded_mainloop_signal(polypsink->mainloop, 0);
+ pulsesink->operation_success = success;
+ pa_threaded_mainloop_signal(pulsesink->mainloop, 0);
}
-static void gst_polypsink_reset(GstAudioSink *asink) {
- GstPolypSink *polypsink = GST_POLYPSINK(asink);
+static void gst_pulsesink_reset(GstAudioSink *asink) {
+ GstPolypSink *pulsesink = GST_PULSESINK(asink);
pa_operation *o = NULL;
- pa_threaded_mainloop_lock(polypsink->mainloop);
+ pa_threaded_mainloop_lock(pulsesink->mainloop);
- CHECK_DEAD_GOTO(polypsink, unlock_and_fail);
+ CHECK_DEAD_GOTO(pulsesink, unlock_and_fail);
- if (!(o = pa_stream_flush(polypsink->stream, gst_polypsink_success_cb, polypsink))) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("pa_stream_flush() failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ if (!(o = pa_stream_flush(pulsesink->stream, gst_pulsesink_success_cb, pulsesink))) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("pa_stream_flush() failed: %s", pa_strerror(pa_context_errno(pulsesink->context))), (NULL));
goto unlock_and_fail;
}
- polypsink->operation_success = 0;
+ pulsesink->operation_success = 0;
while (pa_operation_get_state(o) != PA_OPERATION_DONE) {
- CHECK_DEAD_GOTO(polypsink, unlock_and_fail);
+ CHECK_DEAD_GOTO(pulsesink, unlock_and_fail);
- pa_threaded_mainloop_wait(polypsink->mainloop);
+ pa_threaded_mainloop_wait(pulsesink->mainloop);
}
- if (!polypsink->operation_success) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Flush failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ if (!pulsesink->operation_success) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("Flush failed: %s", pa_strerror(pa_context_errno(pulsesink->context))), (NULL));
goto unlock_and_fail;
}
@@ -546,24 +546,24 @@ unlock_and_fail:
pa_operation_unref(o);
}
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
}
-static void gst_polypsink_change_title(GstPolypSink *polypsink, const gchar *t) {
+static void gst_pulsesink_change_title(GstPolypSink *pulsesink, const gchar *t) {
pa_operation *o = NULL;
- pa_threaded_mainloop_lock(polypsink->mainloop);
+ pa_threaded_mainloop_lock(pulsesink->mainloop);
- g_free(polypsink->stream_name);
- polypsink->stream_name = g_strdup(t);
+ g_free(pulsesink->stream_name);
+ pulsesink->stream_name = g_strdup(t);
- if (!(polypsink)->context || pa_context_get_state((polypsink)->context) != PA_CONTEXT_READY ||
- !(polypsink)->stream || pa_stream_get_state((polypsink)->stream) != PA_STREAM_READY) {
+ if (!(pulsesink)->context || pa_context_get_state((pulsesink)->context) != PA_CONTEXT_READY ||
+ !(pulsesink)->stream || pa_stream_get_state((pulsesink)->stream) != PA_STREAM_READY) {
goto unlock_and_fail;
}
- if (!(o = pa_stream_set_name(polypsink->stream, polypsink->stream_name, NULL, polypsink))) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("pa_stream_set_name() failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ if (!(o = pa_stream_set_name(pulsesink->stream, pulsesink->stream_name, NULL, pulsesink))) {
+ GST_ELEMENT_ERROR(pulsesink, RESOURCE, FAILED, ("pa_stream_set_name() failed: %s", pa_strerror(pa_context_errno(pulsesink->context))), (NULL));
goto unlock_and_fail;
}
@@ -574,11 +574,11 @@ unlock_and_fail:
if (o)
pa_operation_unref(o);
- pa_threaded_mainloop_unlock(polypsink->mainloop);
+ pa_threaded_mainloop_unlock(pulsesink->mainloop);
}
-static gboolean gst_polypsink_event(GstBaseSink *sink, GstEvent *event) {
- GstPolypSink *polypsink = GST_POLYPSINK(sink);
+static gboolean gst_pulsesink_event(GstBaseSink *sink, GstEvent *event) {
+ GstPolypSink *pulsesink = GST_PULSESINK(sink);
switch (GST_EVENT_TYPE(event)) {
case GST_EVENT_TAG: {
@@ -602,7 +602,7 @@ static gboolean gst_polypsink_event(GstBaseSink *sink, GstEvent *event) {
t = location;
if (t)
- gst_polypsink_change_title(polypsink, t);
+ gst_pulsesink_change_title(pulsesink, t);
g_free(title);
g_free(artist);
@@ -619,29 +619,29 @@ static gboolean gst_polypsink_event(GstBaseSink *sink, GstEvent *event) {
return GST_BASE_SINK_CLASS(parent_class)->event(sink, event);
}
-GType gst_polypsink_get_type(void) {
- static GType polypsink_type = 0;
+GType gst_pulsesink_get_type(void) {
+ static GType pulsesink_type = 0;
- if (!polypsink_type) {
+ if (!pulsesink_type) {
- static const GTypeInfo polypsink_info = {
+ static const GTypeInfo pulsesink_info = {
sizeof(GstPolypSinkClass),
- gst_polypsink_base_init,
+ gst_pulsesink_base_init,
NULL,
- gst_polypsink_class_init,
+ gst_pulsesink_class_init,
NULL,
NULL,
sizeof(GstPolypSink),
0,
- gst_polypsink_init,
+ gst_pulsesink_init,
};
- polypsink_type = g_type_register_static(
+ pulsesink_type = g_type_register_static(
GST_TYPE_AUDIO_SINK,
"GstPolypSink",
- &polypsink_info,
+ &pulsesink_info,
0);
}
- return polypsink_type;
+ return pulsesink_type;
}