mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-16 08:56:40 -05:00
bluetooth/aptx: Simplify lifetime of caps
Fixes: 73c80ffba ("bluetooth/aptx: Deduplicate caps setup for encoding and decoding")
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/487>
This commit is contained in:
parent
bf99b4bdfc
commit
6b5857c1ac
1 changed files with 7 additions and 10 deletions
|
|
@ -270,7 +270,7 @@ static uint8_t fill_preferred_configuration_hd(const pa_sample_spec *default_sam
|
||||||
|
|
||||||
bool gst_init_aptx(struct gst_info *info, pa_sample_spec *ss, bool for_encoding) {
|
bool gst_init_aptx(struct gst_info *info, pa_sample_spec *ss, bool for_encoding) {
|
||||||
GstElement *enc, *dec, *capsf;
|
GstElement *enc, *dec, *capsf;
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps;
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
const char *aptx_codec_media_type;
|
const char *aptx_codec_media_type;
|
||||||
|
|
||||||
|
|
@ -334,17 +334,18 @@ bool gst_init_aptx(struct gst_info *info, pa_sample_spec *ss, bool for_encoding)
|
||||||
|
|
||||||
aptx_codec_media_type = info->codec_type == APTX_HD ? "audio/aptx-hd" : "audio/aptx";
|
aptx_codec_media_type = info->codec_type == APTX_HD ? "audio/aptx-hd" : "audio/aptx";
|
||||||
|
|
||||||
caps = gst_caps_new_simple(aptx_codec_media_type,
|
|
||||||
"rate", G_TYPE_INT, (int) ss->rate,
|
|
||||||
"channels", G_TYPE_INT, (int) ss->channels,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
capsf = gst_element_factory_make("capsfilter", "aptx_capsfilter");
|
capsf = gst_element_factory_make("capsfilter", "aptx_capsfilter");
|
||||||
if (!capsf) {
|
if (!capsf) {
|
||||||
pa_log_error("Could not create aptX capsfilter element");
|
pa_log_error("Could not create aptX capsfilter element");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
caps = gst_caps_new_simple(aptx_codec_media_type,
|
||||||
|
"rate", G_TYPE_INT, (int) ss->rate,
|
||||||
|
"channels", G_TYPE_INT, (int) ss->channels,
|
||||||
|
NULL);
|
||||||
g_object_set(capsf, "caps", caps, NULL);
|
g_object_set(capsf, "caps", caps, NULL);
|
||||||
|
gst_caps_unref(caps);
|
||||||
|
|
||||||
if (for_encoding) {
|
if (for_encoding) {
|
||||||
enc = gst_element_factory_make("openaptxenc", "aptx_encoder");
|
enc = gst_element_factory_make("openaptxenc", "aptx_encoder");
|
||||||
|
|
@ -390,7 +391,6 @@ bool gst_init_aptx(struct gst_info *info, pa_sample_spec *ss, bool for_encoding)
|
||||||
gst_object_unref(GST_OBJECT(pad));
|
gst_object_unref(GST_OBJECT(pad));
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_caps_unref(caps);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -398,9 +398,6 @@ fail_enc_dec:
|
||||||
gst_object_unref(GST_OBJECT(capsf));
|
gst_object_unref(GST_OBJECT(capsf));
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (caps)
|
|
||||||
gst_caps_unref(caps);
|
|
||||||
|
|
||||||
pa_log_error("aptX initialisation failed");
|
pa_log_error("aptX initialisation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue