2 * Wine Driver for CoreAudio / AudioUnit
4 * Copyright 2005, 2006 Emmanuel Maillard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(wave);
26 #ifdef HAVE_AUDIOUNIT_AUDIOUNIT_H
27 #include <AudioUnit/AudioUnit.h>
29 extern OSStatus CoreAudio_woAudioUnitIOProc(void *inRefCon,
30 AudioUnitRenderActionFlags *ioActionFlags,
31 const AudioTimeStamp *inTimeStamp,
33 UInt32 inNumberFrames,
34 AudioBufferList *ioData);
36 int AudioUnit_CreateDefaultAudioUnit(void *wwo, AudioUnit *au)
40 ComponentDescription desc;
41 AURenderCallbackStruct callbackStruct;
43 desc.componentType = kAudioUnitType_Output;
44 desc.componentSubType = kAudioUnitSubType_DefaultOutput;
45 desc.componentManufacturer = kAudioUnitManufacturer_Apple;
46 desc.componentFlags = 0;
47 desc.componentFlagsMask = 0;
49 comp = FindNextComponent(NULL, &desc);
53 err = OpenAComponent(comp, au);
57 callbackStruct.inputProc = CoreAudio_woAudioUnitIOProc;
58 callbackStruct.inputProcRefCon = wwo;
60 err = AudioUnitSetProperty( *au,
61 kAudioUnitProperty_SetRenderCallback,
62 kAudioUnitScope_Input,
65 sizeof(callbackStruct));
66 return (err == noErr);
69 int AudioUnit_CloseAudioUnit(AudioUnit au)
71 OSStatus err = CloseComponent(au);
72 return (err == noErr);
75 int AudioUnit_InitializeWithStreamDescription(AudioUnit au, AudioStreamBasicDescription *stream)
79 err = AudioUnitSetProperty(au, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input,
80 0, stream, sizeof(*stream));
84 ERR("AudioUnitSetProperty return an error %c%c%c%c\n", (char) (err >> 24), (char) (err >> 16), (char) (err >> 8), (char) err);
88 err = AudioUnitInitialize(au);
91 ERR("AudioUnitInitialize return an error %c%c%c%c\n", (char) (err >> 24), (char) (err >> 16), (char) (err >> 8), (char) err);
97 int AudioUnit_SetVolume(AudioUnit au, float left, float right)
101 err = AudioUnitSetParameter(au, kHALOutputParam_Volume, kAudioUnitParameterFlag_Output, 0, left, 0);
105 ERR("AudioUnitSetParameter return an error %c%c%c%c\n", (char) (err >> 24), (char) (err >> 16), (char) (err >> 8), (char) err);
111 int AudioUnit_GetVolume(AudioUnit au, float *left, float *right)
113 OSStatus err = noErr;
115 err = AudioUnitGetParameter(au, kHALOutputParam_Volume, kAudioUnitParameterFlag_Output, 0, left);
118 ERR("AudioUnitGetParameter return an error %c%c%c%c\n", (char) (err >> 24), (char) (err >> 16), (char) (err >> 8), (char) err);