1c284bb0fSMatt Madia/*
2c284bb0fSMatt Madia * Copyright (c) 1999-2000, Eric Moon.
3c284bb0fSMatt Madia * All rights reserved.
4c284bb0fSMatt Madia *
5c284bb0fSMatt Madia * Redistribution and use in source and binary forms, with or without
6c284bb0fSMatt Madia * modification, are permitted provided that the following conditions
7c284bb0fSMatt Madia * are met:
8c284bb0fSMatt Madia *
9c284bb0fSMatt Madia * 1. Redistributions of source code must retain the above copyright
10c284bb0fSMatt Madia *    notice, this list of conditions, and the following disclaimer.
11c284bb0fSMatt Madia *
12c284bb0fSMatt Madia * 2. Redistributions in binary form must reproduce the above copyright
13c284bb0fSMatt Madia *    notice, this list of conditions, and the following disclaimer in the
14c284bb0fSMatt Madia *    documentation and/or other materials provided with the distribution.
15c284bb0fSMatt Madia *
16c284bb0fSMatt Madia * 3. The name of the author may not be used to endorse or promote products
17c284bb0fSMatt Madia *    derived from this software without specific prior written permission.
18c284bb0fSMatt Madia *
19c284bb0fSMatt Madia * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20c284bb0fSMatt Madia * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21c284bb0fSMatt Madia * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22c284bb0fSMatt Madia * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23c284bb0fSMatt Madia * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24c284bb0fSMatt Madia * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25c284bb0fSMatt Madia * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26c284bb0fSMatt Madia * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27c284bb0fSMatt Madia * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28c284bb0fSMatt Madia * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29c284bb0fSMatt Madia */
30c284bb0fSMatt Madia
31c284bb0fSMatt Madia
32a0795c6fSMarcus Overhagen// AudioAdapterOp.cpp
33a0795c6fSMarcus Overhagen
34a0795c6fSMarcus Overhagen#include "AudioAdapterOp.h"
35a0795c6fSMarcus Overhagen#include "IAudioOp.h"
36a0795c6fSMarcus Overhagen
37a0795c6fSMarcus Overhagen#include "AudioAdapterParams.h"
38a0795c6fSMarcus Overhagen
39a0795c6fSMarcus Overhagen#include "audio_buffer_tools.h"
40a0795c6fSMarcus Overhagen
41a0795c6fSMarcus Overhagen#include <Debug.h>
42a0795c6fSMarcus Overhagen#include <ParameterWeb.h>
43a0795c6fSMarcus Overhagen
44a0795c6fSMarcus Overhagen
45a0795c6fSMarcus Overhagen//// empty parameter-set implementation
46a0795c6fSMarcus Overhagen//// +++++ move to IParameterSet.h!
47a0795c6fSMarcus Overhagen//
48a0795c6fSMarcus Overhagen//class _EmptyParameterSet :
49a0795c6fSMarcus Overhagen//	public	IParameterSet {
50a0795c6fSMarcus Overhagen//public:
51a0795c6fSMarcus Overhagen//	status_t store(
52a0795c6fSMarcus Overhagen//		int32										parameterID,
53a0795c6fSMarcus Overhagen//		void*										data,
54a0795c6fSMarcus Overhagen//		size_t									size) { return B_ERROR; }
55a0795c6fSMarcus Overhagen//
56a0795c6fSMarcus Overhagen//	status_t retrieve(
57a0795c6fSMarcus Overhagen//		int32										parameterID,
58a0795c6fSMarcus Overhagen//		void*										data,
59a0795c6fSMarcus Overhagen//		size_t*									ioSize) { return B_ERROR; }
60a0795c6fSMarcus Overhagen//
61a0795c6fSMarcus Overhagen//	void populateGroup(
62a0795c6fSMarcus Overhagen//		BParameterGroup* 				group) {}
63a0795c6fSMarcus Overhagen//};
64a0795c6fSMarcus Overhagen
65a0795c6fSMarcus Overhagen// -------------------------------------------------------- //
66a0795c6fSMarcus Overhagen// _AudioAdapterOp_base
67a0795c6fSMarcus Overhagen// -------------------------------------------------------- //
68a0795c6fSMarcus Overhagen
69a0795c6fSMarcus Overhagenclass _AudioAdapterOp_base :
70a0795c6fSMarcus Overhagen	public	IAudioOp {
71a0795c6fSMarcus Overhagenpublic:
72a0795c6fSMarcus Overhagen	_AudioAdapterOp_base(
73a0795c6fSMarcus Overhagen		IAudioOpHost*						_host) :
74a0795c6fSMarcus Overhagen		IAudioOp(_host) {}
75a0795c6fSMarcus Overhagen
76a0795c6fSMarcus Overhagen	void replace(
77a0795c6fSMarcus Overhagen		IAudioOp*								oldOp) {
78a0795c6fSMarcus Overhagen		delete oldOp;
79a0795c6fSMarcus Overhagen	}
80a0795c6fSMarcus Overhagen};
81a0795c6fSMarcus Overhagen
82a0795c6fSMarcus Overhagen// -------------------------------------------------------- //
83a0795c6fSMarcus Overhagen// _AudioAdapterOp implementations
84a0795c6fSMarcus Overhagen// -------------------------------------------------------- //
85a0795c6fSMarcus Overhagen
86a0795c6fSMarcus Overhagen// direct conversion:
87a0795c6fSMarcus Overhagen// - source and destination channel_count must be identical
88a0795c6fSMarcus Overhagen// - source and destination must be host-endian
89a0795c6fSMarcus Overhagen
90a0795c6fSMarcus Overhagentemplate <class in_t, class out_t>
91a0795c6fSMarcus Overhagenclass _AudioAdapterOp_direct :
92a0795c6fSMarcus Overhagen	public	_AudioAdapterOp_base {
93a0795c6fSMarcus Overhagen
94a0795c6fSMarcus Overhagenpublic:
95a0795c6fSMarcus Overhagen	_AudioAdapterOp_direct(
96a0795c6fSMarcus Overhagen		IAudioOpHost*						_host) :
97a0795c6fSMarcus Overhagen		_AudioAdapterOp_base(_host) {
98a0795c6fSMarcus Overhagen
99a0795c6fSMarcus Overhagen		PRINT(("### _AudioAdapterOp_direct()\n"));
100a0795c6fSMarcus Overhagen	}
101a0795c6fSMarcus Overhagen
102a0795c6fSMarcus Overhagen	uint32 process(
103a0795c6fSMarcus Overhagen		const AudioBuffer&			source,
104a0795c6fSMarcus Overhagen		AudioBuffer&						destination,
105a0795c6fSMarcus Overhagen		double&									sourceFrame,
106a0795c6fSMarcus Overhagen		uint32&									destinationFrame,
107a0795c6fSMarcus Overhagen		uint32									framesRequired,
108a0795c6fSMarcus Overhagen		bigtime_t								performanceTime) {
109a0795c6fSMarcus Overhagen
110a0795c6fSMarcus Overhagen		int32 inChannels = source.format().channel_count;
111a0795c6fSMarcus Overhagen		ASSERT(inChannels <= 2);
112a0795c6fSMarcus Overhagen		int32 outChannels = destination.format().channel_count;
113a0795c6fSMarcus Overhagen		ASSERT(outChannels == inChannels);
114a0795c6fSMarcus Overhagen
115a0795c6fSMarcus Overhagen		bool stereo = (inChannels == 2);
116a0795c6fSMarcus Overhagen
117a0795c6fSMarcus Overhagen		in_t* inBuffer =
118a0795c6fSMarcus Overhagen			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
119a0795c6fSMarcus Overhagen
120a0795c6fSMarcus Overhagen		out_t* outBuffer =
121a0795c6fSMarcus Overhagen			((out_t*)destination.data()) + destinationFrame*outChannels;
122a0795c6fSMarcus Overhagen
123a0795c6fSMarcus Overhagen		uint32 frame = framesRequired;
124a0795c6fSMarcus Overhagen		while(frame--) {
125a0795c6fSMarcus Overhagen
126a0795c6fSMarcus Overhagen			float val;
127a0795c6fSMarcus Overhagen			convert_sample(
128a0795c6fSMarcus Overhagen				*inBuffer,
129a0795c6fSMarcus Overhagen				val);
130a0795c6fSMarcus Overhagen			convert_sample(
131a0795c6fSMarcus Overhagen				val,
132a0795c6fSMarcus Overhagen				*outBuffer);
133a0795c6fSMarcus Overhagen
134a0795c6fSMarcus Overhagen			++inBuffer;
135a0795c6fSMarcus Overhagen			++outBuffer;
136a0795c6fSMarcus Overhagen
137a0795c6fSMarcus Overhagen			if(stereo) {
138a0795c6fSMarcus Overhagen				convert_sample(
139a0795c6fSMarcus Overhagen					*inBuffer,
140a0795c6fSMarcus Overhagen					val);
141a0795c6fSMarcus Overhagen				convert_sample(
142a0795c6fSMarcus Overhagen					val,
143a0795c6fSMarcus Overhagen					*outBuffer);
144a0795c6fSMarcus Overhagen				++inBuffer;
145a0795c6fSMarcus Overhagen				++outBuffer;
146a0795c6fSMarcus Overhagen			}
147a0795c6fSMarcus Overhagen
148a0795c6fSMarcus Overhagen			sourceFrame += 1.0;
149a0795c6fSMarcus Overhagen			destinationFrame++;
150a0795c6fSMarcus Overhagen		}
151a0795c6fSMarcus Overhagen
152a0795c6fSMarcus Overhagen		return framesRequired;
153a0795c6fSMarcus Overhagen	}
154a0795c6fSMarcus Overhagen};
155a0795c6fSMarcus Overhagen
156a0795c6fSMarcus Overhagen// direct conversion + incoming data byteswapped
157a0795c6fSMarcus Overhagen// - source and destination channel_count must be identical
158a0795c6fSMarcus Overhagen// - destination must be host-endian
159a0795c6fSMarcus Overhagen
160a0795c6fSMarcus Overhagentemplate <class in_t, class out_t>
161a0795c6fSMarcus Overhagenclass _AudioAdapterOp_swap_direct :
162a0795c6fSMarcus Overhagen	public	_AudioAdapterOp_base {
163a0795c6fSMarcus Overhagen
164a0795c6fSMarcus Overhagenpublic:
165a0795c6fSMarcus Overhagen	_AudioAdapterOp_swap_direct(
166a0795c6fSMarcus Overhagen		IAudioOpHost*						_host) :
167a0795c6fSMarcus Overhagen		_AudioAdapterOp_base(_host) {
168a0795c6fSMarcus Overhagen
169a0795c6fSMarcus Overhagen		PRINT(("### _AudioAdapterOp_swap_direct()\n"));
170a0795c6fSMarcus Overhagen	}
171a0795c6fSMarcus Overhagen
172a0795c6fSMarcus Overhagen	uint32 process(
173a0795c6fSMarcus Overhagen		const AudioBuffer&			source,
174a0795c6fSMarcus Overhagen		AudioBuffer&						destination,
175a0795c6fSMarcus Overhagen		double&									sourceFrame,
176a0795c6fSMarcus Overhagen		uint32&									destinationFrame,
177a0795c6fSMarcus Overhagen		uint32									framesRequired,
178a0795c6fSMarcus Overhagen		bigtime_t								performanceTime) {
179a0795c6fSMarcus Overhagen
180a0795c6fSMarcus Overhagen		int32 inChannels = source.format().channel_count;
181a0795c6fSMarcus Overhagen		ASSERT(inChannels <= 2);
182a0795c6fSMarcus Overhagen		int32 outChannels = destination.format().channel_count;
183a0795c6fSMarcus Overhagen		ASSERT(outChannels == inChannels);
184a0795c6fSMarcus Overhagen
185a0795c6fSMarcus Overhagen		bool stereo = (inChannels == 2);
186a0795c6fSMarcus Overhagen
187a0795c6fSMarcus Overhagen		in_t* inBuffer =
188a0795c6fSMarcus Overhagen			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
189a0795c6fSMarcus Overhagen
190a0795c6fSMarcus Overhagen		out_t* outBuffer =
191a0795c6fSMarcus Overhagen			((out_t*)destination.data()) + destinationFrame*outChannels;
192a0795c6fSMarcus Overhagen
193a0795c6fSMarcus Overhagen		uint32 frame = framesRequired;
194a0795c6fSMarcus Overhagen		while(frame--) {
195a0795c6fSMarcus Overhagen
196a0795c6fSMarcus Overhagen			float val;
197a0795c6fSMarcus Overhagen			swap_convert_sample(
198a0795c6fSMarcus Overhagen				*inBuffer,
199a0795c6fSMarcus Overhagen				val);
200a0795c6fSMarcus Overhagen			convert_sample(
201a0795c6fSMarcus Overhagen				val,
202a0795c6fSMarcus Overhagen				*outBuffer);
203a0795c6fSMarcus Overhagen
204a0795c6fSMarcus Overhagen			++inBuffer;
205a0795c6fSMarcus Overhagen			++outBuffer;
206a0795c6fSMarcus Overhagen
207a0795c6fSMarcus Overhagen			if(stereo) {
208a0795c6fSMarcus Overhagen				swap_convert_sample(
209a0795c6fSMarcus Overhagen					*inBuffer,
210a0795c6fSMarcus Overhagen					val);
211a0795c6fSMarcus Overhagen				convert_sample(
212a0795c6fSMarcus Overhagen					val,
213a0795c6fSMarcus Overhagen					*outBuffer);
214a0795c6fSMarcus Overhagen				++inBuffer;
215a0795c6fSMarcus Overhagen				++outBuffer;
216a0795c6fSMarcus Overhagen			}
217a0795c6fSMarcus Overhagen
218a0795c6fSMarcus Overhagen			sourceFrame += 1.0;
219a0795c6fSMarcus Overhagen			destinationFrame++;
220a0795c6fSMarcus Overhagen		}
221a0795c6fSMarcus Overhagen
222a0795c6fSMarcus Overhagen		return framesRequired;
223a0795c6fSMarcus Overhagen	}
224a0795c6fSMarcus Overhagen};
225a0795c6fSMarcus Overhagen
226a0795c6fSMarcus Overhagentemplate <class in_t, class out_t>
227a0795c6fSMarcus Overhagenclass _AudioAdapterOp_split :
228a0795c6fSMarcus Overhagen	public	_AudioAdapterOp_base {
229a0795c6fSMarcus Overhagenpublic:
230a0795c6fSMarcus Overhagen	_AudioAdapterOp_split(
231a0795c6fSMarcus Overhagen		IAudioOpHost*						_host) :
232a0795c6fSMarcus Overhagen		_AudioAdapterOp_base(_host) {
233a0795c6fSMarcus Overhagen
234a0795c6fSMarcus Overhagen		PRINT(("### _AudioAdapterOp_split()\n"));
235a0795c6fSMarcus Overhagen	}
236a0795c6fSMarcus Overhagen
237a0795c6fSMarcus Overhagen	uint32 process(
238a0795c6fSMarcus Overhagen		const AudioBuffer&			source,
239a0795c6fSMarcus Overhagen		AudioBuffer&						destination,
240a0795c6fSMarcus Overhagen		double&									sourceFrame,
241a0795c6fSMarcus Overhagen		uint32&									destinationFrame,
242a0795c6fSMarcus Overhagen		uint32									framesRequired,
243a0795c6fSMarcus Overhagen		bigtime_t								performanceTime) {
244a0795c6fSMarcus Overhagen
245a0795c6fSMarcus Overhagen		int32 inChannels = source.format().channel_count;
246a0795c6fSMarcus Overhagen		ASSERT(inChannels == 1);
247a0795c6fSMarcus Overhagen		int32 outChannels = destination.format().channel_count;
248a0795c6fSMarcus Overhagen		ASSERT(outChannels == 2);
249a0795c6fSMarcus Overhagen
250a0795c6fSMarcus Overhagen		in_t* inBuffer =
251a0795c6fSMarcus Overhagen			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
252a0795c6fSMarcus Overhagen
253a0795c6fSMarcus Overhagen		out_t* outBuffer =
254a0795c6fSMarcus Overhagen			((out_t*)destination.data()) + destinationFrame*outChannels;
255a0795c6fSMarcus Overhagen
256a0795c6fSMarcus Overhagen		uint32 frame = framesRequired;
257a0795c6fSMarcus Overhagen		while(frame--) {
258a0795c6fSMarcus Overhagen
259a0795c6fSMarcus Overhagen			float val;
260a0795c6fSMarcus Overhagen			convert_sample(
261a0795c6fSMarcus Overhagen				*inBuffer,
262a0795c6fSMarcus Overhagen				val);
263a0795c6fSMarcus Overhagen			// write channel 0
264a0795c6fSMarcus Overhagen			convert_sample(
265a0795c6fSMarcus Overhagen				val,
266a0795c6fSMarcus Overhagen				*outBuffer);
267a0795c6fSMarcus Overhagen
268a0795c6fSMarcus Overhagen			// write channel 1
269a0795c6fSMarcus Overhagen			++outBuffer;
270a0795c6fSMarcus Overhagen			convert_sample(
271a0795c6fSMarcus Overhagen				val,
272a0795c6fSMarcus Overhagen				*outBuffer);
273a0795c6fSMarcus Overhagen
274a0795c6fSMarcus Overhagen			++inBuffer;
275a0795c6fSMarcus Overhagen			++outBuffer;
276a0795c6fSMarcus Overhagen
277a0795c6fSMarcus Overhagen			sourceFrame += 1.0;
278a0795c6fSMarcus Overhagen			destinationFrame++;
279a0795c6fSMarcus Overhagen		}
280a0795c6fSMarcus Overhagen
281a0795c6fSMarcus Overhagen		return framesRequired;
282a0795c6fSMarcus Overhagen	}
283a0795c6fSMarcus Overhagen};
284a0795c6fSMarcus Overhagen
285a0795c6fSMarcus Overhagentemplate <class in_t, class out_t>
286a0795c6fSMarcus Overhagenclass _AudioAdapterOp_swap_split :
287a0795c6fSMarcus Overhagen	public	_AudioAdapterOp_base {
288a0795c6fSMarcus Overhagenpublic:
289a0795c6fSMarcus Overhagen	_AudioAdapterOp_swap_split(
290a0795c6fSMarcus Overhagen		IAudioOpHost*						_host) :
291a0795c6fSMarcus Overhagen		_AudioAdapterOp_base(_host) {
292a0795c6fSMarcus Overhagen
293a0795c6fSMarcus Overhagen		PRINT(("### _AudioAdapterOp_swap_split()\n"));
294a0795c6fSMarcus Overhagen	}
295a0795c6fSMarcus Overhagen
296a0795c6fSMarcus Overhagen	uint32 process(
297a0795c6fSMarcus Overhagen		const AudioBuffer&			source,
298a0795c6fSMarcus Overhagen		AudioBuffer&						destination,
299a0795c6fSMarcus Overhagen		double&									sourceFrame,
300a0795c6fSMarcus Overhagen		uint32&									destinationFrame,
301a0795c6fSMarcus Overhagen		uint32									framesRequired,
302a0795c6fSMarcus Overhagen		bigtime_t								performanceTime) {
303a0795c6fSMarcus Overhagen
304a0795c6fSMarcus Overhagen		int32 inChannels = source.format().channel_count;
305a0795c6fSMarcus Overhagen		ASSERT(inChannels == 1);
306a0795c6fSMarcus Overhagen		int32 outChannels = destination.format().channel_count;
307a0795c6fSMarcus Overhagen		ASSERT(outChannels == 2);
308a0795c6fSMarcus Overhagen
309a0795c6fSMarcus Overhagen		in_t* inBuffer =
310a0795c6fSMarcus Overhagen			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
311a0795c6fSMarcus Overhagen
312a0795c6fSMarcus Overhagen		out_t* outBuffer =
313a0795c6fSMarcus Overhagen			((out_t*)destination.data()) + destinationFrame*outChannels;
314a0795c6fSMarcus Overhagen
315a0795c6fSMarcus Overhagen		uint32 frame = framesRequired;
316a0795c6fSMarcus Overhagen		while(frame--) {
317a0795c6fSMarcus Overhagen
318a0795c6fSMarcus Overhagen			float val;
319a0795c6fSMarcus Overhagen			swap_convert_sample(
320a0795c6fSMarcus Overhagen				*inBuffer,
321a0795c6fSMarcus Overhagen				val);
322a0795c6fSMarcus Overhagen			// write channel 0
323a0795c6fSMarcus Overhagen			convert_sample(
324a0795c6fSMarcus Overhagen				val,
325a0795c6fSMarcus Overhagen				*outBuffer);
326a0795c6fSMarcus Overhagen
327a0795c6fSMarcus Overhagen			// write channel 1
328a0795c6fSMarcus Overhagen			++outBuffer;
329a0795c6fSMarcus Overhagen			convert_sample(
330a0795c6fSMarcus Overhagen				val,
331a0795c6fSMarcus Overhagen				*outBuffer);
332a0795c6fSMarcus Overhagen
333a0795c6fSMarcus Overhagen			++inBuffer;
334a0795c6fSMarcus Overhagen			++outBuffer;
335a0795c6fSMarcus Overhagen
336a0795c6fSMarcus Overhagen			sourceFrame += 1.0;
337a0795c6fSMarcus Overhagen			destinationFrame++;
338a0795c6fSMarcus Overhagen		}
339a0795c6fSMarcus Overhagen
340a0795c6fSMarcus Overhagen		return framesRequired;
341a0795c6fSMarcus Overhagen	}
342a0795c6fSMarcus Overhagen};
343a0795c6fSMarcus Overhagen
344a0795c6fSMarcus Overhagen
345a0795c6fSMarcus Overhagentemplate <class in_t, class out_t>
346a0795c6fSMarcus Overhagenclass _AudioAdapterOp_mix :
347a0795c6fSMarcus Overhagen	public	_AudioAdapterOp_base {
348a0795c6fSMarcus Overhagenpublic:
349a0795c6fSMarcus Overhagen	_AudioAdapterOp_mix(
350a0795c6fSMarcus Overhagen		IAudioOpHost*						_host) :
351a0795c6fSMarcus Overhagen		_AudioAdapterOp_base(_host) {
352a0795c6fSMarcus Overhagen
353a0795c6fSMarcus Overhagen		PRINT(("### _AudioAdapterOp_mix()\n"));
354a0795c6fSMarcus Overhagen	}
355a0795c6fSMarcus Overhagen
356a0795c6fSMarcus Overhagen	uint32 process(
357a0795c6fSMarcus Overhagen		const AudioBuffer&			source,
358a0795c6fSMarcus Overhagen		AudioBuffer&						destination,
359a0795c6fSMarcus Overhagen		double&									sourceFrame,
360a0795c6fSMarcus Overhagen		uint32&									destinationFrame,
361a0795c6fSMarcus Overhagen		uint32									framesRequired,
362a0795c6fSMarcus Overhagen		bigtime_t								performanceTime) {
363a0795c6fSMarcus Overhagen
364a0795c6fSMarcus Overhagen		int32 inChannels = source.format().channel_count;
365a0795c6fSMarcus Overhagen		ASSERT(inChannels == 2);
366a0795c6fSMarcus Overhagen		int32 outChannels = destination.format().channel_count;
367a0795c6fSMarcus Overhagen		ASSERT(outChannels == 1);
368a0795c6fSMarcus Overhagen
369a0795c6fSMarcus Overhagen		in_t* inBuffer =
370a0795c6fSMarcus Overhagen			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
371a0795c6fSMarcus Overhagen
372a0795c6fSMarcus Overhagen		out_t* outBuffer =
373a0795c6fSMarcus Overhagen			((out_t*)destination.data()) + destinationFrame*outChannels;
374a0795c6fSMarcus Overhagen
375a0795c6fSMarcus Overhagen		uint32 frame = framesRequired;
376a0795c6fSMarcus Overhagen		while(frame--) {
377a0795c6fSMarcus Overhagen
378a0795c6fSMarcus Overhagen			float out, in;
379a0795c6fSMarcus Overhagen			convert_sample(
380a0795c6fSMarcus Overhagen				*inBuffer,
381a0795c6fSMarcus Overhagen				in);
382a0795c6fSMarcus Overhagen
383a0795c6fSMarcus Overhagen			out = in * 0.5;
384a0795c6fSMarcus Overhagen			++inBuffer;
385a0795c6fSMarcus Overhagen
386a0795c6fSMarcus Overhagen			convert_sample(
387a0795c6fSMarcus Overhagen				*inBuffer,
388a0795c6fSMarcus Overhagen				in);
389a0795c6fSMarcus Overhagen
390a0795c6fSMarcus Overhagen			out += (in * 0.5);
391a0795c6fSMarcus Overhagen
392a0795c6fSMarcus Overhagen			// write channel 0
393a0795c6fSMarcus Overhagen			convert_sample(
394a0795c6fSMarcus Overhagen				out,
395a0795c6fSMarcus Overhagen				*outBuffer);
396a0795c6fSMarcus Overhagen
397a0795c6fSMarcus Overhagen			++inBuffer;
398a0795c6fSMarcus Overhagen			++outBuffer;
399a0795c6fSMarcus Overhagen
400a0795c6fSMarcus Overhagen			sourceFrame += 1.0;
401a0795c6fSMarcus Overhagen			destinationFrame++;
402a0795c6fSMarcus Overhagen		}
403a0795c6fSMarcus Overhagen
404a0795c6fSMarcus Overhagen		return framesRequired;
405a0795c6fSMarcus Overhagen	}
406a0795c6fSMarcus Overhagen};
407a0795c6fSMarcus Overhagen
408a0795c6fSMarcus Overhagentemplate <class in_t, class out_t>
409a0795c6fSMarcus Overhagenclass _AudioAdapterOp_swap_mix :
410a0795c6fSMarcus Overhagen	public	_AudioAdapterOp_base {
411a0795c6fSMarcus Overhagenpublic:
412a0795c6fSMarcus Overhagen	_AudioAdapterOp_swap_mix(
413a0795c6fSMarcus Overhagen		IAudioOpHost*						_host) :
414a0795c6fSMarcus Overhagen		_AudioAdapterOp_base(_host) {
415a0795c6fSMarcus Overhagen
416a0795c6fSMarcus Overhagen		PRINT(("### _AudioAdapterOp_swap_mix()\n"));
417a0795c6fSMarcus Overhagen	}
418a0795c6fSMarcus Overhagen
419a0795c6fSMarcus Overhagen	uint32 process(
420a0795c6fSMarcus Overhagen		const AudioBuffer&			source,
421a0795c6fSMarcus Overhagen		AudioBuffer&						destination,
422a0795c6fSMarcus Overhagen		double&									sourceFrame,
423a0795c6fSMarcus Overhagen		uint32&									destinationFrame,
424a0795c6fSMarcus Overhagen		uint32									framesRequired,
425a0795c6fSMarcus Overhagen		bigtime_t								performanceTime) {
426a0795c6fSMarcus Overhagen
427a0795c6fSMarcus Overhagen		int32 inChannels = source.format().channel_count;
428a0795c6fSMarcus Overhagen		ASSERT(inChannels == 2);
429a0795c6fSMarcus Overhagen		int32 outChannels = destination.format().channel_count;
430a0795c6fSMarcus Overhagen		ASSERT(outChannels == 1);
431a0795c6fSMarcus Overhagen
432a0795c6fSMarcus Overhagen		in_t* inBuffer =
433a0795c6fSMarcus Overhagen			((in_t*)source.data()) + (uint32)sourceFrame*inChannels;
434a0795c6fSMarcus Overhagen
435a0795c6fSMarcus Overhagen		out_t* outBuffer =
436a0795c6fSMarcus Overhagen			((out_t*)destination.data()) + destinationFrame*outChannels;
437a0795c6fSMarcus Overhagen
438a0795c6fSMarcus Overhagen		uint32 frame = framesRequired;
439a0795c6fSMarcus Overhagen		while(frame--) {
440a0795c6fSMarcus Overhagen
441a0795c6fSMarcus Overhagen			float out, in;
442a0795c6fSMarcus Overhagen			swap_convert_sample(
443a0795c6fSMarcus Overhagen				*inBuffer,
444a0795c6fSMarcus Overhagen				in);
445a0795c6fSMarcus Overhagen
446a0795c6fSMarcus Overhagen			out = in * 0.5;
447a0795c6fSMarcus Overhagen			++inBuffer;
448a0795c6fSMarcus Overhagen
449a0795c6fSMarcus Overhagen			swap_convert_sample(
450a0795c6fSMarcus Overhagen				*inBuffer,
451a0795c6fSMarcus Overhagen				in);
452a0795c6fSMarcus Overhagen
453a0795c6fSMarcus Overhagen			out += (in * 0.5);
454a0795c6fSMarcus Overhagen
455a0795c6fSMarcus Overhagen			// write channel 0
456a0795c6fSMarcus Overhagen			convert_sample(
457a0795c6fSMarcus Overhagen				out,
458a0795c6fSMarcus Overhagen				*outBuffer);
459a0795c6fSMarcus Overhagen
460a0795c6fSMarcus Overhagen			++inBuffer;
461a0795c6fSMarcus Overhagen			++outBuffer;
462a0795c6fSMarcus Overhagen
463a0795c6fSMarcus Overhagen			sourceFrame += 1.0;
464a0795c6fSMarcus Overhagen			destinationFrame++;
465a0795c6fSMarcus Overhagen		}
466a0795c6fSMarcus Overhagen
467a0795c6fSMarcus Overhagen		return framesRequired;
468a0795c6fSMarcus Overhagen	}
469a0795c6fSMarcus Overhagen};
470a0795c6fSMarcus Overhagen
471a0795c6fSMarcus Overhagen// -------------------------------------------------------- //
472a0795c6fSMarcus Overhagen// AudioAdapterOpFactory impl.
473a0795c6fSMarcus Overhagen// -------------------------------------------------------- //
474a0795c6fSMarcus Overhagen
475a0795c6fSMarcus Overhagen// [8sep99]  yeeechk!
476a0795c6fSMarcus Overhagen// [16sep99] now handles pre-conversion byteswapping
477a0795c6fSMarcus Overhagen
478a0795c6fSMarcus OverhagenIAudioOp* AudioAdapterOpFactory::createOp(
479a0795c6fSMarcus Overhagen	IAudioOpHost*										host,
480a0795c6fSMarcus Overhagen	const media_raw_audio_format&		inputFormat,
481a0795c6fSMarcus Overhagen	const media_raw_audio_format&		outputFormat) {
482a0795c6fSMarcus Overhagen
483a0795c6fSMarcus Overhagen	// [16sep99] ensure fully-specified input & output formats
484a0795c6fSMarcus Overhagen	ASSERT(
485a0795c6fSMarcus Overhagen		inputFormat.frame_rate &&
486a0795c6fSMarcus Overhagen		inputFormat.byte_order &&
487a0795c6fSMarcus Overhagen		inputFormat.channel_count &&
488a0795c6fSMarcus Overhagen		inputFormat.format &&
489a0795c6fSMarcus Overhagen		inputFormat.buffer_size);
490a0795c6fSMarcus Overhagen	ASSERT(
491a0795c6fSMarcus Overhagen		outputFormat.frame_rate &&
492a0795c6fSMarcus Overhagen		outputFormat.byte_order &&
493a0795c6fSMarcus Overhagen		outputFormat.channel_count &&
494a0795c6fSMarcus Overhagen		outputFormat.format &&
495a0795c6fSMarcus Overhagen		outputFormat.buffer_size);
496a0795c6fSMarcus Overhagen
497a0795c6fSMarcus Overhagen	int32 inChannels = inputFormat.channel_count;
498a0795c6fSMarcus Overhagen	int32 outChannels = outputFormat.channel_count;
499a0795c6fSMarcus Overhagen
500a0795c6fSMarcus Overhagen//	char fmt_buffer[256];
501a0795c6fSMarcus Overhagen//	media_format f;
502a0795c6fSMarcus Overhagen//	f.type = B_MEDIA_RAW_AUDIO;
503a0795c6fSMarcus Overhagen//	f.u.raw_audio = inputFormat;
504a0795c6fSMarcus Overhagen//	string_for_format(f, fmt_buffer, 255);
505a0795c6fSMarcus Overhagen
506a0795c6fSMarcus Overhagen	bool swapBefore = (inputFormat.byte_order !=
507a0795c6fSMarcus Overhagen		((B_HOST_IS_BENDIAN) ? B_MEDIA_BIG_ENDIAN : B_MEDIA_LITTLE_ENDIAN));
508a0795c6fSMarcus Overhagen
509a0795c6fSMarcus Overhagen//	PRINT(("### swapBefore: '%s'\n", fmt_buffer));
510a0795c6fSMarcus Overhagen
511a0795c6fSMarcus Overhagen	bool split = outChannels > inChannels;
512a0795c6fSMarcus Overhagen	bool mix = outChannels < inChannels;
513a0795c6fSMarcus Overhagen
514a0795c6fSMarcus Overhagen	switch(inputFormat.format) {
515a0795c6fSMarcus Overhagen		case media_raw_audio_format::B_AUDIO_UCHAR:
516a0795c6fSMarcus Overhagen			switch(outputFormat.format) {
517a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_UCHAR:
518a0795c6fSMarcus Overhagen					return
519a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < uint8, uint8>(host) :
520a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < uint8, uint8>(host) :
521a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < uint8, uint8>(host);
522a0795c6fSMarcus Overhagen					break;
523a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_SHORT:
524a0795c6fSMarcus Overhagen					if(swapBefore) return
525a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< uint8, short>(host) :
526a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < uint8, short>(host) :
527a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < uint8, short>(host);
528a0795c6fSMarcus Overhagen					else return
529a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < uint8, short>(host) :
530a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < uint8, short>(host) :
531a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < uint8, short>(host);
532a0795c6fSMarcus Overhagen					break;
533a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_FLOAT:
534a0795c6fSMarcus Overhagen					if(swapBefore) return
535a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< uint8, float>(host) :
536a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < uint8, float>(host) :
537a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < uint8, float>(host);
538a0795c6fSMarcus Overhagen					else return
539a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < uint8, float>(host) :
540a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < uint8, float>(host) :
541a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < uint8, float>(host);
542a0795c6fSMarcus Overhagen					break;
543a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_INT:
544a0795c6fSMarcus Overhagen					if(swapBefore) return
545a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< uint8, int32>(host) :
546a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < uint8, int32>(host) :
547a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < uint8, int32>(host);
548a0795c6fSMarcus Overhagen					else return
549a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < uint8, int32>(host) :
550a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < uint8, int32>(host) :
551a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < uint8, int32>(host);
552a0795c6fSMarcus Overhagen					break;
553a0795c6fSMarcus Overhagen			}
554a0795c6fSMarcus Overhagen			break;
555a0795c6fSMarcus Overhagen
556a0795c6fSMarcus Overhagen		case media_raw_audio_format::B_AUDIO_SHORT:
557a0795c6fSMarcus Overhagen			switch(outputFormat.format) {
558a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_UCHAR:
559a0795c6fSMarcus Overhagen					if(swapBefore) return
560a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< short, uint8>(host) :
561a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < short, uint8>(host) :
562a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < short, uint8>(host);
563a0795c6fSMarcus Overhagen					else return
564a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < short, uint8>(host) :
565a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < short, uint8>(host) :
566a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < short, uint8>(host);
567a0795c6fSMarcus Overhagen					break;
568a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_SHORT:
569a0795c6fSMarcus Overhagen					if(swapBefore) return
570a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< short, short>(host) :
571a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < short, short>(host) :
572a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < short, short>(host);
573a0795c6fSMarcus Overhagen					else return
574a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < short, short>(host) :
575a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < short, short>(host) :
576a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < short, short>(host);
577a0795c6fSMarcus Overhagen					break;
578a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_FLOAT:
579a0795c6fSMarcus Overhagen					if(swapBefore) return
580a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< short, float>(host) :
581a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < short, float>(host) :
582a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < short, float>(host);
583a0795c6fSMarcus Overhagen					else return
584a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < short, float>(host) :
585a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < short, float>(host) :
586a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < short, float>(host);
587a0795c6fSMarcus Overhagen					break;
588a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_INT:
589a0795c6fSMarcus Overhagen					if(swapBefore) return
590a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< short, int32>(host) :
591a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < short, int32>(host) :
592a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < short, int32>(host);
593a0795c6fSMarcus Overhagen					else return
594a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < short, int32>(host) :
595a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < short, int32>(host) :
596a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < short, int32>(host);
597a0795c6fSMarcus Overhagen					break;
598a0795c6fSMarcus Overhagen			}
599a0795c6fSMarcus Overhagen			break;
600a0795c6fSMarcus Overhagen
601a0795c6fSMarcus Overhagen		case media_raw_audio_format::B_AUDIO_FLOAT:
602a0795c6fSMarcus Overhagen			switch(outputFormat.format) {
603a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_UCHAR:
604a0795c6fSMarcus Overhagen					if(swapBefore) return
605a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< float, uint8>(host) :
606a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < float, uint8>(host) :
607a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < float, uint8>(host);
608a0795c6fSMarcus Overhagen					else return
609a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < float, uint8>(host) :
610a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < float, uint8>(host) :
611a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < float, uint8>(host);
612a0795c6fSMarcus Overhagen					break;
613a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_SHORT:
614a0795c6fSMarcus Overhagen					if(swapBefore) return
615a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< float, short>(host) :
616a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < float, short>(host) :
617a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < float, short>(host);
618a0795c6fSMarcus Overhagen					else return
619a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < float, short>(host) :
620a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < float, short>(host) :
621a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < float, short>(host);
622a0795c6fSMarcus Overhagen					break;
623a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_FLOAT:
624a0795c6fSMarcus Overhagen					if(swapBefore) return
625a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< float, float>(host) :
626a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < float, float>(host) :
627a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < float, float>(host);
628a0795c6fSMarcus Overhagen					else return
629a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < float, float>(host) :
630a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < float, float>(host) :
631a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < float, float>(host);
632a0795c6fSMarcus Overhagen					break;
633a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_INT:
634a0795c6fSMarcus Overhagen					if(swapBefore) return
635a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< float, int32>(host) :
636a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < float, int32>(host) :
637a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < float, int32>(host);
638a0795c6fSMarcus Overhagen					else return
639a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < float, int32>(host) :
640a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < float, int32>(host) :
641a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < float, int32>(host);
642a0795c6fSMarcus Overhagen					break;
643a0795c6fSMarcus Overhagen			}
644a0795c6fSMarcus Overhagen			break;
645a0795c6fSMarcus Overhagen
646a0795c6fSMarcus Overhagen		case media_raw_audio_format::B_AUDIO_INT:
647a0795c6fSMarcus Overhagen			switch(outputFormat.format) {
648a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_UCHAR:
649a0795c6fSMarcus Overhagen					if(swapBefore) return
650a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< int32, uint8>(host) :
651a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < int32, uint8>(host) :
652a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < int32, uint8>(host);
653a0795c6fSMarcus Overhagen					else return
654a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < int32, uint8>(host) :
655a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < int32, uint8>(host) :
656a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < int32, uint8>(host);
657a0795c6fSMarcus Overhagen					break;
658a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_SHORT:
659a0795c6fSMarcus Overhagen					if(swapBefore) return
660a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< int32, short>(host) :
661a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < int32, short>(host) :
662a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < int32, short>(host);
663a0795c6fSMarcus Overhagen					else return
664a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < int32, short>(host) :
665a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < int32, short>(host) :
666a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < int32, short>(host);
667a0795c6fSMarcus Overhagen					break;
668a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_FLOAT:
669a0795c6fSMarcus Overhagen					if(swapBefore) return
670a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< int32, float>(host) :
671a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < int32, float>(host) :
672a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < int32, float>(host);
673a0795c6fSMarcus Overhagen					else return
674a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < int32, float>(host) :
675a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < int32, float>(host) :
676a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < int32, float>(host);
677a0795c6fSMarcus Overhagen					break;
678a0795c6fSMarcus Overhagen				case media_raw_audio_format::B_AUDIO_INT:
679a0795c6fSMarcus Overhagen					if(swapBefore) return
680a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_swap_split< int32, int32>(host) :
681a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_swap_mix  < int32, int32>(host) :
682a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_swap_direct   < int32, int32>(host);
683a0795c6fSMarcus Overhagen					else return
684a0795c6fSMarcus Overhagen						split ? (IAudioOp*)new _AudioAdapterOp_split     < int32, int32>(host) :
685a0795c6fSMarcus Overhagen							mix ? (IAudioOp*)new _AudioAdapterOp_mix       < int32, int32>(host) :
686a0795c6fSMarcus Overhagen								(IAudioOp*)new _AudioAdapterOp_direct        < int32, int32>(host);
687a0795c6fSMarcus Overhagen					break;
688a0795c6fSMarcus Overhagen			}
689a0795c6fSMarcus Overhagen			break;
690a0795c6fSMarcus Overhagen	}
691a0795c6fSMarcus Overhagen
692a0795c6fSMarcus Overhagen	return 0;
693a0795c6fSMarcus Overhagen}
694a0795c6fSMarcus Overhagen
695a0795c6fSMarcus OverhagenIParameterSet* AudioAdapterOpFactory::createParameterSet() {
696a0795c6fSMarcus Overhagen	return new _AudioAdapterParams();
697a0795c6fSMarcus Overhagen}
698a0795c6fSMarcus Overhagen
699a0795c6fSMarcus Overhagen
700083b91d4SMaurice Kalinowski// END -- AudioAdapterOp.cpp --
701