MPD

src/song.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003-2010 The Music Player Daemon Project
00003  * http://www.musicpd.org
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, write to the Free Software Foundation, Inc.,
00017  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 
00020 #ifndef MPD_SONG_H
00021 #define MPD_SONG_H
00022 
00023 #include <stddef.h>
00024 #include <stdbool.h>
00025 #include <sys/time.h>
00026 
00027 #define SONG_FILE       "file: "
00028 #define SONG_TIME       "Time: "
00029 
00030 struct song {
00031         struct tag *tag;
00032         struct directory *parent;
00033         time_t mtime;
00034 
00038         unsigned start_ms;
00039 
00044         unsigned end_ms;
00045 
00046         char uri[sizeof(int)];
00047 };
00048 
00050 struct song *
00051 song_remote_new(const char *uri);
00052 
00054 struct song *
00055 song_file_new(const char *path, struct directory *parent);
00056 
00062 struct song *
00063 song_file_load(const char *path, struct directory *parent);
00064 
00065 void
00066 song_free(struct song *song);
00067 
00068 bool
00069 song_file_update(struct song *song);
00070 
00071 bool
00072 song_file_update_inarchive(struct song *song);
00073 
00081 char *
00082 song_get_uri(const struct song *song);
00083 
00084 double
00085 song_get_duration(const struct song *song);
00086 
00087 static inline bool
00088 song_in_database(const struct song *song)
00089 {
00090         return song->parent != NULL;
00091 }
00092 
00093 static inline bool
00094 song_is_file(const struct song *song)
00095 {
00096         return song_in_database(song) || song->uri[0] == '/';
00097 }
00098 
00099 #endif