repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / cortex / addons / AudioAdapter / AudioAdapterParams.cpp
blobbdb2d21f1aff982710db30d4c8d5e736040914b9
1 /*
2 * Copyright (c) 1999-2000, Eric Moon.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // AudioAdapterParams.cpp
34 #include "AudioAdapterParams.h"
36 #include <Debug.h>
37 #include <ParameterWeb.h>
39 status_t
40 _AudioAdapterParams::store(int32 parameterID, const void* data, size_t size)
42 if (size < sizeof(int32))
43 return B_NO_MEMORY;
45 const uint32 d = *(uint32*)data;
47 switch (parameterID) {
48 // input format restrictions (0='wildcard')
49 case P_INPUT_FORMAT:
50 inputFormat.format = d;
51 break;
53 case P_INPUT_CHANNEL_COUNT:
54 inputFormat.channel_count = d;
55 break;
57 // output format restrictions (0='wildcard')
58 case P_OUTPUT_FORMAT:
59 outputFormat.format = d;
60 break;
62 case P_OUTPUT_CHANNEL_COUNT:
63 outputFormat.channel_count = d;
64 break;
66 default:
67 return B_BAD_INDEX;
70 return B_OK;
73 status_t _AudioAdapterParams::retrieve(
74 int32 parameterID,
75 void* data,
76 size_t* ioSize) {
78 if(*ioSize < sizeof(int32)) {
79 *ioSize = sizeof(int32);
80 return B_NO_MEMORY;
83 switch(parameterID) {
84 // input format restrictions (0='wildcard')
85 case P_INPUT_FORMAT:
86 *(uint32*)data = inputFormat.format;
87 break;
89 case P_INPUT_CHANNEL_COUNT:
90 *(uint32*)data = inputFormat.channel_count;
91 break;
93 // output format restrictions (0='wildcard')
94 case P_OUTPUT_FORMAT:
95 *(uint32*)data = outputFormat.format;
96 PRINT(("P_OUTPUT_FORMAT retrieved\n")); //+++++
97 break;
99 case P_OUTPUT_CHANNEL_COUNT:
100 *(uint32*)data = outputFormat.channel_count;
101 break;
103 default:
104 return B_BAD_INDEX;
107 return B_OK;
110 void _AudioAdapterParams::populateGroup(
111 BParameterGroup* group) {
113 BParameterGroup* inputGroup = group->MakeGroup("Input Format");
115 BNullParameter* groupName;
116 BDiscreteParameter* param;
118 groupName = inputGroup->MakeNullParameter(
119 0, B_MEDIA_NO_TYPE, "Input Format", B_GENERIC);
121 param = inputGroup->MakeDiscreteParameter(
122 P_INPUT_FORMAT,
123 B_MEDIA_NO_TYPE,
124 "Sample format:",
125 B_GENERIC);
126 param->AddItem(
128 "*");
129 param->AddItem(
130 media_multi_audio_format::B_AUDIO_FLOAT,
131 "float");
132 param->AddItem(
133 media_multi_audio_format::B_AUDIO_SHORT,
134 "short");
135 param->AddItem(
136 media_multi_audio_format::B_AUDIO_INT,
137 "int32");
138 param->AddItem(
139 media_multi_audio_format::B_AUDIO_UCHAR,
140 "uint8");
142 param = inputGroup->MakeDiscreteParameter(
143 P_INPUT_CHANNEL_COUNT,
144 B_MEDIA_NO_TYPE,
145 "Channels:",
146 B_GENERIC);
147 param->AddItem(
149 "*");
150 param->AddItem(
152 "mono");
153 param->AddItem(
155 "stereo");
156 param->AddItem(
158 "4");
159 param->AddItem(
161 "8");
163 BParameterGroup* outputGroup = group->MakeGroup("Output Format");
165 groupName = outputGroup->MakeNullParameter(
166 0, B_MEDIA_NO_TYPE, "Output Format", B_GENERIC);
168 param = outputGroup->MakeDiscreteParameter(
169 P_OUTPUT_FORMAT,
170 B_MEDIA_NO_TYPE,
171 "Sample format:",
172 B_GENERIC);
173 param->AddItem(
175 "*");
176 param->AddItem(
177 media_multi_audio_format::B_AUDIO_FLOAT,
178 "float");
179 param->AddItem(
180 media_multi_audio_format::B_AUDIO_SHORT,
181 "short");
182 param->AddItem(
183 media_multi_audio_format::B_AUDIO_INT,
184 "int32");
185 param->AddItem(
186 media_multi_audio_format::B_AUDIO_UCHAR,
187 "uint8");
189 param = outputGroup->MakeDiscreteParameter(
190 P_OUTPUT_CHANNEL_COUNT,
191 B_MEDIA_NO_TYPE,
192 "Channels:",
193 B_GENERIC);
194 param->AddItem(
196 "*");
197 param->AddItem(
199 "mono");
200 param->AddItem(
202 "stereo");
203 param->AddItem(
205 "4");
206 param->AddItem(
208 "8");
211 // END -- AudioAdapterParams.cpp