Mercurial > mplayer.hg
comparison libao2/ao_macosx.c @ 15486:1f3e8d675f0a
simplifies the format matching logic. Chris Roccati <roccati@pobox.com>
author | nplourde |
---|---|
date | Mon, 16 May 2005 00:16:43 +0000 |
parents | 324046793f7c |
children | f46eae5e271b |
comparison
equal
deleted
inserted
replaced
15485:62074f6caca7 | 15486:1f3e8d675f0a |
---|---|
174 case AOCONTROL_GET_DEVICE: | 174 case AOCONTROL_GET_DEVICE: |
175 /* unimplemented/meaningless */ | 175 /* unimplemented/meaningless */ |
176 return CONTROL_FALSE; | 176 return CONTROL_FALSE; |
177 case AOCONTROL_GET_VOLUME: | 177 case AOCONTROL_GET_VOLUME: |
178 propertySize=sizeof(stereoChannels); | 178 propertySize=sizeof(stereoChannels); |
179 status = AudioDeviceGetProperty(ao->outputDeviceID, NULL, 0, | 179 status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, |
180 kAudioDevicePropertyPreferredChannelsForStereo, &propertySize, | 180 kAudioDevicePropertyPreferredChannelsForStereo, &propertySize, |
181 &stereoChannels); | 181 &stereoChannels); |
182 // printf("OSX: stereochannels %d ; %d \n",stereoChannels[0],stereoChannels[1]); | 182 // printf("OSX: stereochannels %d ; %d \n",stereoChannels[0],stereoChannels[1]); |
183 propertySize=sizeof(volume); | 183 propertySize=sizeof(volume); |
184 status = AudioDeviceGetProperty(ao->outputDeviceID, stereoChannels[0], false, kAudioDevicePropertyVolumeScalar, &propertySize, &volume); | 184 status = AudioDeviceGetProperty(ao->outputDeviceID, stereoChannels[0], false, kAudioDevicePropertyVolumeScalar, &propertySize, &volume); |
187 status = AudioDeviceGetProperty(ao->outputDeviceID, stereoChannels[1], false, kAudioDevicePropertyVolumeScalar, &propertySize, &volume); | 187 status = AudioDeviceGetProperty(ao->outputDeviceID, stereoChannels[1], false, kAudioDevicePropertyVolumeScalar, &propertySize, &volume); |
188 vol->right=(int)(volume*100.0); | 188 vol->right=(int)(volume*100.0); |
189 return CONTROL_TRUE; | 189 return CONTROL_TRUE; |
190 case AOCONTROL_SET_VOLUME: | 190 case AOCONTROL_SET_VOLUME: |
191 propertySize=sizeof(stereoChannels); | 191 propertySize=sizeof(stereoChannels); |
192 status = AudioDeviceGetProperty(ao->outputDeviceID, NULL, 0, | 192 status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, |
193 kAudioDevicePropertyPreferredChannelsForStereo, &propertySize, | 193 kAudioDevicePropertyPreferredChannelsForStereo, &propertySize, |
194 &stereoChannels); | 194 &stereoChannels); |
195 // printf("OSX: stereochannels %d ; %d \n",stereoChannels[0],stereoChannels[1]); | 195 // printf("OSX: stereochannels %d ; %d \n",stereoChannels[0],stereoChannels[1]); |
196 propertySize=sizeof(volume); | 196 propertySize=sizeof(volume); |
197 volume=vol->left/100.0; | 197 volume=vol->left/100.0; |
297 propertySize = sizeof(ao->outputStreamBasicDescription); | 297 propertySize = sizeof(ao->outputStreamBasicDescription); |
298 memset(&ao->outputStreamBasicDescription,0,propertySize); | 298 memset(&ao->outputStreamBasicDescription,0,propertySize); |
299 ao->outputStreamBasicDescription.mSampleRate=rate; | 299 ao->outputStreamBasicDescription.mSampleRate=rate; |
300 ao->outputStreamBasicDescription.mFormatID=kAudioFormatLinearPCM; | 300 ao->outputStreamBasicDescription.mFormatID=kAudioFormatLinearPCM; |
301 ao->outputStreamBasicDescription.mChannelsPerFrame=channels; | 301 ao->outputStreamBasicDescription.mChannelsPerFrame=channels; |
302 switch(format&AF_FORMAT_BITS_MASK){ | |
303 case AF_FORMAT_8BIT: ao->outputStreamBasicDescription.mBitsPerChannel=8; break; | |
304 case AF_FORMAT_16BIT: ao->outputStreamBasicDescription.mBitsPerChannel=16; break; | |
305 case AF_FORMAT_24BIT: ao->outputStreamBasicDescription.mBitsPerChannel=24; break; | |
306 case AF_FORMAT_32BIT: ao->outputStreamBasicDescription.mBitsPerChannel=32; break; | |
307 } | |
308 if((format&AF_FORMAT_POINT_MASK)==AF_FORMAT_F){ | |
309 // float | |
310 ao->outputStreamBasicDescription.mFormatFlags=kAudioFormatFlagIsFloat|kAudioFormatFlagIsPacked; | |
311 } else if((format&AF_FORMAT_SIGN_MASK)==AF_FORMAT_SI){ | |
312 // signed int | |
313 ao->outputStreamBasicDescription.mFormatFlags=kAudioFormatFlagIsSignedInteger|kAudioFormatFlagIsPacked; | |
314 } else { | |
315 // unsigned int | |
316 ao->outputStreamBasicDescription.mFormatFlags=kAudioFormatFlagIsPacked; | |
317 } | |
318 if((format&AF_FORMAT_END_MASK)==AF_FORMAT_BE) | |
319 ao->outputStreamBasicDescription.mFormatFlags|=kAudioFormatFlagIsBigEndian; | |
320 | |
321 ao->outputStreamBasicDescription.mBytesPerPacket= | |
322 ao->outputStreamBasicDescription.mBytesPerFrame=channels*(ao->outputStreamBasicDescription.mBitsPerChannel/8); | |
323 ao->outputStreamBasicDescription.mFramesPerPacket=1; | |
324 | 302 |
325 print_format("wanted: ",&ao->outputStreamBasicDescription); | 303 print_format("wanted: ",&ao->outputStreamBasicDescription); |
326 | 304 |
327 // try 1: ask if it accepts our specific requirements? | 305 // try 1: ask if it accepts our specific requirements? |
328 propertySize = sizeof(ao->outputStreamBasicDescription); | 306 propertySize = sizeof(ao->outputStreamBasicDescription); |
329 // status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, kAudioStreamPropertyPhysicalFormatMatch, &propertySize, &ao->outputStreamBasicDescription); | 307 // status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, kAudioStreamPropertyPhysicalFormatMatch, &propertySize, &ao->outputStreamBasicDescription); |
330 status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, kAudioDevicePropertyStreamFormatMatch, &propertySize, &ao->outputStreamBasicDescription); | 308 status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, kAudioDevicePropertyStreamFormatMatch, &propertySize, &ao->outputStreamBasicDescription); |
331 if (status || ao->outputStreamBasicDescription.mSampleRate!=rate | 309 if (status) { |
332 || ao->outputStreamBasicDescription.mFormatID!=kAudioFormatLinearPCM) { | |
333 ao_msg(MSGT_AO,MSGL_V, "AudioDeviceGetProperty returned 0x%X when getting kAudioDevicePropertyStreamFormatMatch\n", (int)status); | 310 ao_msg(MSGT_AO,MSGL_V, "AudioDeviceGetProperty returned 0x%X when getting kAudioDevicePropertyStreamFormatMatch\n", (int)status); |
334 // failed (error, bad rate or bad type) | |
335 // try 2: set only rate & type, no format details (bits, channels etc) | |
336 propertySize = sizeof(ao->outputStreamBasicDescription); | |
337 memset(&ao->outputStreamBasicDescription,0,propertySize); | |
338 ao->outputStreamBasicDescription.mSampleRate=rate; | |
339 ao->outputStreamBasicDescription.mFormatID=kAudioFormatLinearPCM; | |
340 ao->outputStreamBasicDescription.mChannelsPerFrame=channels; | |
341 // status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, kAudioStreamPropertyPhysicalFormatMatch, &propertySize, &ao->outputStreamBasicDescription); | |
342 status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, kAudioDevicePropertyStreamFormatMatch, &propertySize, &ao->outputStreamBasicDescription); | |
343 if (status || ao->outputStreamBasicDescription.mFormatID!=kAudioFormatLinearPCM) { | |
344 ao_msg(MSGT_AO,MSGL_V, "AudioDeviceGetProperty returned 0x%X when getting kAudioDevicePropertyStreamFormatMatch\n", (int)status); | |
345 // failed again. (error or bad type) | |
346 // giving up... just read the default. | |
347 propertySize = sizeof(ao->outputStreamBasicDescription); | |
348 // status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, kAudioStreamPropertyPhysicalFormat, &propertySize, &ao->outputStreamBasicDescription); | |
349 status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, kAudioDevicePropertyStreamFormat, &propertySize, &ao->outputStreamBasicDescription); | |
350 if (status) { | |
351 // failed to read the default format - WTF? | |
352 ao_msg(MSGT_AO,MSGL_WARN, "AudioDeviceGetProperty returned 0x%X when getting kAudioDevicePropertyStreamFormat\n", (int)status); | |
353 return CONTROL_FALSE; | 311 return CONTROL_FALSE; |
354 } | |
355 } | |
356 } | 312 } |
357 | 313 |
358 // propertySize = sizeof(ao->outputStreamBasicDescription); | 314 // propertySize = sizeof(ao->outputStreamBasicDescription); |
359 // status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, kAudioDevicePropertyStreamFormatSupported, &propertySize, &ao->outputStreamBasicDescription); | 315 // status = AudioDeviceGetProperty(ao->outputDeviceID, 0, false, kAudioDevicePropertyStreamFormatSupported, &propertySize, &ao->outputStreamBasicDescription); |
360 // if (status) { | 316 // if (status) { |