Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
4728f7c6
Commit
4728f7c6
authored
Jul 02, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use AudioComponent instead of Carbon Component
parent
1c4c0fe8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
24 deletions
+21
-24
OSXOutputPlugin.cxx
src/output/plugins/OSXOutputPlugin.cxx
+21
-24
No files found.
src/output/plugins/OSXOutputPlugin.cxx
View file @
4728f7c6
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include "system/ByteOrder.hxx"
#include "system/ByteOrder.hxx"
#include "Log.hxx"
#include "Log.hxx"
#include <CoreAudio/
AudioHardware
.h>
#include <CoreAudio/
CoreAudio
.h>
#include <AudioUnit/AudioUnit.h>
#include <AudioUnit/AudioUnit.h>
#include <CoreServices/CoreServices.h>
#include <CoreServices/CoreServices.h>
...
@@ -40,7 +40,7 @@ struct OSXOutput {
...
@@ -40,7 +40,7 @@ struct OSXOutput {
/* only applicable with kAudioUnitSubType_HALOutput */
/* only applicable with kAudioUnitSubType_HALOutput */
const
char
*
device_name
;
const
char
*
device_name
;
Audio
Unit
au
;
Audio
ComponentInstance
au
;
Mutex
mutex
;
Mutex
mutex
;
Cond
condition
;
Cond
condition
;
...
@@ -109,6 +109,7 @@ osx_output_set_device(OSXOutput *oo, Error &error)
...
@@ -109,6 +109,7 @@ osx_output_set_device(OSXOutput *oo, Error &error)
OSStatus
status
;
OSStatus
status
;
UInt32
size
,
numdevices
;
UInt32
size
,
numdevices
;
AudioDeviceID
*
deviceids
=
nullptr
;
AudioDeviceID
*
deviceids
=
nullptr
;
AudioObjectPropertyAddress
propaddr
;
char
name
[
256
];
char
name
[
256
];
unsigned
int
i
;
unsigned
int
i
;
...
@@ -116,9 +117,8 @@ osx_output_set_device(OSXOutput *oo, Error &error)
...
@@ -116,9 +117,8 @@ osx_output_set_device(OSXOutput *oo, Error &error)
goto
done
;
goto
done
;
/* how many audio devices are there? */
/* how many audio devices are there? */
status
=
AudioHardwareGetPropertyInfo
(
kAudioHardwarePropertyDevices
,
propaddr
=
{
kAudioHardwarePropertyDevices
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
};
&
size
,
status
=
AudioObjectGetPropertyDataSize
(
kAudioObjectSystemObject
,
&
propaddr
,
0
,
nullptr
,
&
size
);
nullptr
);
if
(
status
!=
noErr
)
{
if
(
status
!=
noErr
)
{
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"Unable to determine number of OS X audio devices: %s"
,
"Unable to determine number of OS X audio devices: %s"
,
...
@@ -130,9 +130,7 @@ osx_output_set_device(OSXOutput *oo, Error &error)
...
@@ -130,9 +130,7 @@ osx_output_set_device(OSXOutput *oo, Error &error)
/* what are the available audio device IDs? */
/* what are the available audio device IDs? */
numdevices
=
size
/
sizeof
(
AudioDeviceID
);
numdevices
=
size
/
sizeof
(
AudioDeviceID
);
deviceids
=
new
AudioDeviceID
[
numdevices
];
deviceids
=
new
AudioDeviceID
[
numdevices
];
status
=
AudioHardwareGetProperty
(
kAudioHardwarePropertyDevices
,
status
=
AudioObjectGetPropertyData
(
kAudioObjectSystemObject
,
&
propaddr
,
0
,
nullptr
,
&
size
,
deviceids
);
&
size
,
deviceids
);
if
(
status
!=
noErr
)
{
if
(
status
!=
noErr
)
{
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"Unable to determine OS X audio device IDs: %s"
,
"Unable to determine OS X audio device IDs: %s"
,
...
@@ -142,11 +140,10 @@ osx_output_set_device(OSXOutput *oo, Error &error)
...
@@ -142,11 +140,10 @@ osx_output_set_device(OSXOutput *oo, Error &error)
}
}
/* which audio device matches oo->device_name? */
/* which audio device matches oo->device_name? */
propaddr
=
{
kAudioObjectPropertyName
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
};
for
(
i
=
0
;
i
<
numdevices
;
i
++
)
{
for
(
i
=
0
;
i
<
numdevices
;
i
++
)
{
size
=
sizeof
(
name
);
size
=
sizeof
(
name
);
status
=
AudioDeviceGetProperty
(
deviceids
[
i
],
0
,
false
,
status
=
AudioObjectGetPropertyData
(
deviceids
[
i
],
&
propaddr
,
0
,
nullptr
,
&
size
,
name
);
kAudioDevicePropertyDeviceName
,
&
size
,
name
);
if
(
status
!=
noErr
)
{
if
(
status
!=
noErr
)
{
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"Unable to determine OS X device name "
"Unable to determine OS X device name "
...
@@ -238,21 +235,21 @@ osx_output_enable(AudioOutput *ao, Error &error)
...
@@ -238,21 +235,21 @@ osx_output_enable(AudioOutput *ao, Error &error)
{
{
OSXOutput
*
oo
=
(
OSXOutput
*
)
ao
;
OSXOutput
*
oo
=
(
OSXOutput
*
)
ao
;
ComponentDescription
desc
;
Audio
ComponentDescription
desc
;
desc
.
componentType
=
kAudioUnitType_Output
;
desc
.
componentType
=
kAudioUnitType_Output
;
desc
.
componentSubType
=
oo
->
component_subtype
;
desc
.
componentSubType
=
oo
->
component_subtype
;
desc
.
componentManufacturer
=
kAudioUnitManufacturer_Apple
;
desc
.
componentManufacturer
=
kAudioUnitManufacturer_Apple
;
desc
.
componentFlags
=
0
;
desc
.
componentFlags
=
0
;
desc
.
componentFlagsMask
=
0
;
desc
.
componentFlagsMask
=
0
;
Component
comp
=
FindNextComponen
t
(
nullptr
,
&
desc
);
AudioComponent
comp
=
AudioComponentFindNex
t
(
nullptr
,
&
desc
);
if
(
comp
==
0
)
{
if
(
comp
==
0
)
{
error
.
Set
(
osx_output_domain
,
error
.
Set
(
osx_output_domain
,
"Error finding OS X component"
);
"Error finding OS X component"
);
return
false
;
return
false
;
}
}
OSStatus
status
=
OpenAComponent
(
comp
,
&
oo
->
au
);
OSStatus
status
=
AudioComponentInstanceNew
(
comp
,
&
oo
->
au
);
if
(
status
!=
noErr
)
{
if
(
status
!=
noErr
)
{
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"Unable to open OS X component: %s"
,
"Unable to open OS X component: %s"
,
...
@@ -261,7 +258,7 @@ osx_output_enable(AudioOutput *ao, Error &error)
...
@@ -261,7 +258,7 @@ osx_output_enable(AudioOutput *ao, Error &error)
}
}
if
(
!
osx_output_set_device
(
oo
,
error
))
{
if
(
!
osx_output_set_device
(
oo
,
error
))
{
CloseComponent
(
oo
->
au
);
AudioComponentInstanceDispose
(
oo
->
au
);
return
false
;
return
false
;
}
}
...
@@ -269,14 +266,14 @@ osx_output_enable(AudioOutput *ao, Error &error)
...
@@ -269,14 +266,14 @@ osx_output_enable(AudioOutput *ao, Error &error)
callback
.
inputProc
=
osx_render
;
callback
.
inputProc
=
osx_render
;
callback
.
inputProcRefCon
=
oo
;
callback
.
inputProcRefCon
=
oo
;
ComponentResult
result
=
status
=
AudioUnitSetProperty
(
oo
->
au
,
AudioUnitSetProperty
(
oo
->
au
,
kAudioUnitProperty_SetRenderCallback
,
kAudioUnitProperty_SetRenderCallback
,
kAudioUnitScope_Input
,
0
,
kAudioUnitScope_Input
,
0
,
&
callback
,
sizeof
(
callback
));
&
callback
,
sizeof
(
callback
));
if
(
result
!=
noErr
)
{
if
(
status
!=
noErr
)
{
CloseComponent
(
oo
->
au
);
AudioComponentInstanceDispose
(
oo
->
au
);
error
.
Set
(
osx_output_domain
,
result
,
error
.
Set
(
osx_output_domain
,
status
,
"unable to set callback for OS X audio unit"
);
"unable to set callback for OS X audio unit"
);
return
false
;
return
false
;
}
}
...
@@ -289,7 +286,7 @@ osx_output_disable(AudioOutput *ao)
...
@@ -289,7 +286,7 @@ osx_output_disable(AudioOutput *ao)
{
{
OSXOutput
*
oo
=
(
OSXOutput
*
)
ao
;
OSXOutput
*
oo
=
(
OSXOutput
*
)
ao
;
CloseComponent
(
oo
->
au
);
AudioComponentInstanceDispose
(
oo
->
au
);
}
}
static
void
static
void
...
@@ -350,18 +347,18 @@ osx_output_open(AudioOutput *ao, AudioFormat &audio_format,
...
@@ -350,18 +347,18 @@ osx_output_open(AudioOutput *ao, AudioFormat &audio_format,
stream_description
.
mBytesPerFrame
=
stream_description
.
mBytesPerPacket
;
stream_description
.
mBytesPerFrame
=
stream_description
.
mBytesPerPacket
;
stream_description
.
mChannelsPerFrame
=
audio_format
.
channels
;
stream_description
.
mChannelsPerFrame
=
audio_format
.
channels
;
ComponentResult
result
=
OSStatus
status
=
AudioUnitSetProperty
(
od
->
au
,
kAudioUnitProperty_StreamFormat
,
AudioUnitSetProperty
(
od
->
au
,
kAudioUnitProperty_StreamFormat
,
kAudioUnitScope_Input
,
0
,
kAudioUnitScope_Input
,
0
,
&
stream_description
,
&
stream_description
,
sizeof
(
stream_description
));
sizeof
(
stream_description
));
if
(
result
!=
noErr
)
{
if
(
status
!=
noErr
)
{
error
.
Set
(
osx_output_domain
,
result
,
error
.
Set
(
osx_output_domain
,
status
,
"Unable to set format on OS X device"
);
"Unable to set format on OS X device"
);
return
false
;
return
false
;
}
}
OSStatus
status
=
AudioUnitInitialize
(
od
->
au
);
status
=
AudioUnitInitialize
(
od
->
au
);
if
(
status
!=
noErr
)
{
if
(
status
!=
noErr
)
{
error
.
Format
(
osx_output_domain
,
status
,
error
.
Format
(
osx_output_domain
,
status
,
"Unable to initialize OS X audio unit: %s"
,
"Unable to initialize OS X audio unit: %s"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment