player/Control: use class Error as C++ exception, throw it

This commit is contained in:
Max Kellermann
2016-09-08 10:29:49 +02:00
parent 3da4648112
commit 6e52ab285a
9 changed files with 150 additions and 141 deletions

View File

@@ -49,20 +49,18 @@ PlayerControl::~PlayerControl()
delete tagged_song;
}
bool
PlayerControl::Play(DetachedSong *song, Error &error_r)
void
PlayerControl::Play(DetachedSong *song)
{
assert(song != nullptr);
const ScopeLock protect(mutex);
bool success = SeekLocked(song, SongTime::zero(), error_r);
SeekLocked(song, SongTime::zero());
if (success && state == PlayerState::PAUSE)
if (state == PlayerState::PAUSE)
/* if the player was paused previously, we need to
unpause it */
PauseLocked();
return success;
}
void
@@ -203,8 +201,8 @@ PlayerControl::LockEnqueueSong(DetachedSong *song)
EnqueueSongLocked(song);
}
bool
PlayerControl::SeekLocked(DetachedSong *song, SongTime t, Error &error_r)
void
PlayerControl::SeekLocked(DetachedSong *song, SongTime t)
{
assert(song != nullptr);
@@ -226,28 +224,23 @@ PlayerControl::SeekLocked(DetachedSong *song, SongTime t, Error &error_r)
if (error_type != PlayerError::NONE) {
assert(error.IsDefined());
error_r.Set(error);
return false;
throw error;
}
assert(!error.IsDefined());
return true;
}
bool
PlayerControl::LockSeek(DetachedSong *song, SongTime t, Error &error_r)
void
PlayerControl::LockSeek(DetachedSong *song, SongTime t)
{
assert(song != nullptr);
{
const ScopeLock protect(mutex);
if (!SeekLocked(song, t, error_r))
return false;
SeekLocked(song, t);
}
idle_add(IDLE_PLAYER);
return true;
}
void