MPD 0.17~git
src/song.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003-2011 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 "util/list.h"
00024 
00025 #include <stddef.h>
00026 #include <stdbool.h>
00027 #include <sys/time.h>
00028 
00029 #define SONG_FILE       "file: "
00030 #define SONG_TIME       "Time: "
00031 
00032 struct song {
00041         struct list_head siblings;
00042 
00043         struct tag *tag;
00044         struct directory *parent;
00045         time_t mtime;
00046 
00050         unsigned start_ms;
00051 
00056         unsigned end_ms;
00057 
00058         char uri[sizeof(int)];
00059 };
00060 
00062 struct song *
00063 song_remote_new(const char *uri);
00064 
00066 struct song *
00067 song_file_new(const char *path, struct directory *parent);
00068 
00074 struct song *
00075 song_file_load(const char *path, struct directory *parent);
00076 
00077 void
00078 song_free(struct song *song);
00079 
00080 bool
00081 song_file_update(struct song *song);
00082 
00083 bool
00084 song_file_update_inarchive(struct song *song);
00085 
00093 char *
00094 song_get_uri(const struct song *song);
00095 
00096 double
00097 song_get_duration(const struct song *song);
00098 
00099 static inline bool
00100 song_in_database(const struct song *song)
00101 {
00102         return song->parent != NULL;
00103 }
00104 
00105 static inline bool
00106 song_is_file(const struct song *song)
00107 {
00108         return song_in_database(song) || song->uri[0] == '/';
00109 }
00110 
00111 #endif