Commit 4ef6f099 authored by Marijn Suijten's avatar Marijn Suijten 🦀
Browse files

bluetooth/gst: Only retrieve sink pad once

This causes pretty verbose logs otherwise, and is unnecessarily
expensive.
parent bd3408a8
Pipeline #264740 passed with stages
in 8 minutes and 11 seconds
...@@ -150,7 +150,7 @@ bool gst_codec_init(struct gst_info *info, bool for_encoding, GstElement *transc ...@@ -150,7 +150,7 @@ bool gst_codec_init(struct gst_info *info, bool for_encoding, GstElement *transc
// Expose sink pad through `info->pipeline` // Expose sink pad through `info->pipeline`
pad = gst_element_get_static_pad(transcoder, "sink"); pad = gst_element_get_static_pad(transcoder, "sink");
pa_assert_se(gst_element_add_pad(info->pipeline, gst_ghost_pad_new("sink", pad))); pa_assert_se(gst_element_add_pad(info->pipeline, gst_ghost_pad_new("sink", pad)));
gst_object_unref(GST_OBJECT(pad)); info->pad_sink = pad;
if (gst_element_set_state(info->pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { if (gst_element_set_state(info->pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
pa_log_error("Could not start pipeline"); pa_log_error("Could not start pipeline");
...@@ -195,9 +195,10 @@ size_t gst_transcode_buffer(void *codec_info, const uint8_t *input_buffer, size_ ...@@ -195,9 +195,10 @@ size_t gst_transcode_buffer(void *codec_info, const uint8_t *input_buffer, size_
GstBuffer *in_buf; GstBuffer *in_buf;
GstFlowReturn ret; GstFlowReturn ret;
size_t written = 0; size_t written = 0;
GstPad *in_pad;
GstSample *sample; GstSample *sample;
pa_assert(info->pad_sink);
// pa_log_debug("%s thread %p", __func__, pa_thread_mq_get()); // pa_log_debug("%s thread %p", __func__, pa_thread_mq_get());
// TODO: Silence startup warnings // TODO: Silence startup warnings
...@@ -207,12 +208,8 @@ size_t gst_transcode_buffer(void *codec_info, const uint8_t *input_buffer, size_ ...@@ -207,12 +208,8 @@ size_t gst_transcode_buffer(void *codec_info, const uint8_t *input_buffer, size_
(gpointer)input_buffer, input_size, 0, input_size, NULL, NULL); (gpointer)input_buffer, input_size, 0, input_size, NULL, NULL);
pa_assert(in_buf); pa_assert(in_buf);
in_pad = gst_element_get_static_pad(info->pipeline, "sink");
pa_assert(in_pad);
// pa_log_debug("Pushing %d new bytes", input_size); // pa_log_debug("Pushing %d new bytes", input_size);
ret = gst_pad_chain(in_pad, in_buf); ret = gst_pad_chain(info->pad_sink, in_buf);
gst_object_unref(GST_OBJECT(in_pad));
// pa_log_debug("Flow %d", ret); // pa_log_debug("Flow %d", ret);
if (ret != GST_FLOW_OK) { if (ret != GST_FLOW_OK) {
pa_log_error("failed to push buffer for transcoding %d", ret); pa_log_error("failed to push buffer for transcoding %d", ret);
...@@ -258,5 +255,8 @@ void gst_codec_deinit(void *codec_info) { ...@@ -258,5 +255,8 @@ void gst_codec_deinit(void *codec_info) {
gst_object_unref(info->pipeline); gst_object_unref(info->pipeline);
} }
if (info->pad_sink)
gst_object_unref(GST_OBJECT(info->pad_sink));
pa_xfree(info); pa_xfree(info);
} }
...@@ -45,6 +45,7 @@ struct gst_info { ...@@ -45,6 +45,7 @@ struct gst_info {
GstElement *app_sink; GstElement *app_sink;
GstElement *pipeline; GstElement *pipeline;
GstPad *pad_sink;
uint16_t seq_num; uint16_t seq_num;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment