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
fb83936f
Commit
fb83936f
authored
Jul 02, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apple/AudioUnit: add AudioUnitSetPropertyT()
parent
db8bf52f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
43 deletions
+67
-43
AudioUnit.hxx
src/apple/AudioUnit.hxx
+56
-0
OSXOutputPlugin.cxx
src/output/plugins/OSXOutputPlugin.cxx
+11
-43
No files found.
src/apple/AudioUnit.hxx
View file @
fb83936f
...
@@ -52,4 +52,60 @@ AudioUnitGetPropertyT(AudioUnit inUnit, AudioUnitPropertyID inID,
...
@@ -52,4 +52,60 @@ AudioUnitGetPropertyT(AudioUnit inUnit, AudioUnitPropertyID inID,
return
value
;
return
value
;
}
}
template
<
typename
T
>
void
AudioUnitSetPropertyT
(
AudioUnit
inUnit
,
AudioUnitPropertyID
inID
,
AudioUnitScope
inScope
,
AudioUnitElement
inElement
,
const
T
&
value
)
{
OSStatus
status
=
AudioUnitSetProperty
(
inUnit
,
inID
,
inScope
,
inElement
,
&
value
,
sizeof
(
value
));
if
(
status
!=
noErr
)
Apple
::
ThrowOSStatus
(
status
);
}
inline
void
AudioUnitSetCurrentDevice
(
AudioUnit
inUnit
,
const
AudioDeviceID
&
value
)
{
AudioUnitSetPropertyT
(
inUnit
,
kAudioOutputUnitProperty_CurrentDevice
,
kAudioUnitScope_Global
,
0
,
value
);
}
inline
void
AudioUnitSetInputStreamFormat
(
AudioUnit
inUnit
,
const
AudioStreamBasicDescription
&
value
)
{
AudioUnitSetPropertyT
(
inUnit
,
kAudioUnitProperty_StreamFormat
,
kAudioUnitScope_Input
,
0
,
value
);
}
inline
void
AudioUnitSetInputRenderCallback
(
AudioUnit
inUnit
,
const
AURenderCallbackStruct
&
value
)
{
AudioUnitSetPropertyT
(
inUnit
,
kAudioUnitProperty_SetRenderCallback
,
kAudioUnitScope_Input
,
0
,
value
);
}
inline
UInt32
AudioUnitGetBufferFrameSize
(
AudioUnit
inUnit
)
{
return
AudioUnitGetPropertyT
<
UInt32
>
(
inUnit
,
kAudioDevicePropertyBufferFrameSize
,
kAudioUnitScope_Global
,
0
);
}
inline
void
AudioUnitSetBufferFrameSize
(
AudioUnit
inUnit
,
const
UInt32
&
value
)
{
AudioUnitSetPropertyT
(
inUnit
,
kAudioDevicePropertyBufferFrameSize
,
kAudioUnitScope_Global
,
0
,
value
);
}
#endif
#endif
src/output/plugins/OSXOutputPlugin.cxx
View file @
fb83936f
...
@@ -450,24 +450,14 @@ osx_output_set_buffer_size(AudioUnit au, AudioStreamBasicDescription desc)
...
@@ -450,24 +450,14 @@ osx_output_set_buffer_size(AudioUnit au, AudioStreamBasicDescription desc)
kAudioUnitScope_Global
,
kAudioUnitScope_Global
,
0
);
0
);
UInt32
buffer_frame_size
=
value_range
.
mMaximum
;
try
{
OSStatus
err
;
AudioUnitSetBufferFrameSize
(
au
,
value_range
.
mMaximum
);
err
=
AudioUnitSetProperty
(
au
,
}
catch
(...)
{
kAudioDevicePropertyBufferFrameSize
,
LogError
(
std
::
current_exception
(),
kAudioUnitScope_Global
,
"Failed to set maximum buffer size"
);
0
,
}
&
buffer_frame_size
,
sizeof
(
buffer_frame_size
));
if
(
err
!=
noErr
)
FormatWarning
(
osx_output_domain
,
"Failed to set maximum buffer size: %d"
,
err
);
buffer_frame_size
=
AudioUnitGetPropertyT
<
UInt32
>
(
au
,
kAudioDevicePropertyBufferFrameSize
,
kAudioUnitScope_Global
,
0
);
auto
buffer_frame_size
=
AudioUnitGetBufferFrameSize
(
au
);
buffer_frame_size
*=
desc
.
mBytesPerFrame
;
buffer_frame_size
*=
desc
.
mBytesPerFrame
;
// We set the frame size to a power of two integer that
// We set the frame size to a power of two integer that
...
@@ -583,15 +573,7 @@ osx_output_set_device(OSXOutput *oo)
...
@@ -583,15 +573,7 @@ osx_output_set_device(OSXOutput *oo)
"found matching device: ID=%u, name=%s"
,
"found matching device: ID=%u, name=%s"
,
(
unsigned
)
id
,
oo
->
device_name
);
(
unsigned
)
id
,
oo
->
device_name
);
OSStatus
status
;
AudioUnitSetCurrentDevice
(
oo
->
au
,
id
);
status
=
AudioUnitSetProperty
(
oo
->
au
,
kAudioOutputUnitProperty_CurrentDevice
,
kAudioUnitScope_Global
,
0
,
&
id
,
sizeof
(
id
));
if
(
status
!=
noErr
)
Apple
::
ThrowOSStatus
(
status
,
"Unable to set OS X audio output device"
);
oo
->
dev_id
=
id
;
oo
->
dev_id
=
id
;
FormatDebug
(
osx_output_domain
,
FormatDebug
(
osx_output_domain
,
...
@@ -742,29 +724,15 @@ OSXOutput::Open(AudioFormat &audio_format)
...
@@ -742,29 +724,15 @@ OSXOutput::Open(AudioFormat &audio_format)
dop_enabled
=
params
.
dop
;
dop_enabled
=
params
.
dop
;
#endif
#endif
OSStatus
status
=
AudioUnitSetInputStreamFormat
(
au
,
asbd
);
AudioUnitSetProperty
(
au
,
kAudioUnitProperty_StreamFormat
,
kAudioUnitScope_Input
,
0
,
&
asbd
,
sizeof
(
asbd
));
if
(
status
!=
noErr
)
throw
std
::
runtime_error
(
"Unable to set format on OS X device"
);
AURenderCallbackStruct
callback
;
AURenderCallbackStruct
callback
;
callback
.
inputProc
=
osx_render
;
callback
.
inputProc
=
osx_render
;
callback
.
inputProcRefCon
=
this
;
callback
.
inputProcRefCon
=
this
;
status
=
AudioUnitSetInputRenderCallback
(
au
,
callback
);
AudioUnitSetProperty
(
au
,
kAudioUnitProperty_SetRenderCallback
,
kAudioUnitScope_Input
,
0
,
&
callback
,
sizeof
(
callback
));
if
(
status
!=
noErr
)
{
AudioComponentInstanceDispose
(
au
);
throw
std
::
runtime_error
(
"Unable to set callback for OS X audio unit"
);
}
status
=
AudioUnitInitialize
(
au
);
OSStatus
status
=
AudioUnitInitialize
(
au
);
if
(
status
!=
noErr
)
if
(
status
!=
noErr
)
Apple
::
ThrowOSStatus
(
status
,
"Unable to initialize OS X audio unit"
);
Apple
::
ThrowOSStatus
(
status
,
"Unable to initialize OS X audio unit"
);
...
...
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