mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-18 15:15:37 +00:00
Update byte-slice-cast dependency to 1.0
This commit is contained in:
parent
1e661e6d5b
commit
48b9a5400b
6 changed files with 38 additions and 18 deletions
|
@ -12,7 +12,7 @@ glib = { git = "https://github.com/gtk-rs/glib" }
|
|||
gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
gstreamer-base = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
gstreamer-audio = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
byte-slice-cast = "0.3"
|
||||
byte-slice-cast = "1.0"
|
||||
num-traits = "0.2"
|
||||
lazy_static = "1.0"
|
||||
ebur128 = "0.1"
|
||||
|
|
|
@ -13,7 +13,7 @@ gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
|||
gstreamer-audio = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
gstreamer-check = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
claxon = { version = "0.4" }
|
||||
byte-slice-cast = "~0.3.4"
|
||||
byte-slice-cast = "1.0"
|
||||
atomic_refcell = "0.1"
|
||||
|
||||
[lib]
|
||||
|
|
|
@ -301,7 +301,7 @@ impl ClaxonDec {
|
|||
};
|
||||
|
||||
let depth_adjusted = depth.adjust_samples(v);
|
||||
let outbuf = gst::Buffer::from_slice(depth_adjusted);
|
||||
let outbuf = gst::Buffer::from_mut_slice(depth_adjusted);
|
||||
element.finish_frame(Some(outbuf), 1)
|
||||
}
|
||||
}
|
||||
|
@ -318,6 +318,32 @@ enum AudioDepth {
|
|||
I32,
|
||||
}
|
||||
|
||||
enum ByteVec {
|
||||
I8(Vec<i8>),
|
||||
I16(Vec<i16>),
|
||||
I32(Vec<i32>),
|
||||
}
|
||||
|
||||
impl AsRef<[u8]> for ByteVec {
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
match self {
|
||||
ByteVec::I8(ref vec) => vec.as_byte_slice(),
|
||||
ByteVec::I16(ref vec) => vec.as_byte_slice(),
|
||||
ByteVec::I32(ref vec) => vec.as_byte_slice(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<[u8]> for ByteVec {
|
||||
fn as_mut(&mut self) -> &mut [u8] {
|
||||
match self {
|
||||
ByteVec::I8(ref mut vec) => vec.as_mut_byte_slice(),
|
||||
ByteVec::I16(ref mut vec) => vec.as_mut_byte_slice(),
|
||||
ByteVec::I32(ref mut vec) => vec.as_mut_byte_slice(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AudioDepth {
|
||||
/// Validate input audio depth.
|
||||
fn validate(input: u32) -> Result<Self, gst::FlowError> {
|
||||
|
@ -335,19 +361,13 @@ impl AudioDepth {
|
|||
///
|
||||
/// This takes a vector of 32bits samples, adjusts the depth of each,
|
||||
/// and returns the adjusted bytes stream.
|
||||
fn adjust_samples(&self, input: Vec<i32>) -> Vec<u8> {
|
||||
fn adjust_samples(&self, input: Vec<i32>) -> ByteVec {
|
||||
match *self {
|
||||
AudioDepth::I8 => input
|
||||
.into_iter()
|
||||
.map(|x| x as i8)
|
||||
.collect::<Vec<_>>()
|
||||
.into_byte_vec(),
|
||||
AudioDepth::I16 => input
|
||||
.into_iter()
|
||||
.map(|x| x as i16)
|
||||
.collect::<Vec<_>>()
|
||||
.into_byte_vec(),
|
||||
AudioDepth::I24 | AudioDepth::I32 => input.into_byte_vec(),
|
||||
AudioDepth::I8 => ByteVec::I8(input.into_iter().map(|x| x as i8).collect::<Vec<_>>()),
|
||||
AudioDepth::I16 => {
|
||||
ByteVec::I16(input.into_iter().map(|x| x as i16).collect::<Vec<_>>())
|
||||
}
|
||||
AudioDepth::I24 | AudioDepth::I32 => ByteVec::I32(input),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ gst_audio = { package = "gstreamer-audio", git = "https://gitlab.freedesktop.org
|
|||
gst_check = { package = "gstreamer-check", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
csound = "0.1.8"
|
||||
once_cell = "1.0"
|
||||
byte-slice-cast = "0.3"
|
||||
byte-slice-cast = "1.0"
|
||||
|
||||
[lib]
|
||||
name = "gstcsound"
|
||||
|
|
|
@ -13,7 +13,7 @@ gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
|||
gstreamer-audio = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
gstreamer-check = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
lewton = { version = "0.10", default-features = false }
|
||||
byte-slice-cast = "0.3"
|
||||
byte-slice-cast = "1.0"
|
||||
atomic_refcell = "0.1"
|
||||
lazy_static = "1.0"
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
|||
gstreamer-base = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
gstreamer-video = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
gstreamer-audio = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
byte-slice-cast = "0.3"
|
||||
byte-slice-cast = "1.0"
|
||||
num-traits = "0.2"
|
||||
once_cell = "1.0"
|
||||
|
||||
|
|
Loading…
Reference in a new issue