decoder/Control: Seek() returns Error information
This commit is contained in:
parent
5e93c05095
commit
faca8bc02a
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "DecoderControl.hxx"
|
#include "DecoderControl.hxx"
|
||||||
|
#include "DecoderError.hxx"
|
||||||
#include "MusicPipe.hxx"
|
#include "MusicPipe.hxx"
|
||||||
#include "DetachedSong.hxx"
|
#include "DetachedSong.hxx"
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ DecoderControl::Stop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DecoderControl::Seek(SongTime t)
|
DecoderControl::Seek(SongTime t, Error &error_r)
|
||||||
{
|
{
|
||||||
assert(state != DecoderState::START);
|
assert(state != DecoderState::START);
|
||||||
assert(state != DecoderState::ERROR);
|
assert(state != DecoderState::ERROR);
|
||||||
@ -116,20 +117,30 @@ DecoderControl::Seek(SongTime t)
|
|||||||
gcc_unreachable();
|
gcc_unreachable();
|
||||||
|
|
||||||
case DecoderState::STOP:
|
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;
|
return false;
|
||||||
|
|
||||||
case DecoderState::DECODE:
|
case DecoderState::DECODE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!seekable)
|
if (!seekable) {
|
||||||
|
error_r.Set(decoder_domain, "Not seekable");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
seek_time = t;
|
seek_time = t;
|
||||||
seek_error = false;
|
seek_error = false;
|
||||||
LockSynchronousCommand(DecoderCommand::SEEK);
|
LockSynchronousCommand(DecoderCommand::SEEK);
|
||||||
|
|
||||||
return !seek_error;
|
if (seek_error) {
|
||||||
|
error_r.Set(decoder_domain, "Decoder failed to seek");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -365,7 +365,7 @@ public:
|
|||||||
|
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
bool Seek(SongTime t);
|
bool Seek(SongTime t, Error &error_r);
|
||||||
|
|
||||||
void Quit();
|
void Quit();
|
||||||
|
|
||||||
|
@ -605,8 +605,10 @@ Player::SeekDecoder()
|
|||||||
where = total_time;
|
where = total_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dc.Seek(where + start_time)) {
|
Error error;
|
||||||
|
if (!dc.Seek(where + start_time, error)) {
|
||||||
/* decoder failure */
|
/* decoder failure */
|
||||||
|
pc.SetError(PlayerError::DECODER, std::move(error));
|
||||||
pc.LockCommandFinished();
|
pc.LockCommandFinished();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user