mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
opusdec: tweak caps negotiation
... so as to avoid leaking caps or manipulating NULL caps.
This commit is contained in:
parent
a38bf7788d
commit
6cb77d0c7f
1 changed files with 12 additions and 8 deletions
|
@ -214,14 +214,18 @@ gst_opus_dec_negotiate (GstOpusDec * dec, const GstAudioChannelPosition * pos)
|
|||
GstStructure *s;
|
||||
GstAudioInfo info;
|
||||
|
||||
caps = gst_caps_truncate (caps);
|
||||
|
||||
caps = gst_caps_make_writable (caps);
|
||||
s = gst_caps_get_structure (caps, 0);
|
||||
gst_structure_fixate_field_nearest_int (s, "rate", 48000);
|
||||
gst_structure_get_int (s, "rate", &dec->sample_rate);
|
||||
gst_structure_fixate_field_nearest_int (s, "channels", dec->n_channels);
|
||||
gst_structure_get_int (s, "channels", &dec->n_channels);
|
||||
if (caps) {
|
||||
caps = gst_caps_truncate (caps);
|
||||
caps = gst_caps_make_writable (caps);
|
||||
s = gst_caps_get_structure (caps, 0);
|
||||
gst_structure_fixate_field_nearest_int (s, "rate", 48000);
|
||||
gst_structure_get_int (s, "rate", &dec->sample_rate);
|
||||
gst_structure_fixate_field_nearest_int (s, "channels", dec->n_channels);
|
||||
gst_structure_get_int (s, "channels", &dec->n_channels);
|
||||
gst_caps_unref (caps);
|
||||
} else {
|
||||
dec->sample_rate = 48000;
|
||||
}
|
||||
|
||||
GST_INFO_OBJECT (dec, "Negotiated %d channels, %d Hz", dec->n_channels,
|
||||
dec->sample_rate);
|
||||
|
|
Loading…
Reference in a new issue