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
bfaa7afc
Commit
bfaa7afc
authored
May 28, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/osx: make more AudioObjectPropertyAddress instances `static constexpr`
parent
7fdbaa61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
35 deletions
+62
-35
OSXOutputPlugin.cxx
src/output/plugins/OSXOutputPlugin.cxx
+62
-35
No files found.
src/output/plugins/OSXOutputPlugin.cxx
View file @
bfaa7afc
...
...
@@ -161,25 +161,28 @@ AudioOutput *
OSXOutput
::
Create
(
EventLoop
&
,
const
ConfigBlock
&
block
)
{
OSXOutput
*
oo
=
new
OSXOutput
(
block
);
AudioObjectPropertyAddress
aopa
;
AudioDeviceID
dev_id
=
kAudioDeviceUnknown
;
UInt32
dev_id_size
=
sizeof
(
dev_id
);
if
(
oo
->
component_subtype
==
kAudioUnitSubType_SystemOutput
)
static
constexpr
AudioObjectPropertyAddress
default_system_output_device
{
kAudioHardwarePropertyDefaultSystemOutputDevice
,
kAudioObjectPropertyScopeOutput
,
kAudioObjectPropertyElementMaster
,
};
static
constexpr
AudioObjectPropertyAddress
default_output_device
{
kAudioHardwarePropertyDefaultOutputDevice
,
kAudioObjectPropertyScopeOutput
,
kAudioObjectPropertyElementMaster
};
const
auto
&
aopa
=
oo
->
component_subtype
==
kAudioUnitSubType_SystemOutput
// get system output dev_id if configured
aopa
=
{
kAudioHardwarePropertyDefaultSystemOutputDevice
,
kAudioObjectPropertyScopeOutput
,
kAudioObjectPropertyElementMaster
};
else
?
default_system_output_device
/* fallback to default device initially (can still be
changed by osx_output_set_device) */
aopa
=
{
kAudioHardwarePropertyDefaultOutputDevice
,
kAudioObjectPropertyScopeOutput
,
kAudioObjectPropertyElementMaster
};
:
default_output_device
;
AudioObjectGetPropertyData
(
kAudioObjectSystemObject
,
&
aopa
,
...
...
@@ -387,15 +390,34 @@ static Float64
osx_output_set_device_format
(
AudioDeviceID
dev_id
,
const
AudioStreamBasicDescription
&
target_format
)
{
AudioObjectPropertyAddress
aopa
=
{
static
constexpr
AudioObjectPropertyAddress
aopa_device_streams
=
{
kAudioDevicePropertyStreams
,
kAudioObjectPropertyScopeOutput
,
kAudioObjectPropertyElementMaster
};
static
constexpr
AudioObjectPropertyAddress
aopa_stream_direction
=
{
kAudioStreamPropertyDirection
,
kAudioObjectPropertyScopeOutput
,
kAudioObjectPropertyElementMaster
};
static
constexpr
AudioObjectPropertyAddress
aopa_stream_phys_formats
=
{
kAudioStreamPropertyAvailablePhysicalFormats
,
kAudioObjectPropertyScopeOutput
,
kAudioObjectPropertyElementMaster
};
static
constexpr
AudioObjectPropertyAddress
aopa_stream_phys_format
=
{
kAudioStreamPropertyPhysicalFormat
,
kAudioObjectPropertyScopeOutput
,
kAudioObjectPropertyElementMaster
};
UInt32
property_size
;
OSStatus
err
=
AudioObjectGetPropertyDataSize
(
dev_id
,
&
aopa
,
0
,
NULL
,
&
property_size
);
OSStatus
err
=
AudioObjectGetPropertyDataSize
(
dev_id
,
&
aopa_device_streams
,
0
,
NULL
,
&
property_size
);
if
(
err
!=
noErr
)
throw
FormatRuntimeError
(
"Cannot get number of streams: %d"
,
err
);
...
...
@@ -405,7 +427,7 @@ osx_output_set_device_format(AudioDeviceID dev_id,
throw
std
::
runtime_error
(
"Too many streams"
);
AudioStreamID
streams
[
MAX_STREAMS
];
err
=
AudioObjectGetPropertyData
(
dev_id
,
&
aopa
,
0
,
NULL
,
err
=
AudioObjectGetPropertyData
(
dev_id
,
&
aopa
_device_streams
,
0
,
NULL
,
&
property_size
,
streams
);
if
(
err
!=
noErr
)
throw
FormatRuntimeError
(
"Cannot get streams: %d"
,
err
);
...
...
@@ -417,10 +439,9 @@ osx_output_set_device_format(AudioDeviceID dev_id,
for
(
size_t
i
=
0
;
i
<
n_streams
;
i
++
)
{
UInt32
direction
;
AudioStreamID
stream
=
streams
[
i
];
aopa
.
mSelector
=
kAudioStreamPropertyDirection
;
property_size
=
sizeof
(
direction
);
err
=
AudioObjectGetPropertyData
(
stream
,
&
aopa
,
&
aopa
_stream_direction
,
0
,
NULL
,
&
property_size
,
...
...
@@ -432,9 +453,9 @@ osx_output_set_device_format(AudioDeviceID dev_id,
if
(
direction
!=
0
)
continue
;
aopa
.
mSelector
=
kAudioStreamPropertyAvailablePhysicalFormats
;
err
=
AudioObjectGetPropertyDataSize
(
stream
,
&
aopa
,
0
,
NULL
,
&
property_size
);
err
=
AudioObjectGetPropertyDataSize
(
stream
,
&
aopa_stream_phys_formats
,
0
,
NULL
,
&
property_size
);
if
(
err
!=
noErr
)
throw
FormatRuntimeError
(
"Unable to get format size s for stream %d. Error = %s"
,
streams
[
i
],
err
);
...
...
@@ -445,7 +466,9 @@ osx_output_set_device_format(AudioDeviceID dev_id,
throw
std
::
runtime_error
(
"Too many formats"
);
AudioStreamRangedDescription
format_list
[
MAX_FORMATS
];
err
=
AudioObjectGetPropertyData
(
stream
,
&
aopa
,
0
,
NULL
,
err
=
AudioObjectGetPropertyData
(
stream
,
&
aopa_stream_phys_formats
,
0
,
NULL
,
&
property_size
,
format_list
);
if
(
err
!=
noErr
)
throw
FormatRuntimeError
(
"Unable to get available formats for stream %d. Error = %s"
,
...
...
@@ -478,9 +501,8 @@ osx_output_set_device_format(AudioDeviceID dev_id,
}
if
(
format_found
)
{
aopa
.
mSelector
=
kAudioStreamPropertyPhysicalFormat
;
err
=
AudioObjectSetPropertyData
(
output_stream
,
&
aopa
,
&
aopa
_stream_phys_format
,
0
,
NULL
,
sizeof
(
output_format
),
...
...
@@ -608,7 +630,6 @@ osx_output_set_device(OSXOutput *oo)
{
OSStatus
status
;
UInt32
size
,
numdevices
;
AudioObjectPropertyAddress
propaddr
;
CFStringRef
cfname
=
nullptr
;
char
errormsg
[
1024
];
char
name
[
256
];
...
...
@@ -623,11 +644,14 @@ osx_output_set_device(OSXOutput *oo)
return
;
/* how many audio devices are there? */
propaddr
=
{
kAudioHardwarePropertyDevices
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
};
static
constexpr
AudioObjectPropertyAddress
aopa_hw_devices
{
kAudioHardwarePropertyDevices
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
,
};
status
=
AudioObjectGetPropertyDataSize
(
kAudioObjectSystemObject
,
&
propaddr
,
0
,
nullptr
,
&
size
);
&
aopa_hw_devices
,
0
,
nullptr
,
&
size
);
if
(
status
!=
noErr
)
{
osx_os_status_to_cstring
(
status
,
errormsg
,
sizeof
(
errormsg
));
throw
FormatRuntimeError
(
"Unable to determine number of OS X audio devices: %s"
,
...
...
@@ -638,7 +662,7 @@ osx_output_set_device(OSXOutput *oo)
numdevices
=
size
/
sizeof
(
AudioDeviceID
);
std
::
unique_ptr
<
AudioDeviceID
[]
>
deviceids
(
new
AudioDeviceID
[
numdevices
]);
status
=
AudioObjectGetPropertyData
(
kAudioObjectSystemObject
,
&
propaddr
,
0
,
nullptr
,
&
aopa_hw_devices
,
0
,
nullptr
,
&
size
,
deviceids
.
get
());
if
(
status
!=
noErr
)
{
osx_os_status_to_cstring
(
status
,
errormsg
,
sizeof
(
errormsg
));
...
...
@@ -647,12 +671,15 @@ osx_output_set_device(OSXOutput *oo)
}
/* which audio device matches oo->device_name? */
propaddr
=
{
kAudioObjectPropertyName
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
};
static
constexpr
AudioObjectPropertyAddress
aopa_name
{
kAudioObjectPropertyName
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
,
};
size
=
sizeof
(
CFStringRef
);
for
(
i
=
0
;
i
<
numdevices
;
i
++
)
{
status
=
AudioObjectGetPropertyData
(
deviceids
[
i
],
&
propaddr
,
status
=
AudioObjectGetPropertyData
(
deviceids
[
i
],
&
aopa_name
,
0
,
nullptr
,
&
size
,
&
cfname
);
if
(
status
!=
noErr
)
{
...
...
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