Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
c3ccbfd4
Commit
c3ccbfd4
authored
5 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue/Playlist: add `noexcept`
parent
de3cd96c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
53 deletions
+65
-53
Playlist.cxx
src/queue/Playlist.cxx
+14
-13
Playlist.hxx
src/queue/Playlist.hxx
+40
-30
PlaylistControl.cxx
src/queue/PlaylistControl.cxx
+2
-2
PlaylistEdit.cxx
src/queue/PlaylistEdit.cxx
+9
-8
No files found.
src/queue/Playlist.cxx
View file @
c3ccbfd4
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include <assert.h>
#include <assert.h>
void
void
playlist
::
TagModified
(
DetachedSong
&&
song
)
playlist
::
TagModified
(
DetachedSong
&&
song
)
noexcept
{
{
if
(
!
playing
)
if
(
!
playing
)
return
;
return
;
...
@@ -62,7 +62,7 @@ playlist::TagModified(const char *uri, const Tag &tag) noexcept
...
@@ -62,7 +62,7 @@ playlist::TagModified(const char *uri, const Tag &tag) noexcept
}
}
inline
void
inline
void
playlist
::
QueueSongOrder
(
PlayerControl
&
pc
,
unsigned
order
)
playlist
::
QueueSongOrder
(
PlayerControl
&
pc
,
unsigned
order
)
noexcept
{
{
assert
(
queue
.
IsValidOrder
(
order
));
assert
(
queue
.
IsValidOrder
(
order
));
...
@@ -78,7 +78,7 @@ playlist::QueueSongOrder(PlayerControl &pc, unsigned order)
...
@@ -78,7 +78,7 @@ playlist::QueueSongOrder(PlayerControl &pc, unsigned order)
}
}
void
void
playlist
::
SongStarted
()
playlist
::
SongStarted
()
noexcept
{
{
assert
(
current
>=
0
);
assert
(
current
>=
0
);
...
@@ -88,7 +88,7 @@ playlist::SongStarted()
...
@@ -88,7 +88,7 @@ playlist::SongStarted()
}
}
inline
void
inline
void
playlist
::
QueuedSongStarted
(
PlayerControl
&
pc
)
playlist
::
QueuedSongStarted
(
PlayerControl
&
pc
)
noexcept
{
{
assert
(
!
pc
.
LockGetSyncInfo
().
has_next_song
);
assert
(
!
pc
.
LockGetSyncInfo
().
has_next_song
);
assert
(
queued
>=
-
1
);
assert
(
queued
>=
-
1
);
...
@@ -118,7 +118,8 @@ playlist::GetQueuedSong() const noexcept
...
@@ -118,7 +118,8 @@ playlist::GetQueuedSong() const noexcept
}
}
void
void
playlist
::
UpdateQueuedSong
(
PlayerControl
&
pc
,
const
DetachedSong
*
prev
)
playlist
::
UpdateQueuedSong
(
PlayerControl
&
pc
,
const
DetachedSong
*
prev
)
noexcept
{
{
if
(
!
playing
)
if
(
!
playing
)
return
;
return
;
...
@@ -187,7 +188,7 @@ playlist::PlayOrder(PlayerControl &pc, unsigned order)
...
@@ -187,7 +188,7 @@ playlist::PlayOrder(PlayerControl &pc, unsigned order)
}
}
void
void
playlist
::
SyncWithPlayer
(
PlayerControl
&
pc
)
playlist
::
SyncWithPlayer
(
PlayerControl
&
pc
)
noexcept
{
{
if
(
!
playing
)
if
(
!
playing
)
/* this event has reached us out of sync: we aren't
/* this event has reached us out of sync: we aren't
...
@@ -216,7 +217,7 @@ playlist::SyncWithPlayer(PlayerControl &pc)
...
@@ -216,7 +217,7 @@ playlist::SyncWithPlayer(PlayerControl &pc)
}
}
inline
void
inline
void
playlist
::
ResumePlayback
(
PlayerControl
&
pc
)
playlist
::
ResumePlayback
(
PlayerControl
&
pc
)
noexcept
{
{
assert
(
playing
);
assert
(
playing
);
assert
(
pc
.
GetState
()
==
PlayerState
::
STOP
);
assert
(
pc
.
GetState
()
==
PlayerState
::
STOP
);
...
@@ -243,7 +244,7 @@ playlist::ResumePlayback(PlayerControl &pc)
...
@@ -243,7 +244,7 @@ playlist::ResumePlayback(PlayerControl &pc)
}
}
void
void
playlist
::
SetRepeat
(
PlayerControl
&
pc
,
bool
status
)
playlist
::
SetRepeat
(
PlayerControl
&
pc
,
bool
status
)
noexcept
{
{
if
(
status
==
queue
.
repeat
)
if
(
status
==
queue
.
repeat
)
return
;
return
;
...
@@ -260,7 +261,7 @@ playlist::SetRepeat(PlayerControl &pc, bool status)
...
@@ -260,7 +261,7 @@ playlist::SetRepeat(PlayerControl &pc, bool status)
}
}
static
void
static
void
playlist_order
(
playlist
&
playlist
)
playlist_order
(
playlist
&
playlist
)
noexcept
{
{
if
(
playlist
.
current
>=
0
)
if
(
playlist
.
current
>=
0
)
/* update playlist.current, order==position now */
/* update playlist.current, order==position now */
...
@@ -270,7 +271,7 @@ playlist_order(playlist &playlist)
...
@@ -270,7 +271,7 @@ playlist_order(playlist &playlist)
}
}
void
void
playlist
::
SetSingle
(
PlayerControl
&
pc
,
SingleMode
status
)
playlist
::
SetSingle
(
PlayerControl
&
pc
,
SingleMode
status
)
noexcept
{
{
if
(
status
==
queue
.
single
)
if
(
status
==
queue
.
single
)
return
;
return
;
...
@@ -288,7 +289,7 @@ playlist::SetSingle(PlayerControl &pc, SingleMode status)
...
@@ -288,7 +289,7 @@ playlist::SetSingle(PlayerControl &pc, SingleMode status)
}
}
void
void
playlist
::
SetConsume
(
bool
status
)
playlist
::
SetConsume
(
bool
status
)
noexcept
{
{
if
(
status
==
queue
.
consume
)
if
(
status
==
queue
.
consume
)
return
;
return
;
...
@@ -298,7 +299,7 @@ playlist::SetConsume(bool status)
...
@@ -298,7 +299,7 @@ playlist::SetConsume(bool status)
}
}
void
void
playlist
::
SetRandom
(
PlayerControl
&
pc
,
bool
status
)
playlist
::
SetRandom
(
PlayerControl
&
pc
,
bool
status
)
noexcept
{
{
if
(
status
==
queue
.
random
)
if
(
status
==
queue
.
random
)
return
;
return
;
...
@@ -358,7 +359,7 @@ playlist::GetNextPosition() const noexcept
...
@@ -358,7 +359,7 @@ playlist::GetNextPosition() const noexcept
}
}
void
void
playlist
::
BorderPause
(
PlayerControl
&
pc
)
playlist
::
BorderPause
(
PlayerControl
&
pc
)
noexcept
{
{
if
(
queue
.
single
==
SingleMode
::
ONE_SHOT
)
{
if
(
queue
.
single
==
SingleMode
::
ONE_SHOT
)
{
queue
.
single
=
SingleMode
::
OFF
;
queue
.
single
=
SingleMode
::
OFF
;
...
...
This diff is collapsed.
Click to expand it.
src/queue/Playlist.hxx
View file @
c3ccbfd4
...
@@ -92,21 +92,21 @@ struct playlist {
...
@@ -92,21 +92,21 @@ struct playlist {
int
queued
=
-
1
;
int
queued
=
-
1
;
playlist
(
unsigned
max_length
,
playlist
(
unsigned
max_length
,
QueueListener
&
_listener
)
QueueListener
&
_listener
)
noexcept
:
queue
(
max_length
),
:
queue
(
max_length
),
listener
(
_listener
)
listener
(
_listener
)
{
{
}
}
uint32_t
GetVersion
()
const
{
uint32_t
GetVersion
()
const
noexcept
{
return
queue
.
version
;
return
queue
.
version
;
}
}
unsigned
GetLength
()
const
{
unsigned
GetLength
()
const
noexcept
{
return
queue
.
GetLength
();
return
queue
.
GetLength
();
}
}
unsigned
PositionToId
(
unsigned
position
)
const
{
unsigned
PositionToId
(
unsigned
position
)
const
noexcept
{
return
queue
.
PositionToId
(
position
);
return
queue
.
PositionToId
(
position
);
}
}
...
@@ -128,13 +128,13 @@ struct playlist {
...
@@ -128,13 +128,13 @@ struct playlist {
* player thread whenever it requests a new queued song, or
* player thread whenever it requests a new queued song, or
* when it exits.
* when it exits.
*/
*/
void
SyncWithPlayer
(
PlayerControl
&
pc
);
void
SyncWithPlayer
(
PlayerControl
&
pc
)
noexcept
;
/**
/**
* This is the "BORDER_PAUSE" event handler. It is invoked by
* This is the "BORDER_PAUSE" event handler. It is invoked by
* the player thread whenever playback goes into border pause.
* the player thread whenever playback goes into border pause.
*/
*/
void
BorderPause
(
PlayerControl
&
pc
);
void
BorderPause
(
PlayerControl
&
pc
)
noexcept
;
protected
:
protected
:
/**
/**
...
@@ -142,7 +142,7 @@ protected:
...
@@ -142,7 +142,7 @@ protected:
* Updates the queue version and invokes
* Updates the queue version and invokes
* QueueListener::OnQueueModified().
* QueueListener::OnQueueModified().
*/
*/
void
OnModified
();
void
OnModified
()
noexcept
;
/**
/**
* Called when playback of a new song starts. Unlike
* Called when playback of a new song starts. Unlike
...
@@ -153,7 +153,7 @@ protected:
...
@@ -153,7 +153,7 @@ protected:
* The song being started is specified by the #current
* The song being started is specified by the #current
* attribute.
* attribute.
*/
*/
void
SongStarted
();
void
SongStarted
()
noexcept
;
/**
/**
* Updates the "queued song". Calculates the next song
* Updates the "queued song". Calculates the next song
...
@@ -164,38 +164,38 @@ protected:
...
@@ -164,38 +164,38 @@ protected:
* @param prev the song which was previously queued, as
* @param prev the song which was previously queued, as
* determined by playlist_get_queued_song()
* 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.
* 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
* Called when the player thread has started playing the
* "queued" song, i.e. it has switched from one song to the
* "queued" song, i.e. it has switched from one song to the
* next automatically.
* next automatically.
*/
*/
void
QueuedSongStarted
(
PlayerControl
&
pc
);
void
QueuedSongStarted
(
PlayerControl
&
pc
)
noexcept
;
/**
/**
* The player has stopped for some reason. Check the error,
* The player has stopped for some reason. Check the error,
* and decide whether to re-start playback.
* and decide whether to re-start playback.
*/
*/
void
ResumePlayback
(
PlayerControl
&
pc
);
void
ResumePlayback
(
PlayerControl
&
pc
)
noexcept
;
public
:
public
:
void
BeginBulk
();
void
BeginBulk
()
noexcept
;
void
CommitBulk
(
PlayerControl
&
pc
);
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
* A tag in the play queue has been modified by the player
* thread. Apply the given song's tag to the current song if
* thread. Apply the given song's tag to the current song if
* the song matches.
* the song matches.
*/
*/
void
TagModified
(
DetachedSong
&&
song
);
void
TagModified
(
DetachedSong
&&
song
)
noexcept
;
void
TagModified
(
const
char
*
uri
,
const
Tag
&
tag
)
noexcept
;
void
TagModified
(
const
char
*
uri
,
const
Tag
&
tag
)
noexcept
;
#ifdef ENABLE_DATABASE
#ifdef ENABLE_DATABASE
...
@@ -223,7 +223,7 @@ public:
...
@@ -223,7 +223,7 @@ public:
protected
:
protected
:
void
DeleteInternal
(
PlayerControl
&
pc
,
void
DeleteInternal
(
PlayerControl
&
pc
,
unsigned
song
,
const
DetachedSong
**
queued_p
);
unsigned
song
,
const
DetachedSong
**
queued_p
)
noexcept
;
public
:
public
:
void
DeletePosition
(
PlayerControl
&
pc
,
unsigned
position
);
void
DeletePosition
(
PlayerControl
&
pc
,
unsigned
position
);
...
@@ -248,9 +248,9 @@ public:
...
@@ -248,9 +248,9 @@ public:
* database. The method attempts to remove all instances of
* database. The method attempts to remove all instances of
* this song from the queue.
* 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
,
void
MoveRange
(
PlayerControl
&
pc
,
unsigned
start
,
unsigned
end
,
int
to
);
unsigned
end
,
int
to
);
...
@@ -271,14 +271,24 @@ public:
...
@@ -271,14 +271,24 @@ public:
/**
/**
* Sets the start_time and end_time attributes on the song
* Sets the start_time and end_time attributes on the song
* with the specified id.
* with the specified id.
*
* Throws on error.
*/
*/
void
SetSongIdRange
(
PlayerControl
&
pc
,
unsigned
id
,
void
SetSongIdRange
(
PlayerControl
&
pc
,
unsigned
id
,
SongTime
start
,
SongTime
end
);
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
ClearSongIdTag
(
unsigned
id
,
TagType
tag_type
);
void
Stop
(
PlayerControl
&
pc
);
void
Stop
(
PlayerControl
&
pc
)
noexcept
;
/**
/**
* Throws on error.
* Throws on error.
...
@@ -338,29 +348,29 @@ public:
...
@@ -338,29 +348,29 @@ public:
void
SeekCurrent
(
PlayerControl
&
pc
,
void
SeekCurrent
(
PlayerControl
&
pc
,
SignedSongTime
seek_time
,
bool
relative
);
SignedSongTime
seek_time
,
bool
relative
);
bool
GetRepeat
()
const
{
bool
GetRepeat
()
const
noexcept
{
return
queue
.
repeat
;
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
;
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
;
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
;
return
queue
.
consume
;
}
}
void
SetConsume
(
bool
new_value
);
void
SetConsume
(
bool
new_value
)
noexcept
;
private
:
private
:
/**
/**
...
@@ -372,7 +382,7 @@ private:
...
@@ -372,7 +382,7 @@ private:
*
*
* @return the new order number of the given song
* @return the new order number of the given song
*/
*/
unsigned
MoveOrderToCurrent
(
unsigned
old_order
);
unsigned
MoveOrderToCurrent
(
unsigned
old_order
)
noexcept
;
};
};
#endif
#endif
This diff is collapsed.
Click to expand it.
src/queue/PlaylistControl.cxx
View file @
c3ccbfd4
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#include "Log.hxx"
#include "Log.hxx"
void
void
playlist
::
Stop
(
PlayerControl
&
pc
)
playlist
::
Stop
(
PlayerControl
&
pc
)
noexcept
{
{
if
(
!
playing
)
if
(
!
playing
)
return
;
return
;
...
@@ -56,7 +56,7 @@ playlist::Stop(PlayerControl &pc)
...
@@ -56,7 +56,7 @@ playlist::Stop(PlayerControl &pc)
}
}
unsigned
unsigned
playlist
::
MoveOrderToCurrent
(
unsigned
old_order
)
playlist
::
MoveOrderToCurrent
(
unsigned
old_order
)
noexcept
{
{
if
(
!
queue
.
random
)
if
(
!
queue
.
random
)
/* no-op because there is no order list */
/* no-op because there is no order list */
...
...
This diff is collapsed.
Click to expand it.
src/queue/PlaylistEdit.cxx
View file @
c3ccbfd4
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
#include <stdlib.h>
#include <stdlib.h>
void
void
playlist
::
OnModified
()
playlist
::
OnModified
()
noexcept
{
{
if
(
bulk_edit
)
{
if
(
bulk_edit
)
{
/* postponed to CommitBulk() */
/* postponed to CommitBulk() */
...
@@ -49,7 +49,7 @@ playlist::OnModified()
...
@@ -49,7 +49,7 @@ playlist::OnModified()
}
}
void
void
playlist
::
Clear
(
PlayerControl
&
pc
)
playlist
::
Clear
(
PlayerControl
&
pc
)
noexcept
{
{
Stop
(
pc
);
Stop
(
pc
);
...
@@ -60,7 +60,7 @@ playlist::Clear(PlayerControl &pc)
...
@@ -60,7 +60,7 @@ playlist::Clear(PlayerControl &pc)
}
}
void
void
playlist
::
BeginBulk
()
playlist
::
BeginBulk
()
noexcept
{
{
assert
(
!
bulk_edit
);
assert
(
!
bulk_edit
);
...
@@ -69,7 +69,7 @@ playlist::BeginBulk()
...
@@ -69,7 +69,7 @@ playlist::BeginBulk()
}
}
void
void
playlist
::
CommitBulk
(
PlayerControl
&
pc
)
playlist
::
CommitBulk
(
PlayerControl
&
pc
)
noexcept
{
{
assert
(
bulk_edit
);
assert
(
bulk_edit
);
...
@@ -213,7 +213,7 @@ playlist::SetPriorityId(PlayerControl &pc,
...
@@ -213,7 +213,7 @@ playlist::SetPriorityId(PlayerControl &pc,
void
void
playlist
::
DeleteInternal
(
PlayerControl
&
pc
,
playlist
::
DeleteInternal
(
PlayerControl
&
pc
,
unsigned
song
,
const
DetachedSong
**
queued_p
)
unsigned
song
,
const
DetachedSong
**
queued_p
)
noexcept
{
{
assert
(
song
<
GetLength
());
assert
(
song
<
GetLength
());
...
@@ -306,7 +306,7 @@ playlist::DeleteId(PlayerControl &pc, unsigned id)
...
@@ -306,7 +306,7 @@ playlist::DeleteId(PlayerControl &pc, unsigned id)
}
}
void
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
/* don't remove the song if it's currently being played, to
avoid disrupting playback; a deleted file may still be
avoid disrupting playback; a deleted file may still be
...
@@ -322,7 +322,8 @@ playlist::StaleSong(PlayerControl &pc, const char *uri)
...
@@ -322,7 +322,8 @@ playlist::StaleSong(PlayerControl &pc, const char *uri)
}
}
void
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
))
if
(
!
queue
.
IsValidPosition
(
start
)
||
!
queue
.
IsValidPosition
(
end
-
1
))
throw
PlaylistError
::
BadRange
();
throw
PlaylistError
::
BadRange
();
...
@@ -383,7 +384,7 @@ playlist::MoveId(PlayerControl &pc, unsigned id1, int to)
...
@@ -383,7 +384,7 @@ playlist::MoveId(PlayerControl &pc, unsigned id1, int to)
}
}
void
void
playlist
::
Shuffle
(
PlayerControl
&
pc
,
unsigned
start
,
unsigned
end
)
playlist
::
Shuffle
(
PlayerControl
&
pc
,
unsigned
start
,
unsigned
end
)
noexcept
{
{
if
(
end
>
GetLength
())
if
(
end
>
GetLength
())
/* correct the "end" offset */
/* correct the "end" offset */
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment