diff options
Diffstat (limited to '')
-rw-r--r-- | src/song.h | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/src/song.h b/src/song.h index 9aa9efa94..338bcf6c1 100644 --- a/src/song.h +++ b/src/song.h @@ -22,8 +22,6 @@ #include "../config.h" #include "os_compat.h" #include "tag.h" -#include "list.h" -#include "gcc.h" #define SONG_KEY "key: " #define SONG_MTIME "mtime: " @@ -33,42 +31,53 @@ #define SONG_FILE "file: " #define SONG_TIME "Time: " -typedef struct _Song { +struct mpd_song { struct mpd_tag *tag; - struct _Directory *parentDir; + struct directory *parent; time_t mtime; - char url[1]; -} mpd_packed Song; + char url[sizeof(size_t)]; +}; -Song *newSong(const char *url, struct _Directory *parentDir); +void song_free(struct mpd_song *); -void freeJustSong(Song *); +/** allocate a new song with a remote URL */ +struct mpd_song * song_remote_new(const char *url); -ssize_t song_print_info(Song * song, int fd); +/** allocate a new song with a local file name */ +struct mpd_song * 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 mpd_song * song_file_load(const char *path, struct directory *parent); + +ssize_t song_print_info(struct mpd_song * song, int fd); /* like song_print_info, but casts data into an fd first */ -int song_print_info_x(Song * song, void *data); +int song_print_info_x(struct mpd_song * song, void *data); -void readSongInfoIntoList(FILE * fp, struct _Directory *parent); +void readSongInfoIntoList(FILE * fp, struct directory *parent); -int updateSongInfo(Song * song); +int song_file_update(struct mpd_song * song); -ssize_t song_print_url(Song * song, int fd); +ssize_t song_print_url(struct mpd_song * song, int fd); /* like song_print_url_x, but casts data into an fd first */ -int song_print_url_x(Song * song, void *data); +int song_print_url_x(struct mpd_song * song, void *data); /* - * get_song_url - Returns a path of a song in UTF8-encoded form + * song_get_url - Returns a path of a song in UTF8-encoded form * path_max_tmp is the argument that the URL is written to, this * buffer is assumed to be MPD_PATH_MAX or greater (including * terminating '\0'). */ -char *get_song_url(char *path_max_tmp, Song * song); +char *song_get_url(struct mpd_song * song, char *path_max_tmp); -static inline int song_is_file(const Song *song) +static inline int song_is_file(const struct mpd_song *song) { - return !!song->parentDir; + return !!song->parent; } #endif |