song: adding support for songs in archives
This commit is contained in:
parent
4d604a7540
commit
455b39fa26
|
@ -34,6 +34,8 @@
|
|||
#define DIRECTORY_MPD_VERSION "mpd_version: "
|
||||
#define DIRECTORY_FS_CHARSET "fs_charset: "
|
||||
|
||||
#define DEVICE_INARCHIVE (unsigned)(-1)
|
||||
|
||||
struct directory {
|
||||
struct dirvec children;
|
||||
struct songvec songs;
|
||||
|
|
33
src/song.c
33
src/song.c
|
@ -74,7 +74,12 @@ song_file_load(const char *path, struct directory *parent)
|
|||
|
||||
song = song_file_new(path, parent);
|
||||
|
||||
//in archive ?
|
||||
if (parent->device == DEVICE_INARCHIVE) {
|
||||
ret = song_file_update_inarchive(song);
|
||||
} else {
|
||||
ret = song_file_update(song);
|
||||
}
|
||||
if (!ret) {
|
||||
song_free(song);
|
||||
return NULL;
|
||||
|
@ -123,6 +128,34 @@ song_file_update(struct song *song)
|
|||
return song->tag != NULL;
|
||||
}
|
||||
|
||||
bool
|
||||
song_file_update_inarchive(struct song *song)
|
||||
{
|
||||
char buffer[MPD_PATH_MAX];
|
||||
const char *path_fs;
|
||||
const struct decoder_plugin *plugin;
|
||||
|
||||
assert(song_is_file(song));
|
||||
|
||||
path_fs = map_song_fs(song, buffer);
|
||||
if (path_fs == NULL)
|
||||
return false;
|
||||
|
||||
if (song->tag != NULL) {
|
||||
tag_free(song->tag);
|
||||
song->tag = NULL;
|
||||
}
|
||||
//accept every file that has music suffix
|
||||
//because we dont support tag reading throught
|
||||
//input streams
|
||||
plugin = hasMusicSuffix(path_fs, 0);
|
||||
if (plugin) {
|
||||
song->tag = tag_new();
|
||||
//tag_add_item(tag, TAG_ITEM_TITLE, f->title);
|
||||
}
|
||||
return song->tag != NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
song_get_url(const struct song *song, char *path_max_tmp)
|
||||
{
|
||||
|
|
|
@ -58,6 +58,9 @@ song_free(struct song *song);
|
|||
bool
|
||||
song_file_update(struct song *song);
|
||||
|
||||
bool
|
||||
song_file_update_inarchive(struct song *song);
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
|
Loading…
Reference in New Issue