Song: pass reference to song_equals()
This commit is contained in:
parent
f6d67ac260
commit
20cba9e89f
@ -47,10 +47,8 @@ decoder_control::~decoder_control()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
decoder_control::IsCurrentSong(const Song *_song) const
|
decoder_control::IsCurrentSong(const Song &_song) const
|
||||||
{
|
{
|
||||||
assert(_song != nullptr);
|
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case DecoderState::STOP:
|
case DecoderState::STOP:
|
||||||
case DecoderState::ERROR:
|
case DecoderState::ERROR:
|
||||||
@ -58,7 +56,7 @@ decoder_control::IsCurrentSong(const Song *_song) const
|
|||||||
|
|
||||||
case DecoderState::START:
|
case DecoderState::START:
|
||||||
case DecoderState::DECODE:
|
case DecoderState::DECODE:
|
||||||
return song_equals(song, _song);
|
return SongEquals(*song, _song);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(false);
|
assert(false);
|
||||||
|
@ -274,10 +274,10 @@ struct decoder_control {
|
|||||||
* Caller must lock the object.
|
* Caller must lock the object.
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool IsCurrentSong(const Song *_song) const;
|
bool IsCurrentSong(const Song &_song) const;
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool LockIsCurrentSong(const Song *_song) const {
|
bool LockIsCurrentSong(const Song &_song) const {
|
||||||
Lock();
|
Lock();
|
||||||
const bool result = IsCurrentSong(_song);
|
const bool result = IsCurrentSong(_song);
|
||||||
Unlock();
|
Unlock();
|
||||||
|
@ -521,7 +521,7 @@ Player::SeekDecoder()
|
|||||||
|
|
||||||
const unsigned start_ms = pc.next_song->start_ms;
|
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 -
|
/* the decoder is already decoding the "next" song -
|
||||||
stop it and start the previous song again */
|
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
|
bool
|
||||||
song_equals(const Song *a, const Song *b)
|
SongEquals(const Song &a, const Song &b)
|
||||||
{
|
{
|
||||||
assert(a != nullptr);
|
if (a.parent != nullptr && b.parent != nullptr &&
|
||||||
assert(b != 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
|
/* must compare the full URI if one of the objects is
|
||||||
"detached" */
|
"detached" */
|
||||||
const auto au = a->GetURI();
|
const auto au = a.GetURI();
|
||||||
const auto bu = b->GetURI();
|
const auto bu = b.GetURI();
|
||||||
return au == bu;
|
return au == bu;
|
||||||
}
|
}
|
||||||
|
|
||||||
return directory_is_same(a->parent, b->parent) &&
|
return directory_is_same(a.parent, b.parent) &&
|
||||||
strcmp(a->uri, b->uri) == 0;
|
strcmp(a.uri, b.uri) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
@ -145,6 +145,6 @@ struct Song {
|
|||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool
|
bool
|
||||||
song_equals(const Song *a, const Song *b);
|
SongEquals(const Song &a, const Song &b);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user