mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
audio-format: add gst_audio_formats_raw()
The existing GST_AUDIO_FORMATS_ALL macro is not binding friendly. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/676>
This commit is contained in:
parent
84e0689d58
commit
75411ce1e7
2 changed files with 65 additions and 0 deletions
|
@ -516,3 +516,65 @@ gst_audio_format_fill_silence (const GstAudioFormatInfo * info,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct RawAudioFormats
|
||||
{
|
||||
GstAudioFormat *formats;
|
||||
guint n;
|
||||
};
|
||||
|
||||
static gpointer
|
||||
generate_raw_audio_formats (gpointer data)
|
||||
{
|
||||
GValue list = G_VALUE_INIT;
|
||||
struct RawAudioFormats *all = g_new (struct RawAudioFormats, 1);
|
||||
gchar *tmp;
|
||||
guint i;
|
||||
|
||||
g_value_init (&list, GST_TYPE_LIST);
|
||||
/* Workaround a bug in our parser that would lead to segfaults
|
||||
* when deserializing container types using static strings,
|
||||
* see https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/446 */
|
||||
tmp = g_strdup (GST_AUDIO_FORMATS_ALL);
|
||||
g_assert (gst_value_deserialize (&list, tmp));
|
||||
g_free (tmp);
|
||||
|
||||
all->n = gst_value_list_get_size (&list);
|
||||
all->formats = g_new (GstAudioFormat, all->n);
|
||||
|
||||
for (i = 0; i < all->n; i++) {
|
||||
const GValue *v = gst_value_list_get_value (&list, i);
|
||||
|
||||
all->formats[i] = gst_audio_format_from_string (g_value_get_string (v));
|
||||
g_assert (all->formats[i] != GST_AUDIO_FORMAT_UNKNOWN
|
||||
&& all->formats[i] != GST_AUDIO_FORMAT_ENCODED);
|
||||
}
|
||||
|
||||
g_value_unset (&list);
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_audio_formats_raw:
|
||||
* @len: (out): the number of elements in the returned array
|
||||
*
|
||||
* Return all the raw audio formats supported by GStreamer.
|
||||
*
|
||||
* Returns: (transfer none) (array length=len): an array of #GstAudioFormat
|
||||
* Since: 1.18
|
||||
*/
|
||||
const GstAudioFormat *
|
||||
gst_audio_formats_raw (guint * len)
|
||||
{
|
||||
static GOnce raw_audio_formats_once = G_ONCE_INIT;
|
||||
struct RawAudioFormats *all;
|
||||
|
||||
g_return_val_if_fail (len, NULL);
|
||||
|
||||
g_once (&raw_audio_formats_once, generate_raw_audio_formats, NULL);
|
||||
|
||||
all = raw_audio_formats_once.retval;
|
||||
*len = all->n;
|
||||
return all->formats;
|
||||
}
|
||||
|
|
|
@ -336,6 +336,9 @@ void gst_audio_format_fill_silence (const GstAudioFormatInfo *info
|
|||
"S18LE, S18BE, U18LE, U18BE, " \
|
||||
"F32LE, F32BE, F64LE, F64BE }"
|
||||
|
||||
GST_AUDIO_API
|
||||
const GstAudioFormat * gst_audio_formats_raw (guint * len);
|
||||
|
||||
/**
|
||||
* GST_AUDIO_CAPS_MAKE:
|
||||
* @format: string format that describes the sample layout, as string
|
||||
|
|
Loading…
Reference in a new issue