1 /* 2 * Copyright (c) 1999-2000, Eric Moon. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions, and the following disclaimer. 11 * 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. 15 * 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. 18 * 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. 29 */ 30 31 32 // AudioAdapterParams.cpp 33 34 #include "AudioAdapterParams.h" 35 36 #include <Debug.h> 37 #include <ParameterWeb.h> 38 39 status_t 40 _AudioAdapterParams::store(int32 parameterID, const void* data, size_t size) 41 { 42 if (size < sizeof(int32)) 43 return B_NO_MEMORY; 44 45 const uint32 d = *(uint32*)data; 46 47 switch (parameterID) { 48 // input format restrictions (0='wildcard') 49 case P_INPUT_FORMAT: 50 inputFormat.format = d; 51 break; 52 53 case P_INPUT_CHANNEL_COUNT: 54 inputFormat.channel_count = d; 55 break; 56 57 // output format restrictions (0='wildcard') 58 case P_OUTPUT_FORMAT: 59 outputFormat.format = d; 60 break; 61 62 case P_OUTPUT_CHANNEL_COUNT: 63 outputFormat.channel_count = d; 64 break; 65 66 default: 67 return B_BAD_INDEX; 68 } 69 70 return B_OK; 71 } 72 73 status_t _AudioAdapterParams::retrieve( 74 int32 parameterID, 75 void* data, 76 size_t* ioSize) { 77 78 if(*ioSize < sizeof(int32)) { 79 *ioSize = sizeof(int32); 80 return B_NO_MEMORY; 81 } 82 83 switch(parameterID) { 84 // input format restrictions (0='wildcard') 85 case P_INPUT_FORMAT: 86 *(uint32*)data = inputFormat.format; 87 break; 88 89 case P_INPUT_CHANNEL_COUNT: 90 *(uint32*)data = inputFormat.channel_count; 91 break; 92 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; 98 99 case P_OUTPUT_CHANNEL_COUNT: 100 *(uint32*)data = outputFormat.channel_count; 101 break; 102 103 default: 104 return B_BAD_INDEX; 105 } 106 107 return B_OK; 108 } 109 110 void _AudioAdapterParams::populateGroup( 111 BParameterGroup* group) { 112 113 BParameterGroup* inputGroup = group->MakeGroup("Input Format"); 114 115 BNullParameter* groupName; 116 BDiscreteParameter* param; 117 118 groupName = inputGroup->MakeNullParameter( 119 0, B_MEDIA_NO_TYPE, "Input Format", B_GENERIC); 120 121 param = inputGroup->MakeDiscreteParameter( 122 P_INPUT_FORMAT, 123 B_MEDIA_NO_TYPE, 124 "Sample format:", 125 B_GENERIC); 126 param->AddItem( 127 0, 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"); 141 142 param = inputGroup->MakeDiscreteParameter( 143 P_INPUT_CHANNEL_COUNT, 144 B_MEDIA_NO_TYPE, 145 "Channels:", 146 B_GENERIC); 147 param->AddItem( 148 0, 149 "*"); 150 param->AddItem( 151 1, 152 "mono"); 153 param->AddItem( 154 2, 155 "stereo"); 156 param->AddItem( 157 4, 158 "4"); 159 param->AddItem( 160 8, 161 "8"); 162 163 BParameterGroup* outputGroup = group->MakeGroup("Output Format"); 164 165 groupName = outputGroup->MakeNullParameter( 166 0, B_MEDIA_NO_TYPE, "Output Format", B_GENERIC); 167 168 param = outputGroup->MakeDiscreteParameter( 169 P_OUTPUT_FORMAT, 170 B_MEDIA_NO_TYPE, 171 "Sample format:", 172 B_GENERIC); 173 param->AddItem( 174 0, 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"); 188 189 param = outputGroup->MakeDiscreteParameter( 190 P_OUTPUT_CHANNEL_COUNT, 191 B_MEDIA_NO_TYPE, 192 "Channels:", 193 B_GENERIC); 194 param->AddItem( 195 0, 196 "*"); 197 param->AddItem( 198 1, 199 "mono"); 200 param->AddItem( 201 2, 202 "stereo"); 203 param->AddItem( 204 4, 205 "4"); 206 param->AddItem( 207 8, 208 "8"); 209 } 210 211 // END -- AudioAdapterParams.cpp 212 213