diff options
-rw-r--r-- | hw/xquartz/quartzAudio.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/hw/xquartz/quartzAudio.c b/hw/xquartz/quartzAudio.c index e4b49fcd8..708202b5b 100644 --- a/hw/xquartz/quartzAudio.c +++ b/hw/xquartz/quartzAudio.c @@ -62,7 +62,6 @@ typedef struct QuartzAudioRec { UInt32 curFrame; UInt32 remainingFrames; UInt32 totalFrames; - UInt32 bytesPerFrame; double sampleRate; UInt32 fadeLength; @@ -117,9 +116,9 @@ static void QuartzFillBuffer( unsigned int bufferFrameCount; float multiplier, v; int i; - + buffer = (float *)audiobuffer->mData; - bufferFrameCount = audiobuffer->mDataByteSize / data->bytesPerFrame; + bufferFrameCount = audiobuffer->mDataByteSize / (sizeof(float) * audiobuffer->mNumberChannels); frameCount = min(bufferFrameCount, data->remainingFrames); @@ -141,7 +140,7 @@ static void QuartzFillBuffer( data->prevFrame = 0; // adjust for space eaten by prev fade - buffer += audiobuffer->mNumberChannels*frame; + b += audiobuffer->mNumberChannels*frame; bufferFrameCount -= frame; frameCount = min(bufferFrameCount, data->remainingFrames); } @@ -204,7 +203,8 @@ QuartzAudioIOProc( if (wasPlaying && !data->playing) { OSStatus err; err = AudioDeviceStop(inDevice, QuartzAudioIOProc); - fprintf(stderr, "Error stopping audio device: %ld\n", (long int)err); + if(err != noErr) + fprintf(stderr, "Error stopping audio device: %ld\n", (long int)err); } pthread_mutex_unlock(&data->lock); return 0; @@ -263,16 +263,17 @@ void QuartzAudioInit(void) UInt32 propertySize; OSStatus status; AudioDeviceID outputDevice; - AudioStreamBasicDescription outputStreamDescription; double sampleRate; - + AudioObjectPropertyAddress devicePropertyAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; + AudioObjectPropertyAddress sampleRatePropertyAddress = { kAudioDevicePropertyNominalSampleRate, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; + // Get the default output device propertySize = sizeof(outputDevice); - status = AudioHardwareGetProperty( - kAudioHardwarePropertyDefaultOutputDevice, - &propertySize, &outputDevice); + status = AudioObjectGetPropertyData(kAudioObjectSystemObject, &devicePropertyAddress, + 0, NULL, + &propertySize, &outputDevice); if (status) { - ErrorF("QuartzAudioInit: AudioHardwareGetProperty returned %ld\n", + ErrorF("QuartzAudioInit: AudioObjectGetPropertyData(output device) returned %ld\n", (long)status); return; } @@ -282,23 +283,22 @@ void QuartzAudioInit(void) } // Get the basic device description - propertySize = sizeof(outputStreamDescription); - status = AudioDeviceGetProperty(outputDevice, 0, FALSE, - kAudioDevicePropertyStreamFormat, - &propertySize, &outputStreamDescription); + sampleRate = 0.; + propertySize = sizeof(sampleRate); + status = AudioObjectGetPropertyData(outputDevice, &sampleRatePropertyAddress, + 0, NULL, + &propertySize, &sampleRate); if (status) { - ErrorF("QuartzAudioInit: GetProperty(stream format) returned %ld\n", + ErrorF("QuartzAudioInit: AudioObjectGetPropertyData(sample rate) returned %ld\n", (long)status); return; } - sampleRate = outputStreamDescription.mSampleRate; // Fill in the playback data data.frequency = 0; data.amplitude = 0; data.curFrame = 0; data.remainingFrames = 0; - data.bytesPerFrame = outputStreamDescription.mBytesPerFrame; data.sampleRate = sampleRate; // data.bufferByteCount = bufferByteCount; data.playing = FALSE; |