aboutsummaryrefslogtreecommitdiffstats
path: root/src/song.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-25 22:59:13 +0100
committerMax Kellermann <max@duempel.org>2009-12-27 14:46:04 +0100
commita038bca74580359a883dc8d526feb7104a677d8c (patch)
tree0ade8231ea065723839086f135d715d4284a21e9 /src/song.c
parentcf38505d8fddbfee431936969e34b9d438243f31 (diff)
downloadmpd-a038bca74580359a883dc8d526feb7104a677d8c.tar.gz
mpd-a038bca74580359a883dc8d526feb7104a677d8c.tar.xz
mpd-a038bca74580359a883dc8d526feb7104a677d8c.zip
song: added support for selecting a time range
Added attributes start_ms, end_ms. This allows us to address a portion of a song file (important for CUE support). There is no support yet for storing these attributes in the state file.
Diffstat (limited to 'src/song.c')
-rw-r--r--src/song.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/song.c b/src/song.c
index bc6cb11c4..64f476b7e 100644
--- a/src/song.c
+++ b/src/song.c
@@ -42,6 +42,7 @@ song_alloc(const char *uri, struct directory *parent)
memcpy(song->uri, uri, uri_length + 1);
song->parent = parent;
song->mtime = 0;
+ song->start_ms = song->end_ms = 0;
return song;
}
@@ -84,8 +85,11 @@ song_get_uri(const struct song *song)
double
song_get_duration(const struct song *song)
{
+ if (song->end_ms > 0)
+ return (song->end_ms - song->start_ms) / 1000.0;
+
if (song->tag == NULL)
return 0;
- return song->tag->time;
+ return song->tag->time - song->start_ms / 1000.0;
}