diff options
| author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-11-23 17:00:13 +0000 | 
|---|---|---|
| committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-11-23 17:00:13 +0000 | 
| commit | d509d4960ff6fb74bf86bf2791067197d3795440 (patch) | |
| tree | a86fe1cfed50ef1bcfa8c45d55f6139b8303b284 | |
| parent | 6e49d2d6ab859761671b51b10a40b5750551e152 (diff) | |
Code cleanup.
| -rw-r--r-- | audio/gsta2dpsink.c | 21 | ||||
| -rw-r--r-- | audio/gstsbcenc.c | 57 | ||||
| -rw-r--r-- | audio/gstsbcenc.h | 3 | 
3 files changed, 21 insertions, 60 deletions
diff --git a/audio/gsta2dpsink.c b/audio/gsta2dpsink.c index 535f6c5e..b24dc8b8 100644 --- a/audio/gsta2dpsink.c +++ b/audio/gsta2dpsink.c @@ -831,25 +831,6 @@ static gboolean gst_a2dp_sink_unlock(GstBaseSink *basesink)  	return TRUE;  } -static GstFlowReturn gst_a2dp_sink_buffer_alloc(GstBaseSink *basesink, -				guint64 offset, guint size, GstCaps* caps, -				GstBuffer **buf) -{ -	GstA2dpSink *self = GST_A2DP_SINK(basesink); - -	*buf = gst_buffer_new_and_alloc(size); -	if (!(*buf)) { -		GST_ERROR_OBJECT(self, "buffer allocation failed"); -		return GST_FLOW_ERROR; -	} - -	gst_buffer_set_caps(*buf, caps); - -	GST_BUFFER_OFFSET(*buf) = offset; - -	return GST_FLOW_OK; -} -  static void gst_a2dp_sink_class_init(GstA2dpSinkClass *klass)  {  	GObjectClass *object_class = G_OBJECT_CLASS(klass); @@ -870,8 +851,6 @@ static void gst_a2dp_sink_class_init(GstA2dpSinkClass *klass)  	basesink_class->set_caps = GST_DEBUG_FUNCPTR(gst_a2dp_sink_set_caps);  	basesink_class->get_caps = GST_DEBUG_FUNCPTR(gst_a2dp_sink_get_caps);  	basesink_class->unlock = GST_DEBUG_FUNCPTR(gst_a2dp_sink_unlock); -	basesink_class->buffer_alloc = -		GST_DEBUG_FUNCPTR(gst_a2dp_sink_buffer_alloc);  	g_object_class_install_property(object_class, PROP_DEVICE,  					g_param_spec_string("device", "Device", diff --git a/audio/gstsbcenc.c b/audio/gstsbcenc.c index 021ecacf..185151f5 100644 --- a/audio/gstsbcenc.c +++ b/audio/gstsbcenc.c @@ -345,23 +345,11 @@ gboolean gst_sbc_enc_fill_sbc_params(GstSbcEnc *enc, GstCaps *caps)  	enc->sbc.bitpool = bitpool;  	enc->mode = enc->sbc.joint = gst_sbc_get_mode_int(mode);  	enc->allocation = enc->sbc.allocation = gst_sbc_get_allocation_mode_int(allocation); - -	return TRUE; -} - -static gboolean gst_sbc_enc_change_caps(GstSbcEnc *enc, GstCaps *caps) -{ -	GST_INFO_OBJECT(enc, "Changing srcpad caps (renegotiation)"); - -	if (!gst_pad_accept_caps(enc->srcpad, caps)) { -		GST_WARNING_OBJECT(enc, "Src pad refused caps"); -		return FALSE; -	} - -	if (!gst_sbc_enc_fill_sbc_params(enc, caps)) { -		GST_ERROR_OBJECT(enc, "couldn't get sbc parameters from caps"); -		return FALSE; -	} +	enc->codesize = sbc_get_codesize(&enc->sbc); +	enc->frame_length = sbc_get_frame_length(&enc->sbc); +	enc->frame_duration = sbc_get_frame_duration(&enc->sbc); +	GST_DEBUG("codesize: %d, frame_length: %d, frame_duration: %d", +			enc->codesize, enc->frame_length, enc->frame_duration);  	return TRUE;  } @@ -371,45 +359,36 @@ static GstFlowReturn sbc_enc_chain(GstPad *pad, GstBuffer *buffer)  	GstSbcEnc *enc = GST_SBC_ENC(gst_pad_get_parent(pad));  	GstAdapter *adapter = enc->adapter;  	GstFlowReturn res = GST_FLOW_OK; -	gint codesize, frame_len; -	codesize = sbc_get_codesize(&enc->sbc); -	frame_len = sbc_get_frame_length(&enc->sbc);  	gst_adapter_push(adapter, buffer); -	while (gst_adapter_available(adapter) >= codesize && res == GST_FLOW_OK) { +	while (gst_adapter_available(adapter) >= enc->codesize && +			res == GST_FLOW_OK) {  		GstBuffer *output;  		GstCaps *caps;  		const guint8 *data;  		int consumed;  		caps = GST_PAD_CAPS(enc->srcpad); -  		res = gst_pad_alloc_buffer_and_set_caps(enc->srcpad,  						GST_BUFFER_OFFSET_NONE, -						frame_len, caps, &output); +						enc->frame_length, caps, +						&output); +		if (res != GST_FLOW_OK) +			goto done; -		data = gst_adapter_peek(adapter, codesize); -		consumed = sbc_encode(&enc->sbc, (gpointer) data, codesize, -					GST_BUFFER_DATA(output), frame_len, -					NULL); +		data = gst_adapter_peek(adapter, enc->codesize); +		consumed = sbc_encode(&enc->sbc, (gpointer) data, +					enc->codesize, +					GST_BUFFER_DATA(output), +					GST_BUFFER_SIZE(output), NULL);  		if (consumed <= 0) { -			GST_ERROR ("comsumed < 0, codesize: %d", codesize); +			GST_ERROR ("comsumed < 0, codesize: %d", +					enc->codesize);  			break;  		}  		gst_adapter_flush(adapter, consumed); -		if (res != GST_FLOW_OK) -			goto done; - -		if (!gst_caps_is_equal(caps, GST_BUFFER_CAPS(output))) -			if (!gst_sbc_enc_change_caps(enc, -					GST_BUFFER_CAPS(output))) { -				res = GST_FLOW_ERROR; -				GST_ERROR_OBJECT(enc, "couldn't renegotiate caps"); -				goto done; -		} -  		GST_BUFFER_TIMESTAMP(output) = GST_BUFFER_TIMESTAMP(buffer);  		res = gst_pad_push(enc->srcpad, output); diff --git a/audio/gstsbcenc.h b/audio/gstsbcenc.h index f65bcc94..d81428c9 100644 --- a/audio/gstsbcenc.h +++ b/audio/gstsbcenc.h @@ -55,6 +55,9 @@ struct _GstSbcEnc {  	gint blocks;  	gint allocation;  	gint subbands; +	gint codesize; +	gint frame_length; +	gint frame_duration;  	sbc_t sbc;  };  | 
