author | bjarni |
Mon, 09 Oct 2006 21:42:18 +0000 | |
changeset 4788 | 76ed308037b1 |
parent 4077 | d4d440dd8925 |
child 5383 | ba6d46dd90c3 |
permissions | -rw-r--r-- |
2743
a6c91eb763e8
(svn r3288) Set svn properties on cocoa related files, and add Id tag.
peter1138
parents:
2736
diff
changeset
|
1 |
/* $Id$ */ |
a6c91eb763e8
(svn r3288) Set svn properties on cocoa related files, and add Id tag.
peter1138
parents:
2736
diff
changeset
|
2 |
|
2953
4d933ef9a41f
(svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents:
2837
diff
changeset
|
3 |
/***************************************************************************** |
4d933ef9a41f
(svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents:
2837
diff
changeset
|
4 |
* Cocoa sound driver * |
4d933ef9a41f
(svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents:
2837
diff
changeset
|
5 |
* Known things left to do: * |
4d933ef9a41f
(svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents:
2837
diff
changeset
|
6 |
* - Might need to do endian checking for it to work on both ppc and x86 * |
4d933ef9a41f
(svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents:
2837
diff
changeset
|
7 |
*****************************************************************************/ |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
8 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
9 |
#ifdef WITH_COCOA |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
10 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
11 |
#include <AudioUnit/AudioUnit.h> |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
12 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
13 |
/* Name conflict */ |
2953
4d933ef9a41f
(svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents:
2837
diff
changeset
|
14 |
#define Rect OTTDRect |
4d933ef9a41f
(svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents:
2837
diff
changeset
|
15 |
#define Point OTTDPoint |
4d933ef9a41f
(svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents:
2837
diff
changeset
|
16 |
#define WindowClass OTTDWindowClass |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
17 |
/* Defined in stdbool.h */ |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
18 |
#ifndef __cplusplus |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
19 |
# ifndef __BEOS__ |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
20 |
# undef bool |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
21 |
# undef false |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
22 |
# undef true |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
23 |
# endif |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
24 |
#endif |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
25 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
26 |
#include "../stdafx.h" |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
27 |
#include "../openttd.h" |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
28 |
#include "../debug.h" |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
29 |
#include "../driver.h" |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
30 |
#include "../mixer.h" |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
31 |
#include "../sdl.h" |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
32 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
33 |
#include "cocoa_s.h" |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
34 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
35 |
#undef WindowClass |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
36 |
#undef Point |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
37 |
#undef Rect |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
38 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
39 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
40 |
static AudioUnit _outputAudioUnit; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
41 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
42 |
/* The CoreAudio callback */ |
2953
4d933ef9a41f
(svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents:
2837
diff
changeset
|
43 |
static OSStatus audioCallback(void *inRefCon, AudioUnitRenderActionFlags inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, AudioBuffer *ioData) |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
44 |
{ |
2977 | 45 |
MxMixSamples(ioData->mData, ioData->mDataByteSize / 4); |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
46 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
47 |
return noErr; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
48 |
} |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
49 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
50 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
51 |
static const char *CocoaSoundStart(const char * const *parm) |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
52 |
{ |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
53 |
Component comp; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
54 |
ComponentDescription desc; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
55 |
struct AudioUnitInputCallback callback; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
56 |
AudioStreamBasicDescription requestedDesc; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
57 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
58 |
DEBUG(driver, 1)("cocoa_s: CocoaSoundStart"); |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
59 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
60 |
/* Setup a AudioStreamBasicDescription with the requested format */ |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
61 |
requestedDesc.mFormatID = kAudioFormatLinearPCM; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
62 |
requestedDesc.mFormatFlags = kLinearPCMFormatFlagIsPacked; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
63 |
requestedDesc.mChannelsPerFrame = 2; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
64 |
requestedDesc.mSampleRate = GetDriverParamInt(parm, "hz", 11025); |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
65 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
66 |
requestedDesc.mBitsPerChannel = 16; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
67 |
requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger; |
2837
aa088bf6e451
(svn r3385) -Fix: [OSX] fixed endian issue in cocoa sound driver. Now it works correctly on x86 too (hopefully)
bjarni
parents:
2743
diff
changeset
|
68 |
|
aa088bf6e451
(svn r3385) -Fix: [OSX] fixed endian issue in cocoa sound driver. Now it works correctly on x86 too (hopefully)
bjarni
parents:
2743
diff
changeset
|
69 |
#ifdef TTD_BIG_ENDIAN |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
70 |
requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
71 |
#endif |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
72 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
73 |
requestedDesc.mFramesPerPacket = 1; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
74 |
requestedDesc.mBytesPerFrame = requestedDesc.mBitsPerChannel * requestedDesc.mChannelsPerFrame / 8; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
75 |
requestedDesc.mBytesPerPacket = requestedDesc.mBytesPerFrame * requestedDesc.mFramesPerPacket; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
76 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
77 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
78 |
/* Locate the default output audio unit */ |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
79 |
desc.componentType = kAudioUnitComponentType; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
80 |
desc.componentSubType = kAudioUnitSubType_Output; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
81 |
desc.componentManufacturer = kAudioUnitID_DefaultOutput; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
82 |
desc.componentFlags = 0; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
83 |
desc.componentFlagsMask = 0; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
84 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
85 |
comp = FindNextComponent (NULL, &desc); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
86 |
if (comp == NULL) { |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
87 |
return "cocoa_s: Failed to start CoreAudio: FindNextComponent returned NULL"; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
88 |
} |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
89 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
90 |
/* Open & initialize the default output audio unit */ |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
91 |
if (OpenAComponent(comp, &_outputAudioUnit) != noErr) { |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
92 |
return "cocoa_s: Failed to start CoreAudio: OpenAComponent"; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
93 |
} |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
94 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
95 |
if (AudioUnitInitialize(_outputAudioUnit) != noErr) { |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
96 |
return "cocoa_s: Failed to start CoreAudio: AudioUnitInitialize"; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
97 |
} |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
98 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
99 |
/* Set the input format of the audio unit. */ |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
100 |
if (AudioUnitSetProperty(_outputAudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &requestedDesc, sizeof(requestedDesc)) != noErr) { |
2953
4d933ef9a41f
(svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents:
2837
diff
changeset
|
101 |
return "cocoa_s: Failed to start CoreAudio: AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)"; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
102 |
} |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
103 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
104 |
/* Set the audio callback */ |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
105 |
callback.inputProc = audioCallback; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
106 |
callback.inputProcRefCon = NULL; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
107 |
if (AudioUnitSetProperty(_outputAudioUnit, kAudioUnitProperty_SetInputCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback)) != noErr) { |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
108 |
return "cocoa_s: Failed to start CoreAudio: AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)"; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
109 |
} |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
110 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
111 |
/* Finally, start processing of the audio unit */ |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
112 |
if (AudioOutputUnitStart(_outputAudioUnit) != noErr) { |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
113 |
return "cocoa_s: Failed to start CoreAudio: AudioOutputUnitStart"; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
114 |
} |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
115 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
116 |
/* We're running! */ |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
117 |
return NULL; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
118 |
} |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
119 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
120 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
121 |
static void CocoaSoundStop(void) |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
122 |
{ |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
123 |
struct AudioUnitInputCallback callback; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
124 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
125 |
DEBUG(driver, 1)("cocoa_s: CocoaSoundStop"); |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
126 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
127 |
/* stop processing the audio unit */ |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
2977
diff
changeset
|
128 |
if (AudioOutputUnitStop(_outputAudioUnit) != noErr) { |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
129 |
DEBUG(driver, 1)("cocoa_s: Core_CloseAudio: AudioOutputUnitStop failed"); |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
130 |
return; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
131 |
} |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
132 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
133 |
/* Remove the input callback */ |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
134 |
callback.inputProc = 0; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
135 |
callback.inputProcRefCon = 0; |
2953
4d933ef9a41f
(svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents:
2837
diff
changeset
|
136 |
if (AudioUnitSetProperty(_outputAudioUnit, kAudioUnitProperty_SetInputCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback)) != noErr) { |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
137 |
DEBUG(driver, 1)("cocoa_s: Core_CloseAudio: AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback) failed"); |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
138 |
return; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
139 |
} |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
140 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
141 |
if (CloseComponent(_outputAudioUnit) != noErr) { |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
142 |
DEBUG(driver, 1)("cocoa_s: Core_CloseAudio: CloseComponent failed"); |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
143 |
return; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
144 |
} |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
145 |
} |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
146 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
147 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
148 |
const HalSoundDriver _cocoa_sound_driver = { |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
149 |
CocoaSoundStart, |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
150 |
CocoaSoundStop, |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
151 |
}; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
152 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff
changeset
|
153 |
#endif /* WITH_COCOA */ |