output/Multiple: migrate from class Error to C++ exceptions
This commit is contained in:
@@ -58,14 +58,8 @@ try {
|
||||
AudioOutput *output = audio_output_new(event_loop, block,
|
||||
mixer_listener,
|
||||
pc, error);
|
||||
if (output == nullptr) {
|
||||
if (block.line > 0)
|
||||
FormatFatalError("line %i: %s",
|
||||
block.line,
|
||||
error.GetMessage());
|
||||
else
|
||||
FatalError(error);
|
||||
}
|
||||
if (output == nullptr)
|
||||
throw std::runtime_error(error.GetMessage());
|
||||
|
||||
return output;
|
||||
} catch (const std::runtime_error &e) {
|
||||
@@ -192,32 +186,27 @@ MultipleOutputs::SetReplayGainMode(ReplayGainMode mode)
|
||||
ao->SetReplayGainMode(mode);
|
||||
}
|
||||
|
||||
bool
|
||||
MultipleOutputs::Play(MusicChunk *chunk, Error &error)
|
||||
void
|
||||
MultipleOutputs::Play(MusicChunk *chunk)
|
||||
{
|
||||
assert(buffer != nullptr);
|
||||
assert(pipe != nullptr);
|
||||
assert(chunk != nullptr);
|
||||
assert(chunk->CheckFormat(input_audio_format));
|
||||
|
||||
if (!Update()) {
|
||||
if (!Update())
|
||||
/* TODO: obtain real error */
|
||||
error.Set(output_domain, "Failed to open audio output");
|
||||
return false;
|
||||
}
|
||||
throw std::runtime_error("Failed to open audio output");
|
||||
|
||||
pipe->Push(chunk);
|
||||
|
||||
for (auto ao : outputs)
|
||||
ao->LockPlay();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
void
|
||||
MultipleOutputs::Open(const AudioFormat audio_format,
|
||||
MusicBuffer &_buffer,
|
||||
Error &error)
|
||||
MusicBuffer &_buffer)
|
||||
{
|
||||
bool ret = false, enabled = false;
|
||||
|
||||
@@ -251,17 +240,16 @@ MultipleOutputs::Open(const AudioFormat audio_format,
|
||||
ret = true;
|
||||
}
|
||||
|
||||
if (!enabled)
|
||||
error.Set(output_domain, "All audio outputs are disabled");
|
||||
else if (!ret)
|
||||
/* TODO: obtain real error */
|
||||
error.Set(output_domain, "Failed to open audio output");
|
||||
|
||||
if (!ret)
|
||||
if (!enabled) {
|
||||
/* close all devices if there was an error */
|
||||
Close();
|
||||
|
||||
return ret;
|
||||
throw std::runtime_error("All audio outputs are disabled");
|
||||
} else if (!ret) {
|
||||
/* close all devices if there was an error */
|
||||
Close();
|
||||
/* TODO: obtain real error */
|
||||
throw std::runtime_error("Failed to open audio output");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -118,13 +118,13 @@ public:
|
||||
/**
|
||||
* Opens all audio outputs which are not disabled.
|
||||
*
|
||||
* Throws #std::runtime_error on error.
|
||||
*
|
||||
* @param audio_format the preferred audio format
|
||||
* @param _buffer the #music_buffer where consumed #MusicChunk objects
|
||||
* should be returned
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
bool Open(const AudioFormat audio_format, MusicBuffer &_buffer,
|
||||
Error &error);
|
||||
void Open(const AudioFormat audio_format, MusicBuffer &_buffer);
|
||||
|
||||
/**
|
||||
* Closes all audio outputs.
|
||||
@@ -143,11 +143,11 @@ public:
|
||||
* Enqueue a #MusicChunk object for playing, i.e. pushes it to a
|
||||
* #MusicPipe.
|
||||
*
|
||||
* Throws #std::runtime_error on error (all closed then).
|
||||
*
|
||||
* @param chunk the #MusicChunk object to be played
|
||||
* @return true on success, false if no audio output was able to play
|
||||
* (all closed then)
|
||||
*/
|
||||
bool Play(MusicChunk *chunk, Error &error);
|
||||
void Play(MusicChunk *chunk);
|
||||
|
||||
/**
|
||||
* Checks if the output devices have drained their music pipe, and
|
||||
|
||||
Reference in New Issue
Block a user