DecoderThread: use Song references

This commit is contained in:
Max Kellermann 2014-01-08 00:35:28 +01:00
parent 3f3ae48ff4
commit cbf57e7421

View File

@ -347,18 +347,18 @@ decoder_run_file(Decoder &decoder, const char *path_fs)
static void static void
decoder_run_song(DecoderControl &dc, decoder_run_song(DecoderControl &dc,
const Song *song, const char *uri) const Song &song, const char *uri)
{ {
Decoder decoder(dc, dc.start_ms > 0, Decoder decoder(dc, dc.start_ms > 0,
song->tag != nullptr && song->IsFile() song.tag != nullptr && song.IsFile()
? new Tag(*song->tag) : nullptr); ? new Tag(*song.tag) : nullptr);
int ret; int ret;
dc.state = DecoderState::START; dc.state = DecoderState::START;
decoder_command_finished_locked(dc); decoder_command_finished_locked(dc);
ret = song->IsFile() ret = song.IsFile()
? decoder_run_file(decoder, uri) ? decoder_run_file(decoder, uri)
: decoder_run_stream(decoder, uri); : decoder_run_stream(decoder, uri);
@ -381,7 +381,7 @@ decoder_run_song(DecoderControl &dc,
else { else {
dc.state = DecoderState::ERROR; dc.state = DecoderState::ERROR;
const char *error_uri = song->uri; const char *error_uri = song.uri;
const std::string allocated = uri_remove_auth(error_uri); const std::string allocated = uri_remove_auth(error_uri);
if (!allocated.empty()) if (!allocated.empty())
error_uri = allocated.c_str(); error_uri = allocated.c_str();
@ -398,12 +398,12 @@ decoder_run(DecoderControl &dc)
{ {
dc.ClearError(); dc.ClearError();
const Song *song = dc.song; assert(dc.song != nullptr);
assert(song != nullptr); const Song &song = *dc.song;
const std::string uri = song->IsFile() const std::string uri = song.IsFile()
? std::string(map_song_fs(*song).c_str()) ? std::string(map_song_fs(song).c_str())
: song->GetURI(); : song.GetURI();
if (uri.empty()) { if (uri.empty()) {
dc.state = DecoderState::ERROR; dc.state = DecoderState::ERROR;