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
5b456cad
Commit
5b456cad
authored
Mar 07, 2018
by
Christian Kröner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reset sample rate to initial state on OSX output
parent
4be80982
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
2 deletions
+41
-2
OSXOutputPlugin.cxx
src/output/plugins/OSXOutputPlugin.cxx
+41
-2
No files found.
src/output/plugins/OSXOutputPlugin.cxx
View file @
5b456cad
...
@@ -62,7 +62,7 @@ struct OSXOutput final : AudioOutput {
...
@@ -62,7 +62,7 @@ struct OSXOutput final : AudioOutput {
AudioDeviceID
dev_id
;
AudioDeviceID
dev_id
;
AudioComponentInstance
au
;
AudioComponentInstance
au
;
AudioStreamBasicDescription
asbd
;
AudioStreamBasicDescription
asbd
;
Float64
sample_rate
;
Float64
initial_
sample_rate
;
Manual
<
PcmExport
>
pcm_export
;
Manual
<
PcmExport
>
pcm_export
;
boost
::
lockfree
::
spsc_queue
<
uint8_t
>
*
ring_buffer
;
boost
::
lockfree
::
spsc_queue
<
uint8_t
>
*
ring_buffer
;
...
@@ -650,6 +650,24 @@ OSXOutput::Enable()
...
@@ -650,6 +650,24 @@ OSXOutput::Enable()
throw
;
throw
;
}
}
AudioObjectPropertyAddress
aopa
=
{
kAudioDevicePropertyNominalSampleRate
,
kAudioObjectPropertyScopeOutput
,
kAudioObjectPropertyElementMaster
};
UInt32
property_size
=
sizeof
(
initial_sample_rate
);
status
=
AudioObjectGetPropertyData
(
dev_id
,
&
aopa
,
0
,
NULL
,
&
property_size
,
&
initial_sample_rate
);
if
(
status
!=
noErr
)
{
AudioComponentInstanceDispose
(
au
);
pcm_export
.
Destruct
();
throw
std
::
runtime_error
(
"Cannot get sample rate of macOS output device"
);
}
if
(
hog_device
)
if
(
hog_device
)
osx_output_hog_device
(
dev_id
,
true
);
osx_output_hog_device
(
dev_id
,
true
);
}
}
...
@@ -667,9 +685,29 @@ OSXOutput::Disable() noexcept
...
@@ -667,9 +685,29 @@ OSXOutput::Disable() noexcept
void
void
OSXOutput
::
Close
()
noexcept
OSXOutput
::
Close
()
noexcept
{
{
AudioObjectPropertyAddress
aopa
=
{
kAudioDevicePropertyNominalSampleRate
,
kAudioObjectPropertyScopeOutput
,
kAudioObjectPropertyElementMaster
};
OSStatus
err
;
AudioOutputUnitStop
(
au
);
AudioOutputUnitStop
(
au
);
AudioUnitUninitialize
(
au
);
AudioUnitUninitialize
(
au
);
// Reset sample rate to initial state
if
(
sync_sample_rate
#ifdef ENABLE_DSD
||
dop_setting
#endif
)
{
err
=
AudioObjectSetPropertyData
(
dev_id
,
&
aopa
,
0
,
NULL
,
sizeof
(
initial_sample_rate
),
&
initial_sample_rate
);
if
(
err
!=
noErr
)
FormatWarning
(
osx_output_domain
,
"Unable to reset sample rate of macOS output device"
);
}
delete
ring_buffer
;
delete
ring_buffer
;
}
}
...
@@ -680,6 +718,7 @@ OSXOutput::Open(AudioFormat &audio_format)
...
@@ -680,6 +718,7 @@ OSXOutput::Open(AudioFormat &audio_format)
#ifdef ENABLE_DSD
#ifdef ENABLE_DSD
bool
dop
=
dop_setting
;
bool
dop
=
dop_setting
;
#endif
#endif
Float64
sample_rate
=
initial_sample_rate
;
PcmExport
::
Params
params
;
PcmExport
::
Params
params
;
params
.
alsa_channel_order
=
true
;
params
.
alsa_channel_order
=
true
;
params
.
dop
=
false
;
params
.
dop
=
false
;
...
...
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