mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-22 16:16:37 +00:00
audio: sort AUDIO_FORMATS_ALL
Test also ensures that the formats list returned by gst_audio_formats_raw() is properly sorted when running with feature 1.18.
This commit is contained in:
parent
a6faa83908
commit
bb065be349
3 changed files with 84 additions and 32 deletions
|
@ -29,6 +29,9 @@ once_cell = "1.0"
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
rustdoc-stripper = { version = "0.1", optional = true }
|
rustdoc-stripper = { version = "0.1", optional = true }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
itertools = "0.9"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
v1_10 = ["gstreamer/v1_10", "gstreamer-base/v1_10", "gstreamer-audio-sys/v1_10"]
|
v1_10 = ["gstreamer/v1_10", "gstreamer-base/v1_10", "gstreamer-audio-sys/v1_10"]
|
||||||
|
|
|
@ -29,38 +29,76 @@ pub static AUDIO_FORMATS_ALL: Lazy<Box<[::AudioFormat]>> = Lazy::new(|| unsafe {
|
||||||
|
|
||||||
#[cfg(not(feature = "v1_18"))]
|
#[cfg(not(feature = "v1_18"))]
|
||||||
pub static AUDIO_FORMATS_ALL: Lazy<Box<[::AudioFormat]>> = Lazy::new(|| {
|
pub static AUDIO_FORMATS_ALL: Lazy<Box<[::AudioFormat]>> = Lazy::new(|| {
|
||||||
Box::new([
|
#[cfg(target_endian = "little")]
|
||||||
::AudioFormat::S8,
|
{
|
||||||
::AudioFormat::U8,
|
Box::new([
|
||||||
::AudioFormat::S16le,
|
::AudioFormat::F64le,
|
||||||
::AudioFormat::S16be,
|
::AudioFormat::F64be,
|
||||||
::AudioFormat::U16le,
|
::AudioFormat::F32le,
|
||||||
::AudioFormat::U16be,
|
::AudioFormat::F32be,
|
||||||
::AudioFormat::S2432le,
|
::AudioFormat::S32le,
|
||||||
::AudioFormat::S2432be,
|
::AudioFormat::S32be,
|
||||||
::AudioFormat::U2432le,
|
::AudioFormat::U32le,
|
||||||
::AudioFormat::U2432be,
|
::AudioFormat::U32be,
|
||||||
::AudioFormat::S32le,
|
::AudioFormat::S2432le,
|
||||||
::AudioFormat::S32be,
|
::AudioFormat::S2432be,
|
||||||
::AudioFormat::U32le,
|
::AudioFormat::U2432le,
|
||||||
::AudioFormat::U32be,
|
::AudioFormat::U2432be,
|
||||||
::AudioFormat::S24le,
|
::AudioFormat::S24le,
|
||||||
::AudioFormat::S24be,
|
::AudioFormat::S24be,
|
||||||
::AudioFormat::U24le,
|
::AudioFormat::U24le,
|
||||||
::AudioFormat::U24be,
|
::AudioFormat::U24be,
|
||||||
::AudioFormat::S20le,
|
::AudioFormat::S20le,
|
||||||
::AudioFormat::S20be,
|
::AudioFormat::S20be,
|
||||||
::AudioFormat::U20le,
|
::AudioFormat::U20le,
|
||||||
::AudioFormat::U20be,
|
::AudioFormat::U20be,
|
||||||
::AudioFormat::S18le,
|
::AudioFormat::S18le,
|
||||||
::AudioFormat::S18be,
|
::AudioFormat::S18be,
|
||||||
::AudioFormat::U18le,
|
::AudioFormat::U18le,
|
||||||
::AudioFormat::U18be,
|
::AudioFormat::U18be,
|
||||||
::AudioFormat::F32le,
|
::AudioFormat::S16le,
|
||||||
::AudioFormat::F32be,
|
::AudioFormat::S16be,
|
||||||
::AudioFormat::F64le,
|
::AudioFormat::U16le,
|
||||||
::AudioFormat::F64be,
|
::AudioFormat::U16be,
|
||||||
])
|
::AudioFormat::S8,
|
||||||
|
::AudioFormat::U8,
|
||||||
|
])
|
||||||
|
}
|
||||||
|
#[cfg(target_endian = "big")]
|
||||||
|
{
|
||||||
|
Box::new([
|
||||||
|
::AudioFormat::F64be,
|
||||||
|
::AudioFormat::F64le,
|
||||||
|
::AudioFormat::F32be,
|
||||||
|
::AudioFormat::F32le,
|
||||||
|
::AudioFormat::S32be,
|
||||||
|
::AudioFormat::S32le,
|
||||||
|
::AudioFormat::U32be,
|
||||||
|
::AudioFormat::U32le,
|
||||||
|
::AudioFormat::S2432be,
|
||||||
|
::AudioFormat::S2432le,
|
||||||
|
::AudioFormat::U2432be,
|
||||||
|
::AudioFormat::U2432le,
|
||||||
|
::AudioFormat::S24be,
|
||||||
|
::AudioFormat::S24le,
|
||||||
|
::AudioFormat::U24be,
|
||||||
|
::AudioFormat::U24le,
|
||||||
|
::AudioFormat::S20be,
|
||||||
|
::AudioFormat::S20le,
|
||||||
|
::AudioFormat::U20be,
|
||||||
|
::AudioFormat::U20le,
|
||||||
|
::AudioFormat::S18be,
|
||||||
|
::AudioFormat::S18le,
|
||||||
|
::AudioFormat::U18be,
|
||||||
|
::AudioFormat::U18le,
|
||||||
|
::AudioFormat::S16be,
|
||||||
|
::AudioFormat::S16le,
|
||||||
|
::AudioFormat::U16be,
|
||||||
|
::AudioFormat::U16le,
|
||||||
|
::AudioFormat::S8,
|
||||||
|
::AudioFormat::U8,
|
||||||
|
])
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
impl ::AudioFormat {
|
impl ::AudioFormat {
|
||||||
|
@ -295,6 +333,7 @@ where
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use gst;
|
use gst;
|
||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_display() {
|
fn test_display() {
|
||||||
|
@ -363,5 +402,12 @@ mod tests {
|
||||||
> ::AudioFormatInfo::from_format(::AudioFormat::U8)
|
> ::AudioFormatInfo::from_format(::AudioFormat::U8)
|
||||||
);
|
);
|
||||||
assert!(::AudioFormat::S20be > ::AudioFormat::S18be);
|
assert!(::AudioFormat::S20be > ::AudioFormat::S18be);
|
||||||
|
|
||||||
|
let sorted: Vec<::AudioFormat> = ::AudioFormat::iter_raw().sorted().rev().collect();
|
||||||
|
// FIXME: use is_sorted_by() once API is in stable
|
||||||
|
assert_eq!(
|
||||||
|
sorted,
|
||||||
|
::AudioFormat::iter_raw().collect::<Vec<::AudioFormat>>()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@ extern crate gstreamer_base as gst_base;
|
||||||
extern crate gstreamer_base_sys as gst_base_sys;
|
extern crate gstreamer_base_sys as gst_base_sys;
|
||||||
extern crate gstreamer_sys as gst_sys;
|
extern crate gstreamer_sys as gst_sys;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
extern crate itertools;
|
||||||
|
|
||||||
macro_rules! assert_initialized_main_thread {
|
macro_rules! assert_initialized_main_thread {
|
||||||
() => {
|
() => {
|
||||||
if unsafe { ::gst_sys::gst_is_initialized() } != ::glib_sys::GTRUE {
|
if unsafe { ::gst_sys::gst_is_initialized() } != ::glib_sys::GTRUE {
|
||||||
|
|
Loading…
Reference in a new issue