diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-10-05 00:36:55 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-10-05 00:36:55 -0700 |
commit | c4802008b899cc2d272d5e9b6c7000736ed3a6df (patch) | |
tree | 5d9146af43e9999ed32e726d52de7e0d2674958c /src/song.c | |
parent | 9beb6b61ab28122de049da918afad424b1e92c42 (diff) | |
parent | 1533279fb18b2b0f53345f0e0727d2f0f968c00d (diff) | |
download | mpd-c4802008b899cc2d272d5e9b6c7000736ed3a6df.tar.gz mpd-c4802008b899cc2d272d5e9b6c7000736ed3a6df.tar.xz mpd-c4802008b899cc2d272d5e9b6c7000736ed3a6df.zip |
Merge commit '1533279fb18b2b0f53345f0e0727d2f0f968c00d'
* commit '1533279fb18b2b0f53345f0e0727d2f0f968c00d':
directory: reuse existing directory if found on update
song: better handling of existing songs when rereading DB
tag: merge clearMpdTag into tag_free
song: start avoiding race in updateSongInfo
command: get rid of specialized list handlers
directory: simplify list update handling logic
main_notify: define main_task so we can use it for assertions
directory: streamline deletes
song: start avoiding race in updateSongInfo
playlist: small lines of code reduction
Revert "Start using song pointers in core data structures"
Conflicts:
src/playlist.c
Diffstat (limited to '')
-rw-r--r-- | src/song.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/song.c b/src/song.c index 5c5024391..4f7b2f8bb 100644 --- a/src/song.c +++ b/src/song.c @@ -123,11 +123,20 @@ static void insertSongIntoList(struct songvec *sv, Song *newsong) tag_end_add(newsong->tag); } else { /* prevent dupes, just update the existing song info */ if (existing->mtime != newsong->mtime) { - tag_free(existing->tag); - if (newsong->tag) - tag_end_add(newsong->tag); - existing->tag = newsong->tag; existing->mtime = newsong->mtime; + if (tag_equal(existing->tag, newsong->tag)) { + if (newsong->tag) + tag_free(newsong->tag); + } else { + struct mpd_tag *old_tag = existing->tag; + + if (newsong->tag) + tag_end_add(newsong->tag); + existing->tag = newsong->tag; + if (old_tag) + tag_free(old_tag); + } + /* prevent tag_free in freeJustSong */ newsong->tag = NULL; } freeJustSong(newsong); @@ -207,19 +216,22 @@ int updateSongInfo(Song * song) unsigned int next = 0; char path_max_tmp[MPD_PATH_MAX]; char abs_path[MPD_PATH_MAX]; + struct mpd_tag *old_tag = song->tag; + struct mpd_tag *new_tag = NULL; utf8_to_fs_charset(abs_path, get_song_url(path_max_tmp, song)); rmp2amp_r(abs_path, abs_path); - if (song->tag) - tag_free(song->tag); - - song->tag = NULL; - - while (!song->tag && (plugin = isMusic(abs_path, - &(song->mtime), - next++))) { - song->tag = plugin->tagDupFunc(abs_path); + while ((plugin = isMusic(abs_path, &song->mtime, next++))) { + if ((new_tag = plugin->tagDupFunc(abs_path))) + break; + } + if (new_tag && tag_equal(new_tag, old_tag)) { + tag_free(new_tag); + } else { + song->tag = new_tag; + if (old_tag) + tag_free(old_tag); } if (!song->tag || song->tag->time < 0) return -1; |