queue/Playlist: add noexcept

This commit is contained in:
Max Kellermann 2019-05-31 13:56:09 +02:00
parent de3cd96c76
commit c3ccbfd407
4 changed files with 65 additions and 53 deletions

View File

@ -28,7 +28,7 @@
#include <assert.h>
void
playlist::TagModified(DetachedSong &&song)
playlist::TagModified(DetachedSong &&song) noexcept
{
if (!playing)
return;
@ -62,7 +62,7 @@ playlist::TagModified(const char *uri, const Tag &tag) noexcept
}
inline void
playlist::QueueSongOrder(PlayerControl &pc, unsigned order)
playlist::QueueSongOrder(PlayerControl &pc, unsigned order) noexcept
{
assert(queue.IsValidOrder(order));
@ -78,7 +78,7 @@ playlist::QueueSongOrder(PlayerControl &pc, unsigned order)
}
void
playlist::SongStarted()
playlist::SongStarted() noexcept
{
assert(current >= 0);
@ -88,7 +88,7 @@ playlist::SongStarted()
}
inline void
playlist::QueuedSongStarted(PlayerControl &pc)
playlist::QueuedSongStarted(PlayerControl &pc) noexcept
{
assert(!pc.LockGetSyncInfo().has_next_song);
assert(queued >= -1);
@ -118,7 +118,8 @@ playlist::GetQueuedSong() const noexcept
}
void
playlist::UpdateQueuedSong(PlayerControl &pc, const DetachedSong *prev)
playlist::UpdateQueuedSong(PlayerControl &pc,
const DetachedSong *prev) noexcept
{
if (!playing)
return;
@ -187,7 +188,7 @@ playlist::PlayOrder(PlayerControl &pc, unsigned order)
}
void
playlist::SyncWithPlayer(PlayerControl &pc)
playlist::SyncWithPlayer(PlayerControl &pc) noexcept
{
if (!playing)
/* this event has reached us out of sync: we aren't
@ -216,7 +217,7 @@ playlist::SyncWithPlayer(PlayerControl &pc)
}
inline void
playlist::ResumePlayback(PlayerControl &pc)
playlist::ResumePlayback(PlayerControl &pc) noexcept
{
assert(playing);
assert(pc.GetState() == PlayerState::STOP);
@ -243,7 +244,7 @@ playlist::ResumePlayback(PlayerControl &pc)
}
void
playlist::SetRepeat(PlayerControl &pc, bool status)
playlist::SetRepeat(PlayerControl &pc, bool status) noexcept
{
if (status == queue.repeat)
return;
@ -260,7 +261,7 @@ playlist::SetRepeat(PlayerControl &pc, bool status)
}
static void
playlist_order(playlist &playlist)
playlist_order(playlist &playlist) noexcept
{
if (playlist.current >= 0)
/* update playlist.current, order==position now */
@ -270,7 +271,7 @@ playlist_order(playlist &playlist)
}
void
playlist::SetSingle(PlayerControl &pc, SingleMode status)
playlist::SetSingle(PlayerControl &pc, SingleMode status) noexcept
{
if (status == queue.single)
return;
@ -288,7 +289,7 @@ playlist::SetSingle(PlayerControl &pc, SingleMode status)
}
void
playlist::SetConsume(bool status)
playlist::SetConsume(bool status) noexcept
{
if (status == queue.consume)
return;
@ -298,7 +299,7 @@ playlist::SetConsume(bool status)
}
void
playlist::SetRandom(PlayerControl &pc, bool status)
playlist::SetRandom(PlayerControl &pc, bool status) noexcept
{
if (status == queue.random)
return;
@ -358,7 +359,7 @@ playlist::GetNextPosition() const noexcept
}
void
playlist::BorderPause(PlayerControl &pc)
playlist::BorderPause(PlayerControl &pc) noexcept
{
if (queue.single == SingleMode::ONE_SHOT) {
queue.single = SingleMode::OFF;

View File

@ -92,21 +92,21 @@ struct playlist {
int queued = -1;
playlist(unsigned max_length,
QueueListener &_listener)
QueueListener &_listener) noexcept
:queue(max_length),
listener(_listener)
{
}
uint32_t GetVersion() const {
uint32_t GetVersion() const noexcept {
return queue.version;
}
unsigned GetLength() const {
unsigned GetLength() const noexcept {
return queue.GetLength();
}
unsigned PositionToId(unsigned position) const {
unsigned PositionToId(unsigned position) const noexcept {
return queue.PositionToId(position);
}
@ -128,13 +128,13 @@ struct playlist {
* player thread whenever it requests a new queued song, or
* when it exits.
*/
void SyncWithPlayer(PlayerControl &pc);
void SyncWithPlayer(PlayerControl &pc) noexcept;
/**
* This is the "BORDER_PAUSE" event handler. It is invoked by
* the player thread whenever playback goes into border pause.
*/
void BorderPause(PlayerControl &pc);
void BorderPause(PlayerControl &pc) noexcept;
protected:
/**
@ -142,7 +142,7 @@ protected:
* Updates the queue version and invokes
* QueueListener::OnQueueModified().
*/
void OnModified();
void OnModified() noexcept;
/**
* Called when playback of a new song starts. Unlike
@ -153,7 +153,7 @@ protected:
* The song being started is specified by the #current
* attribute.
*/
void SongStarted();
void SongStarted() noexcept;
/**
* Updates the "queued song". Calculates the next song
@ -164,38 +164,38 @@ protected:
* @param prev the song which was previously queued, as
* determined by playlist_get_queued_song()
*/
void UpdateQueuedSong(PlayerControl &pc, const DetachedSong *prev);
void UpdateQueuedSong(PlayerControl &pc, const DetachedSong *prev) noexcept;
/**
* Queue a song, addressed by its order number.
*/
void QueueSongOrder(PlayerControl &pc, unsigned order);
void QueueSongOrder(PlayerControl &pc, unsigned order) noexcept;
/**
* Called when the player thread has started playing the
* "queued" song, i.e. it has switched from one song to the
* next automatically.
*/
void QueuedSongStarted(PlayerControl &pc);
void QueuedSongStarted(PlayerControl &pc) noexcept;
/**
* The player has stopped for some reason. Check the error,
* and decide whether to re-start playback.
*/
void ResumePlayback(PlayerControl &pc);
void ResumePlayback(PlayerControl &pc) noexcept;
public:
void BeginBulk();
void CommitBulk(PlayerControl &pc);
void BeginBulk() noexcept;
void CommitBulk(PlayerControl &pc) noexcept;
void Clear(PlayerControl &pc);
void Clear(PlayerControl &pc) noexcept;
/**
* A tag in the play queue has been modified by the player
* thread. Apply the given song's tag to the current song if
* the song matches.
*/
void TagModified(DetachedSong &&song);
void TagModified(DetachedSong &&song) noexcept;
void TagModified(const char *uri, const Tag &tag) noexcept;
#ifdef ENABLE_DATABASE
@ -223,7 +223,7 @@ public:
protected:
void DeleteInternal(PlayerControl &pc,
unsigned song, const DetachedSong **queued_p);
unsigned song, const DetachedSong **queued_p) noexcept;
public:
void DeletePosition(PlayerControl &pc, unsigned position);
@ -248,9 +248,9 @@ public:
* database. The method attempts to remove all instances of
* this song from the queue.
*/
void StaleSong(PlayerControl &pc, const char *uri);
void StaleSong(PlayerControl &pc, const char *uri) noexcept;
void Shuffle(PlayerControl &pc, unsigned start, unsigned end);
void Shuffle(PlayerControl &pc, unsigned start, unsigned end) noexcept;
void MoveRange(PlayerControl &pc, unsigned start,
unsigned end, int to);
@ -271,14 +271,24 @@ public:
/**
* Sets the start_time and end_time attributes on the song
* with the specified id.
*
* Throws on error.
*/
void SetSongIdRange(PlayerControl &pc, unsigned id,
SongTime start, SongTime end);
void AddSongIdTag(unsigned id, TagType tag_type, const char *value);
/**
* Throws on error.
*/
void AddSongIdTag(unsigned id, TagType tag_type,
const char *value);
/**
* Throws on error.
*/
void ClearSongIdTag(unsigned id, TagType tag_type);
void Stop(PlayerControl &pc);
void Stop(PlayerControl &pc) noexcept;
/**
* Throws on error.
@ -338,29 +348,29 @@ public:
void SeekCurrent(PlayerControl &pc,
SignedSongTime seek_time, bool relative);
bool GetRepeat() const {
bool GetRepeat() const noexcept {
return queue.repeat;
}
void SetRepeat(PlayerControl &pc, bool new_value);
void SetRepeat(PlayerControl &pc, bool new_value) noexcept;
bool GetRandom() const {
bool GetRandom() const noexcept {
return queue.random;
}
void SetRandom(PlayerControl &pc, bool new_value);
void SetRandom(PlayerControl &pc, bool new_value) noexcept;
SingleMode GetSingle() const {
SingleMode GetSingle() const noexcept {
return queue.single;
}
void SetSingle(PlayerControl &pc, SingleMode new_value);
void SetSingle(PlayerControl &pc, SingleMode new_value) noexcept;
bool GetConsume() const {
bool GetConsume() const noexcept {
return queue.consume;
}
void SetConsume(bool new_value);
void SetConsume(bool new_value) noexcept;
private:
/**
@ -372,7 +382,7 @@ private:
*
* @return the new order number of the given song
*/
unsigned MoveOrderToCurrent(unsigned old_order);
unsigned MoveOrderToCurrent(unsigned old_order) noexcept;
};
#endif

View File

@ -29,7 +29,7 @@
#include "Log.hxx"
void
playlist::Stop(PlayerControl &pc)
playlist::Stop(PlayerControl &pc) noexcept
{
if (!playing)
return;
@ -56,7 +56,7 @@ playlist::Stop(PlayerControl &pc)
}
unsigned
playlist::MoveOrderToCurrent(unsigned old_order)
playlist::MoveOrderToCurrent(unsigned old_order) noexcept
{
if (!queue.random)
/* no-op because there is no order list */

View File

@ -35,7 +35,7 @@
#include <stdlib.h>
void
playlist::OnModified()
playlist::OnModified() noexcept
{
if (bulk_edit) {
/* postponed to CommitBulk() */
@ -49,7 +49,7 @@ playlist::OnModified()
}
void
playlist::Clear(PlayerControl &pc)
playlist::Clear(PlayerControl &pc) noexcept
{
Stop(pc);
@ -60,7 +60,7 @@ playlist::Clear(PlayerControl &pc)
}
void
playlist::BeginBulk()
playlist::BeginBulk() noexcept
{
assert(!bulk_edit);
@ -69,7 +69,7 @@ playlist::BeginBulk()
}
void
playlist::CommitBulk(PlayerControl &pc)
playlist::CommitBulk(PlayerControl &pc) noexcept
{
assert(bulk_edit);
@ -213,7 +213,7 @@ playlist::SetPriorityId(PlayerControl &pc,
void
playlist::DeleteInternal(PlayerControl &pc,
unsigned song, const DetachedSong **queued_p)
unsigned song, const DetachedSong **queued_p) noexcept
{
assert(song < GetLength());
@ -306,7 +306,7 @@ playlist::DeleteId(PlayerControl &pc, unsigned id)
}
void
playlist::StaleSong(PlayerControl &pc, const char *uri)
playlist::StaleSong(PlayerControl &pc, const char *uri) noexcept
{
/* don't remove the song if it's currently being played, to
avoid disrupting playback; a deleted file may still be
@ -322,7 +322,8 @@ playlist::StaleSong(PlayerControl &pc, const char *uri)
}
void
playlist::MoveRange(PlayerControl &pc, unsigned start, unsigned end, int to)
playlist::MoveRange(PlayerControl &pc,
unsigned start, unsigned end, int to)
{
if (!queue.IsValidPosition(start) || !queue.IsValidPosition(end - 1))
throw PlaylistError::BadRange();
@ -383,7 +384,7 @@ playlist::MoveId(PlayerControl &pc, unsigned id1, int to)
}
void
playlist::Shuffle(PlayerControl &pc, unsigned start, unsigned end)
playlist::Shuffle(PlayerControl &pc, unsigned start, unsigned end) noexcept
{
if (end > GetLength())
/* correct the "end" offset */