diff options
author | Max Kellermann <max@musicpd.org> | 2020-07-02 15:07:39 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-07-02 15:18:37 +0200 |
commit | f032925c2d8e82b4fd1836dc1f5cf15979895c47 (patch) | |
tree | a061a54dff38fc87bd71817b030aba464bc3dab9 /src/output/plugins | |
parent | 8125a5dddb250b9a9ceb4917b31a33c5813d392e (diff) |
output/osx: add `started` flag
This will keep track of AudioOutputUnitStart() and
AudioOutputUnitStop(). This will provide some separation between "not
(yet) (re)started" and "paused".
Diffstat (limited to 'src/output/plugins')
-rw-r--r-- | src/output/plugins/OSXOutputPlugin.cxx | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index e7b677d04..10cf419e9 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -73,7 +73,14 @@ struct OSXOutput final : AudioOutput { const char *device_name; const char *const channel_map; const bool hog_device; + bool pause; + + /** + * Is the audio unit "started", i.e. was AudioOutputUnitStart() called? + */ + bool started; + #ifdef ENABLE_DSD /** * Enable DSD over PCM according to the DoP standard? @@ -755,18 +762,22 @@ OSXOutput::Open(AudioFormat &audio_format) Apple::ThrowOSStatus(status, "Unable to start audio output"); pause = false; + started = true; } size_t OSXOutput::Play(const void *chunk, size_t size) { assert(size > 0); - if (pause) { + + pause = false; + + if (!started) { OSStatus status = AudioOutputUnitStart(au); if (status != noErr) throw std::runtime_error("Unable to restart audio output after pause"); - pause = false; + started = true; } #ifdef ENABLE_DSD if (dop_enabled) { @@ -797,10 +808,13 @@ OSXOutput::Delay() const noexcept bool OSXOutput::Pause() { - if (!pause) { - pause = true; + pause = true; + + if (started) { AudioOutputUnitStop(au); + started = false; } + return true; } |