aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/directory.c2
-rw-r--r--src/locate.c4
-rw-r--r--src/playlist.c18
-rw-r--r--src/song.c35
-rw-r--r--src/song.h12
-rw-r--r--src/storedPlaylist.c4
-rw-r--r--src/update.c14
7 files changed, 44 insertions, 45 deletions
diff --git a/src/directory.c b/src/directory.c
index 93bde7de9..f76dd9c95 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -536,7 +536,7 @@ struct mpd_song *getSongFromDB(const char *file)
goto out;
if (!(song = songvec_find(&directory->songs, shortname)))
goto out;
- assert(song->parentDir == directory);
+ assert(song->parent == directory);
out:
free(duplicated);
diff --git a/src/locate.c b/src/locate.c
index dfe1e2236..96fa4ee58 100644
--- a/src/locate.c
+++ b/src/locate.c
@@ -132,7 +132,7 @@ static int strstrSearchTag(struct mpd_song * song,
if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) {
char path_max_tmp[MPD_PATH_MAX];
- string_toupper(get_song_url(path_max_tmp, song));
+ string_toupper(song_get_url(song, path_max_tmp));
if (strstr(path_max_tmp, str))
ret = 1;
if (ret == 1 || type == LOCATE_TAG_FILE_TYPE)
@@ -190,7 +190,7 @@ tagItemFoundAndMatches(struct mpd_song * song, enum tag_type type, char *str)
if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) {
char path_max_tmp[MPD_PATH_MAX];
- if (0 == strcmp(str, get_song_url(path_max_tmp, song)))
+ if (0 == strcmp(str, song_get_url(song, path_max_tmp)))
return 1;
if (type == LOCATE_TAG_FILE_TYPE)
return 0;
diff --git a/src/playlist.c b/src/playlist.c
index 22df8be5d..24f74b02d 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -189,7 +189,7 @@ void finishPlaylist(void)
for (i = playlist.length; --i >= 0; ) {
if (!song_is_file(playlist.songs[i]))
- freeJustSong(playlist.songs[i]);
+ song_free(playlist.songs[i]);
}
playlist.length = 0;
@@ -214,7 +214,7 @@ void clearPlaylist(void)
for (i = playlist.length; --i >= 0 ; ) {
if (!song_is_file(playlist.songs[i]))
- freeJustSong(playlist.songs[i]);
+ song_free(playlist.songs[i]);
playlist.idToPosition[playlist.positionToId[i]] = -1;
playlist.songs[i] = NULL;
}
@@ -236,7 +236,7 @@ void showPlaylist(int fd)
for (i = 0; i < playlist.length; i++)
fdprintf(fd, "%i:%s\n", i,
- get_song_url(path_max_tmp, playlist.songs[i]));
+ song_get_url(playlist.songs[i], path_max_tmp));
}
void savePlaylistState(int fd)
@@ -543,7 +543,7 @@ char *playlist_queued_url(char utf8url[MPD_PATH_MAX])
pthread_mutex_lock(&queue_lock);
song = song_at(playlist.queued);
- return song ? get_song_url(utf8url, song) : NULL;
+ return song ? song_get_url(song, utf8url) : NULL;
}
static void queue_song_locked(int order_num)
@@ -598,7 +598,7 @@ int addToStoredPlaylist(const char *url, const char *utf8file)
if ((song = song_remote_new(url))) {
int ret = appendSongToStoredPlaylistByPath(utf8file, song);
- freeJustSong(song);
+ song_free(song);
return ret;
}
@@ -741,7 +741,7 @@ enum playlist_result deleteFromPlaylist(int song)
}
if (!song_is_file(playlist.songs[song]))
- freeJustSong(playlist.songs[song]);
+ song_free(playlist.songs[song]);
playlist.idToPosition[playlist.positionToId[song]] = -1;
@@ -842,7 +842,7 @@ static void play_order_num(int order_num, float seek_time)
assert(song_at(order_num));
DEBUG("playlist: play %i:\"%s\"\n", order_num,
- get_song_url(path, song_at(order_num)));
+ song_get_url(song_at(order_num), path));
dc_trigger_action(DC_ACTION_STOP, 0);
queue_song_locked(order_num);
@@ -1259,7 +1259,7 @@ enum playlist_result savePlaylist(const char *utf8file)
for (i = 0; i < playlist.length; i++) {
char tmp[MPD_PATH_MAX];
- get_song_url(path_max_tmp, playlist.songs[i]);
+ song_get_url(playlist.songs[i], path_max_tmp);
utf8_to_fs_charset(tmp, path_max_tmp);
if (playlist_saveAbsolutePaths &&
@@ -1326,7 +1326,7 @@ enum playlist_result seekSongInPlaylist(int song, float seek_time)
*/
}
- DEBUG("playlist: seek %i:\"%s\"\n", i, get_song_url(path, song_at(i)));
+ DEBUG("playlist: seek %i:\"%s\"\n", i, song_get_url(song_at(i), path));
play_order_num(i, seek_time);
return PLAYLIST_RESULT_SUCCESS;
}
diff --git a/src/song.c b/src/song.c
index cf9994086..5803d4f97 100644
--- a/src/song.c
+++ b/src/song.c
@@ -41,7 +41,7 @@ static struct mpd_song * song_alloc(const char *url, struct directory *parent)
song->tag = NULL;
memcpy(song->url, url, urllen + 1);
- song->parentDir = parent;
+ song->parent = parent;
return song;
}
@@ -72,21 +72,21 @@ struct mpd_song * song_file_load(const char *path, struct directory *parent)
}
song = song_file_new(path, parent);
- abs_path = rmp2amp_r(path_max_tmp, get_song_url(path_max_tmp, song));
+ abs_path = rmp2amp_r(path_max_tmp, song_get_url(song, path_max_tmp));
while (!song->tag &&
(plugin = isMusic(abs_path, &song->mtime, next++))) {
song->tag = plugin->tagDupFunc(abs_path);
}
if (!song->tag || song->tag->time < 0) {
- freeJustSong(song);
+ song_free(song);
return NULL;
}
return song;
}
-void freeJustSong(struct mpd_song * song)
+void song_free(struct mpd_song * song)
{
if (song->tag)
tag_free(song->tag);
@@ -95,9 +95,9 @@ void freeJustSong(struct mpd_song * song)
ssize_t song_print_url(struct mpd_song *song, int fd)
{
- if (song->parentDir && song->parentDir->path)
+ if (song->parent && song->parent->path)
return fdprintf(fd, "%s%s/%s\n", SONG_FILE,
- getDirectoryPath(song->parentDir), song->url);
+ getDirectoryPath(song->parent), song->url);
return fdprintf(fd, "%s%s\n", SONG_FILE, song->url);
}
@@ -146,10 +146,10 @@ static void insertSongIntoList(struct songvec *sv, struct mpd_song *newsong)
if (old_tag)
tag_free(old_tag);
}
- /* prevent tag_free in freeJustSong */
+ /* prevent tag_free in song_free */
newsong->tag = NULL;
}
- freeJustSong(newsong);
+ song_free(newsong);
}
}
@@ -167,20 +167,19 @@ static int matchesAnMpdTagItemKey(char *buffer, int *itemType)
return 0;
}
-void readSongInfoIntoList(FILE * fp, struct directory * parentDir)
+void readSongInfoIntoList(FILE * fp, struct directory * parent)
{
char buffer[MPD_PATH_MAX + 1024];
int bufferSize = MPD_PATH_MAX + 1024;
struct mpd_song *song = NULL;
- struct songvec *sv = &parentDir->songs;
+ struct songvec *sv = &parent->songs;
int itemType;
while (myFgets(buffer, bufferSize, fp) && 0 != strcmp(SONG_END, buffer)) {
if (!prefixcmp(buffer, SONG_KEY)) {
if (song)
insertSongIntoList(sv, song);
- song = song_file_new(buffer + strlen(SONG_KEY),
- parentDir);
+ song = song_file_new(buffer + strlen(SONG_KEY), parent);
} else if (*buffer == 0) {
/* ignore empty lines (starting with '\0') */
} else if (song == NULL) {
@@ -215,7 +214,7 @@ void readSongInfoIntoList(FILE * fp, struct directory * parentDir)
insertSongIntoList(sv, song);
}
-int updateSongInfo(struct mpd_song * song)
+int song_file_update(struct mpd_song * song)
{
if (song_is_file(song)) {
InputPlugin *plugin;
@@ -225,7 +224,7 @@ int updateSongInfo(struct mpd_song * song)
struct mpd_tag *old_tag = song->tag;
struct mpd_tag *new_tag = NULL;
- utf8_to_fs_charset(abs_path, get_song_url(path_max_tmp, song));
+ utf8_to_fs_charset(abs_path, song_get_url(song, path_max_tmp));
rmp2amp_r(abs_path, abs_path);
while ((plugin = isMusic(abs_path, &song->mtime, next++))) {
@@ -246,18 +245,18 @@ int updateSongInfo(struct mpd_song * song)
return 0;
}
-char *get_song_url(char *path_max_tmp, struct mpd_song *song)
+char *song_get_url(struct mpd_song *song, char *path_max_tmp)
{
if (!song)
return NULL;
assert(*song->url);
- if (!song->parentDir || !song->parentDir->path)
+ if (!song->parent || !song->parent->path)
strcpy(path_max_tmp, song->url);
else
pfx_dir(path_max_tmp, song->url, strlen(song->url),
- getDirectoryPath(song->parentDir),
- strlen(getDirectoryPath(song->parentDir)));
+ getDirectoryPath(song->parent),
+ strlen(getDirectoryPath(song->parent)));
return path_max_tmp;
}
diff --git a/src/song.h b/src/song.h
index 0d2f976ac..338bcf6c1 100644
--- a/src/song.h
+++ b/src/song.h
@@ -33,12 +33,12 @@
struct mpd_song {
struct mpd_tag *tag;
- struct directory *parentDir;
+ struct directory *parent;
time_t mtime;
char url[sizeof(size_t)];
};
-void freeJustSong(struct mpd_song *);
+void song_free(struct mpd_song *);
/** allocate a new song with a remote URL */
struct mpd_song * song_remote_new(const char *url);
@@ -60,7 +60,7 @@ int song_print_info_x(struct mpd_song * song, void *data);
void readSongInfoIntoList(FILE * fp, struct directory *parent);
-int updateSongInfo(struct mpd_song * song);
+int song_file_update(struct mpd_song * song);
ssize_t song_print_url(struct mpd_song * song, int fd);
@@ -68,16 +68,16 @@ ssize_t song_print_url(struct mpd_song * song, int fd);
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, struct mpd_song * song);
+char *song_get_url(struct mpd_song * song, char *path_max_tmp);
static inline int song_is_file(const struct mpd_song *song)
{
- return !!song->parentDir;
+ return !!song->parent;
}
#endif
diff --git a/src/storedPlaylist.c b/src/storedPlaylist.c
index 482e9e241..b74ef1404 100644
--- a/src/storedPlaylist.c
+++ b/src/storedPlaylist.c
@@ -119,7 +119,7 @@ List *loadStoredPlaylist(const char *utf8path)
memmove(s, s + musicDir_len + 1,
strlen(s + musicDir_len + 1) + 1);
if ((song = getSongFromDB(s))) {
- get_song_url(path_max_tmp, song);
+ song_get_url(song, path_max_tmp);
insertInListWithoutKey(list, xstrdup(path_max_tmp));
} else if (isValidRemoteUtf8Url(s))
insertInListWithoutKey(list, xstrdup(s));
@@ -295,7 +295,7 @@ appendSongToStoredPlaylistByPath(const char *utf8path, struct mpd_song *song)
return PLAYLIST_RESULT_TOO_LARGE;
}
- s = utf8_to_fs_charset(path_max_tmp2, get_song_url(path_max_tmp, song));
+ s = utf8_to_fs_charset(path_max_tmp2, song_get_url(song, path_max_tmp));
if (playlist_saveAbsolutePaths && song_is_file(song))
s = rmp2amp_r(path_max_tmp, s);
diff --git a/src/update.c b/src/update.c
index c40f25694..e7a49e56e 100644
--- a/src/update.c
+++ b/src/update.c
@@ -75,7 +75,7 @@ static void delete_song(struct directory *dir, struct mpd_song *del)
cond_leave(&delete_cond);
/* finally, all possible references gone, free it */
- freeJustSong(del);
+ song_free(del);
}
struct delete_data {
@@ -89,7 +89,7 @@ static int delete_song_if_removed(struct mpd_song *song, void *_data)
{
struct delete_data *data = _data;
- data->tmp = get_song_url(data->tmp, song);
+ data->tmp = song_get_url(song, data->tmp);
assert(data->tmp);
if (!isFile(data->tmp, NULL)) {
@@ -226,7 +226,7 @@ updateInDirectory(struct directory *directory, const char *name)
return UPDATE_RETURN_UPDATED;
} else if (st.st_mtime != song->mtime) {
LOG("updating %s\n", name);
- if (updateSongInfo(song) < 0)
+ if (song_file_update(song) < 0)
delete_song(directory, song);
return UPDATE_RETURN_UPDATED;
}
@@ -393,7 +393,7 @@ static enum update_return updatePath(const char *utf8path)
/* don't return, path maybe a song now */
}
} else if ((song = getSongFromDB(utf8path))) {
- parentDirectory = song->parentDir;
+ parentDirectory = song->parent;
if (!parentDirectory->stat
&& statDirectory(parentDirectory) < 0) {
return UPDATE_RETURN_NOUPDATE;
@@ -402,10 +402,10 @@ static enum update_return updatePath(const char *utf8path)
else if (!inodeFoundInParent(parentDirectory->parent,
parentDirectory->inode,
parentDirectory->device) &&
- isMusic(get_song_url(path_max_tmp, song), &mtime, 0)) {
+ isMusic(song_get_url(song, path_max_tmp), &mtime, 0)) {
if (song->mtime == mtime)
return UPDATE_RETURN_NOUPDATE;
- else if (updateSongInfo(song) == 0)
+ else if (song_file_update(song) == 0)
return UPDATE_RETURN_UPDATED;
else {
delete_song(parentDirectory, song);
@@ -503,7 +503,7 @@ void reap_update_task(void)
cond_enter(&delete_cond);
if (delete) {
char tmp[MPD_PATH_MAX];
- LOG("removing: %s\n", get_song_url(tmp, delete));
+ LOG("removing: %s\n", song_get_url(delete, tmp));
deleteASongFromPlaylist(delete);
delete = NULL;
cond_signal(&delete_cond);