diff options
Diffstat (limited to '')
-rw-r--r-- | src/decoder_api.c | 2 | ||||
-rw-r--r-- | src/decoder_thread.c | 2 | ||||
-rw-r--r-- | src/directory.c | 2 | ||||
-rw-r--r-- | src/locate.c | 4 | ||||
-rw-r--r-- | src/player_control.c | 6 | ||||
-rw-r--r-- | src/player_thread.c | 4 | ||||
-rw-r--r-- | src/playlist.c | 32 | ||||
-rw-r--r-- | src/song.c | 20 | ||||
-rw-r--r-- | src/song.h | 12 | ||||
-rw-r--r-- | src/song_print.c | 4 | ||||
-rw-r--r-- | src/song_save.c | 10 | ||||
-rw-r--r-- | src/storedPlaylist.c | 5 | ||||
-rw-r--r-- | src/update.c | 14 |
13 files changed, 59 insertions, 58 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c index 3ce2622a4..2d2bed796 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -63,7 +63,7 @@ void decoder_initialized(struct decoder * decoder, const char *decoder_get_url(mpd_unused struct decoder * decoder, char * buffer) { - return get_song_url(buffer, dc.current_song); + return song_get_url(dc.current_song, buffer); } enum decoder_command decoder_get_command(mpd_unused struct decoder * decoder) diff --git a/src/decoder_thread.c b/src/decoder_thread.c index fd617a6ac..a8ff2541b 100644 --- a/src/decoder_thread.c +++ b/src/decoder_thread.c @@ -37,7 +37,7 @@ static void decodeStart(void) char path_max_fs[MPD_PATH_MAX]; char path_max_utf8[MPD_PATH_MAX]; - if (!get_song_url(path_max_utf8, dc.next_song)) { + if (!song_get_url(dc.next_song, path_max_utf8)) { dc.error = DECODE_ERROR_FILE; goto stop_no_close; } diff --git a/src/directory.c b/src/directory.c index 5e8f89f31..af00b90f3 100644 --- a/src/directory.c +++ b/src/directory.c @@ -522,7 +522,7 @@ 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 4c3374538..05463b5c9 100644 --- a/src/locate.c +++ b/src/locate.c @@ -134,7 +134,7 @@ strstrSearchTag(struct 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]; - 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) @@ -192,7 +192,7 @@ tagItemFoundAndMatches(struct 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/player_control.c b/src/player_control.c index b274c29e0..0339af5de 100644 --- a/src/player_control.c +++ b/src/player_control.c @@ -158,11 +158,11 @@ char *getPlayerErrorStr(void) case PLAYER_ERROR_FILENOTFOUND: snprintf(error, errorlen, "file \"%s\" does not exist or is inaccessible", - get_song_url(path_max_tmp, pc.errored_song)); + song_get_url(pc.errored_song, path_max_tmp)); break; case PLAYER_ERROR_FILE: snprintf(error, errorlen, "problems decoding \"%s\"", - get_song_url(path_max_tmp, pc.errored_song)); + song_get_url(pc.errored_song, path_max_tmp)); break; case PLAYER_ERROR_AUDIO: strcpy(error, "problems opening audio device"); @@ -172,7 +172,7 @@ char *getPlayerErrorStr(void) break; case PLAYER_ERROR_UNKTYPE: snprintf(error, errorlen, "file type of \"%s\" is unknown", - get_song_url(path_max_tmp, pc.errored_song)); + song_get_url(pc.errored_song, path_max_tmp)); } return *error ? error : NULL; } diff --git a/src/player_thread.c b/src/player_thread.c index a9e594eea..6a08bf46e 100644 --- a/src/player_thread.c +++ b/src/player_thread.c @@ -135,7 +135,7 @@ static void processDecodeInput(int *pause_r, unsigned int *bbp_r, pc.error = PLAYER_ERROR_AUDIO; ERROR("problems opening audio device " "while playing \"%s\"\n", - get_song_url(tmp, dc.next_song)); + song_get_url(dc.next_song, tmp)); *pause_r = -1; } } @@ -244,7 +244,7 @@ static void do_play(void) pc.error = PLAYER_ERROR_AUDIO; ERROR("problems opening audio device " "while playing \"%s\"\n", - get_song_url(tmp, dc.next_song)); + song_get_url(dc.next_song, tmp)); break; } diff --git a/src/playlist.c b/src/playlist.c index 823720aef..c147c4d22 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -176,7 +176,7 @@ void finishPlaylist(void) int i; for (i = 0; i < playlist.length; i++) { if (!song_is_file(playlist.songs[i])) { - freeJustSong(playlist.songs[i]); + song_free(playlist.songs[i]); } } @@ -202,7 +202,7 @@ void clearPlaylist(void) for (i = 0; i < playlist.length; i++) { 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; @@ -225,7 +225,7 @@ void showPlaylist(struct client *client) for (i = 0; i < playlist.length; i++) { client_printf(client, "%i:%s\n", i, - get_song_url(path_max_tmp, playlist.songs[i])); + song_get_url(playlist.songs[i], path_max_tmp)); } } @@ -236,7 +236,7 @@ static void playlist_save(FILE *fp) for (i = 0; i < playlist.length; i++) fprintf(fp, "%i:%s\n", i, - get_song_url(path_max_tmp, playlist.songs[i])); + song_get_url(playlist.songs[i], path_max_tmp)); } void savePlaylistState(FILE *fp) @@ -479,9 +479,9 @@ static void queueNextSongInPlaylist(void) playlist.queued = playlist.current + 1; DEBUG("playlist: queue song %i:\"%s\"\n", playlist.queued, - get_song_url(path_max_tmp, - playlist. - songs[playlist.order[playlist.queued]])); + song_get_url(playlist. + songs[playlist.order[playlist.queued]], + path_max_tmp)); queueSong(playlist.songs[playlist.order[playlist.queued]]); } else if (playlist.length && playlist.repeat) { if (playlist.length > 1 && playlist.random) { @@ -490,9 +490,9 @@ static void queueNextSongInPlaylist(void) playlist.queued = 0; DEBUG("playlist: queue song %i:\"%s\"\n", playlist.queued, - get_song_url(path_max_tmp, - playlist. - songs[playlist.order[playlist.queued]])); + song_get_url(playlist. + songs[playlist.order[playlist.queued]], + path_max_tmp)); queueSong(playlist.songs[playlist.order[playlist.queued]]); } } @@ -584,7 +584,7 @@ int addToStoredPlaylist(const char *url, const char *utf8file) song = song_remote_new(url); if (song) { int ret = appendSongToStoredPlaylistByPath(utf8file, song); - freeJustSong(song); + song_free(song); return ret; } @@ -718,7 +718,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; @@ -812,8 +812,8 @@ static void playPlaylistOrderNumber(int orderNum) playlist.queued = -1; DEBUG("playlist: play %i:\"%s\"\n", orderNum, - get_song_url(path_max_tmp, - playlist.songs[playlist.order[orderNum]])); + song_get_url(playlist.songs[playlist.order[orderNum]], + path_max_tmp)); playerPlay(playlist.songs[playlist.order[orderNum]]); playlist.current = orderNum; @@ -895,7 +895,7 @@ static void syncCurrentPlayerDecodeMetadata(void) song = playlist.songs[songNum]; if (!song_is_file(song) && - 0 == strcmp(get_song_url(path_max_tmp, song), songPlayer->url) && + 0 == strcmp(song_get_url(song, path_max_tmp), songPlayer->url) && !tag_equal(song->tag, songPlayer->tag)) { if (song->tag) tag_free(song->tag); @@ -1265,7 +1265,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 && diff --git a/src/song.c b/src/song.c index f96f90c8a..71fa80e7f 100644 --- a/src/song.c +++ b/src/song.c @@ -39,7 +39,7 @@ 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; } @@ -75,14 +75,14 @@ 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 == NULL && (plugin = isMusic(abs_path, &(song->mtime), next++))) { song->tag = plugin->tag_dup(abs_path); } if (song->tag == NULL || song->tag->time < 0) { - freeJustSong(song); + song_free(song); return NULL; } @@ -90,7 +90,7 @@ song_file_load(const char *path, struct directory *parent) } void -freeJustSong(struct song *song) +song_free(struct song *song) { if (song->tag) tag_free(song->tag); @@ -98,7 +98,7 @@ freeJustSong(struct song *song) } int -updateSongInfo(struct song *song) +song_file_update(struct song *song) { if (song_is_file(song)) { struct decoder_plugin *plugin; @@ -106,7 +106,7 @@ updateSongInfo(struct song *song) char path_max_tmp[MPD_PATH_MAX]; char abs_path[MPD_PATH_MAX]; - 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); if (song->tag) @@ -127,18 +127,18 @@ updateSongInfo(struct song *song) } char * -get_song_url(char *path_max_tmp, struct song *song) +song_get_url(struct 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 c3b79f966..065b0a1bf 100644 --- a/src/song.h +++ b/src/song.h @@ -31,7 +31,7 @@ struct song { struct tag *tag; - struct directory *parentDir; + struct directory *parent; time_t mtime; char url[sizeof(int)]; }; @@ -53,24 +53,24 @@ struct song * song_file_load(const char *path, struct directory *parent); void -freeJustSong(struct song *); +song_free(struct song *song); int -updateSongInfo(struct song *song); +song_file_update(struct song *song); /* - * 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 song *song); +song_get_url(struct song *song, char *path_max_tmp); static inline bool song_is_file(const struct song *song) { - return song->parentDir != NULL; + return song->parent != NULL; } #endif diff --git a/src/song_print.c b/src/song_print.c index cfd6a7357..e646f23de 100644 --- a/src/song_print.c +++ b/src/song_print.c @@ -26,9 +26,9 @@ void song_print_url(struct client *client, struct song *song) { - if (song->parentDir && song->parentDir->path) { + if (song->parent && song->parent->path) { client_printf(client, "%s%s/%s\n", SONG_FILE, - getDirectoryPath(song->parentDir), song->url); + getDirectoryPath(song->parent), song->url); } else { client_printf(client, "%s%s\n", SONG_FILE, song->url); } diff --git a/src/song_save.c b/src/song_save.c index 976a97afd..1afac0979 100644 --- a/src/song_save.c +++ b/src/song_save.c @@ -31,9 +31,9 @@ static void song_save_url(FILE *fp, struct song *song) { - if (song->parentDir != NULL && song->parentDir->path != NULL) + if (song->parent != NULL && song->parent->path != NULL) fprintf(fp, SONG_FILE "%s/%s\n", - getDirectoryPath(song->parentDir), song->url); + getDirectoryPath(song->parent), song->url); else fprintf(fp, SONG_FILE "%s\n", song->url); @@ -81,7 +81,7 @@ insertSongIntoList(struct songvec *sv, struct song *newsong) existing->mtime = newsong->mtime; newsong->tag = NULL; } - freeJustSong(newsong); + song_free(newsong); } } @@ -101,7 +101,7 @@ static int matchesAnMpdTagItemKey(char *buffer, int *itemType) } void readSongInfoIntoList(FILE *fp, struct songvec *sv, - struct directory *parentDir) + struct directory *parent) { char buffer[MPD_PATH_MAX + 1024]; int bufferSize = MPD_PATH_MAX + 1024; @@ -114,7 +114,7 @@ void readSongInfoIntoList(FILE *fp, struct songvec *sv, insertSongIntoList(sv, song); song = song_file_new(buffer + strlen(SONG_KEY), - parentDir); + parent); } else if (*buffer == 0) { /* ignore empty lines (starting with '\0') */ } else if (song == NULL) { diff --git a/src/storedPlaylist.c b/src/storedPlaylist.c index 46caa0a99..6904d0e0d 100644 --- a/src/storedPlaylist.c +++ b/src/storedPlaylist.c @@ -117,7 +117,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)); @@ -293,7 +293,8 @@ appendSongToStoredPlaylistByPath(const char *utf8path, struct 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 e41a23b91..cc2f69843 100644 --- a/src/update.c +++ b/src/update.c @@ -78,7 +78,7 @@ delete_song(struct directory *dir, struct song *del) cond_leave(&delete_cond); /* finally, all possible references gone, free it */ - freeJustSong(del); + song_free(del); } struct delete_data { @@ -93,7 +93,7 @@ delete_song_if_removed(struct 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)) { @@ -232,7 +232,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; } @@ -407,7 +407,7 @@ static enum update_return updatePath(const char *utf8path) /* don't return, path maybe a song now */ } } else if ((song = getSongFromDB(path))) { - parentDirectory = song->parentDir; + parentDirectory = song->parent; if (!parentDirectory->stat && statDirectory(parentDirectory) < 0) { free(path); @@ -417,11 +417,11 @@ 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)) { free(path); 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); @@ -521,7 +521,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_async(&delete_cond); |