util/frame/audio: rename new to empty and make new allocate the buffers
This commit is contained in:
parent
aa5d34ad8e
commit
049e8a6cdd
@ -9,10 +9,24 @@ use super::Frame;
|
|||||||
pub struct Audio(Frame);
|
pub struct Audio(Frame);
|
||||||
|
|
||||||
impl Audio {
|
impl Audio {
|
||||||
pub fn new() -> Self {
|
pub fn empty() -> Self {
|
||||||
Audio(Frame::new())
|
Audio(Frame::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new(format: format::Sample, samples: usize, layout: i64) -> Self {
|
||||||
|
unsafe {
|
||||||
|
let mut frame = Audio(Frame::new());
|
||||||
|
|
||||||
|
frame.set_format(format);
|
||||||
|
frame.set_samples(samples);
|
||||||
|
frame.set_channel_layout(layout);
|
||||||
|
|
||||||
|
av_frame_get_buffer(frame.ptr, 1);
|
||||||
|
|
||||||
|
frame
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn format(&self) -> format::Sample {
|
pub fn format(&self) -> format::Sample {
|
||||||
unsafe {
|
unsafe {
|
||||||
if (*self.ptr).format == -1 {
|
if (*self.ptr).format == -1 {
|
||||||
@ -24,6 +38,12 @@ impl Audio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_format(&mut self, value: format::Sample) {
|
||||||
|
unsafe {
|
||||||
|
(*self.ptr).format = mem::transmute::<AVSampleFormat, c_int>(value.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn channel_layout(&self) -> i64 {
|
pub fn channel_layout(&self) -> i64 {
|
||||||
unsafe {
|
unsafe {
|
||||||
av_frame_get_channel_layout(self.ptr)
|
av_frame_get_channel_layout(self.ptr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user