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
23 #define ULONG CoreFoundation_ULONG
24 #define HRESULT CoreFoundation_HRESULT
25 #ifndef HAVE_AUDIOUNIT_AUDIOCOMPONENT_H
26 #include <CoreServices/CoreServices.h>
28 #include <AudioUnit/AudioUnit.h>
29 #include <AudioToolbox/AudioToolbox.h>
32 #undef STDMETHODCALLTYPE
33 #include "coreaudio.h"
34 #include "wine/debug.h"
36 #ifndef HAVE_AUDIOUNIT_AUDIOCOMPONENT_H
37 /* Define new AudioComponent Manager types for compatibility's sake */
38 typedef ComponentDescription AudioComponentDescription
;
41 #ifndef HAVE_AUGRAPHADDNODE
42 static inline OSStatus
AUGraphAddNode(AUGraph graph
, const AudioComponentDescription
*desc
, AUNode
*node
)
44 return AUGraphNewNode(graph
, desc
, 0, NULL
, node
);
47 static inline OSStatus
AUGraphNodeInfo(AUGraph graph
, AUNode node
, AudioComponentDescription
*desc
, AudioUnit
*au
)
49 return AUGraphGetNodeInfo(graph
, node
, desc
, 0, NULL
, au
);
53 WINE_DEFAULT_DEBUG_CHANNEL(wave
);
54 WINE_DECLARE_DEBUG_CHANNEL(midi
);
56 int AudioUnit_SetVolume(AudioUnit au
, float left
, float right
)
61 if (!once
++) FIXME("independent left/right volume not implemented (%f, %f)\n", left
, right
);
63 err
= AudioUnitSetParameter(au
, kHALOutputParam_Volume
, kAudioUnitParameterFlag_Output
, 0, left
, 0);
67 ERR("AudioUnitSetParameter return an error %s\n", wine_dbgstr_fourcc(err
));
73 int AudioUnit_GetVolume(AudioUnit au
, float *left
, float *right
)
78 if (!once
++) FIXME("independent left/right volume not implemented\n");
80 err
= AudioUnitGetParameter(au
, kHALOutputParam_Volume
, kAudioUnitParameterFlag_Output
, 0, left
);
83 ERR("AudioUnitGetParameter return an error %s\n", wine_dbgstr_fourcc(err
));
94 int SynthUnit_CreateDefaultSynthUnit(AUGraph
*graph
, AudioUnit
*synth
)
97 AudioComponentDescription desc
;
101 err
= NewAUGraph(graph
);
104 ERR_(midi
)("NewAUGraph return %s\n", wine_dbgstr_fourcc(err
));
108 desc
.componentManufacturer
= kAudioUnitManufacturer_Apple
;
109 desc
.componentFlags
= 0;
110 desc
.componentFlagsMask
= 0;
112 /* create synth node */
113 desc
.componentType
= kAudioUnitType_MusicDevice
;
114 desc
.componentSubType
= kAudioUnitSubType_DLSSynth
;
116 err
= AUGraphAddNode(*graph
, &desc
, &synthNode
);
119 ERR_(midi
)("AUGraphAddNode cannot create synthNode : %s\n", wine_dbgstr_fourcc(err
));
123 /* create out node */
124 desc
.componentType
= kAudioUnitType_Output
;
125 desc
.componentSubType
= kAudioUnitSubType_DefaultOutput
;
127 err
= AUGraphAddNode(*graph
, &desc
, &outNode
);
130 ERR_(midi
)("AUGraphAddNode cannot create outNode %s\n", wine_dbgstr_fourcc(err
));
134 err
= AUGraphOpen(*graph
);
137 ERR_(midi
)("AUGraphOpen return %s\n", wine_dbgstr_fourcc(err
));
141 /* connecting the nodes */
142 err
= AUGraphConnectNodeInput(*graph
, synthNode
, 0, outNode
, 0);
145 ERR_(midi
)("AUGraphConnectNodeInput cannot connect synthNode to outNode : %s\n", wine_dbgstr_fourcc(err
));
149 /* Get the synth unit */
150 err
= AUGraphNodeInfo(*graph
, synthNode
, 0, synth
);
153 ERR_(midi
)("AUGraphNodeInfo return %s\n", wine_dbgstr_fourcc(err
));
160 int SynthUnit_Initialize(AudioUnit synth
, AUGraph graph
)
162 OSStatus err
= noErr
;
164 err
= AUGraphInitialize(graph
);
167 ERR_(midi
)("AUGraphInitialize(%p) return %s\n", graph
, wine_dbgstr_fourcc(err
));
171 err
= AUGraphStart(graph
);
174 ERR_(midi
)("AUGraphStart(%p) return %s\n", graph
, wine_dbgstr_fourcc(err
));
181 int SynthUnit_Close(AUGraph graph
)
183 OSStatus err
= noErr
;
185 err
= AUGraphStop(graph
);
188 ERR_(midi
)("AUGraphStop(%p) return %s\n", graph
, wine_dbgstr_fourcc(err
));
192 err
= DisposeAUGraph(graph
);
195 ERR_(midi
)("DisposeAUGraph(%p) return %s\n", graph
, wine_dbgstr_fourcc(err
));