2004-02-24 00:41:20 +01:00
|
|
|
/* the Music Player Daemon (MPD)
|
2007-04-05 05:22:33 +02:00
|
|
|
* Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
|
2004-02-24 00:41:20 +01:00
|
|
|
* This project's homepage is: http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2008-10-31 09:19:53 +01:00
|
|
|
#ifndef MPD_SONG_H
|
|
|
|
#define MPD_SONG_H
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 11:03:39 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdbool.h>
|
2008-10-08 10:49:29 +02:00
|
|
|
#include <sys/time.h>
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2004-11-11 01:41:28 +01:00
|
|
|
#define SONG_BEGIN "songList begin"
|
|
|
|
#define SONG_END "songList end"
|
|
|
|
|
2006-10-28 01:07:34 +02:00
|
|
|
#define SONG_FILE "file: "
|
|
|
|
#define SONG_TIME "Time: "
|
|
|
|
|
2008-10-08 10:49:11 +02:00
|
|
|
struct song {
|
2008-08-29 09:38:11 +02:00
|
|
|
struct tag *tag;
|
2008-10-08 11:05:34 +02:00
|
|
|
struct directory *parent;
|
2004-02-24 00:41:20 +01:00
|
|
|
time_t mtime;
|
2008-10-08 10:49:29 +02:00
|
|
|
char url[sizeof(int)];
|
2008-10-08 10:49:11 +02:00
|
|
|
};
|
2008-10-06 18:46:52 +02:00
|
|
|
|
2008-10-08 11:05:25 +02:00
|
|
|
/** allocate a new song with a remote URL */
|
2008-10-08 10:49:11 +02:00
|
|
|
struct song *
|
2008-10-08 11:05:25 +02:00
|
|
|
song_remote_new(const char *url);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 11:05:25 +02:00
|
|
|
/** allocate a new song with a local file name */
|
2008-10-08 10:49:11 +02:00
|
|
|
struct song *
|
2008-10-08 11:05:25 +02:00
|
|
|
song_file_new(const char *path, struct directory *parent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* allocate a new song structure with a local file name and attempt to
|
|
|
|
* load its metadata. If all decoder plugin fail to read its meta
|
|
|
|
* data, NULL is returned.
|
|
|
|
*/
|
|
|
|
struct song *
|
|
|
|
song_file_load(const char *path, struct directory *parent);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 10:49:11 +02:00
|
|
|
void
|
2008-10-08 11:05:34 +02:00
|
|
|
song_free(struct song *song);
|
2004-05-13 20:46:38 +02:00
|
|
|
|
2008-10-08 11:06:26 +02:00
|
|
|
bool
|
2008-10-08 11:05:34 +02:00
|
|
|
song_file_update(struct song *song);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-12-16 21:42:42 +01:00
|
|
|
bool
|
|
|
|
song_file_update_inarchive(struct song *song);
|
|
|
|
|
2009-01-04 19:09:34 +01:00
|
|
|
/**
|
|
|
|
* Returns the URI of the song in UTF-8 encoding, including its
|
|
|
|
* location within the music directory.
|
|
|
|
*
|
|
|
|
* The return value is allocated on the heap, and must be freed by the
|
|
|
|
* caller.
|
2008-04-12 06:08:18 +02:00
|
|
|
*/
|
2008-10-08 10:49:11 +02:00
|
|
|
char *
|
2009-01-04 19:09:34 +01:00
|
|
|
song_get_uri(const struct song *song);
|
2004-11-11 03:36:25 +01:00
|
|
|
|
2008-10-08 11:03:39 +02:00
|
|
|
static inline bool
|
2008-10-15 22:34:47 +02:00
|
|
|
song_in_database(const struct song *song)
|
2008-10-06 18:52:13 +02:00
|
|
|
{
|
2008-10-08 11:05:34 +02:00
|
|
|
return song->parent != NULL;
|
2008-10-06 18:52:13 +02:00
|
|
|
}
|
|
|
|
|
2008-10-15 22:34:47 +02:00
|
|
|
static inline bool
|
|
|
|
song_is_file(const struct song *song)
|
|
|
|
{
|
2008-10-15 22:35:13 +02:00
|
|
|
return song_in_database(song) || song->url[0] == '/';
|
2008-10-15 22:34:47 +02:00
|
|
|
}
|
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
#endif
|