PlayerThread: use Song references
This commit is contained in:
parent
cbf57e7421
commit
c152a88ff6
@ -370,19 +370,17 @@ Player::WaitForDecoder()
|
|||||||
* indicated by the decoder plugin.
|
* indicated by the decoder plugin.
|
||||||
*/
|
*/
|
||||||
static double
|
static double
|
||||||
real_song_duration(const Song *song, double decoder_duration)
|
real_song_duration(const Song &song, double decoder_duration)
|
||||||
{
|
{
|
||||||
assert(song != nullptr);
|
|
||||||
|
|
||||||
if (decoder_duration <= 0.0)
|
if (decoder_duration <= 0.0)
|
||||||
/* the decoder plugin didn't provide information; fall
|
/* the decoder plugin didn't provide information; fall
|
||||||
back to Song::GetDuration() */
|
back to Song::GetDuration() */
|
||||||
return song->GetDuration();
|
return song.GetDuration();
|
||||||
|
|
||||||
if (song->end_ms > 0 && song->end_ms / 1000.0 < decoder_duration)
|
if (song.end_ms > 0 && song.end_ms / 1000.0 < decoder_duration)
|
||||||
return (song->end_ms - song->start_ms) / 1000.0;
|
return (song.end_ms - song.start_ms) / 1000.0;
|
||||||
|
|
||||||
return decoder_duration - song->start_ms / 1000.0;
|
return decoder_duration - song.start_ms / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -450,7 +448,7 @@ Player::CheckDecoderStartup()
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
pc.Lock();
|
pc.Lock();
|
||||||
pc.total_time = real_song_duration(dc.song, dc.total_time);
|
pc.total_time = real_song_duration(*dc.song, dc.total_time);
|
||||||
pc.audio_format = dc.in_audio_format;
|
pc.audio_format = dc.in_audio_format;
|
||||||
pc.Unlock();
|
pc.Unlock();
|
||||||
|
|
||||||
@ -683,19 +681,19 @@ Player::ProcessCommand()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_song_tag(PlayerControl &pc, Song *song, const Tag &new_tag)
|
update_song_tag(PlayerControl &pc, Song &song, const Tag &new_tag)
|
||||||
{
|
{
|
||||||
if (song->IsFile())
|
if (song.IsFile())
|
||||||
/* don't update tags of local files, only remote
|
/* don't update tags of local files, only remote
|
||||||
streams may change tags dynamically */
|
streams may change tags dynamically */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Tag *old_tag = song->tag;
|
Tag *old_tag = song.tag;
|
||||||
song->tag = new Tag(new_tag);
|
song.tag = new Tag(new_tag);
|
||||||
|
|
||||||
delete old_tag;
|
delete old_tag;
|
||||||
|
|
||||||
pc.LockSetTaggedSong(*song);
|
pc.LockSetTaggedSong(song);
|
||||||
|
|
||||||
/* the main thread will update the playlist version when he
|
/* the main thread will update the playlist version when he
|
||||||
receives this event */
|
receives this event */
|
||||||
@ -715,7 +713,7 @@ update_song_tag(PlayerControl &pc, Song *song, const Tag &new_tag)
|
|||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
play_chunk(PlayerControl &pc,
|
play_chunk(PlayerControl &pc,
|
||||||
Song *song, struct music_chunk *chunk,
|
Song &song, struct music_chunk *chunk,
|
||||||
MusicBuffer &buffer,
|
MusicBuffer &buffer,
|
||||||
const AudioFormat format,
|
const AudioFormat format,
|
||||||
Error &error)
|
Error &error)
|
||||||
@ -838,7 +836,7 @@ Player::PlayNextChunk()
|
|||||||
/* play the current chunk */
|
/* play the current chunk */
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
if (!play_chunk(pc, song, chunk, buffer, play_audio_format, error)) {
|
if (!play_chunk(pc, *song, chunk, buffer, play_audio_format, error)) {
|
||||||
LogError(error);
|
LogError(error);
|
||||||
|
|
||||||
buffer.Return(chunk);
|
buffer.Return(chunk);
|
||||||
|
Loading…
Reference in New Issue
Block a user