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// AudioAdapterParams.cpp
33a0795c6fSMarcus Overhagen
34a0795c6fSMarcus Overhagen#include "AudioAdapterParams.h"
35a0795c6fSMarcus Overhagen
36a0795c6fSMarcus Overhagen#include <Debug.h>
37a0795c6fSMarcus Overhagen#include <ParameterWeb.h>
38a0795c6fSMarcus Overhagen
39f37b1856SAxel Dörflerstatus_t
40083b91d4SMaurice Kalinowski_AudioAdapterParams::store(int32 parameterID, const void* data, size_t size)
41f37b1856SAxel Dörfler{
42f37b1856SAxel Dörfler	if (size < sizeof(int32))
43a0795c6fSMarcus Overhagen		return B_NO_MEMORY;
44f37b1856SAxel Dörfler
45a0795c6fSMarcus Overhagen	const uint32 d = *(uint32*)data;
46f37b1856SAxel Dörfler
47f37b1856SAxel Dörfler	switch (parameterID) {
48a0795c6fSMarcus Overhagen		// input format restrictions (0='wildcard')
49a0795c6fSMarcus Overhagen		case P_INPUT_FORMAT:
50a0795c6fSMarcus Overhagen			inputFormat.format = d;
51a0795c6fSMarcus Overhagen			break;
52a0795c6fSMarcus Overhagen
53a0795c6fSMarcus Overhagen		case P_INPUT_CHANNEL_COUNT:
54a0795c6fSMarcus Overhagen			inputFormat.channel_count = d;
55a0795c6fSMarcus Overhagen			break;
56a0795c6fSMarcus Overhagen
57a0795c6fSMarcus Overhagen		// output format restrictions (0='wildcard')
58a0795c6fSMarcus Overhagen		case P_OUTPUT_FORMAT:
59a0795c6fSMarcus Overhagen			outputFormat.format = d;
60a0795c6fSMarcus Overhagen			break;
61a0795c6fSMarcus Overhagen
62a0795c6fSMarcus Overhagen		case P_OUTPUT_CHANNEL_COUNT:
63a0795c6fSMarcus Overhagen			outputFormat.channel_count = d;
64a0795c6fSMarcus Overhagen			break;
65a0795c6fSMarcus Overhagen
66a0795c6fSMarcus Overhagen		default:
67a0795c6fSMarcus Overhagen			return B_BAD_INDEX;
68a0795c6fSMarcus Overhagen	}
69a0795c6fSMarcus Overhagen
70a0795c6fSMarcus Overhagen	return B_OK;
71a0795c6fSMarcus Overhagen}
72a0795c6fSMarcus Overhagen
73a0795c6fSMarcus Overhagenstatus_t _AudioAdapterParams::retrieve(
74a0795c6fSMarcus Overhagen	int32										parameterID,
75a0795c6fSMarcus Overhagen	void*										data,
76a0795c6fSMarcus Overhagen	size_t*									ioSize) {
77a0795c6fSMarcus Overhagen
78a0795c6fSMarcus Overhagen	if(*ioSize < sizeof(int32)) {
79a0795c6fSMarcus Overhagen		*ioSize = sizeof(int32);
80a0795c6fSMarcus Overhagen		return B_NO_MEMORY;
81a0795c6fSMarcus Overhagen	}
82a0795c6fSMarcus Overhagen
83a0795c6fSMarcus Overhagen	switch(parameterID) {
84a0795c6fSMarcus Overhagen		// input format restrictions (0='wildcard')
85a0795c6fSMarcus Overhagen		case P_INPUT_FORMAT:
86a0795c6fSMarcus Overhagen			*(uint32*)data = inputFormat.format;
87a0795c6fSMarcus Overhagen			break;
88a0795c6fSMarcus Overhagen
89a0795c6fSMarcus Overhagen		case P_INPUT_CHANNEL_COUNT:
90a0795c6fSMarcus Overhagen			*(uint32*)data = inputFormat.channel_count;
91a0795c6fSMarcus Overhagen			break;
92a0795c6fSMarcus Overhagen
93a0795c6fSMarcus Overhagen		// output format restrictions (0='wildcard')
94a0795c6fSMarcus Overhagen		case P_OUTPUT_FORMAT:
95a0795c6fSMarcus Overhagen			*(uint32*)data = outputFormat.format;
96a0795c6fSMarcus Overhagen			PRINT(("P_OUTPUT_FORMAT retrieved\n")); //+++++
97a0795c6fSMarcus Overhagen			break;
98a0795c6fSMarcus Overhagen
99a0795c6fSMarcus Overhagen		case P_OUTPUT_CHANNEL_COUNT:
100a0795c6fSMarcus Overhagen			*(uint32*)data = outputFormat.channel_count;
101a0795c6fSMarcus Overhagen			break;
102a0795c6fSMarcus Overhagen
103a0795c6fSMarcus Overhagen		default:
104a0795c6fSMarcus Overhagen			return B_BAD_INDEX;
105a0795c6fSMarcus Overhagen	}
106a0795c6fSMarcus Overhagen
107a0795c6fSMarcus Overhagen	return B_OK;
108a0795c6fSMarcus Overhagen}
109a0795c6fSMarcus Overhagen
110a0795c6fSMarcus Overhagenvoid _AudioAdapterParams::populateGroup(
111a0795c6fSMarcus Overhagen	BParameterGroup* 				group) {
112a0795c6fSMarcus Overhagen
113a0795c6fSMarcus Overhagen	BParameterGroup* inputGroup = group->MakeGroup("Input Format");
114a0795c6fSMarcus Overhagen
115a0795c6fSMarcus Overhagen	BNullParameter* groupName;
116a0795c6fSMarcus Overhagen	BDiscreteParameter* param;
117a0795c6fSMarcus Overhagen
118a0795c6fSMarcus Overhagen	groupName = inputGroup->MakeNullParameter(
119a0795c6fSMarcus Overhagen		0, B_MEDIA_NO_TYPE, "Input Format", B_GENERIC);
120a0795c6fSMarcus Overhagen
121a0795c6fSMarcus Overhagen	param = inputGroup->MakeDiscreteParameter(
122a0795c6fSMarcus Overhagen		P_INPUT_FORMAT,
123a0795c6fSMarcus Overhagen		B_MEDIA_NO_TYPE,
1247974d3dcSStephan Aßmus		"Sample format:",
125a0795c6fSMarcus Overhagen		B_GENERIC);
126a0795c6fSMarcus Overhagen	param->AddItem(
127a0795c6fSMarcus Overhagen		0,
128a0795c6fSMarcus Overhagen		"*");
129a0795c6fSMarcus Overhagen	param->AddItem(
130a0795c6fSMarcus Overhagen		media_multi_audio_format::B_AUDIO_FLOAT,
131a0795c6fSMarcus Overhagen		"float");
132a0795c6fSMarcus Overhagen	param->AddItem(
133a0795c6fSMarcus Overhagen		media_multi_audio_format::B_AUDIO_SHORT,
134a0795c6fSMarcus Overhagen		"short");
135a0795c6fSMarcus Overhagen	param->AddItem(
136a0795c6fSMarcus Overhagen		media_multi_audio_format::B_AUDIO_INT,
137a0795c6fSMarcus Overhagen		"int32");
138a0795c6fSMarcus Overhagen	param->AddItem(
139a0795c6fSMarcus Overhagen		media_multi_audio_format::B_AUDIO_UCHAR,
140a0795c6fSMarcus Overhagen		"uint8");
141a0795c6fSMarcus Overhagen
142a0795c6fSMarcus Overhagen	param = inputGroup->MakeDiscreteParameter(
143a0795c6fSMarcus Overhagen		P_INPUT_CHANNEL_COUNT,
144a0795c6fSMarcus Overhagen		B_MEDIA_NO_TYPE,
1457974d3dcSStephan Aßmus		"Channels:",
146a0795c6fSMarcus Overhagen		B_GENERIC);
147a0795c6fSMarcus Overhagen	param->AddItem(
148a0795c6fSMarcus Overhagen		0,
149a0795c6fSMarcus Overhagen		"*");
150a0795c6fSMarcus Overhagen	param->AddItem(
151a0795c6fSMarcus Overhagen		1,
152a0795c6fSMarcus Overhagen		"mono");
153a0795c6fSMarcus Overhagen	param->AddItem(
154a0795c6fSMarcus Overhagen		2,
155a0795c6fSMarcus Overhagen		"stereo");
156a0795c6fSMarcus Overhagen	param->AddItem(
157a0795c6fSMarcus Overhagen		4,
158a0795c6fSMarcus Overhagen		"4");
159a0795c6fSMarcus Overhagen	param->AddItem(
160a0795c6fSMarcus Overhagen		8,
161a0795c6fSMarcus Overhagen		"8");
162a0795c6fSMarcus Overhagen
163a0795c6fSMarcus Overhagen	BParameterGroup* outputGroup = group->MakeGroup("Output Format");
164a0795c6fSMarcus Overhagen
165a0795c6fSMarcus Overhagen	groupName = outputGroup->MakeNullParameter(
166a0795c6fSMarcus Overhagen		0, B_MEDIA_NO_TYPE, "Output Format", B_GENERIC);
167a0795c6fSMarcus Overhagen
168a0795c6fSMarcus Overhagen	param = outputGroup->MakeDiscreteParameter(
169a0795c6fSMarcus Overhagen		P_OUTPUT_FORMAT,
170a0795c6fSMarcus Overhagen		B_MEDIA_NO_TYPE,
1717974d3dcSStephan Aßmus		"Sample format:",
172a0795c6fSMarcus Overhagen		B_GENERIC);
173a0795c6fSMarcus Overhagen	param->AddItem(
174a0795c6fSMarcus Overhagen		0,
175a0795c6fSMarcus Overhagen		"*");
176a0795c6fSMarcus Overhagen	param->AddItem(
177a0795c6fSMarcus Overhagen		media_multi_audio_format::B_AUDIO_FLOAT,
178a0795c6fSMarcus Overhagen		"float");
179a0795c6fSMarcus Overhagen	param->AddItem(
180a0795c6fSMarcus Overhagen		media_multi_audio_format::B_AUDIO_SHORT,
181a0795c6fSMarcus Overhagen		"short");
182a0795c6fSMarcus Overhagen	param->AddItem(
183a0795c6fSMarcus Overhagen		media_multi_audio_format::B_AUDIO_INT,
184a0795c6fSMarcus Overhagen		"int32");
185a0795c6fSMarcus Overhagen	param->AddItem(
186a0795c6fSMarcus Overhagen		media_multi_audio_format::B_AUDIO_UCHAR,
187a0795c6fSMarcus Overhagen		"uint8");
188a0795c6fSMarcus Overhagen
189a0795c6fSMarcus Overhagen	param = outputGroup->MakeDiscreteParameter(
190a0795c6fSMarcus Overhagen		P_OUTPUT_CHANNEL_COUNT,
191a0795c6fSMarcus Overhagen		B_MEDIA_NO_TYPE,
1927974d3dcSStephan Aßmus		"Channels:",
193a0795c6fSMarcus Overhagen		B_GENERIC);
194a0795c6fSMarcus Overhagen	param->AddItem(
195a0795c6fSMarcus Overhagen		0,
196a0795c6fSMarcus Overhagen		"*");
197a0795c6fSMarcus Overhagen	param->AddItem(
198a0795c6fSMarcus Overhagen		1,
199a0795c6fSMarcus Overhagen		"mono");
200a0795c6fSMarcus Overhagen	param->AddItem(
201a0795c6fSMarcus Overhagen		2,
202a0795c6fSMarcus Overhagen		"stereo");
203a0795c6fSMarcus Overhagen	param->AddItem(
204a0795c6fSMarcus Overhagen		4,
205a0795c6fSMarcus Overhagen		"4");
206a0795c6fSMarcus Overhagen	param->AddItem(
207a0795c6fSMarcus Overhagen		8,
208a0795c6fSMarcus Overhagen		"8");
209a0795c6fSMarcus Overhagen}
210a0795c6fSMarcus Overhagen
211a0795c6fSMarcus Overhagen// END -- AudioAdapterParams.cpp
212a0795c6fSMarcus Overhagen
213