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>
34 #undef STDMETHODCALLTYPE
35 #include "coreaudio.h"
36 #include "wine/debug.h"
38 #ifndef HAVE_AUDIOUNIT_AUDIOCOMPONENT_H
39 /* Define new AudioComponent Manager types for compatibility's sake */
40 typedef ComponentDescription AudioComponentDescription
;
43 #ifndef HAVE_AUGRAPHADDNODE
44 static inline OSStatus
AUGraphAddNode(AUGraph graph
, const AudioComponentDescription
*desc
, AUNode
*node
)
46 return AUGraphNewNode(graph
, desc
, 0, NULL
, node
);
49 static inline OSStatus
AUGraphNodeInfo(AUGraph graph
, AUNode node
, AudioComponentDescription
*desc
, AudioUnit
*au
)
51 return AUGraphGetNodeInfo(graph
, node
, desc
, 0, NULL
, au
);
55 WINE_DEFAULT_DEBUG_CHANNEL(wave
);
56 WINE_DECLARE_DEBUG_CHANNEL(midi
);
58 int AudioUnit_SetVolume(AudioUnit au
, float left
, float right
)
63 if (!once
++) FIXME("independent left/right volume not implemented (%f, %f)\n", left
, right
);
65 err
= AudioUnitSetParameter(au
, kHALOutputParam_Volume
, kAudioUnitParameterFlag_Output
, 0, left
, 0);
69 ERR("AudioUnitSetParameter return an error %s\n", wine_dbgstr_fourcc(err
));
75 int AudioUnit_GetVolume(AudioUnit au
, float *left
, float *right
)
80 if (!once
++) FIXME("independent left/right volume not implemented\n");
82 err
= AudioUnitGetParameter(au
, kHALOutputParam_Volume
, kAudioUnitParameterFlag_Output
, 0, left
);
85 ERR("AudioUnitGetParameter return an error %s\n", wine_dbgstr_fourcc(err
));
96 int SynthUnit_CreateDefaultSynthUnit(AUGraph
*graph
, AudioUnit
*synth
)
99 AudioComponentDescription desc
;
103 err
= NewAUGraph(graph
);
106 ERR_(midi
)("NewAUGraph return %s\n", wine_dbgstr_fourcc(err
));
110 desc
.componentManufacturer
= kAudioUnitManufacturer_Apple
;
111 desc
.componentFlags
= 0;
112 desc
.componentFlagsMask
= 0;
114 /* create synth node */
115 desc
.componentType
= kAudioUnitType_MusicDevice
;
116 desc
.componentSubType
= kAudioUnitSubType_DLSSynth
;
118 err
= AUGraphAddNode(*graph
, &desc
, &synthNode
);
121 ERR_(midi
)("AUGraphAddNode cannot create synthNode : %s\n", wine_dbgstr_fourcc(err
));
125 /* create out node */
126 desc
.componentType
= kAudioUnitType_Output
;
127 desc
.componentSubType
= kAudioUnitSubType_DefaultOutput
;
129 err
= AUGraphAddNode(*graph
, &desc
, &outNode
);
132 ERR_(midi
)("AUGraphAddNode cannot create outNode %s\n", wine_dbgstr_fourcc(err
));
136 err
= AUGraphOpen(*graph
);
139 ERR_(midi
)("AUGraphOpen return %s\n", wine_dbgstr_fourcc(err
));
143 /* connecting the nodes */
144 err
= AUGraphConnectNodeInput(*graph
, synthNode
, 0, outNode
, 0);
147 ERR_(midi
)("AUGraphConnectNodeInput cannot connect synthNode to outNode : %s\n", wine_dbgstr_fourcc(err
));
151 /* Get the synth unit */
152 err
= AUGraphNodeInfo(*graph
, synthNode
, 0, synth
);
155 ERR_(midi
)("AUGraphNodeInfo return %s\n", wine_dbgstr_fourcc(err
));
162 int SynthUnit_Initialize(AudioUnit synth
, AUGraph graph
)
164 OSStatus err
= noErr
;
166 err
= AUGraphInitialize(graph
);
169 ERR_(midi
)("AUGraphInitialize(%p) return %s\n", graph
, wine_dbgstr_fourcc(err
));
173 err
= AUGraphStart(graph
);
176 ERR_(midi
)("AUGraphStart(%p) return %s\n", graph
, wine_dbgstr_fourcc(err
));
183 int SynthUnit_Close(AUGraph graph
)
185 OSStatus err
= noErr
;
187 err
= AUGraphStop(graph
);
190 ERR_(midi
)("AUGraphStop(%p) return %s\n", graph
, wine_dbgstr_fourcc(err
));
194 err
= DisposeAUGraph(graph
);
197 ERR_(midi
)("DisposeAUGraph(%p) return %s\n", graph
, wine_dbgstr_fourcc(err
));