summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-21 23:19:15 +0200
committerMax Kellermann <max@duempel.org>2013-10-21 23:19:15 +0200
commit20cba9e89f80d788a1cc65473865f52de94ea451 (patch)
tree7e9d96754b4f59ea2235c1455e18ba83cd31411a
parentf6d67ac260ad12a6465378d93d03d98fea857ec8 (diff)
Song: pass reference to song_equals()
-rw-r--r--src/DecoderControl.cxx6
-rw-r--r--src/DecoderControl.hxx4
-rw-r--r--src/PlayerThread.cxx2
-rw-r--r--src/Song.cxx19
-rw-r--r--src/Song.hxx2
5 files changed, 14 insertions, 19 deletions
diff --git a/src/DecoderControl.cxx b/src/DecoderControl.cxx
index 26751855d..ff6d1ad2d 100644
--- a/src/DecoderControl.cxx
+++ b/src/DecoderControl.cxx
@@ -47,10 +47,8 @@ decoder_control::~decoder_control()
}
bool
-decoder_control::IsCurrentSong(const Song *_song) const
+decoder_control::IsCurrentSong(const Song &_song) const
{
- assert(_song != nullptr);
-
switch (state) {
case DecoderState::STOP:
case DecoderState::ERROR:
@@ -58,7 +56,7 @@ decoder_control::IsCurrentSong(const Song *_song) const
case DecoderState::START:
case DecoderState::DECODE:
- return song_equals(song, _song);
+ return SongEquals(*song, _song);
}
assert(false);
diff --git a/src/DecoderControl.hxx b/src/DecoderControl.hxx
index 07ec71ea2..bc2e7d786 100644
--- a/src/DecoderControl.hxx
+++ b/src/DecoderControl.hxx
@@ -274,10 +274,10 @@ struct decoder_control {
* Caller must lock the object.
*/
gcc_pure
- bool IsCurrentSong(const Song *_song) const;
+ bool IsCurrentSong(const Song &_song) const;
gcc_pure
- bool LockIsCurrentSong(const Song *_song) const {
+ bool LockIsCurrentSong(const Song &_song) const {
Lock();
const bool result = IsCurrentSong(_song);
Unlock();
diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx
index 830039fc3..4f5b15bba 100644
--- a/src/PlayerThread.cxx
+++ b/src/PlayerThread.cxx
@@ -521,7 +521,7 @@ Player::SeekDecoder()
const unsigned start_ms = pc.next_song->start_ms;
- if (!dc.LockIsCurrentSong(pc.next_song)) {
+ if (!dc.LockIsCurrentSong(*pc.next_song)) {
/* the decoder is already decoding the "next" song -
stop it and start the previous song again */
diff --git a/src/Song.cxx b/src/Song.cxx
index c63dc8753..7a11a0611 100644
--- a/src/Song.cxx
+++ b/src/Song.cxx
@@ -127,23 +127,20 @@ directory_is_same(const Directory *a, const Directory *b)
}
bool
-song_equals(const Song *a, const Song *b)
+SongEquals(const Song &a, const Song &b)
{
- assert(a != nullptr);
- assert(b != nullptr);
-
- if (a->parent != nullptr && b->parent != nullptr &&
- !directory_equals(*a->parent, *b->parent) &&
- (a->parent == &detached_root || b->parent == &detached_root)) {
+ if (a.parent != nullptr && b.parent != nullptr &&
+ !directory_equals(*a.parent, *b.parent) &&
+ (a.parent == &detached_root || b.parent == &detached_root)) {
/* must compare the full URI if one of the objects is
"detached" */
- const auto au = a->GetURI();
- const auto bu = b->GetURI();
+ const auto au = a.GetURI();
+ const auto bu = b.GetURI();
return au == bu;
}
- return directory_is_same(a->parent, b->parent) &&
- strcmp(a->uri, b->uri) == 0;
+ return directory_is_same(a.parent, b.parent) &&
+ strcmp(a.uri, b.uri) == 0;
}
std::string
diff --git a/src/Song.hxx b/src/Song.hxx
index 32158aedf..bd7465013 100644
--- a/src/Song.hxx
+++ b/src/Song.hxx
@@ -145,6 +145,6 @@ struct Song {
*/
gcc_pure
bool
-song_equals(const Song *a, const Song *b);
+SongEquals(const Song &a, const Song &b);
#endif