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 00083 struct song * 00084 song_replace_uri(struct song *song, const char *uri); 00085 00086 void 00087 song_free(struct song *song); 00088 00089 bool 00090 song_file_update(struct song *song); 00091 00092 bool 00093 song_file_update_inarchive(struct song *song); 00094 00102 char * 00103 song_get_uri(const struct song *song); 00104 00105 double 00106 song_get_duration(const struct song *song); 00107 00108 static inline bool 00109 song_in_database(const struct song *song) 00110 { 00111 return song->parent != NULL; 00112 } 00113 00114 static inline bool 00115 song_is_file(const struct song *song) 00116 { 00117 return song_in_database(song) || song->uri[0] == '/'; 00118 } 00119 00120 #endif