Add #[inline] attributes

This commit is contained in:
Pierre Krieger 2015-09-11 10:55:29 +02:00
parent 6ecc5f5078
commit 75f828b04f
9 changed files with 59 additions and 0 deletions

View file

@ -21,12 +21,14 @@ thread_local!(static COM_INITIALIZED: ComInitialized = {
struct ComInitialized(*mut ());
impl Drop for ComInitialized {
#[inline]
fn drop(&mut self) {
unsafe { ole32::CoUninitialize() };
}
}
/// Ensures that COM is initialized in this thread.
#[inline]
pub fn com_initialized() {
COM_INITIALIZED.with(|_| {});
}

View file

@ -37,6 +37,7 @@ unsafe impl Send for Enumerator {}
unsafe impl Sync for Enumerator {}
impl Drop for Enumerator {
#[inline]
fn drop(&mut self) {
unsafe {
(*self.0).Release();
@ -55,6 +56,7 @@ unsafe impl Send for EndpointsIterator {}
unsafe impl Sync for EndpointsIterator {}
impl Drop for EndpointsIterator {
#[inline]
fn drop(&mut self) {
unsafe {
(*self.collection).Release();

View file

@ -43,6 +43,7 @@ mod com;
mod enumerate;
mod voice;
#[inline]
fn check_result(result: winapi::HRESULT) -> Result<(), IoError> {
if result < 0 {
Err(IoError::from_raw_os_error(result))
@ -103,6 +104,7 @@ impl Endpoint {
}
/// Returns an uninitialized `IAudioClient`.
#[inline]
fn build_audioclient(&self) -> Result<*mut winapi::IAudioClient, IoError> {
let mut lock = try!(self.ensure_future_audio_client());
let client = lock.unwrap().0;
@ -204,6 +206,7 @@ impl Endpoint {
}
impl PartialEq for Endpoint {
#[inline]
fn eq(&self, other: &Endpoint) -> bool {
self.device == other.device
}
@ -212,6 +215,7 @@ impl PartialEq for Endpoint {
impl Eq for Endpoint {}
impl Clone for Endpoint {
#[inline]
fn clone(&self) -> Endpoint {
unsafe { (*self.device).AddRef(); }
@ -223,6 +227,7 @@ impl Clone for Endpoint {
}
impl Drop for Endpoint {
#[inline]
fn drop(&mut self) {
unsafe { (*self.device).Release(); }

View file

@ -211,14 +211,17 @@ impl Voice {
}
}
#[inline]
pub fn get_channels(&self) -> ::ChannelsCount {
self.num_channels as ::ChannelsCount
}
#[inline]
pub fn get_samples_rate(&self) -> ::SamplesRate {
::SamplesRate(self.samples_per_second as u32)
}
#[inline]
pub fn get_samples_format(&self) -> ::SampleFormat {
match self.bits_per_sample {
16 => ::SampleFormat::I16,
@ -275,6 +278,7 @@ impl Voice {
}
}
#[inline]
pub fn play(&mut self) {
if !self.playing {
unsafe {
@ -286,6 +290,7 @@ impl Voice {
self.playing = true;
}
#[inline]
pub fn pause(&mut self) {
if self.playing {
unsafe {
@ -299,6 +304,7 @@ impl Voice {
}
impl Drop for Voice {
#[inline]
fn drop(&mut self) {
unsafe {
(*self.render_client).Release();
@ -316,16 +322,19 @@ pub struct Buffer<'a, T: 'a> {
}
impl<'a, T> Buffer<'a, T> {
#[inline]
pub fn get_buffer<'b>(&'b mut self) -> &'b mut [T] {
unsafe {
slice::from_raw_parts_mut(self.buffer_data, self.buffer_len)
}
}
#[inline]
pub fn len(&self) -> usize {
self.buffer_len
}
#[inline]
pub fn finish(self) {
// releasing buffer
unsafe {