summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-11-07 09:03:17 +0100
committerMax Kellermann <max@musicpd.org>2016-11-07 09:05:28 +0100
commit4cd21f1e072d4219b44a54d5e6e62c6294c9a236 (patch)
tree730ff823e3d04c17d05414bd7161bc34dba35230 /src
parent403f0f8c649f0d51521f4a0b067ba66a5fc47000 (diff)
decoder/Control: throw exception on Seek() error
Diffstat (limited to 'src')
-rw-r--r--src/command/AllCommands.cxx1
-rw-r--r--src/decoder/DecoderControl.cxx24
-rw-r--r--src/decoder/DecoderControl.hxx6
-rw-r--r--src/player/Thread.cxx8
4 files changed, 18 insertions, 21 deletions
diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx
index 2999e35f5..5405b0920 100644
--- a/src/command/AllCommands.cxx
+++ b/src/command/AllCommands.cxx
@@ -362,7 +362,6 @@ CommandResult
command_process(Client &client, unsigned num, char *line)
try {
Response r(client, num);
- Error error;
/* get the command name (first word on the line) */
/* we have to set current_command because Response::Error()
diff --git a/src/decoder/DecoderControl.cxx b/src/decoder/DecoderControl.cxx
index c4250be0e..cc48ff951 100644
--- a/src/decoder/DecoderControl.cxx
+++ b/src/decoder/DecoderControl.cxx
@@ -22,7 +22,8 @@
#include "DecoderError.hxx"
#include "MusicPipe.hxx"
#include "DetachedSong.hxx"
-#include "util/Error.hxx"
+
+#include <stdexcept>
#include <assert.h>
@@ -104,8 +105,8 @@ DecoderControl::Stop()
SynchronousCommandLocked(DecoderCommand::STOP);
}
-bool
-DecoderControl::Seek(SongTime t, Error &error_r)
+void
+DecoderControl::Seek(SongTime t)
{
assert(state != DecoderState::START);
assert(state != DecoderState::ERROR);
@@ -118,28 +119,21 @@ DecoderControl::Seek(SongTime t, Error &error_r)
case DecoderState::STOP:
/* TODO: if this happens, the caller should be given a
chance to restart the decoder */
- error_r.Set(decoder_domain, "Decoder is dead");
- return false;
+ throw std::runtime_error("Decoder is dead");
case DecoderState::DECODE:
break;
}
- if (!seekable) {
- error_r.Set(decoder_domain, "Not seekable");
- return false;
- }
+ if (!seekable)
+ throw std::runtime_error("Not seekable");
seek_time = t;
seek_error = false;
LockSynchronousCommand(DecoderCommand::SEEK);
- if (seek_error) {
- error_r.Set(decoder_domain, "Decoder failed to seek");
- return false;
- }
-
- return true;
+ if (seek_error)
+ throw std::runtime_error("Decoder failed to seek");
}
void
diff --git a/src/decoder/DecoderControl.hxx b/src/decoder/DecoderControl.hxx
index e3ef63192..5a30e822b 100644
--- a/src/decoder/DecoderControl.hxx
+++ b/src/decoder/DecoderControl.hxx
@@ -40,7 +40,6 @@
#undef ERROR
#endif
-class Error;
class DetachedSong;
class MusicBuffer;
class MusicPipe;
@@ -367,7 +366,10 @@ public:
void Stop();
- bool Seek(SongTime t, Error &error_r);
+ /**
+ * Throws #std::runtime_error on error.
+ */
+ void Seek(SongTime t);
void Quit();
diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx
index 1e4a3cc7d..9acc091a3 100644
--- a/src/player/Thread.cxx
+++ b/src/player/Thread.cxx
@@ -618,10 +618,12 @@ Player::SeekDecoder()
where = total_time;
}
- Error error;
- if (!dc.Seek(where + start_time, error)) {
+ try {
+ dc.Seek(where + start_time);
+ } catch (...) {
/* decoder failure */
- pc.SetError(PlayerError::DECODER, std::move(error));
+ pc.SetError(PlayerError::DECODER,
+ std::current_exception());
pc.LockCommandFinished();
return false;
}