changeset 15722:b53c4b26dc96

removes the use of AudioConverters. patch by Alexander Strange <alexander.strange@ithinksw.com>
author nplourde
date Tue, 14 Jun 2005 12:41:42 +0000
parents eec6ace22741
children ac7dcf4a1f8a
files libao2/ao_macosx.c
diffstat 1 files changed, 5 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_macosx.c	Tue Jun 14 05:33:34 2005 +0000
+++ b/libao2/ao_macosx.c	Tue Jun 14 12:41:42 2005 +0000
@@ -74,7 +74,6 @@
 {
   /* AudioUnit */
   AudioUnit theOutputUnit;
-  AudioConverterRef theConverter;
   int packetSize;
 
   /* Ring-buffer */
@@ -155,18 +154,13 @@
   return len;
 }
 
-/* end ring buffer stuff */
-
-OSStatus ACComplexInputProc(AudioConverterRef inAudioConverter, UInt32 *ioNumberDataPackets, AudioBufferList *ioData, AudioStreamPacketDescription **outDataPacketDescription, void *inUserData)
+OSStatus theRenderProc(void *inRefCon, AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
 {
 int amt=buf_used();
-int req=(*ioNumberDataPackets)*ao->packetSize;
+int req=(inNumFrames)*ao->packetSize;
 
 
 	ioData->mBuffers[0].mData = ao->chunk;
- 	ioData->mBuffers[0].mDataByteSize = req;
- 	
-// 	fprintf(stderr, "##### req=%d amt=%d #####\n", req, amt);
 
 	if(amt>req)
  		amt=req;
@@ -174,36 +168,11 @@
 	if(amt)
 		read_buffer((unsigned char *)ioData->mBuffers[0].mData, amt);
 
-	if(req-amt)
-		memset(ioData->mBuffers[0].mData+amt, 0, req-amt);
+	ioData->mBuffers[0].mDataByteSize = amt;
 
  	return noErr;
 }
 
-OSStatus theRenderProc(void *inRefCon, AudioUnitRenderActionFlags *inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumFrames, AudioBufferList *ioData)
-{
-OSStatus err = noErr;
-void *inInputDataProcUserData = NULL;
-AudioStreamPacketDescription *outPacketDescription = NULL;
-
-
-    err = AudioConverterFillComplexBuffer(ao->theConverter, ACComplexInputProc, inInputDataProcUserData, &inNumFrames, ioData, outPacketDescription);
-
-    /*Parameters for AudioConverterFillComplexBuffer()
-	    converter - the converter being used
-	    ACComplexInputProc() - input procedure to supply data to the Audio Converter
-	    inInputDataProcUserData - Used to hold any data that needs to be passed on.
-        inNumFrames - The amount of requested data.  On output, this number is the amount actually received.
-		ioData - Buffer of the converted data recieved on return
-		outPacketDescription - contains the format of the returned data.
-    */
-
-	if(err)
-		ao_msg(MSGT_AO, MSGL_WARN, "AudioConverterFillComplexBuffer failed status %-8d\n", err);
-
-    return err;
-}
-
 static int control(int cmd,void *arg){
 	switch (cmd) {
 	case AOCONTROL_SET_DEVICE:
@@ -333,13 +302,10 @@
 	}
 
 	size =  sizeof(AudioStreamBasicDescription);
-	err = AudioUnitGetProperty(ao->theOutputUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &outDesc, &size);
-	print_format("destination: ", &outDesc);	
-	err = AudioUnitSetProperty(ao->theOutputUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &outDesc, size);
+	err = AudioUnitSetProperty(ao->theOutputUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &inDesc, size);
 
-	err = AudioConverterNew(&inDesc, &outDesc, &(ao->theConverter));
 	if (err) {
-		ao_msg(MSGT_AO, MSGL_WARN, "Unable to create the AudioConverter component (err=%d)\n", err);
+		ao_msg(MSGT_AO, MSGL_WARN, "Unable to set the input format (err=%d)\n", err);
 		return CONTROL_FALSE;
 	}
 
@@ -417,7 +383,6 @@
 
   reset();
 
-  AudioConverterDispose(ao->theConverter);
   AudioOutputUnitStop(ao->theOutputUnit);
   AudioUnitUninitialize(ao->theOutputUnit);
   CloseComponent(ao->theOutputUnit);