[Bluez-devel] Patch: inheritance problem in gsta2dpsink

thiagoss
2007-10-01T21:31:23Z

[-- Attachment #1.1: Type: text/plain, Size: 405 bytes --]

GstA2dpSink was extending GstAudioSink, but there is a problem in that,
GstAudioSink expects only
"audio/x-raw-int", "audio/x-raw-float", "audio/x-mulaw" or "audio/x-alaw" as
media types. GstA2dpSink should support mp3 and sbc, that's causing a
runtime error. This patch changes the base class from GstAudioSink to
GstBaseSink, changing the stub functions to be implemented also.

Best regards,

Thiago

[-- Attachment #1.2: Type: text/html, Size: 476 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gsta2dpsink.patch --]
[-- Type: text/x-patch; name="gsta2dpsink.patch", Size: 4259 bytes --]

Index: audio/gsta2dpsink.c
===================================================================
RCS file: /cvsroot/bluez/utils/audio/gsta2dpsink.c,v
retrieving revision 1.3
diff -u -r1.3 gsta2dpsink.c
--- audio/gsta2dpsink.c 26 Aug 2007 14:14:34 -0000 1.3
+++ audio/gsta2dpsink.c 1 Oct 2007 21:07:19 -0000
@@ -43,7 +43,7 @@
PROP_DEVICE,
};

-GST_BOILERPLATE(GstA2dpSink, gst_a2dp_sink, GstAudioSink, GST_TYPE_AUDIO_SINK);
+GST_BOILERPLATE(GstA2dpSink, gst_a2dp_sink, GstBaseSink, GST_TYPE_BASE_SINK);

static const GstElementDetails a2dp_sink_details =
GST_ELEMENT_DETAILS("Bluetooth A2DP sink",
@@ -85,6 +85,8 @@

g_free(sink->device);

+ g_io_channel_unref(sink->server);
+
G_OBJECT_CLASS(parent_class)->finalize(object);
}

@@ -124,56 +126,26 @@
}
}

-static gboolean gst_a2dp_sink_open(GstAudioSink *self)
-{
- GstA2dpSink *sink = GST_A2DP_SINK(self);
-
- printf("device %s\n", sink->device);
- printf("open\n");
-
- return TRUE;
-}
-
-static gboolean gst_a2dp_sink_prepare(GstAudioSink *self,
- GstRingBufferSpec *spec)
+static gboolean gst_a2dp_sink_start(GstBaseSink *basesink)
{
- printf("perpare\n");
- printf("rate %d\n", spec->rate);
- printf("channels %d\n", spec->channels);
+ g_print("start\n");

return TRUE;
}

-static gboolean gst_a2dp_sink_unprepare(GstAudioSink *self)
+static gboolean gst_a2dp_sink_stop(GstBaseSink *basesink)
{
- printf("unprepare\n");
+ g_print("stop\n");

return TRUE;
}

-static gboolean gst_a2dp_sink_close(GstAudioSink *self)
+static GstFlowReturn gst_a2dp_sink_render(GstBaseSink *basesink,
+ GstBuffer *buffer)
{
- printf("close\n");
+ g_print("render\n");

- return TRUE;
-}
-
-static guint gst_a2dp_sink_write(GstAudioSink *self,
- gpointer data, guint length)
-{
- return 0;
-}
-
-static guint gst_a2dp_sink_delay(GstAudioSink *audiosink)
-{
- printf("delay\n");
-
- return 0;
-}
-
-static void gst_a2dp_sink_reset(GstAudioSink *audiosink)
-{
- printf("reset\n");
+ return GST_FLOW_OK;
}

static gboolean server_callback(GIOChannel *chan,
@@ -187,7 +159,7 @@
static void gst_a2dp_sink_class_init(GstA2dpSinkClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
- GstAudioSinkClass *audiosink_class = GST_AUDIO_SINK_CLASS(klass);
+ GstBaseSinkClass *basesink_class = GST_BASE_SINK_CLASS(klass);

parent_class = g_type_class_peek_parent(klass);

@@ -195,13 +167,9 @@
object_class->set_property = GST_DEBUG_FUNCPTR(gst_a2dp_sink_set_property);
object_class->get_property = GST_DEBUG_FUNCPTR(gst_a2dp_sink_get_property);

- audiosink_class->open = GST_DEBUG_FUNCPTR(gst_a2dp_sink_open);
- audiosink_class->prepare = GST_DEBUG_FUNCPTR(gst_a2dp_sink_prepare);
- audiosink_class->unprepare = GST_DEBUG_FUNCPTR(gst_a2dp_sink_unprepare);
- audiosink_class->close = GST_DEBUG_FUNCPTR(gst_a2dp_sink_close);
- audiosink_class->write = GST_DEBUG_FUNCPTR(gst_a2dp_sink_write);
- audiosink_class->delay = GST_DEBUG_FUNCPTR(gst_a2dp_sink_delay);
- audiosink_class->reset = GST_DEBUG_FUNCPTR(gst_a2dp_sink_reset);
+ basesink_class->start = GST_DEBUG_FUNCPTR(gst_a2dp_sink_start);
+ basesink_class->stop = GST_DEBUG_FUNCPTR(gst_a2dp_sink_stop);
+ basesink_class->render = GST_DEBUG_FUNCPTR(gst_a2dp_sink_render);

g_object_class_install_property(object_class, PROP_DEVICE,
g_param_spec_string("device", "Device",
@@ -232,6 +200,4 @@

g_io_add_watch(self->server, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
server_callback, self);
-
- g_io_channel_unref(self->server);
}
Index: audio/gsta2dpsink.h
===================================================================
RCS file: /cvsroot/bluez/utils/audio/gsta2dpsink.h,v
retrieving revision 1.3
diff -u -r1.3 gsta2dpsink.h
--- audio/gsta2dpsink.h 26 Aug 2007 14:14:34 -0000 1.3
+++ audio/gsta2dpsink.h 1 Oct 2007 21:07:19 -0000
@@ -22,7 +22,7 @@
*/

#include <gst/gst.h>
-#include <gst/audio/gstaudiosink.h>
+#include <gst/base/gstbasesink.h>

G_BEGIN_DECLS

@@ -41,7 +41,7 @@
typedef struct _GstA2dpSinkClass GstA2dpSinkClass;

struct _GstA2dpSink {
- GstAudioSink sink;
+ GstBaseSink sink;

gchar *device;

@@ -49,7 +49,7 @@
};

struct _GstA2dpSinkClass {
- GstAudioSinkClass parent_class;
+ GstBaseSinkClass parent_class;
};

GType gst_a2dp_sink_get_type(void);

[-- Attachment #3: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]