Linux bluetooth development
 help / color / mirror / Atom feed
* [Bluez-devel] [PATCH] Removing unused variables from gsta2dpsink
@ 2007-10-22 19:21 thiagoss
  2007-10-23 12:20 ` thiagoss
  0 siblings, 1 reply; 3+ messages in thread
From: thiagoss @ 2007-10-22 19:21 UTC (permalink / raw)
  To: BlueZ development


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

Patch removing unused variables from gsta2dpsink. Those were needed on alsa
plugin for sbc encoding, but they aren't in gsta2dpsink, because it is not
responsible for the encoding.

[]s

Thiago Sousa Santos

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

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

Index: audio/gsta2dpsink.c
===================================================================
RCS file: /cvsroot/bluez/utils/audio/gsta2dpsink.c,v
retrieving revision 1.6
diff -u -r1.6 gsta2dpsink.c
--- audio/gsta2dpsink.c	18 Oct 2007 23:02:24 -0000	1.6
+++ audio/gsta2dpsink.c	22 Oct 2007 19:09:27 -0000
@@ -83,8 +83,6 @@
 };
 struct bluetooth_data {
 	struct ipc_data_cfg cfg;	/* Bluetooth device config */
-	uint8_t buffer[BUFFER_SIZE];	/* Encoded transfer buffer */
-	int count;			/* Transfer buffer counter */
 	struct bluetooth_a2dp a2dp;	/* A2DP data */
 };
 
@@ -465,14 +463,14 @@
 	data in the pipe - we have to empty it */
 	while (1) {
 		err = g_io_channel_read(sink->stream,
-					(gchar *) sink->data->buffer,
+					(gchar *) sink->data->a2dp.buffer,
 					(gsize) sink->data->cfg.pkt_len,
 					&read);
 		if (err != G_IO_ERROR_NONE || read <= 0)
 			break;
 	}
 
-	memset(sink->data->buffer, 0, sizeof(sink->data->buffer));
+	memset(sink->data->a2dp.buffer, 0, sizeof(sink->data->a2dp.buffer));
 
 	return TRUE;
 }

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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Bluez-devel] [PATCH] Removing unused variables from gsta2dpsink
  2007-10-22 19:21 [Bluez-devel] [PATCH] Removing unused variables from gsta2dpsink thiagoss
@ 2007-10-23 12:20 ` thiagoss
  2007-10-23 17:34   ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 3+ messages in thread
From: thiagoss @ 2007-10-23 12:20 UTC (permalink / raw)
  To: BlueZ development


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

I've worked further and solved more problems on gsta2dpsink, I have a new
patch that includes the modifications on the previous one.

This one also:
- fixes a possible access to unitialized data
- removes the watch from the server g_io_channel when closing it

[]s

Thiago Sousa Santos

On 10/22/07, thiagoss <thiagossantos@gmail.com> wrote:
>
> Patch removing unused variables from gsta2dpsink. Those were needed on
> alsa plugin for sbc encoding, but they aren't in gsta2dpsink, because it is
> not responsible for the encoding.
>
> []s
>
> Thiago Sousa Santos
>
>

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

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

Index: audio/gsta2dpsink.c
===================================================================
RCS file: /cvsroot/bluez/utils/audio/gsta2dpsink.c,v
retrieving revision 1.6
diff -u -r1.6 gsta2dpsink.c
--- audio/gsta2dpsink.c	18 Oct 2007 23:02:24 -0000	1.6
+++ audio/gsta2dpsink.c	23 Oct 2007 12:16:01 -0000
@@ -83,8 +83,6 @@
 };
 struct bluetooth_data {
 	struct ipc_data_cfg cfg;	/* Bluetooth device config */
-	uint8_t buffer[BUFFER_SIZE];	/* Encoded transfer buffer */
-	int count;			/* Transfer buffer counter */
 	struct bluetooth_a2dp a2dp;	/* A2DP data */
 };
 
