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".
This commit is contained in:
parent
8125a5dddb
commit
f032925c2d
@ -73,7 +73,14 @@ struct OSXOutput final : AudioOutput {
|
|||||||
const char *device_name;
|
const char *device_name;
|
||||||
const char *const channel_map;
|
const char *const channel_map;
|
||||||
const bool hog_device;
|
const bool hog_device;
|
||||||
|
|
||||||
bool pause;
|
bool pause;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the audio unit "started", i.e. was AudioOutputUnitStart() called?
|
||||||
|
*/
|
||||||
|
bool started;
|
||||||
|
|
||||||
#ifdef ENABLE_DSD
|
#ifdef ENABLE_DSD
|
||||||
/**
|
/**
|
||||||
* Enable DSD over PCM according to the DoP standard?
|
* 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");
|
Apple::ThrowOSStatus(status, "Unable to start audio output");
|
||||||
|
|
||||||
pause = false;
|
pause = false;
|
||||||
|
started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
OSXOutput::Play(const void *chunk, size_t size)
|
OSXOutput::Play(const void *chunk, size_t size)
|
||||||
{
|
{
|
||||||
assert(size > 0);
|
assert(size > 0);
|
||||||
if (pause) {
|
|
||||||
|
pause = false;
|
||||||
|
|
||||||
|
if (!started) {
|
||||||
OSStatus status = AudioOutputUnitStart(au);
|
OSStatus status = AudioOutputUnitStart(au);
|
||||||
if (status != noErr)
|
if (status != noErr)
|
||||||
throw std::runtime_error("Unable to restart audio output after pause");
|
throw std::runtime_error("Unable to restart audio output after pause");
|
||||||
|
|
||||||
pause = false;
|
started = true;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_DSD
|
#ifdef ENABLE_DSD
|
||||||
if (dop_enabled) {
|
if (dop_enabled) {
|
||||||
@ -797,10 +808,13 @@ OSXOutput::Delay() const noexcept
|
|||||||
|
|
||||||
bool OSXOutput::Pause()
|
bool OSXOutput::Pause()
|
||||||
{
|
{
|
||||||
if (!pause) {
|
pause = true;
|
||||||
pause = true;
|
|
||||||
|
if (started) {
|
||||||
AudioOutputUnitStop(au);
|
AudioOutputUnitStop(au);
|
||||||
|
started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user