From a2979c828d851aedd5f137a20e5dcb54fb30a814 Mon Sep 17 00:00:00 2001 From: lummax Date: Wed, 2 Sep 2015 12:50:16 +0200 Subject: [PATCH] encoder/audio: add getters for fields where setters exist --- src/codec/encoder/audio.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/codec/encoder/audio.rs b/src/codec/encoder/audio.rs index 67a583f..4d3a31b 100644 --- a/src/codec/encoder/audio.rs +++ b/src/codec/encoder/audio.rs @@ -55,23 +55,47 @@ impl Audio { } } + pub fn rate(&self) -> u32 { + unsafe { + (*self.as_ptr()).sample_rate as u32 + } + } + pub fn set_format(&mut self, value: format::Sample) { unsafe { (*self.as_mut_ptr()).sample_fmt = value.into(); } } + pub fn format(&self) -> format::Sample { + unsafe { + format::Sample::from((*self.as_ptr()).sample_fmt) + } + } + pub fn set_channel_layout(&mut self, value: ChannelLayout) { unsafe { (*self.as_mut_ptr()).channel_layout = value.bits(); } } + pub fn channel_layout(&self) -> ChannelLayout { + unsafe { + ChannelLayout::from_bits_truncate((*self.as_ptr()).channel_layout) + } + } + pub fn set_channels(&mut self, value: i32) { unsafe { (*self.as_mut_ptr()).channels = value; } } + + pub fn channels(&self) -> u16 { + unsafe { + (*self.as_ptr()).channels as u16 + } + } } impl Deref for Audio {