1 // AudioAdapterParams.cpp 2 3 #include "AudioAdapterParams.h" 4 5 #include <Debug.h> 6 #include <ParameterWeb.h> 7 8 status_t 9 _AudioAdapterParams::store(parameterID, const void* data, size_t size) 10 { 11 if (size < sizeof(int32)) 12 return B_NO_MEMORY; 13 14 const uint32 d = *(uint32*)data; 15 16 switch (parameterID) { 17 // input format restrictions (0='wildcard') 18 case P_INPUT_FORMAT: 19 inputFormat.format = d; 20 break; 21 22 case P_INPUT_CHANNEL_COUNT: 23 inputFormat.channel_count = d; 24 break; 25 26 // output format restrictions (0='wildcard') 27 case P_OUTPUT_FORMAT: 28 outputFormat.format = d; 29 break; 30 31 case P_OUTPUT_CHANNEL_COUNT: 32 outputFormat.channel_count = d; 33 break; 34 35 default: 36 return B_BAD_INDEX; 37 } 38 39 return B_OK; 40 } 41 42 status_t _AudioAdapterParams::retrieve( 43 int32 parameterID, 44 void* data, 45 size_t* ioSize) { 46 47 if(*ioSize < sizeof(int32)) { 48 *ioSize = sizeof(int32); 49 return B_NO_MEMORY; 50 } 51 52 switch(parameterID) { 53 // input format restrictions (0='wildcard') 54 case P_INPUT_FORMAT: 55 *(uint32*)data = inputFormat.format; 56 break; 57 58 case P_INPUT_CHANNEL_COUNT: 59 *(uint32*)data = inputFormat.channel_count; 60 break; 61 62 // output format restrictions (0='wildcard') 63 case P_OUTPUT_FORMAT: 64 *(uint32*)data = outputFormat.format; 65 PRINT(("P_OUTPUT_FORMAT retrieved\n")); //+++++ 66 break; 67 68 case P_OUTPUT_CHANNEL_COUNT: 69 *(uint32*)data = outputFormat.channel_count; 70 break; 71 72 default: 73 return B_BAD_INDEX; 74 } 75 76 return B_OK; 77 } 78 79 void _AudioAdapterParams::populateGroup( 80 BParameterGroup* group) { 81 82 BParameterGroup* inputGroup = group->MakeGroup("Input Format"); 83 84 BNullParameter* groupName; 85 BDiscreteParameter* param; 86 87 groupName = inputGroup->MakeNullParameter( 88 0, B_MEDIA_NO_TYPE, "Input Format", B_GENERIC); 89 90 param = inputGroup->MakeDiscreteParameter( 91 P_INPUT_FORMAT, 92 B_MEDIA_NO_TYPE, 93 "Sample Format", 94 B_GENERIC); 95 param->AddItem( 96 0, 97 "*"); 98 param->AddItem( 99 media_multi_audio_format::B_AUDIO_FLOAT, 100 "float"); 101 param->AddItem( 102 media_multi_audio_format::B_AUDIO_SHORT, 103 "short"); 104 param->AddItem( 105 media_multi_audio_format::B_AUDIO_INT, 106 "int32"); 107 param->AddItem( 108 media_multi_audio_format::B_AUDIO_UCHAR, 109 "uint8"); 110 111 param = inputGroup->MakeDiscreteParameter( 112 P_INPUT_CHANNEL_COUNT, 113 B_MEDIA_NO_TYPE, 114 "Channels", 115 B_GENERIC); 116 param->AddItem( 117 0, 118 "*"); 119 param->AddItem( 120 1, 121 "mono"); 122 param->AddItem( 123 2, 124 "stereo"); 125 param->AddItem( 126 4, 127 "4"); 128 param->AddItem( 129 8, 130 "8"); 131 132 BParameterGroup* outputGroup = group->MakeGroup("Output Format"); 133 134 groupName = outputGroup->MakeNullParameter( 135 0, B_MEDIA_NO_TYPE, "Output Format", B_GENERIC); 136 137 param = outputGroup->MakeDiscreteParameter( 138 P_OUTPUT_FORMAT, 139 B_MEDIA_NO_TYPE, 140 "Sample Format", 141 B_GENERIC); 142 param->AddItem( 143 0, 144 "*"); 145 param->AddItem( 146 media_multi_audio_format::B_AUDIO_FLOAT, 147 "float"); 148 param->AddItem( 149 media_multi_audio_format::B_AUDIO_SHORT, 150 "short"); 151 param->AddItem( 152 media_multi_audio_format::B_AUDIO_INT, 153 "int32"); 154 param->AddItem( 155 media_multi_audio_format::B_AUDIO_UCHAR, 156 "uint8"); 157 158 param = outputGroup->MakeDiscreteParameter( 159 P_OUTPUT_CHANNEL_COUNT, 160 B_MEDIA_NO_TYPE, 161 "Channels", 162 B_GENERIC); 163 param->AddItem( 164 0, 165 "*"); 166 param->AddItem( 167 1, 168 "mono"); 169 param->AddItem( 170 2, 171 "stereo"); 172 param->AddItem( 173 4, 174 "4"); 175 param->AddItem( 176 8, 177 "8"); 178 } 179 180 // END -- AudioAdapterParams.cpp 181 182