Song: pass reference to song_equals()
This commit is contained in:
parent
f6d67ac260
commit
20cba9e89f
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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 */
|
||||
|
||||
|
19
src/Song.cxx
19
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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user