Mac OS X audio backend now supports int32/float32.
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402050
This commit is contained in:
parent
3e4e137122
commit
28f57c5b3a
1 changed files with 47 additions and 16 deletions
|
@ -207,25 +207,56 @@ Core_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||||
Component comp;
|
Component comp;
|
||||||
ComponentDescription desc;
|
ComponentDescription desc;
|
||||||
struct AudioUnitInputCallback callback;
|
struct AudioUnitInputCallback callback;
|
||||||
AudioStreamBasicDescription requestedDesc;
|
AudioStreamBasicDescription desc;
|
||||||
|
SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
|
||||||
|
int valid_datatype = 0;
|
||||||
|
|
||||||
/* Setup a AudioStreamBasicDescription with the requested format */
|
/* Setup a AudioStreamBasicDescription with the requested format */
|
||||||
requestedDesc.mFormatID = kAudioFormatLinearPCM;
|
memset(&desc, '\0', sizeof (AudioStreamBasicDescription));
|
||||||
requestedDesc.mFormatFlags = kLinearPCMFormatFlagIsPacked;
|
desc.mFormatID = kAudioFormatLinearPCM;
|
||||||
requestedDesc.mChannelsPerFrame = spec->channels;
|
desc.mFormatFlags = kLinearPCMFormatFlagIsPacked;
|
||||||
requestedDesc.mSampleRate = spec->freq;
|
desc.mChannelsPerFrame = spec->channels;
|
||||||
|
desc.mSampleRate = spec->freq;
|
||||||
|
desc.mFramesPerPacket = 1;
|
||||||
|
|
||||||
requestedDesc.mBitsPerChannel = spec->format & 0xFF;
|
while ((!valid_datatype) && (test_format)) {
|
||||||
if (spec->format & 0x8000)
|
spec->format = test_format;
|
||||||
requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
|
desc.mFormatFlags = 0;
|
||||||
if (spec->format & 0x1000)
|
/* Just a list of valid SDL formats, so people don't pass junk here. */
|
||||||
requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
|
switch (test_format) {
|
||||||
|
case AUDIO_U8:
|
||||||
|
case AUDIO_S8:
|
||||||
|
case AUDIO_U16LSB:
|
||||||
|
case AUDIO_S16LSB:
|
||||||
|
case AUDIO_U16MSB:
|
||||||
|
case AUDIO_S16MSB:
|
||||||
|
case AUDIO_S32LSB:
|
||||||
|
case AUDIO_S32MSB:
|
||||||
|
case AUDIO_F32LSB:
|
||||||
|
case AUDIO_F32MSB:
|
||||||
|
valid_datatype = 1;
|
||||||
|
desc.mBitsPerChannel = SDL_AUDIO_BITSIZE(spec->format);
|
||||||
|
|
||||||
requestedDesc.mFramesPerPacket = 1;
|
if (SDL_AUDIO_ISFLOAT(spec->format))
|
||||||
requestedDesc.mBytesPerFrame =
|
desc.mFormatFlags |= kLinearPCMFormatFlagIsFloat;
|
||||||
requestedDesc.mBitsPerChannel * requestedDesc.mChannelsPerFrame / 8;
|
else if (SDL_AUDIO_ISSIGNED(spec->format))
|
||||||
requestedDesc.mBytesPerPacket =
|
desc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
|
||||||
requestedDesc.mBytesPerFrame * requestedDesc.mFramesPerPacket;
|
|
||||||
|
if (SDL_AUDIO_ISBIGENDIAN(spec->format))
|
||||||
|
desc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!valid_datatype) { /* shouldn't happen, but just in case... */
|
||||||
|
SDL_SetError("Unsupported audio format");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
desc.mBytesPerFrame =
|
||||||
|
desc.mBitsPerChannel * desc.mChannelsPerFrame / 8;
|
||||||
|
desc.mBytesPerPacket =
|
||||||
|
desc.mBytesPerFrame * desc.mFramesPerPacket;
|
||||||
|
|
||||||
|
|
||||||
/* Locate the default output audio unit */
|
/* Locate the default output audio unit */
|
||||||
|
@ -252,7 +283,7 @@ Core_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
||||||
kAudioUnitProperty_StreamFormat,
|
kAudioUnitProperty_StreamFormat,
|
||||||
kAudioUnitScope_Input,
|
kAudioUnitScope_Input,
|
||||||
0,
|
0,
|
||||||
&requestedDesc, sizeof(requestedDesc));
|
&desc, sizeof (desc));
|
||||||
CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)")
|
CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)")
|
||||||
/* Set the audio callback */
|
/* Set the audio callback */
|
||||||
callback.inputProc = audioCallback;
|
callback.inputProc = audioCallback;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue