From 956ed014d7e57710d228bfa425a98881d92197ad Mon Sep 17 00:00:00 2001 From: meh Date: Mon, 1 Jun 2015 18:34:42 +0200 Subject: [PATCH] util/frame/audio: use ChannelLayout --- src/util/frame/audio.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/util/frame/audio.rs b/src/util/frame/audio.rs index 4718a6c..aadb7be 100644 --- a/src/util/frame/audio.rs +++ b/src/util/frame/audio.rs @@ -2,8 +2,9 @@ use libc::c_int; use std::mem; use std::ops::{Deref, DerefMut}; +use libc::{int64_t, c_ulonglong}; use ffi::*; -use ::Samples; +use ::{ChannelLayout, Samples}; use ::util::format; use super::Frame; @@ -17,7 +18,7 @@ impl Audio { } } - pub fn new(format: format::Sample, samples: usize, layout: i64) -> Self { + pub fn new(format: format::Sample, samples: usize, layout: ChannelLayout) -> Self { unsafe { let mut frame = Audio::empty(); @@ -48,15 +49,15 @@ impl Audio { } } - pub fn channel_layout(&self) -> i64 { + pub fn channel_layout(&self) -> ChannelLayout { unsafe { - av_frame_get_channel_layout(self.ptr) + ChannelLayout::from_bits_truncate(av_frame_get_channel_layout(self.ptr) as c_ulonglong) } } - pub fn set_channel_layout(&mut self, value: i64) { + pub fn set_channel_layout(&mut self, value: ChannelLayout) { unsafe { - av_frame_set_channel_layout(self.ptr, value); + av_frame_set_channel_layout(self.ptr, value.bits() as int64_t); } }