@@ -132,15 +130,13 @@
 static gboolean gst_a2dp_sink_stop(GstBaseSink *basesink)
 {
 	GstA2dpSink *self = GST_A2DP_SINK(basesink);
-	struct bluetooth_a2dp *a2dp = &self->data->a2dp;
 
 	self->con_state = NOT_CONFIGURED;
 	self->total = 0;
 
-	if (self->stream) {
-		g_io_channel_close(self->stream);
-		g_io_channel_unref(self->stream);
-		self->stream = NULL;
+	if (self->watch_id != -1) {
+		g_source_remove(self->watch_id);
+		self->watch_id = -1;
 	}
 
 	if (self->server) {
@@ -149,10 +145,15 @@
 		self->stream = NULL;
 	}
 
-	if (self->data->cfg.codec == CFG_CODEC_SBC)
-		sbc_finish(&a2dp->sbc);
+	if (self->stream) {
+		g_io_channel_close(self->stream);
+		g_io_channel_unref(self->stream);
+		self->stream = NULL;
+	}
 
 	if (self->data) {
+		if (self->data->cfg.codec == CFG_CODEC_SBC)
+			sbc_finish(&self->data->a2dp.sbc);
 		g_free(self->data);
 		self->data = NULL;
 	}
@@ -449,7 +450,7 @@
 {
 	gint ret;
 	GIOError err;
-	gsize read;
+	gsize read=0;
 
 	ret = gst_a2dp_sink_bluetooth_recvmsg_fd(sink);
 	if (ret < 0)
@@ -465,14 +466,14 @@
 	data in the pipe - we have to empty it */
 	while (1) {
 		err = g_io_channel_read(sink->stream,
-					(gchar *) sink->data->buffer,
+					(gchar *) sink->data->a2dp.buffer,
 					(gsize) sink->data->cfg.pkt_len,
 					&read);
 		if (err != G_IO_ERROR_NONE || read <= 0)
 			break;
 	}
 
-	memset(sink->data->buffer, 0, sizeof(sink->data->buffer));
+	memset(sink->data->a2dp.buffer, 0, sizeof(sink->data->a2dp.buffer));
 
 	return TRUE;
 }
@@ -512,10 +513,11 @@
 static gboolean server_callback(GIOChannel *chan,
 					GIOCondition cond, gpointer data)
 {
-	GstA2dpSink *sink = GST_A2DP_SINK(data);
+	GstA2dpSink *sink;
 
 	switch (cond) {
 	case G_IO_IN:
+		sink = GST_A2DP_SINK(data);
 		if (sink->con_state != NOT_CONFIGURED &&
 			sink->con_state != CONFIGURED)
 			gst_a2dp_sink_conf_recv_data(sink);
@@ -526,12 +528,14 @@
 		return FALSE;
 		break;
 	case G_IO_ERR:
+		sink = GST_A2DP_SINK(data);
 		GST_WARNING_OBJECT(sink, "Untreated callback G_IO_ERR");
 		break;
 	case G_IO_NVAL:
 		return FALSE;
 		break;
 	default:
+		sink = GST_A2DP_SINK(data);
 		GST_WARNING_OBJECT(sink, "Unexpected callback call");
 		break;
 	}
@@ -546,6 +550,8 @@
 	gint sk;
 	gint err;
 
+	self->watch_id = -1;
+
 	sk = socket(PF_LOCAL, SOCK_STREAM, 0);
 	if (sk < 0) {
 		err = errno;
@@ -556,7 +562,7 @@
 
 	if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 		err = errno;
-		GST_ERROR_OBJECT(self, "Connection fail %s (%d)", 
+		GST_ERROR_OBJECT(self, "Connection fail %s (%d)",
 			strerror(err), err);
 		close(sk);
 		return FALSE;
@@ -564,12 +570,18 @@
 
 	self->server = g_io_channel_unix_new(sk);
 
-	g_io_add_watch(self->server, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-			server_callback, self);
+	self->watch_id = g_io_add_watch(self->server, G_IO_IN | G_IO_HUP |
+			G_IO_ERR | G_IO_NVAL, server_callback, self);
 
 	self->data = g_new0(struct bluetooth_data, 1);
 	memset(self->data, 0, sizeof(struct bluetooth_data));
 
+	self->stream = NULL;
+	self->con_state = NOT_CONFIGURED;
+	self->total = 0;
+
+	self->waiting_con_conf = FALSE;
+
 	return TRUE;
 }
 
@@ -668,8 +680,9 @@
 	header->ssrc = htonl(1);
 
 	while (1) {
-		err = g_io_channel_write(sink->stream, (const char *) a2dp->buffer,
-					(gsize) a2dp->count, (gsize *) &ret);
+		err = g_io_channel_write(sink->stream,
+			(const char *) a2dp->buffer,
+			(gsize) a2dp->count, (gsize *) &ret);
 
 		if (err == G_IO_ERROR_AGAIN) {
 			usleep (100);
@@ -694,7 +707,7 @@
 	GstA2dpSink *sink;
 	struct bluetooth_data *data;
 	struct bluetooth_a2dp *a2dp;
-	gint encoded, frame_size=1024;
+	gint encoded=0, frame_size=1024; /* FIXME how to get the frame size? */
 	gint ret=0;
 
 	sink = GST_A2DP_SINK(basesink);
Index: audio/gsta2dpsink.h
===================================================================
RCS file: /cvsroot/bluez/utils/audio/gsta2dpsink.h,v
retrieving revision 1.4
diff -u -r1.4 gsta2dpsink.h
--- audio/gsta2dpsink.h	18 Oct 2007 21:50:00 -0000	1.4
+++ audio/gsta2dpsink.h	23 Oct 2007 12:16:01 -0000
@@ -67,6 +67,7 @@
 	GMutex *sink_lock;
 
 	gint total;
+	gint watch_id;
 
 };
 

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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Bluez-devel] [PATCH] Removing unused variables from gsta2dpsink
  2007-10-23 12:20 ` thiagoss
@ 2007-10-23 17:34   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2007-10-23 17:34 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]

Hi thiago,

I updated your patch with some fixes, you probably need to rework
server_callback
you can't evaluate cond with switch, many flags can be set at once.

On 10/23/07, thiagoss <thiagossantos@gmail.com> wrote:
> I've worked further and solved more problems on gsta2dpsink, I have a new
> patch that includes the modifications on the previous one.
>
> This one also:
> - fixes a possible access to unitialized data
> - removes the watch from the server g_io_channel when closing it
>
> []s
>
> Thiago Sousa Santos
>
>
> On 10/22/07, thiagoss <thiagossantos@gmail.com> wrote:
> > Patch removing unused variables from gsta2dpsink. Those were needed on
> alsa plugin for sbc encoding, but they aren't in gsta2dpsink, because it is
> not responsible for the encoding.
> >
> > []s
> >
> > Thiago Sousa Santos
> >
> >
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
>
>
>


-- 
Luiz Augusto von Dentz
Engenheiro de Computação

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

Index: gsta2dpsink.c
===================================================================
RCS file: /cvsroot/bluez/utils/audio/gsta2dpsink.c,v
retrieving revision 1.6
diff -u -3 -p -u -r1.6 gsta2dpsink.c
--- gsta2dpsink.c	18 Oct 2007 23:02:24 -0000	1.6
+++ gsta2dpsink.c	23 Oct 2007 17:24:37 -0000
@@ -70,23 +70,18 @@ GST_DEBUG_CATEGORY_STATIC(a2dp_sink_debu
 		g_cond_signal (s->con_conf_end);			\
 	} G_STMT_END
 
-struct bluetooth_a2dp {
+struct bluetooth_data {
+	struct ipc_data_cfg cfg;	/* Bluetooth device config */
 	sbc_t sbc;			/* Codec data */
 	int codesize;			/* SBC codesize */
 	int samples;			/* Number of encoded samples */
-	uint8_t buffer[BUFFER_SIZE];	/* Codec transfer buffer */
+	gchar buffer[BUFFER_SIZE];	/* Codec transfer buffer */
 	int count;			/* Codec transfer buffer counter */
 
 	int nsamples;			/* Cumulative number of codec samples */
 	uint16_t seq_num;		/* Cumulative packet sequence */
 	int frame_count;		/* Current frames in buffer*/
 };
-struct bluetooth_data {
-	struct ipc_data_cfg cfg;	/* Bluetooth device config */
-	uint8_t buffer[BUFFER_SIZE];	/* Encoded transfer buffer */
-	int count;			/* Transfer buffer counter */
-	struct bluetooth_a2dp a2dp;	/* A2DP data */
-};
 
 #define IS_SBC(n) (strcmp((n), "audio/x-sbc") == 0)
 #define IS_MPEG(n) (strcmp((n), "audio/mpeg") == 0)
@@ -132,15 +127,13 @@ static void gst_a2dp_sink_base_init(gpoi
 static gboolean gst_a2dp_sink_stop(GstBaseSink *basesink)
 {
 	GstA2dpSink *self = GST_A2DP_SINK(basesink);
-	struct bluetooth_a2dp *a2dp = &self->data->a2dp;
 
 	self->con_state = NOT_CONFIGURED;
 	self->total = 0;
 
-	if (self->stream) {
-		g_io_channel_close(self->stream);
-		g_io_channel_unref(self->stream);
-		self->stream = NULL;
+	if (self->watch_id != -1) {
+		g_source_remove(self->watch_id);
+		self->watch_id = -1;
 	}
 
 	if (self->server) {
@@ -149,10 +142,9 @@ static gboolean gst_a2dp_sink_stop(GstBa
 		self->stream = NULL;
 	}
 
-	if (self->data->cfg.codec == CFG_CODEC_SBC)
-		sbc_finish(&a2dp->sbc);
-
 	if (self->data) {
+		if (self->data->cfg.codec == CFG_CODEC_SBC)
+			sbc_finish(&self->data->sbc);
 		g_free(self->data);
 		self->data = NULL;
 	}
@@ -252,14 +244,14 @@ static gint gst_a2dp_sink_bluetooth_recv
 	return -EINVAL;
 }
 
-static int gst_a2dp_sink_bluetooth_a2dp_init(GstA2dpSink *sink,
+static int gst_a2dp_sink_bluetooth_a2dp_init(GstA2dpSink *self,
 			struct ipc_codec_sbc *sbc)
 {
-	struct bluetooth_a2dp *a2dp = &sink->data->a2dp;
-	struct ipc_data_cfg *cfg = &sink->data->cfg;
+	struct bluetooth_data *data = self->data;
+	struct ipc_data_cfg *cfg = &data->cfg;
 
 	if (cfg == NULL) {
-		GST_ERROR_OBJECT(sink, "Error getting codec parameters");
+		GST_ERROR_OBJECT(self, "Error getting codec parameters");
 		return -1;
 	}
 
@@ -267,24 +259,24 @@ static int gst_a2dp_sink_bluetooth_a2dp_
 		return -1;
 
 	/* FIXME: init using flags? */
-	sbc_init(&a2dp->sbc, 0);
-	a2dp->sbc.rate = cfg->rate;
-	a2dp->sbc.channels = cfg->mode == CFG_MODE_MONO ? 1 : 2;
+	sbc_init(&data->sbc, 0);
+	data->sbc.rate = cfg->rate;
+	data->sbc.channels = cfg->mode == CFG_MODE_MONO ? 1 : 2;
 	if (cfg->mode == CFG_MODE_MONO || cfg->mode == CFG_MODE_JOINT_STEREO)
-		a2dp->sbc.joint = 1;
-	a2dp->sbc.allocation = sbc->allocation;
-	a2dp->sbc.subbands = sbc->subbands;
-	a2dp->sbc.blocks = sbc->blocks;
-	a2dp->sbc.bitpool = sbc->bitpool;
-	a2dp->codesize = a2dp->sbc.subbands * a2dp->sbc.blocks *
-						a2dp->sbc.channels * 2;
-	a2dp->count = sizeof(struct rtp_header) + sizeof(struct rtp_payload);
+		data->sbc.joint = 1;
+	data->sbc.allocation = sbc->allocation;
+	data->sbc.subbands = sbc->subbands;
+	data->sbc.blocks = sbc->blocks;
+	data->sbc.bitpool = sbc->bitpool;
+	data->codesize = data->sbc.subbands * data->sbc.blocks *
+						data->sbc.channels * 2;
+	data->count = sizeof(struct rtp_header) + sizeof(struct rtp_payload);
 
-	GST_DEBUG_OBJECT(sink, "Codec parameters: \
+	GST_DEBUG_OBJECT(self, "Codec parameters: \
 				\tallocation=%u\n\tsubbands=%u\n \
 				\tblocks=%u\n\tbitpool=%u\n",
-				a2dp->sbc.allocation, a2dp->sbc.subbands,
-				a2dp->sbc.blocks, a2dp->sbc.bitpool);
+				data->sbc.allocation, data->sbc.subbands,
+				data->sbc.blocks, data->sbc.bitpool);
 
 	return 0;
 }
@@ -445,18 +437,19 @@ static gboolean gst_a2dp_sink_conf_recv_
 	return TRUE;
 }
 
-static gboolean gst_a2dp_sink_conf_recv_stream_fd(GstA2dpSink *sink)
+static gboolean gst_a2dp_sink_conf_recv_stream_fd(GstA2dpSink *self)
 {
+	struct bluetooth_data *data = self->data;
 	gint ret;
 	GIOError err;
-	gsize read;
+	gsize read=0;
 
-	ret = gst_a2dp_sink_bluetooth_recvmsg_fd(sink);
+	ret = gst_a2dp_sink_bluetooth_recvmsg_fd(self);
 	if (ret < 0)
 		return FALSE;
 
-	if (!sink->stream) {
-		GST_ERROR_OBJECT(sink, "Error while configuring device: "
+	if (!self->stream) {
+		GST_ERROR_OBJECT(self, "Error while configuring device: "
 				"could not acquire audio socket");
 		return FALSE;
 	}
@@ -464,15 +457,14 @@ static gboolean gst_a2dp_sink_conf_recv_
 	/* It is possible there is some outstanding
 	data in the pipe - we have to empty it */
 	while (1) {
-		err = g_io_channel_read(sink->stream,
-					(gchar *) sink->data->buffer,
-					(gsize) sink->data->cfg.pkt_len,
+		err = g_io_channel_read(self->stream, data->buffer,
+					(gsize) data->cfg.pkt_len,
 					&read);
 		if (err != G_IO_ERROR_NONE || read <= 0)
 			break;
 	}
 
-	memset(sink->data->buffer, 0, sizeof(sink->data->buffer));
+	memset(data->buffer, 0, sizeof(data->buffer));
 
 	return TRUE;
 }
@@ -512,10 +504,11 @@ static void gst_a2dp_sink_conf_recv_data
 static gboolean server_callback(GIOChannel *chan,
 					GIOCondition cond, gpointer data)
 {
-	GstA2dpSink *sink = GST_A2DP_SINK(data);
+	GstA2dpSink *sink;
 
 	switch (cond) {
 	case G_IO_IN:
+		sink = GST_A2DP_SINK(data);
 		if (sink->con_state != NOT_CONFIGURED &&
 			sink->con_state != CONFIGURED)
 			gst_a2dp_sink_conf_recv_data(sink);
@@ -526,12 +519,14 @@ static gboolean server_callback(GIOChann
 		return FALSE;
 		break;
 	case G_IO_ERR:
+		sink = GST_A2DP_SINK(data);
 		GST_WARNING_OBJECT(sink, "Untreated callback G_IO_ERR");
 		break;
 	case G_IO_NVAL:
 		return FALSE;
 		break;
 	default:
+		sink = GST_A2DP_SINK(data);
 		GST_WARNING_OBJECT(sink, "Unexpected callback call");
 		break;
 	}
@@ -546,6 +541,8 @@ static gboolean gst_a2dp_sink_start(GstB
 	gint sk;
 	gint err;
 
+	self->watch_id = -1;
+
 	sk = socket(PF_LOCAL, SOCK_STREAM, 0);
 	if (sk < 0) {
 		err = errno;
@@ -556,7 +553,7 @@ static gboolean gst_a2dp_sink_start(GstB
 
 	if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 		err = errno;
-		GST_ERROR_OBJECT(self, "Connection fail %s (%d)", 
+		GST_ERROR_OBJECT(self, "Connection fail %s (%d)",
 			strerror(err), err);
 		close(sk);
 		return FALSE;
@@ -564,12 +561,18 @@ static gboolean gst_a2dp_sink_start(GstB
 
 	self->server = g_io_channel_unix_new(sk);
 
-	g_io_add_watch(self->server, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-			server_callback, self);
+	self->watch_id = g_io_add_watch(self->server, G_IO_IN | G_IO_HUP |
+			G_IO_ERR | G_IO_NVAL, server_callback, self);
 
 	self->data = g_new0(struct bluetooth_data, 1);
 	memset(self->data, 0, sizeof(struct bluetooth_data));
 
+	self->stream = NULL;
+	self->con_state = NOT_CONFIGURED;
+	self->total = 0;
+
+	self->waiting_con_conf = FALSE;
+
 	return TRUE;
 }
 
@@ -643,33 +646,30 @@ static GstFlowReturn gst_a2dp_sink_prero
 	return GST_FLOW_OK;
 }
 
-static int gst_a2dp_sink_avdtp_write(GstA2dpSink *sink)
+static int gst_a2dp_sink_avdtp_write(GstA2dpSink *self)
 {
 	int ret = 0;
-	struct bluetooth_data *data;
+	struct bluetooth_data *data = self->data;
 	struct rtp_header *header;
 	struct rtp_payload *payload;
-	struct bluetooth_a2dp *a2dp;
 	GIOError err;
 
-	data = sink->data;
-	a2dp = &data->a2dp;
-
-	header = (void *) a2dp->buffer;
-	payload = (void *) (a2dp->buffer + sizeof(*header));
+	header = (void *) data->buffer;
+	payload = (void *) (data->buffer + sizeof(*header));
 
-	memset(a2dp->buffer, 0, sizeof(*header) + sizeof(*payload));
+	memset(data->buffer, 0, sizeof(*header) + sizeof(*payload));
 
-	payload->frame_count = a2dp->frame_count;
+	payload->frame_count = data->frame_count;
 	header->v = 2;
 	header->pt = 1;
-	header->sequence_number = htons(a2dp->seq_num);
-	header->timestamp = htonl(a2dp->nsamples);
+	header->sequence_number = htons(data->seq_num);
+	header->timestamp = htonl(data->nsamples);
 	header->ssrc = htonl(1);
 
 	while (1) {
-		err = g_io_channel_write(sink->stream, (const char *) a2dp->buffer,
-					(gsize) a2dp->count, (gsize *) &ret);
+		err = g_io_channel_write(self->stream, data->buffer,
+					(gsize) data->count,
+					(gsize *) &ret);
 
 		if (err == G_IO_ERROR_AGAIN) {
 			usleep (100);
@@ -680,10 +680,10 @@ static int gst_a2dp_sink_avdtp_write(Gst
 	}
 
 	/* Reset buffer of data to send */
-	a2dp->count = sizeof(struct rtp_header) + sizeof(struct rtp_payload);
-	a2dp->frame_count = 0;
-	a2dp->samples = 0;
-	a2dp->seq_num++;
+	data->count = sizeof(struct rtp_header) + sizeof(struct rtp_payload);
+	data->frame_count = 0;
+	data->samples = 0;
+	data->seq_num++;
 
 	return ret;
 }
@@ -691,29 +691,22 @@ static int gst_a2dp_sink_avdtp_write(Gst
 static GstFlowReturn gst_a2dp_sink_render(GstBaseSink *basesink,
 					GstBuffer *buffer)
 {
-	GstA2dpSink *sink;
-	struct bluetooth_data *data;
-	struct bluetooth_a2dp *a2dp;
-	gint encoded, frame_size=1024;
-	gint ret=0;
-
-	sink = GST_A2DP_SINK(basesink);
-	data = (struct bluetooth_data*) sink->data;
-	a2dp = &data->a2dp;
+	GstA2dpSink *self = GST_A2DP_SINK(basesink);
+	struct bluetooth_data *data = self->data;
+	gint encoded = 0;
+	gint ret = 0;
 
 	encoded = GST_BUFFER_SIZE(buffer);
 
-	if (a2dp->count + encoded >= data->cfg.pkt_len) {
-		ret = gst_a2dp_sink_avdtp_write(sink);
+	if (data->count + encoded >= data->cfg.pkt_len) {
+		ret = gst_a2dp_sink_avdtp_write(self);
 		if (ret < 0)
 			return GST_FLOW_ERROR;
 	}
 
-	memcpy(a2dp->buffer + a2dp->count, GST_BUFFER_DATA(buffer), encoded);
-	a2dp->count += encoded;
-	a2dp->frame_count++;
-	a2dp->samples += encoded / frame_size;
-	a2dp->nsamples += encoded / frame_size;
+	memcpy(data->buffer + data->count, GST_BUFFER_DATA(buffer), encoded);
+	data->count += encoded;
+	data->frame_count++;
 
 	return GST_FLOW_OK;
 }
Index: gsta2dpsink.h
===================================================================
RCS file: /cvsroot/bluez/utils/audio/gsta2dpsink.h,v
retrieving revision 1.4
diff -u -3 -p -u -r1.4 gsta2dpsink.h
--- gsta2dpsink.h	18 Oct 2007 21:50:00 -0000	1.4
+++ gsta2dpsink.h	23 Oct 2007 17:24:37 -0000
@@ -67,6 +67,7 @@ struct _GstA2dpSink {
 	GMutex *sink_lock;
 
 	gint total;
+	gint watch_id;
 
 };
 
Index: manager.c
===================================================================
RCS file: /cvsroot/bluez/utils/audio/manager.c,v
retrieving revision 1.75
diff -u -3 -p -u -r1.75 manager.c
--- manager.c	9 Oct 2007 13:31:57 -0000	1.75
+++ manager.c	23 Oct 2007 17:24:37 -0000
@@ -1078,10 +1078,9 @@ static void register_devices_stored(cons
 
 	bacpy(&default_src, BDADDR_ANY);
 	dev_id = hci_get_route(&default_src);
-	if (dev_id < 0)
+	if (dev_id < 0 || hci_devba(dev_id, &default_src))
 		return;
 
-	hci_devba(dev_id, &default_src);
 	if (bacmp(&default_src, &src) != 0)
 		return;
 

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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

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

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-10-23 17:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-22 19:21 [Bluez-devel] [PATCH] Removing unused variables from gsta2dpsink thiagoss
2007-10-23 12:20 ` thiagoss
2007-10-23 17:34   ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox