1 use std::ops::{Deref, DerefMut};
2 
3 use ::{AltoError, AltoResult};
4 use sys;
5 use alc::*;
6 use al::*;
7 use ext;
8 
9 
10 /// Audio formats supported by OpenAL.
11 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
12 pub enum Format {
13 	Standard(StandardFormat),
14 	ExtALaw(ExtALawFormat),
15 	ExtBFormat(ExtBFormat),
16 	ExtDouble(ExtDoubleFormat),
17 	ExtFloat32(ExtFloat32Format),
18 	ExtIma4(ExtIma4Format),
19 	ExtMcFormats(ExtMcFormat),
20 	ExtMuLaw(ExtMuLawFormat),
21 	ExtMuLawBFormat(ExtMuLawBFormat),
22 	ExtMuLawMcFormats(ExtMuLawMcFormat),
23 	SoftMsadpcm(SoftMsadpcmFormat),
24 }
25 
26 
27 /// Standard formats defined in the base specification.
28 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
29 pub enum StandardFormat {
30 	/// `AL_FORMAT_MONO8`
31 	MonoU8,
32 	/// `AL_FORMAT_MONO16`
33 	MonoI16,
34 	/// `AL_FORMAT_STEREO8`
35 	StereoU8,
36 	/// `AL_FORMAT_STEREO16`
37 	StereoI16,
38 }
39 
40 
41 /// Formats provided by `AL_EXT_ALAW`.
42 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
43 pub enum ExtALawFormat {
44 	/// `AL_FORMAT_MONO_ALAW_EXT`
45 	Mono,
46 	/// `AL_FORMAT_STEREO_ALAW_EXT`
47 	Stereo,
48 }
49 
50 
51 /// Formats provided by `AL_EXT_BFORMAT`.
52 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
53 pub enum ExtBFormat {
54 	/// `AL_FORMAT_BFORMAT2D_8`
55 	B2DU8,
56 	/// `AL_FORMAT_BFORMAT2D_16`
57 	B2DI16,
58 	/// `AL_FORMAT_BFORMAT2D_FLOAT32`
59 	B2DF32,
60 	/// `AL_FORMAT_BFORMAT3D_8`
61 	B3DU8,
62 	/// `AL_FORMAT_BFORMAT3D_16`
63 	B3DI16,
64 	/// `AL_FORMAT_BFORMAT3D_FLOAT32`
65 	B3DF32,
66 }
67 
68 
69 /// Formats provided by `AL_EXT_double`.
70 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
71 pub enum ExtDoubleFormat {
72 	/// `AL_FORMAT_MONO_DOUBLE_EXT`
73 	Mono,
74 	/// `AL_FORMAT_STEREO_DOUBLE_EXT`
75 	Stereo,
76 }
77 
78 
79 /// Formats provided by `AL_EXT_float32`.
80 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
81 pub enum ExtFloat32Format {
82 	/// `AL_FORMAT_MONO_FLOAT32`
83 	Mono,
84 	/// `AL_FORMAT_STEREO_FLOAT32`
85 	Stereo,
86 }
87 
88 
89 /// Formats provided by `AL_EXT_IMA4`.
90 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
91 pub enum ExtIma4Format {
92 	/// `AL_FORMAT_MONO_IMA4`
93 	Mono,
94 	/// `AL_FORMAT_STEREO_IMA4`
95 	Stereo,
96 }
97 
98 
99 /// Formats provided by `AL_EXT_MCFORMATS`.
100 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
101 pub enum ExtMcFormat {
102 	/// `AL_FORMAT_QUAD8`
103 	QuadU8,
104 	/// `AL_FORMAT_QUAD16`
105 	QuadI16,
106 	/// `AL_FORMAT_QUAD32`
107 	QuadF32,
108 	/// `AL_FORMAT_REAR8`
109 	RearU8,
110 	/// `AL_FORMAT_REAR16`
111 	RearI16,
112 	/// `AL_FORMAT_REAR32`
113 	RearF32,
114 	/// `AL_FORMAT_51CHN8`
115 	Mc51ChnU8,
116 	/// `AL_FORMAT_51CHN16`
117 	Mc51ChnI16,
118 	/// `AL_FORMAT_51CHN32`
119 	Mc51ChnF32,
120 	/// `AL_FORMAT_61CHN8`
121 	Mc61ChnU8,
122 	/// `AL_FORMAT_61CHN16`
123 	Mc61ChnI16,
124 	/// `AL_FORMAT_61CHN32`
125 	Mc61ChnF32,
126 	/// `AL_FORMAT_71CHN8`
127 	Mc71ChnU8,
128 	/// `AL_FORMAT_71CHN16`
129 	Mc71ChnI16,
130 	/// `AL_FORMAT_71CHN32`
131 	Mc71ChnF32,
132 }
133 
134 
135 /// Formats provided by `AL_EXT_MULAW`.
136 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
137 pub enum ExtMuLawFormat {
138 	/// `AL_FORMAT_MONO_MULAW_EXT`
139 	Mono,
140 	/// `AL_FORMAT_STEREO_MULAW_EXT`
141 	Stereo,
142 }
143 
144 
145 /// Formats provided by `AL_EXT_MULAW_BFORMAT`.
146 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
147 pub enum ExtMuLawBFormat {
148 	/// `AL_FORMAT_BFORMAT2D_MULAW`
149 	B2D,
150 	/// `AL_FORMAT_BFORMAT3D_MULAW`
151 	B3D,
152 }
153 
154 
155 /// Formats provided by `AL_EXT_MULAW_MCFORMATS`.
156 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
157 pub enum ExtMuLawMcFormat {
158 	/// `AL_FORMAT_MONO_MULAW`
159 	Mono,
160 	/// `AL_FORMAT_STEREO_MULAW`
161 	Stereo,
162 	/// `AL_FORMAT_QUAD_MULAW`
163 	Quad,
164 	/// `AL_FORMAT_REAR_MULAW`
165 	Rear,
166 	/// `AL_FORMAT_51CHN_MULAW`
167 	Mc51Chn,
168 	/// `AL_FORMAT_61CHN_MULAW`
169 	Mc61Chn,
170 	/// `AL_FORMAT_71CHN_MULAW`
171 	Mc71Chn,
172 }
173 
174 
175 /// Formats provided by `AL_SOFT_MSADPCM`.
176 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
177 pub enum SoftMsadpcmFormat {
178 	/// `AL_FORMAT_MONO_MSADPCM_SOFT`
179 	Mono,
180 	/// `AL_FORMAT_STEREO_MSADPCM_SOFT`
181 	Stereo,
182 }
183 
184 
185 /// Implemented by structs that represent a frame of audio samples.
186 /// A sample frame is a grouping of audio samples from each channel
187 /// of an output format.
188 pub unsafe trait SampleFrame: Copy + 'static {
189 	/// Underlying sample type.
190 	type Sample: Copy;
191 
192 
193 	/// Length of the frame in samples.
len() -> usize194 	fn len() -> usize;
195 	/// The exact format described by this struct.
format() -> Format196 	fn format() -> Format;
197 }
198 
199 
200 /// Implemented for sample frames specified by the base standard.
201 pub unsafe trait StandardFrame: SampleFrame { }
202 
203 
204 /// Implemented for types that represent a shared buffer of audio data.
205 pub unsafe trait AsBufferData<F: SampleFrame> {
206 	#[doc(hidden)]
as_buffer_data(&self) -> (*const sys::ALvoid, usize)207 	fn as_buffer_data(&self) -> (*const sys::ALvoid, usize);
208 }
209 
210 
211 /// Implemented for types that represent a mutable buffer of audio data.
212 pub unsafe trait AsBufferDataMut<F: SampleFrame> {
213 	#[doc(hidden)]
as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize)214 	fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize);
215 }
216 
217 
218 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
219 #[repr(C)]
220 pub struct ALawSample(pub u8);
221 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
222 #[repr(C)]
223 pub struct MuLawSample(pub u8);
224 
225 
226 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
227 #[repr(C)]
228 pub struct Mono<S: Copy> {
229 	pub center: S,
230 }
231 
232 
233 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
234 #[repr(C)]
235 pub struct Stereo<S: Copy> {
236 	pub left: S,
237 	pub right: S,
238 }
239 
240 
241 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
242 #[repr(C)]
243 pub struct McRear<S: Copy> {
244 	pub rear: S,
245 }
246 
247 
248 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
249 #[repr(C)]
250 pub struct McQuad<S: Copy> {
251 	pub front_left: S,
252 	pub front_right: S,
253 	pub back_left: S,
254 	pub back_right: S,
255 }
256 
257 
258 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
259 #[repr(C)]
260 pub struct Mc51Chn<S: Copy> {
261 	pub front_left: S,
262 	pub front_right: S,
263 	pub front_center: S,
264 	pub low_freq: S,
265 	pub back_left: S,
266 	pub back_right: S,
267 }
268 
269 
270 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
271 #[repr(C)]
272 pub struct Mc61Chn<S: Copy> {
273 	pub front_left: S,
274 	pub front_right: S,
275 	pub front_center: S,
276 	pub low_freq: S,
277 	pub back_left: S,
278 	pub back_right: S,
279 	pub back_center: S,
280 }
281 
282 
283 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
284 #[repr(C)]
285 pub struct Mc71Chn<S: Copy> {
286 	pub front_left: S,
287 	pub front_right: S,
288 	pub front_center: S,
289 	pub low_freq: S,
290 	pub back_left: S,
291 	pub back_right: S,
292 	pub side_left: S,
293 	pub side_right: S,
294 }
295 
296 
297 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
298 #[repr(C)]
299 pub struct BFormat2D<S: Copy> {
300 	pub w: S,
301 	pub x: S,
302 	pub y: S,
303 }
304 
305 
306 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
307 #[repr(C)]
308 pub struct BFormat3D<S: Copy> {
309 	pub w: S,
310 	pub x: S,
311 	pub y: S,
312 	pub z: S,
313 }
314 
315 
316 impl Format {
into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint>317 	pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint> {
318 		match self {
319 			Format::Standard(f) => Ok(f.into_raw()),
320 			Format::ExtALaw(f) => f.into_raw(ctx),
321 			Format::ExtBFormat(f) => f.into_raw(ctx),
322 			Format::ExtDouble(f) => f.into_raw(ctx),
323 			Format::ExtFloat32(f) => f.into_raw(ctx),
324 			Format::ExtIma4(f) => f.into_raw(ctx),
325 			Format::ExtMcFormats(f) => f.into_raw(ctx),
326 			Format::ExtMuLaw(f) => f.into_raw(ctx),
327 			Format::ExtMuLawBFormat(f) => f.into_raw(ctx),
328 			Format::ExtMuLawMcFormats(f) => f.into_raw(ctx),
329 			Format::SoftMsadpcm(f) => f.into_raw(ctx),
330 		}
331 	}
332 }
333 
334 
335 impl StandardFormat {
into_raw(self) -> sys::ALint336 	pub fn into_raw(self) -> sys::ALint {
337 		match self {
338 			StandardFormat::MonoU8 => sys::AL_FORMAT_MONO8,
339 			StandardFormat::MonoI16 => sys::AL_FORMAT_MONO16,
340 			StandardFormat::StereoU8 => sys::AL_FORMAT_STEREO8,
341 			StandardFormat::StereoI16 => sys::AL_FORMAT_STEREO16,
342 		}
343 	}
344 }
345 
346 
347 impl ExtALawFormat {
into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint>348 	pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint> {
349 		ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self {
350 			ExtALawFormat::Mono => Ok(ctx.0.exts.AL_EXT_ALAW()?.AL_FORMAT_MONO_ALAW_EXT?),
351 			ExtALawFormat::Stereo => Ok(ctx.0.exts.AL_EXT_ALAW()?.AL_FORMAT_STEREO_ALAW_EXT?),
352 		})
353 	}
354 }
355 
356 
357 impl ExtBFormat {
into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint>358 	pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint> {
359 		ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self {
360 			ExtBFormat::B2DU8 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT2D_8?),
361 			ExtBFormat::B2DI16 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT2D_16?),
362 			ExtBFormat::B2DF32 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT2D_FLOAT32?),
363 			ExtBFormat::B3DU8 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT3D_8?),
364 			ExtBFormat::B3DI16 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT3D_16?),
365 			ExtBFormat::B3DF32 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT3D_FLOAT32?),
366 		})
367 	}
368 }
369 
370 
371 impl ExtDoubleFormat {
into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint>372 	pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint> {
373 		ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self {
374 			ExtDoubleFormat::Mono => Ok(ctx.0.exts.AL_EXT_double()?.AL_FORMAT_MONO_DOUBLE_EXT?),
375 			ExtDoubleFormat::Stereo => Ok(ctx.0.exts.AL_EXT_double()?.AL_FORMAT_STEREO_DOUBLE_EXT?),
376 		})
377 	}
378 }
379 
380 
381 impl ExtFloat32Format {
into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint>382 	pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint> {
383 		ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self {
384 			ExtFloat32Format::Mono => Ok(ctx.0.exts.AL_EXT_float32()?.AL_FORMAT_MONO_FLOAT32?),
385 			ExtFloat32Format::Stereo => Ok(ctx.0.exts.AL_EXT_float32()?.AL_FORMAT_STEREO_FLOAT32?),
386 		})
387 	}
388 }
389 
390 
391 impl ExtIma4Format {
into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint>392 	pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint> {
393 		ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self {
394 			ExtIma4Format::Mono => Ok(ctx.0.exts.AL_EXT_IMA4()?.AL_FORMAT_MONO_IMA4?),
395 			ExtIma4Format::Stereo => Ok(ctx.0.exts.AL_EXT_IMA4()?.AL_FORMAT_STEREO_IMA4?),
396 		})
397 	}
398 }
399 
400 
401 impl ExtMcFormat {
into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint>402 	pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint> {
403 		ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self {
404 			ExtMcFormat::QuadU8 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_QUAD8?),
405 			ExtMcFormat::QuadI16 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_QUAD16?),
406 			ExtMcFormat::QuadF32 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_QUAD32?),
407 			ExtMcFormat::RearU8 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_REAR8?),
408 			ExtMcFormat::RearI16 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_REAR16?),
409 			ExtMcFormat::RearF32 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_REAR32?),
410 			ExtMcFormat::Mc51ChnU8 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_51CHN8?),
411 			ExtMcFormat::Mc51ChnI16 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_51CHN16?),
412 			ExtMcFormat::Mc51ChnF32 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_51CHN32?),
413 			ExtMcFormat::Mc61ChnU8 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_61CHN8?),
414 			ExtMcFormat::Mc61ChnI16 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_61CHN16?),
415 			ExtMcFormat::Mc61ChnF32 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_61CHN32?),
416 			ExtMcFormat::Mc71ChnU8 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_71CHN8?),
417 			ExtMcFormat::Mc71ChnI16 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_71CHN16?),
418 			ExtMcFormat::Mc71ChnF32 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_71CHN32?),
419 		})
420 	}
421 }
422 
423 
424 impl ExtMuLawFormat {
into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint>425 	pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint> {
426 		ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self {
427 			ExtMuLawFormat::Mono => Ok(ctx.0.exts.AL_EXT_MULAW()?.AL_FORMAT_MONO_MULAW_EXT?),
428 			ExtMuLawFormat::Stereo => Ok(ctx.0.exts.AL_EXT_MULAW()?.AL_FORMAT_STEREO_MULAW_EXT?),
429 		})
430 	}
431 }
432 
433 
434 impl ExtMuLawBFormat {
into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint>435 	pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint> {
436 		ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self {
437 			ExtMuLawBFormat::B2D => Ok(ctx.0.exts.AL_EXT_MULAW_BFORMAT()?.AL_FORMAT_BFORMAT2D_MULAW?),
438 			ExtMuLawBFormat::B3D => Ok(ctx.0.exts.AL_EXT_MULAW_BFORMAT()?.AL_FORMAT_BFORMAT3D_MULAW?),
439 		})
440 	}
441 }
442 
443 
444 impl ExtMuLawMcFormat {
into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint>445 	pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint> {
446 		ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self {
447 			ExtMuLawMcFormat::Mono => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_MONO_MULAW?),
448 			ExtMuLawMcFormat::Stereo => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_STEREO_MULAW?),
449 			ExtMuLawMcFormat::Quad => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_QUAD_MULAW?),
450 			ExtMuLawMcFormat::Rear => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_REAR_MULAW?),
451 			ExtMuLawMcFormat::Mc51Chn => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_51CHN_MULAW?),
452 			ExtMuLawMcFormat::Mc61Chn => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_61CHN_MULAW?),
453 			ExtMuLawMcFormat::Mc71Chn => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_71CHN_MULAW?),
454 		})
455 	}
456 }
457 
458 
459 impl SoftMsadpcmFormat {
into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint>460 	pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult<sys::ALint> {
461 		ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self {
462 			SoftMsadpcmFormat::Mono => Ok(ctx.0.exts.AL_SOFT_MSADPCM()?.AL_FORMAT_MONO_MSADPCM_SOFT?),
463 			SoftMsadpcmFormat::Stereo => Ok(ctx.0.exts.AL_SOFT_MSADPCM()?.AL_FORMAT_STEREO_MSADPCM_SOFT?),
464 		})
465 	}
466 }
467 
468 
469 unsafe impl SampleFrame for Mono<u8> {
470 	type Sample = u8;
471 
len() -> usize472 	#[inline] fn len() -> usize { 1 }
format() -> Format473 	#[inline] fn format() -> Format { Format::Standard(StandardFormat::MonoU8) }
474 }
475 unsafe impl SampleFrame for Mono<i16> {
476 	type Sample = i16;
477 
len() -> usize478 	#[inline] fn len() -> usize { 1 }
format() -> Format479 	#[inline] fn format() -> Format { Format::Standard(StandardFormat::MonoI16) }
480 }
481 unsafe impl SampleFrame for Mono<f32> {
482 	type Sample = f32;
483 
len() -> usize484 	#[inline] fn len() -> usize { 1 }
format() -> Format485 	#[inline] fn format() -> Format { Format::ExtFloat32(ExtFloat32Format::Mono) }
486 }
487 unsafe impl SampleFrame for Mono<f64> {
488 	type Sample = f64;
489 
len() -> usize490 	#[inline] fn len() -> usize { 1 }
format() -> Format491 	#[inline] fn format() -> Format { Format::ExtDouble(ExtDoubleFormat::Mono) }
492 }
493 unsafe impl SampleFrame for Mono<ALawSample> {
494 	type Sample = ALawSample;
495 
len() -> usize496 	#[inline] fn len() -> usize { 1 }
format() -> Format497 	#[inline] fn format() -> Format { Format::ExtALaw(ExtALawFormat::Mono) }
498 }
499 unsafe impl SampleFrame for Mono<MuLawSample> {
500 	type Sample = MuLawSample;
501 
len() -> usize502 	#[inline] fn len() -> usize { 1 }
format() -> Format503 	#[inline] fn format() -> Format { Format::ExtMuLaw(ExtMuLawFormat::Mono) }
504 }
505 
506 
507 unsafe impl SampleFrame for Stereo<u8> {
508 	type Sample = u8;
509 
len() -> usize510 	#[inline] fn len() -> usize { 2 }
format() -> Format511 	#[inline] fn format() -> Format { Format::Standard(StandardFormat::StereoU8) }
512 }
513 unsafe impl SampleFrame for Stereo<i16> {
514 	type Sample = i16;
515 
len() -> usize516 	#[inline] fn len() -> usize { 2 }
format() -> Format517 	#[inline] fn format() -> Format { Format::Standard(StandardFormat::StereoI16) }
518 }
519 unsafe impl SampleFrame for Stereo<f32> {
520 	type Sample = f32;
521 
len() -> usize522 	#[inline] fn len() -> usize { 2 }
format() -> Format523 	#[inline] fn format() -> Format { Format::ExtFloat32(ExtFloat32Format::Stereo) }
524 }
525 unsafe impl SampleFrame for Stereo<f64> {
526 	type Sample = f64;
527 
len() -> usize528 	#[inline] fn len() -> usize { 2 }
format() -> Format529 	#[inline] fn format() -> Format { Format::ExtDouble(ExtDoubleFormat::Stereo) }
530 }
531 unsafe impl SampleFrame for Stereo<ALawSample> {
532 	type Sample = ALawSample;
533 
len() -> usize534 	#[inline] fn len() -> usize { 2 }
format() -> Format535 	#[inline] fn format() -> Format { Format::ExtALaw(ExtALawFormat::Stereo) }
536 }
537 unsafe impl SampleFrame for Stereo<MuLawSample> {
538 	type Sample = MuLawSample;
539 
len() -> usize540 	#[inline] fn len() -> usize { 2 }
format() -> Format541 	#[inline] fn format() -> Format { Format::ExtMuLaw(ExtMuLawFormat::Stereo) }
542 }
543 
544 
545 unsafe impl SampleFrame for McRear<u8> {
546 	type Sample = u8;
547 
len() -> usize548 	#[inline] fn len() -> usize { 1 }
format() -> Format549 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::RearU8) }
550 }
551 unsafe impl SampleFrame for McRear<i16> {
552 	type Sample = i16;
553 
len() -> usize554 	#[inline] fn len() -> usize { 1 }
format() -> Format555 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::RearI16)  }
556 }
557 unsafe impl SampleFrame for McRear<f32> {
558 	type Sample = f32;
559 
len() -> usize560 	#[inline] fn len() -> usize { 1 }
format() -> Format561 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::RearF32) }
562 }
563 unsafe impl SampleFrame for McRear<MuLawSample> {
564 	type Sample = MuLawSample;
565 
len() -> usize566 	#[inline] fn len() -> usize { 1 }
format() -> Format567 	#[inline] fn format() -> Format { Format::ExtMuLawMcFormats(ExtMuLawMcFormat::Rear) }
568 }
569 
570 
571 unsafe impl SampleFrame for McQuad<u8> {
572 	type Sample = u8;
573 
len() -> usize574 	#[inline] fn len() -> usize { 4 }
format() -> Format575 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::QuadU8) }
576 }
577 unsafe impl SampleFrame for McQuad<i16> {
578 	type Sample = i16;
579 
len() -> usize580 	#[inline] fn len() -> usize { 4 }
format() -> Format581 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::QuadI16)  }
582 }
583 unsafe impl SampleFrame for McQuad<f32> {
584 	type Sample = f32;
585 
len() -> usize586 	#[inline] fn len() -> usize { 4 }
format() -> Format587 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::QuadF32) }
588 }
589 unsafe impl SampleFrame for McQuad<MuLawSample> {
590 	type Sample = MuLawSample;
591 
len() -> usize592 	#[inline] fn len() -> usize { 4 }
format() -> Format593 	#[inline] fn format() -> Format { Format::ExtMuLawMcFormats(ExtMuLawMcFormat::Quad) }
594 }
595 
596 
597 unsafe impl SampleFrame for Mc51Chn<u8> {
598 	type Sample = u8;
599 
len() -> usize600 	#[inline] fn len() -> usize { 6 }
format() -> Format601 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc51ChnU8) }
602 }
603 unsafe impl SampleFrame for Mc51Chn<i16> {
604 	type Sample = i16;
605 
len() -> usize606 	#[inline] fn len() -> usize { 6 }
format() -> Format607 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc51ChnI16)  }
608 }
609 unsafe impl SampleFrame for Mc51Chn<f32> {
610 	type Sample = f32;
611 
len() -> usize612 	#[inline] fn len() -> usize { 6 }
format() -> Format613 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc51ChnF32) }
614 }
615 unsafe impl SampleFrame for Mc51Chn<MuLawSample> {
616 	type Sample = MuLawSample;
617 
len() -> usize618 	#[inline] fn len() -> usize { 6 }
format() -> Format619 	#[inline] fn format() -> Format { Format::ExtMuLawMcFormats(ExtMuLawMcFormat::Mc51Chn) }
620 }
621 
622 
623 unsafe impl SampleFrame for Mc61Chn<u8> {
624 	type Sample = u8;
625 
len() -> usize626 	#[inline] fn len() -> usize { 7 }
format() -> Format627 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc61ChnU8) }
628 }
629 unsafe impl SampleFrame for Mc61Chn<i16> {
630 	type Sample = i16;
631 
len() -> usize632 	#[inline] fn len() -> usize { 7 }
format() -> Format633 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc61ChnI16)  }
634 }
635 unsafe impl SampleFrame for Mc61Chn<f32> {
636 	type Sample = f32;
637 
len() -> usize638 	#[inline] fn len() -> usize { 7 }
format() -> Format639 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc61ChnF32) }
640 }
641 unsafe impl SampleFrame for Mc61Chn<MuLawSample> {
642 	type Sample = MuLawSample;
643 
len() -> usize644 	#[inline] fn len() -> usize { 7 }
format() -> Format645 	#[inline] fn format() -> Format { Format::ExtMuLawMcFormats(ExtMuLawMcFormat::Mc61Chn) }
646 }
647 
648 
649 unsafe impl SampleFrame for Mc71Chn<u8> {
650 	type Sample = u8;
651 
len() -> usize652 	#[inline] fn len() -> usize { 8 }
format() -> Format653 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc71ChnU8) }
654 }
655 unsafe impl SampleFrame for Mc71Chn<i16> {
656 	type Sample = i16;
657 
len() -> usize658 	#[inline] fn len() -> usize { 8 }
format() -> Format659 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc71ChnI16)  }
660 }
661 unsafe impl SampleFrame for Mc71Chn<f32> {
662 	type Sample = f32;
663 
len() -> usize664 	#[inline] fn len() -> usize { 8 }
format() -> Format665 	#[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc71ChnF32) }
666 }
667 unsafe impl SampleFrame for Mc71Chn<MuLawSample> {
668 	type Sample = MuLawSample;
669 
len() -> usize670 	#[inline] fn len() -> usize { 8 }
format() -> Format671 	#[inline] fn format() -> Format { Format::ExtMuLawMcFormats(ExtMuLawMcFormat::Mc71Chn) }
672 }
673 
674 
675 unsafe impl SampleFrame for BFormat2D<u8> {
676 	type Sample = u8;
677 
len() -> usize678 	#[inline] fn len() -> usize { 3 }
format() -> Format679 	#[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B2DU8) }
680 }
681 unsafe impl SampleFrame for BFormat2D<i16> {
682 	type Sample = i16;
683 
len() -> usize684 	#[inline] fn len() -> usize { 3 }
format() -> Format685 	#[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B2DI16) }
686 }
687 unsafe impl SampleFrame for BFormat2D<f32> {
688 	type Sample = f32;
689 
len() -> usize690 	#[inline] fn len() -> usize { 3 }
format() -> Format691 	#[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B2DF32) }
692 }
693 unsafe impl SampleFrame for BFormat2D<MuLawSample> {
694 	type Sample = MuLawSample;
695 
len() -> usize696 	#[inline] fn len() -> usize { 3 }
format() -> Format697 	#[inline] fn format() -> Format { Format::ExtMuLawBFormat(ExtMuLawBFormat::B2D) }
698 }
699 
700 
701 unsafe impl SampleFrame for BFormat3D<u8> {
702 	type Sample = u8;
703 
len() -> usize704 	#[inline] fn len() -> usize { 4 }
format() -> Format705 	#[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B3DU8) }
706 }
707 unsafe impl SampleFrame for BFormat3D<i16> {
708 	type Sample = i16;
709 
len() -> usize710 	#[inline] fn len() -> usize { 4 }
format() -> Format711 	#[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B3DI16) }
712 }
713 unsafe impl SampleFrame for BFormat3D<f32> {
714 	type Sample = f32;
715 
len() -> usize716 	#[inline] fn len() -> usize { 4 }
format() -> Format717 	#[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B3DF32) }
718 }
719 unsafe impl SampleFrame for BFormat3D<MuLawSample> {
720 	type Sample = MuLawSample;
721 
len() -> usize722 	#[inline] fn len() -> usize { 4 }
format() -> Format723 	#[inline] fn format() -> Format { Format::ExtMuLawBFormat(ExtMuLawBFormat::B3D) }
724 }
725 
726 
727 unsafe impl StandardFrame for Mono<u8> { }
728 unsafe impl StandardFrame for Mono<i16> { }
729 unsafe impl StandardFrame for Stereo<u8> { }
730 unsafe impl StandardFrame for Stereo<i16> { }
731 
732 
733 unsafe impl LoopbackFrame for Mono<u8>
734 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>735 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_MONO_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>736 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) }
737 }
738 unsafe impl LoopbackFrame for Mono<i16>
739 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>740 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_MONO_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>741 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_SHORT_SOFT?) }
742 }
743 unsafe impl LoopbackFrame for Mono<f32>
744 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>745 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_MONO_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>746 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_FLOAT_SOFT?) }
747 }
748 
749 
750 unsafe impl LoopbackFrame for Stereo<u8>
751 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>752 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_STEREO_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>753 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) }
754 }
755 unsafe impl LoopbackFrame for Stereo<i16>
756 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>757 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_STEREO_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>758 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_SHORT_SOFT?) }
759 }
760 unsafe impl LoopbackFrame for Stereo<f32>
761 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>762 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_STEREO_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>763 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_FLOAT_SOFT?) }
764 }
765 
766 
767 unsafe impl LoopbackFrame for McQuad<u8>
768 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>769 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_QUAD_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>770 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) }
771 }
772 unsafe impl LoopbackFrame for McQuad<i16>
773 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>774 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_QUAD_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>775 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_SHORT_SOFT?) }
776 }
777 unsafe impl LoopbackFrame for McQuad<f32>
778 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>779 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_QUAD_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>780 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_FLOAT_SOFT?) }
781 }
782 
783 
784 unsafe impl LoopbackFrame for Mc51Chn<u8>
785 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>786 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_5POINT1_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>787 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) }
788 }
789 unsafe impl LoopbackFrame for Mc51Chn<i16>
790 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>791 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_5POINT1_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>792 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_SHORT_SOFT?) }
793 }
794 unsafe impl LoopbackFrame for Mc51Chn<f32>
795 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>796 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_5POINT1_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>797 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_FLOAT_SOFT?) }
798 }
799 
800 
801 unsafe impl LoopbackFrame for Mc61Chn<u8>
802 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>803 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_6POINT1_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>804 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) }
805 }
806 unsafe impl LoopbackFrame for Mc61Chn<i16>
807 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>808 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_6POINT1_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>809 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_SHORT_SOFT?) }
810 }
811 unsafe impl LoopbackFrame for Mc61Chn<f32>
812 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>813 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_6POINT1_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>814 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_FLOAT_SOFT?) }
815 }
816 
817 
818 unsafe impl LoopbackFrame for Mc71Chn<u8>
819 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>820 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_7POINT1_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>821 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) }
822 }
823 unsafe impl LoopbackFrame for Mc71Chn<i16>
824 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>825 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_7POINT1_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>826 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_SHORT_SOFT?) }
827 }
828 unsafe impl LoopbackFrame for Mc71Chn<f32>
829 {
channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>830 	fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_7POINT1_SOFT?) }
sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint>831 	fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult<sys::ALint> { Ok(sl.ALC_FLOAT_SOFT?) }
832 }
833 
834 
835 unsafe impl<F> AsBufferData<F> for [F] where F: SampleFrame {
as_buffer_data(&self) -> (*const sys::ALvoid, usize)836 	fn as_buffer_data(&self) -> (*const sys::ALvoid, usize) {
837 		(self.as_ptr() as *const _, self.len() * mem::size_of::<F>())
838 	}
839 }
840 unsafe impl<F> AsBufferData<F> for [u8] where F: SampleFrame<Sample = u8> {
as_buffer_data(&self) -> (*const sys::ALvoid, usize)841 	fn as_buffer_data(&self) -> (*const sys::ALvoid, usize) {
842 		(self.as_ptr() as *const _, self.len() * mem::size_of::<u8>())
843 	}
844 }
845 unsafe impl<F> AsBufferData<F> for [i16] where F: SampleFrame<Sample = i16> {
as_buffer_data(&self) -> (*const sys::ALvoid, usize)846 	fn as_buffer_data(&self) -> (*const sys::ALvoid, usize) {
847 		(self.as_ptr() as *const _, self.len() * mem::size_of::<i16>())
848 	}
849 }
850 unsafe impl<F> AsBufferData<F> for [f32] where F: SampleFrame<Sample = f32> {
as_buffer_data(&self) -> (*const sys::ALvoid, usize)851 	fn as_buffer_data(&self) -> (*const sys::ALvoid, usize) {
852 		(self.as_ptr() as *const _, self.len() * mem::size_of::<f32>())
853 	}
854 }
855 unsafe impl<F, T> AsBufferData<F> for T where
856 	F: SampleFrame,
857 	T: Deref,
858 	<T as Deref>::Target: AsBufferData<F>,
859 {
as_buffer_data(&self) -> (*const sys::ALvoid, usize)860 	fn as_buffer_data(&self) -> (*const sys::ALvoid, usize) { (**self).as_buffer_data() }
861 }
862 
863 
864 unsafe impl<F> AsBufferDataMut<F> for [F] where F: SampleFrame {
as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize)865 	fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize) {
866 		(self.as_mut_ptr() as *mut _, self.len() * mem::size_of::<F>())
867 	}
868 }
869 unsafe impl<F> AsBufferDataMut<F> for [u8] where F: SampleFrame<Sample = u8> {
as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize)870 	fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize) {
871 		(self.as_mut_ptr() as *mut _, self.len() * mem::size_of::<u8>())
872 	}
873 }
874 unsafe impl<F> AsBufferDataMut<F> for [i16] where F: SampleFrame<Sample = i16> {
as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize)875 	fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize) {
876 		(self.as_mut_ptr() as *mut _, self.len() * mem::size_of::<i16>())
877 	}
878 }
879 unsafe impl<F> AsBufferDataMut<F> for [f32] where F: SampleFrame<Sample = f32> {
as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize)880 	fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize) {
881 		(self.as_mut_ptr() as *mut _, self.len() * mem::size_of::<f32>())
882 	}
883 }
884 unsafe impl<F, T> AsBufferDataMut<F> for T where
885 	F: SampleFrame,
886 	T: DerefMut,
887 	<T as Deref>::Target: AsBufferDataMut<F>,
888 {
as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize)889 	fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize) { (**self).as_buffer_data_mut() }
890 }
891