mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
bluetooth/aptx: Deduplicate caps setup for encoding and decoding
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/484>
This commit is contained in:
parent
da1600eb61
commit
73c80ffba0
1 changed files with 11 additions and 11 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) {
|
||||
GstElement *enc, *dec;
|
||||
GstCaps *caps;
|
||||
GstCaps *caps = NULL;
|
||||
GstPad *pad;
|
||||
const char *aptx_codec_media_type;
|
||||
|
||||
|
|
@ -334,6 +334,11 @@ 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";
|
||||
|
||||
caps = gst_caps_new_simple(aptx_codec_media_type,
|
||||
"rate", G_TYPE_INT, (int) ss->rate,
|
||||
"channels", G_TYPE_INT, (int) ss->channels,
|
||||
NULL);
|
||||
|
||||
if (for_encoding) {
|
||||
enc = gst_element_factory_make("openaptxenc", "aptx_encoder");
|
||||
|
||||
|
|
@ -342,12 +347,7 @@ bool gst_init_aptx(struct gst_info *info, pa_sample_spec *ss, bool for_encoding)
|
|||
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(info->enc_sink, "caps", caps, NULL);
|
||||
gst_caps_unref(caps);
|
||||
|
||||
info->enc_bin = gst_bin_new("aptx_enc_bin");
|
||||
pa_assert(info->enc_bin);
|
||||
|
|
@ -369,12 +369,7 @@ bool gst_init_aptx(struct gst_info *info, pa_sample_spec *ss, bool for_encoding)
|
|||
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(info->dec_src, "caps", caps, NULL);
|
||||
gst_caps_unref(caps);
|
||||
|
||||
info->dec_bin = gst_bin_new("aptx_dec_bin");
|
||||
pa_assert(info->dec_bin);
|
||||
|
|
@ -390,9 +385,14 @@ bool gst_init_aptx(struct gst_info *info, pa_sample_spec *ss, bool for_encoding)
|
|||
gst_object_unref(GST_OBJECT(pad));
|
||||
}
|
||||
|
||||
gst_caps_unref(caps);
|
||||
|
||||
return true;
|
||||
|
||||
fail:
|
||||
if (caps)
|
||||
gst_caps_unref(caps);
|
||||
|
||||
pa_log_error("aptX initialisation failed");
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue