aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xquartz/quartzAudio.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-02-24 18:34:17 +0000
committermarha <marha@users.sourceforge.net>2010-02-24 18:34:17 +0000
commit24bc15a386e37908396c3f6088f6fc98ceaa0f46 (patch)
treec66f27ec96c869f10ef53d73ed7dd5e5e0860605 /xorg-server/hw/xquartz/quartzAudio.c
parent6f0a8e51f20073ea01ac5dae8e5c4d49076fc65e (diff)
downloadvcxsrv-24bc15a386e37908396c3f6088f6fc98ceaa0f46.tar.gz
vcxsrv-24bc15a386e37908396c3f6088f6fc98ceaa0f46.tar.bz2
vcxsrv-24bc15a386e37908396c3f6088f6fc98ceaa0f46.zip
Git update 24/2/2010"
Diffstat (limited to 'xorg-server/hw/xquartz/quartzAudio.c')
-rw-r--r--xorg-server/hw/xquartz/quartzAudio.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/xorg-server/hw/xquartz/quartzAudio.c b/xorg-server/hw/xquartz/quartzAudio.c
index af63d18f5..708202b5b 100644
--- a/xorg-server/hw/xquartz/quartzAudio.c
+++ b/xorg-server/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,6 +203,8 @@ QuartzAudioIOProc(
if (wasPlaying && !data->playing) {
OSStatus err;
err = AudioDeviceStop(inDevice, QuartzAudioIOProc);
+ if(err != noErr)
+ fprintf(stderr, "Error stopping audio device: %ld\n", (long int)err);
}
pthread_mutex_unlock(&data->lock);
return 0;
@@ -262,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;
}
@@ -281,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;