aboutsummaryrefslogtreecommitdiffstats
path: root/src/song.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-03-11 00:16:49 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-03-11 00:16:49 +0000
commit1157b5d332eb12a8481198891b724dfae3cf5a92 (patch)
tree06a434b7bd9f0fac07dfe1d4aa5a81883e2cf2f2 /src/song.c
parent31d44ea77584e9118c367b8ab0569dc5d41f826a (diff)
downloadmpd-1157b5d332eb12a8481198891b724dfae3cf5a92.tar.gz
mpd-1157b5d332eb12a8481198891b724dfae3cf5a92.tar.xz
mpd-1157b5d332eb12a8481198891b724dfae3cf5a92.zip
move time back into MpdTag
git-svn-id: https://svn.musicpd.org/mpd/trunk@250 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/song.c43
1 files changed, 12 insertions, 31 deletions
diff --git a/src/song.c b/src/song.c
index 374831e9c..42754c12d 100644
--- a/src/song.c
+++ b/src/song.c
@@ -48,7 +48,6 @@ Song * newNullSong() {
song->tag = NULL;
song->utf8file = NULL;
- song->time = -1;
return song;
}
@@ -61,34 +60,26 @@ Song * newSong(char * utf8file) {
if(0);
#ifdef HAVE_OGG
else if(isOgg(utf8file,&(song->mtime))) {
- song->time = getOggTotalTime(
- rmp2amp(utf8ToFsCharset(utf8file)));
- if(song->time>=0) song->tag = oggTagDup(utf8file);
+ song->tag = oggTagDup(utf8file);
}
#endif
#ifdef HAVE_FLAC
else if((isFlac(utf8file,&(song->mtime)))) {
- song->time = getFlacTotalTime(
- rmp2amp(utf8ToFsCharset(utf8file)));
- if(song->time>=0) song->tag = flacTagDup(utf8file);
+ song->tag = flacTagDup(utf8file);
}
#endif
#ifdef HAVE_MAD
else if(isMp3(utf8file,&(song->mtime))) {
- song->time = getMp3TotalTime(
- rmp2amp(utf8ToFsCharset(utf8file)));
- if(song->time>=0) song->tag = mp3TagDup(utf8file);
+ song->tag = mp3TagDup(utf8file);
}
#endif
#ifdef HAVE_AUDIOFILE
else if(isWave(utf8file,&(song->mtime))) {
- song->time = getAudiofileTotalTime(
- rmp2amp(utf8ToFsCharset(utf8file)));
- if(song->time>=0) song->tag = audiofileTagDup(utf8file);
+ song->tag = audiofileTagDup(utf8file);
}
#endif
- if(song->time<0) {
+ if(!song->tag || song->tag->time<0) {
freeSong(song);
song = NULL;
}
@@ -130,8 +121,6 @@ void freeSongList(SongList * list) {
int printSongInfo(FILE * fp, Song * song) {
myfprintf(fp,"%s%s\n",SONG_FILE,song->utf8file);
- if(song->time>=0) myfprintf(fp,"%s%i\n",SONG_TIME,song->time);
-
if(song->tag) printMpdTag(fp,song->tag);
return 0;
@@ -203,7 +192,8 @@ void readSongInfoIntoList(FILE * fp, SongList * list) {
song->tag->title = strdup(&(buffer[strlen(SONG_TITLE)]));
}
else if(0==strncmp(SONG_TIME,buffer,strlen(SONG_TIME))) {
- song->time = atoi(&(buffer[strlen(SONG_TIME)]));
+ if(!song->tag) song->tag = newMpdTag();
+ song->tag->time = atoi(&(buffer[strlen(SONG_TIME)]));
}
else if(0==strncmp(SONG_MTIME,buffer,strlen(SONG_MTIME))) {
song->mtime = atoi(&(buffer[strlen(SONG_TITLE)]));
@@ -227,40 +217,31 @@ int updateSongInfo(Song * song) {
removeASongFromTables(song);
if(song->tag) freeMpdTag(song->tag);
- song->time = -1;
song->tag = NULL;
if(0);
#ifdef HAVE_OGG
else if(isOgg(utf8file,&(song->mtime))) {
- song->time = getOggTotalTime(
- rmp2amp(utf8ToFsCharset(utf8file)));
- if(song->time>=0) song->tag = oggTagDup(utf8file);
+ song->tag = oggTagDup(utf8file);
}
#endif
#ifdef HAVE_FLAC
else if((isFlac(utf8file,&(song->mtime)))) {
- song->time = getFlacTotalTime(
- rmp2amp(utf8ToFsCharset(utf8file)));
- if(song->time>=0) song->tag = flacTagDup(utf8file);
+ song->tag = flacTagDup(utf8file);
}
#endif
#ifdef HAVE_MAD
else if(isMp3(utf8file,&(song->mtime))) {
- song->time = getMp3TotalTime(
- rmp2amp(utf8ToFsCharset(utf8file)));
- if(song->time>=0) song->tag = mp3TagDup(utf8file);
+ song->tag = mp3TagDup(utf8file);
}
#endif
#ifdef HAVE_AUDIOFILE
else if(isWave(utf8file,&(song->mtime))) {
- song->time = getAudiofileTotalTime(
- rmp2amp(utf8ToFsCharset(utf8file)));
- if(song->time>=0) song->tag = audiofileTagDup(utf8file);
+ song->tag = audiofileTagDup(utf8file);
}
#endif
- if(song->time<0) return -1;
+ if(!song->tag || song->tag->time<0) return -1;
else addSongToTables(song);
return 0;