decoder/Control: throw exception on Seek() error
This commit is contained in:
parent
403f0f8c64
commit
4cd21f1e07
@ -362,7 +362,6 @@ CommandResult
|
|||||||
command_process(Client &client, unsigned num, char *line)
|
command_process(Client &client, unsigned num, char *line)
|
||||||
try {
|
try {
|
||||||
Response r(client, num);
|
Response r(client, num);
|
||||||
Error error;
|
|
||||||
|
|
||||||
/* get the command name (first word on the line) */
|
/* get the command name (first word on the line) */
|
||||||
/* we have to set current_command because Response::Error()
|
/* we have to set current_command because Response::Error()
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
#include "DecoderError.hxx"
|
#include "DecoderError.hxx"
|
||||||
#include "MusicPipe.hxx"
|
#include "MusicPipe.hxx"
|
||||||
#include "DetachedSong.hxx"
|
#include "DetachedSong.hxx"
|
||||||
#include "util/Error.hxx"
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
@ -104,8 +105,8 @@ DecoderControl::Stop()
|
|||||||
SynchronousCommandLocked(DecoderCommand::STOP);
|
SynchronousCommandLocked(DecoderCommand::STOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
DecoderControl::Seek(SongTime t, Error &error_r)
|
DecoderControl::Seek(SongTime t)
|
||||||
{
|
{
|
||||||
assert(state != DecoderState::START);
|
assert(state != DecoderState::START);
|
||||||
assert(state != DecoderState::ERROR);
|
assert(state != DecoderState::ERROR);
|
||||||
@ -118,28 +119,21 @@ DecoderControl::Seek(SongTime t, Error &error_r)
|
|||||||
case DecoderState::STOP:
|
case DecoderState::STOP:
|
||||||
/* TODO: if this happens, the caller should be given a
|
/* TODO: if this happens, the caller should be given a
|
||||||
chance to restart the decoder */
|
chance to restart the decoder */
|
||||||
error_r.Set(decoder_domain, "Decoder is dead");
|
throw std::runtime_error("Decoder is dead");
|
||||||
return false;
|
|
||||||
|
|
||||||
case DecoderState::DECODE:
|
case DecoderState::DECODE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!seekable) {
|
if (!seekable)
|
||||||
error_r.Set(decoder_domain, "Not seekable");
|
throw std::runtime_error("Not seekable");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
seek_time = t;
|
seek_time = t;
|
||||||
seek_error = false;
|
seek_error = false;
|
||||||
LockSynchronousCommand(DecoderCommand::SEEK);
|
LockSynchronousCommand(DecoderCommand::SEEK);
|
||||||
|
|
||||||
if (seek_error) {
|
if (seek_error)
|
||||||
error_r.Set(decoder_domain, "Decoder failed to seek");
|
throw std::runtime_error("Decoder failed to seek");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#undef ERROR
|
#undef ERROR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class Error;
|
|
||||||
class DetachedSong;
|
class DetachedSong;
|
||||||
class MusicBuffer;
|
class MusicBuffer;
|
||||||
class MusicPipe;
|
class MusicPipe;
|
||||||
@ -367,7 +366,10 @@ public:
|
|||||||
|
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
bool Seek(SongTime t, Error &error_r);
|
/**
|
||||||
|
* Throws #std::runtime_error on error.
|
||||||
|
*/
|
||||||
|
void Seek(SongTime t);
|
||||||
|
|
||||||
void Quit();
|
void Quit();
|
||||||
|
|
||||||
|
@ -618,10 +618,12 @@ Player::SeekDecoder()
|
|||||||
where = total_time;
|
where = total_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error error;
|
try {
|
||||||
if (!dc.Seek(where + start_time, error)) {
|
dc.Seek(where + start_time);
|
||||||
|
} catch (...) {
|
||||||
/* decoder failure */
|
/* decoder failure */
|
||||||
pc.SetError(PlayerError::DECODER, std::move(error));
|
pc.SetError(PlayerError::DECODER,
|
||||||
|
std::current_exception());
|
||||||
pc.LockCommandFinished();
|
pc.LockCommandFinished();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user