diff options
author | Max Kellermann <max@duempel.org> | 2008-10-08 10:49:11 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-08 10:49:11 +0200 |
commit | d562ba5fbbe117585eaade40a8e9c6ef1bf7ca1f (patch) | |
tree | 1e82f7b4854c5d15c4ab59c48120da02e4b41be9 /src | |
parent | 25f67da58c671885c86ecfd991f28ec82b6ce1e2 (diff) | |
download | mpd-d562ba5fbbe117585eaade40a8e9c6ef1bf7ca1f.tar.gz mpd-d562ba5fbbe117585eaade40a8e9c6ef1bf7ca1f.tar.xz mpd-d562ba5fbbe117585eaade40a8e9c6ef1bf7ca1f.zip |
song: converted typedef Song to struct song
Again, a data type which can be forward-declared.
Diffstat (limited to '')
-rw-r--r-- | src/dbUtils.c | 35 | ||||
-rw-r--r-- | src/decoder_api.c | 1 | ||||
-rw-r--r-- | src/decoder_control.c | 6 | ||||
-rw-r--r-- | src/decoder_control.h | 14 | ||||
-rw-r--r-- | src/decoder_thread.c | 1 | ||||
-rw-r--r-- | src/directory.c | 13 | ||||
-rw-r--r-- | src/directory.h | 8 | ||||
-rw-r--r-- | src/locate.c | 14 | ||||
-rw-r--r-- | src/locate.h | 11 | ||||
-rw-r--r-- | src/player_control.c | 16 | ||||
-rw-r--r-- | src/player_control.h | 17 | ||||
-rw-r--r-- | src/player_thread.c | 1 | ||||
-rw-r--r-- | src/playlist.c | 23 | ||||
-rw-r--r-- | src/playlist.h | 12 | ||||
-rw-r--r-- | src/song.c | 18 | ||||
-rw-r--r-- | src/song.h | 21 | ||||
-rw-r--r-- | src/song_print.c | 9 | ||||
-rw-r--r-- | src/song_print.h | 10 | ||||
-rw-r--r-- | src/song_save.c | 13 | ||||
-rw-r--r-- | src/song_save.h | 3 | ||||
-rw-r--r-- | src/songvec.c | 25 | ||||
-rw-r--r-- | src/songvec.h | 13 | ||||
-rw-r--r-- | src/stats.c | 4 | ||||
-rw-r--r-- | src/storedPlaylist.c | 5 | ||||
-rw-r--r-- | src/storedPlaylist.h | 5 | ||||
-rw-r--r-- | src/update.c | 16 |
26 files changed, 196 insertions, 118 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c index fb32769ae..301aeba83 100644 --- a/src/dbUtils.c +++ b/src/dbUtils.c @@ -66,7 +66,8 @@ printDirectoryInDirectory(struct directory *directory, void *data) return 0; } -static int printSongInDirectory(Song * song, mpd_unused void *data) +static int +printSongInDirectory(struct song *song, mpd_unused void *data) { struct client *client = data; song_print_url(client, song); @@ -78,7 +79,8 @@ struct search_data { LocateTagItemArray array; }; -static int searchInDirectory(Song * song, void *_data) +static int +searchInDirectory(struct song *song, void *_data) { struct search_data *data = _data; LocateTagItemArray *array = &data->array; @@ -119,7 +121,8 @@ int searchForSongsIn(struct client *client, const char *name, return ret; } -static int findInDirectory(Song * song, void *_data) +static int +findInDirectory(struct song *song, void *_data) { struct search_data *data = _data; LocateTagItemArray *array = &data->array; @@ -148,7 +151,8 @@ static void printSearchStats(struct client *client, SearchStats *stats) client_printf(client, "playtime: %li\n", stats->playTime); } -static int searchStatsInDirectory(Song * song, void *data) +static int +searchStatsInDirectory(struct song *song, void *data) { SearchStats *stats = data; @@ -186,7 +190,8 @@ int printAllIn(struct client *client, const char *name) printDirectoryInDirectory, client); } -static int directoryAddSongToPlaylist(Song * song, mpd_unused void *data) +static int +directoryAddSongToPlaylist(struct song *song, mpd_unused void *data) { return addSongToPlaylist(song, NULL); } @@ -195,7 +200,8 @@ struct add_data { const char *path; }; -static int directoryAddSongToStoredPlaylist(Song *song, void *_data) +static int +directoryAddSongToStoredPlaylist(struct song *song, void *_data) { struct add_data *data = _data; @@ -219,14 +225,16 @@ int addAllInToStoredPlaylist(const char *name, const char *utf8file) &data); } -static int directoryPrintSongInfo(Song * song, void *data) +static int +directoryPrintSongInfo(struct song *song, void *data) { struct client *client = data; song_print_info(client, song); return 0; } -static int sumSongTime(Song * song, void *data) +static int +sumSongTime(struct song *song, void *data) { unsigned long *sum_time = (unsigned long *)data; @@ -279,8 +287,9 @@ static void freeListCommandItem(ListCommandItem * item) free(item); } -static void visitTag(struct client *client, struct strset *set, - Song * song, enum tag_type tagType) +static void +visitTag(struct client *client, struct strset *set, + struct song *song, enum tag_type tagType) { int i; struct tag *tag = song->tag; @@ -308,7 +317,8 @@ struct list_tags_data { struct strset *set; }; -static int listUniqueTagsInDirectory(Song * song, void *_data) +static int +listUniqueTagsInDirectory(struct song *song, void *_data) { struct list_tags_data *data = _data; ListCommandItem *item = data->item; @@ -371,7 +381,8 @@ sumSavedFilenameMemoryInDirectory(struct directory *dir, void *data) return 0; } -static int sumSavedFilenameMemoryInSong(Song * song, void *data) +static int +sumSavedFilenameMemoryInSong(struct song *song, void *data) { int *sum = data; diff --git a/src/decoder_api.c b/src/decoder_api.c index 52ad21e60..fdce30c20 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -22,6 +22,7 @@ #include "decoder_control.h" #include "player_control.h" #include "audio.h" +#include "song.h" #include "utils.h" #include "normalize.h" diff --git a/src/decoder_control.c b/src/decoder_control.c index 58c4e75ee..3c83e7371 100644 --- a/src/decoder_control.c +++ b/src/decoder_control.c @@ -53,7 +53,8 @@ static void dc_command_async(enum decoder_command cmd) notify_signal(&dc.notify); } -void dc_start(Notify *notify, Song *song) +void +dc_start(Notify *notify, struct song *song) { assert(song != NULL); @@ -62,7 +63,8 @@ void dc_start(Notify *notify, Song *song) dc_command(notify, DECODE_COMMAND_START); } -void dc_start_async(Song *song) +void +dc_start_async(struct song *song) { assert(song != NULL); diff --git a/src/decoder_control.h b/src/decoder_control.h index e34e9d607..f9e65bc51 100644 --- a/src/decoder_control.h +++ b/src/decoder_control.h @@ -21,7 +21,6 @@ #define DECODE_H #include "decoder_api.h" -#include "song.h" #include "audio_format.h" #include "notify.h" @@ -49,8 +48,8 @@ struct decoder_control { volatile int8_t seekable; volatile double seekWhere; struct audio_format audioFormat; - Song *current_song; - Song *volatile next_song; + struct song *current_song; + struct song *volatile next_song; volatile float totalTime; }; @@ -72,7 +71,8 @@ static inline int decoder_is_starting(void) dc.state == DECODE_STATE_START; } -static inline Song *decoder_current_song(void) +static inline struct song * +decoder_current_song(void) { if (dc.state == DECODE_STATE_STOP || dc.error != DECODE_ERROR_NOERROR) @@ -83,9 +83,11 @@ static inline Song *decoder_current_song(void) void dc_command_wait(Notify *notify); -void dc_start(Notify *notify, Song *song); +void +dc_start(Notify *notify, struct song *song); -void dc_start_async(Song *song); +void +dc_start_async(struct song *song); void dc_stop(Notify *notify); diff --git a/src/decoder_thread.c b/src/decoder_thread.c index eff3ca05f..c5a2794cc 100644 --- a/src/decoder_thread.c +++ b/src/decoder_thread.c @@ -21,6 +21,7 @@ #include "decoder_control.h" #include "decoder_internal.h" #include "player_control.h" +#include "song.h" #include "path.h" #include "log.h" diff --git a/src/directory.c b/src/directory.c index 75dae22dd..5e8f89f31 100644 --- a/src/directory.c +++ b/src/directory.c @@ -17,7 +17,7 @@ */ #include "directory.h" - +#include "song.h" #include "conf.h" #include "log.h" #include "ls.h" @@ -448,7 +448,7 @@ int readDirectoryDB(void) static int traverseAllInSubDirectory(struct directory * directory, - int (*forEachSong) (Song *, void *), + int (*forEachSong) (struct song *, void *), int (*forEachDir) (struct directory *, void *), void *data) { @@ -474,13 +474,13 @@ traverseAllInSubDirectory(struct directory * directory, int traverseAllIn(const char *name, - int (*forEachSong) (Song *, void *), + int (*forEachSong) (struct song *, void *), int (*forEachDir) (struct directory *, void *), void *data) { struct directory *directory; if ((directory = getDirectory(name)) == NULL) { - Song *song; + struct song *song; if ((song = getSongFromDB(name)) && forEachSong) { return forEachSong(song, data); } @@ -499,9 +499,10 @@ void directory_init(void) stats.dbPlayTime = sumSongTimesIn(NULL); } -Song *getSongFromDB(const char *file) +struct song * +getSongFromDB(const char *file) { - Song *song = NULL; + struct song *song = NULL; struct directory *directory; char *dir = NULL; char *duplicated = xstrdup(file); diff --git a/src/directory.h b/src/directory.h index f33d854c6..c9601b91a 100644 --- a/src/directory.h +++ b/src/directory.h @@ -19,12 +19,13 @@ #ifndef DIRECTORY_H #define DIRECTORY_H -#include "song.h" #include "songvec.h" #include "list.h" #include <stdbool.h> +struct client; + struct dirvec { struct directory **base; size_t nr; @@ -75,12 +76,13 @@ int writeDirectoryDB(void); int readDirectoryDB(void); -Song *getSongFromDB(const char *file); +struct song * +getSongFromDB(const char *file); time_t getDbModTime(void); int traverseAllIn(const char *name, - int (*forEachSong) (Song *, void *), + int (*forEachSong) (struct song *, void *), int (*forEachDir) (struct directory *, void *), void *data); #define getDirectoryPath(dir) ((dir && dir->path) ? dir->path : "") diff --git a/src/locate.c b/src/locate.c index 1ac0fbf9a..4c3374538 100644 --- a/src/locate.c +++ b/src/locate.c @@ -20,6 +20,7 @@ #include "path.h" #include "utils.h" #include "tag.h" +#include "song.h" #define LOCATE_TAG_FILE_KEY "file" #define LOCATE_TAG_FILE_KEY_OLD "filename" @@ -122,7 +123,8 @@ void freeLocateTagItem(LocateTagItem * item) free(item); } -static int strstrSearchTag(Song * song, enum tag_type type, char *str) +static int +strstrSearchTag(struct song *song, enum tag_type type, char *str) { int i; char *duplicate; @@ -167,7 +169,8 @@ static int strstrSearchTag(Song * song, enum tag_type type, char *str) return ret; } -int strstrSearchTags(Song * song, int numItems, LocateTagItem * items) +int +strstrSearchTags(struct song *song, int numItems, LocateTagItem *items) { int i; @@ -181,7 +184,8 @@ int strstrSearchTags(Song * song, int numItems, LocateTagItem * items) return 1; } -static int tagItemFoundAndMatches(Song * song, enum tag_type type, char *str) +static int +tagItemFoundAndMatches(struct song *song, enum tag_type type, char *str) { int i; int8_t visitedTypes[TAG_NUM_OF_ITEM_TYPES] = { 0 }; @@ -221,7 +225,9 @@ static int tagItemFoundAndMatches(Song * song, enum tag_type type, char *str) } -int tagItemsFoundAndMatches(Song * song, int numItems, LocateTagItem * items) +int +tagItemsFoundAndMatches(struct song *song, int numItems, + LocateTagItem * items) { int i; diff --git a/src/locate.h b/src/locate.h index 7a817828a..4fbc634b7 100644 --- a/src/locate.h +++ b/src/locate.h @@ -19,11 +19,13 @@ #ifndef LOCATE_H #define LOCATE_H -#include "song.h" +#include <stdint.h> #define LOCATE_TAG_FILE_TYPE TAG_NUM_OF_ITEM_TYPES+10 #define LOCATE_TAG_ANY_TYPE TAG_NUM_OF_ITEM_TYPES+20 +struct song; + /* struct used for search, find, list queries */ typedef struct _LocateTagItem { int8_t tagType; @@ -44,8 +46,11 @@ void freeLocateTagItemArray(int count, LocateTagItem * array); void freeLocateTagItem(LocateTagItem * item); -int strstrSearchTags(Song * song, int numItems, LocateTagItem * items); +int +strstrSearchTags(struct song *song, int numItems, LocateTagItem * items); -int tagItemsFoundAndMatches(Song * song, int numItems, LocateTagItem * items); +int +tagItemsFoundAndMatches(struct song *song, int numItems, + LocateTagItem * items); #endif diff --git a/src/player_control.c b/src/player_control.c index 5bc08b776..b274c29e0 100644 --- a/src/player_control.c +++ b/src/player_control.c @@ -20,6 +20,7 @@ #include "path.h" #include "log.h" #include "tag.h" +#include "song.h" #include "os_compat.h" #include "main_notify.h" @@ -43,7 +44,8 @@ void pc_deinit(void) notify_deinit(&pc.notify); } -static void set_current_song(Song *song) +static void +set_current_song(struct song *song) { assert(song != NULL); assert(song->url != NULL); @@ -61,7 +63,8 @@ static void player_command(enum player_command cmd) } } -void playerPlay(Song * song) +void +playerPlay(struct song *song) { assert(pc.queueLockState == PLAYER_QUEUE_UNLOCKED); @@ -174,7 +177,8 @@ char *getPlayerErrorStr(void) return *error ? error : NULL; } -void queueSong(Song * song) +void +queueSong(struct song *song) { assert(pc.queueState == PLAYER_QUEUE_BLANK); @@ -208,7 +212,8 @@ void playerQueueUnlock(void) assert(pc.queueLockState == PLAYER_QUEUE_UNLOCKED); } -int playerSeek(Song * song, float seek_time) +int +playerSeek(struct song *song, float seek_time) { assert(song != NULL); @@ -265,7 +270,8 @@ int getPlayerChannels(void) } /* this actually creates a dupe of the current metadata */ -Song *playerCurrentDecodeSong(void) +struct song * +playerCurrentDecodeSong(void) { return NULL; } diff --git a/src/player_control.h b/src/player_control.h index 375b2f3c1..fd2a5ca45 100644 --- a/src/player_control.h +++ b/src/player_control.h @@ -20,7 +20,6 @@ #define PLAYER_H #include "notify.h" -#include "song.h" #include "os_compat.h" enum player_state { @@ -92,8 +91,8 @@ struct player_control { volatile float totalTime; volatile float elapsedTime; volatile float fileTime; - Song *volatile next_song; - Song *errored_song; + struct song *volatile next_song; + struct song *errored_song; volatile enum player_queue_state queueState; volatile int8_t queueLockState; volatile double seekWhere; @@ -108,7 +107,8 @@ void pc_init(unsigned int buffered_before_play); void pc_deinit(void); -void playerPlay(Song * song); +void +playerPlay(struct song *song); void playerSetPause(int pause_flag); @@ -132,7 +132,8 @@ int getPlayerError(void); void playerWait(void); -void queueSong(Song * song); +void +queueSong(struct song *song); enum player_queue_state getPlayerQueueState(void); @@ -142,7 +143,8 @@ void playerQueueLock(void); void playerQueueUnlock(void); -int playerSeek(Song * song, float seek_time); +int +playerSeek(struct song *song, float seek_time); void setPlayerCrossFade(float crossFadeInSeconds); @@ -158,7 +160,8 @@ int getPlayerBits(void); int getPlayerChannels(void); -Song *playerCurrentDecodeSong(void); +struct song * +playerCurrentDecodeSong(void); void playerInit(void); diff --git a/src/player_thread.c b/src/player_thread.c index 48715dd20..0c07778ed 100644 --- a/src/player_thread.c +++ b/src/player_thread.c @@ -25,6 +25,7 @@ #include "log.h" #include "main_notify.h" #include "crossfade.h" +#include "song.h" enum xfade_state { XFADE_DISABLED = -1, diff --git a/src/playlist.c b/src/playlist.c index 96b170b0a..fe172ebbf 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -21,6 +21,7 @@ #include "command.h" #include "ls.h" #include "tag.h" +#include "song.h" #include "song_print.h" #include "client.h" #include "conf.h" @@ -140,7 +141,7 @@ void initPlaylist(void) playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS; - playlist.songs = xmalloc(sizeof(Song *) * playlist_max_length); + playlist.songs = xmalloc(sizeof(struct song *) * playlist_max_length); playlist.songMod = xmalloc(sizeof(uint32_t) * playlist_max_length); playlist.order = xmalloc(sizeof(int) * playlist_max_length); playlist.idToPosition = xmalloc(sizeof(int) * playlist_max_length * @@ -452,7 +453,7 @@ enum playlist_result playlistId(struct client *client, int id) static void swapSongs(int song1, int song2) { - Song *sTemp; + struct song *sTemp; int iTemp; sTemp = playlist.songs[song1]; @@ -554,7 +555,7 @@ static void clearPlayerQueue(void) enum playlist_result addToPlaylist(const char *url, int *added_id) { - Song *song; + struct song *song; DEBUG("add to playlist: %s\n", url); @@ -569,7 +570,7 @@ enum playlist_result addToPlaylist(const char *url, int *added_id) int addToStoredPlaylist(const char *url, const char *utf8file) { - Song *song; + struct song *song; DEBUG("add to stored playlist: %s\n", url); @@ -590,7 +591,8 @@ int addToStoredPlaylist(const char *url, const char *utf8file) return ACK_ERROR_NO_EXIST; } -enum playlist_result addSongToPlaylist(Song * song, int *added_id) +enum playlist_result +addSongToPlaylist(struct song *song, int *added_id) { int id; @@ -775,7 +777,8 @@ enum playlist_result deleteFromPlaylistById(int id) return deleteFromPlaylist(song); } -void deleteASongFromPlaylist(const Song * song) +void +deleteASongFromPlaylist(const struct song *song) { int i; @@ -877,8 +880,8 @@ enum playlist_result playPlaylistById(int id, int stopOnError) static void syncCurrentPlayerDecodeMetadata(void) { - Song *songPlayer = playerCurrentDecodeSong(); - Song *song; + struct song *songPlayer = playerCurrentDecodeSong(); + struct song *song; int songNum; char path_max_tmp[MPD_PATH_MAX]; @@ -1000,7 +1003,7 @@ void setPlaylistRepeatStatus(int status) enum playlist_result moveSongInPlaylist(int from, int to) { int i; - Song *tmpSong; + struct song *tmpSong; int tmpId; int currentSong; @@ -1358,7 +1361,7 @@ int PlaylistInfo(struct client *client, const char *utf8file, int detail) int wrote = 0; if (detail) { - Song *song = getSongFromDB(temp); + struct song *song = getSongFromDB(temp); if (song) { song_print_info(client, song); wrote = 1; diff --git a/src/playlist.h b/src/playlist.h index acc44aca6..a5b340ddc 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -21,9 +21,13 @@ #include "locate.h" +#include <stdio.h> + #define PLAYLIST_FILE_SUFFIX "m3u" #define PLAYLIST_COMMENT '#' +struct client; + enum playlist_result { PLAYLIST_RESULT_SUCCESS, PLAYLIST_RESULT_ERRNO, @@ -37,7 +41,7 @@ enum playlist_result { }; typedef struct _Playlist { - Song **songs; + struct song **songs; /* holds version a song was modified on */ uint32_t *songMod; int *order; @@ -71,7 +75,8 @@ enum playlist_result addToPlaylist(const char *file, int *added_id); int addToStoredPlaylist(const char *file, const char *utf8file); -enum playlist_result addSongToPlaylist(Song * song, int *added_id); +enum playlist_result +addSongToPlaylist(struct song *song, int *added_id); void showPlaylist(struct client *client); @@ -101,7 +106,8 @@ enum playlist_result savePlaylist(const char *utf8file); enum playlist_result deletePlaylist(const char *utf8file); -void deleteASongFromPlaylist(const Song * song); +void +deleteASongFromPlaylist(const struct song *song); enum playlist_result moveSongInPlaylist(int from, int to); diff --git a/src/song.c b/src/song.c index 014490eca..c09a49cf0 100644 --- a/src/song.c +++ b/src/song.c @@ -28,11 +28,11 @@ #include "os_compat.h" -Song * +struct song * song_alloc(const char *url, struct directory *parent) { size_t urllen; - Song *song; + struct song *song; assert(url); urllen = strlen(url); @@ -46,9 +46,10 @@ song_alloc(const char *url, struct directory *parent) return song; } -Song *newSong(const char *url, struct directory *parentDir) +struct song * +newSong(const char *url, struct directory *parentDir) { - Song *song; + struct song *song; assert(*url); if (strchr(url, '\n')) { @@ -79,14 +80,16 @@ Song *newSong(const char *url, struct directory *parentDir) return song; } -void freeJustSong(Song * song) +void +freeJustSong(struct song *song) { if (song->tag) tag_free(song->tag); free(song); } -int updateSongInfo(Song * song) +int +updateSongInfo(struct song *song) { if (song_is_file(song)) { struct decoder_plugin *plugin; @@ -114,7 +117,8 @@ int updateSongInfo(Song * song) return 0; } -char *get_song_url(char *path_max_tmp, Song *song) +char * +get_song_url(char *path_max_tmp, struct song *song) { if (!song) return NULL; diff --git a/src/song.h b/src/song.h index fc50e70c1..658921324 100644 --- a/src/song.h +++ b/src/song.h @@ -30,21 +30,24 @@ struct client; -typedef struct _Song { +struct song { struct tag *tag; struct directory *parentDir; time_t mtime; char url[sizeof(size_t)]; -} Song; +}; -Song * +struct song * song_alloc(const char *url, struct directory *parent); -Song *newSong(const char *url, struct directory *parentDir); +struct song * +newSong(const char *url, struct directory *parentDir); -void freeJustSong(Song *); +void +freeJustSong(struct song *); -int updateSongInfo(Song * song); +int +updateSongInfo(struct song *song); /* * get_song_url - Returns a path of a song in UTF8-encoded form @@ -52,9 +55,11 @@ int updateSongInfo(Song * song); * buffer is assumed to be MPD_PATH_MAX or greater (including * terminating '\0'). */ -char *get_song_url(char *path_max_tmp, Song * song); +char * +get_song_url(char *path_max_tmp, struct song *song); -static inline int song_is_file(const Song *song) +static inline int +song_is_file(const struct song *song) { return !!song->parentDir; } diff --git a/src/song_print.c b/src/song_print.c index 647e6d594..cfd6a7357 100644 --- a/src/song_print.c +++ b/src/song_print.c @@ -17,12 +17,14 @@ */ #include "song_print.h" +#include "song.h" #include "songvec.h" #include "directory.h" #include "tag_print.h" #include "client.h" -void song_print_url(struct client *client, Song * song) +void +song_print_url(struct client *client, struct song *song) { if (song->parentDir && song->parentDir->path) { client_printf(client, "%s%s/%s\n", SONG_FILE, @@ -32,7 +34,8 @@ void song_print_url(struct client *client, Song * song) } } -int song_print_info(struct client *client, Song * song) +int +song_print_info(struct client *client, struct song *song) { song_print_url(client, song); @@ -43,7 +46,7 @@ int song_print_info(struct client *client, Song * song) } static int -song_print_info_x(Song *song, void *data) +song_print_info_x(struct song *song, void *data) { struct client *client = data; return song_print_info(client, song); diff --git a/src/song_print.h b/src/song_print.h index 78537f064..85fbcf036 100644 --- a/src/song_print.h +++ b/src/song_print.h @@ -19,14 +19,16 @@ #ifndef SONG_PRINT_H #define SONG_PRINT_H -#include "song.h" - +struct client; +struct song; struct songvec; -int song_print_info(struct client *client, Song * song); +int +song_print_info(struct client *client, struct song *song); int songvec_print(struct client *client, const struct songvec *sv); -void song_print_url(struct client *client, Song * song); +void +song_print_url(struct client *client, struct song *song); #endif diff --git a/src/song_save.c b/src/song_save.c index 14bce4ce0..00e4a8580 100644 --- a/src/song_save.c +++ b/src/song_save.c @@ -17,6 +17,7 @@ */ #include "song_save.h" +#include "song.h" #include "tag_save.h" #include "directory.h" #include "path.h" @@ -27,7 +28,8 @@ #define SONG_KEY "key: " #define SONG_MTIME "mtime: " -static void song_save_url(FILE *fp, Song * song) +static void +song_save_url(FILE *fp, struct song *song) { if (song->parentDir != NULL && song->parentDir->path != NULL) fprintf(fp, SONG_FILE "%s/%s\n", @@ -38,7 +40,7 @@ static void song_save_url(FILE *fp, Song * song) } static int -song_save(Song *song, void *data) +song_save(struct song *song, void *data) { FILE *fp = data; @@ -61,9 +63,10 @@ void songvec_save(FILE *fp, struct songvec *sv) fprintf(fp, "%s\n", SONG_END); } -static void insertSongIntoList(struct songvec *sv, Song *newsong) +static void +insertSongIntoList(struct songvec *sv, struct song *newsong) { - Song *existing = songvec_find(sv, newsong->url); + struct song *existing = songvec_find(sv, newsong->url); if (!existing) { songvec_add(sv, newsong); @@ -102,7 +105,7 @@ void readSongInfoIntoList(FILE *fp, struct songvec *sv, { char buffer[MPD_PATH_MAX + 1024]; int bufferSize = MPD_PATH_MAX + 1024; - Song *song = NULL; + struct song *song = NULL; int itemType; while (myFgets(buffer, bufferSize, fp) && 0 != strcmp(SONG_END, buffer)) { diff --git a/src/song_save.h b/src/song_save.h index f77ff8fa7..480e35ae4 100644 --- a/src/song_save.h +++ b/src/song_save.h @@ -19,9 +19,10 @@ #ifndef SONG_SAVE_H #define SONG_SAVE_H -#include "song.h" +#include <stdio.h> struct songvec; +struct directory; void songvec_save(FILE *fp, struct songvec *sv); diff --git a/src/songvec.c b/src/songvec.c index 08ff7f236..7181dd67e 100644 --- a/src/songvec.c +++ b/src/songvec.c @@ -1,4 +1,5 @@ #include "songvec.h" +#include "song.h" #include "utils.h" static pthread_mutex_t nr_lock = PTHREAD_MUTEX_INITIALIZER; @@ -6,28 +7,28 @@ static pthread_mutex_t nr_lock = PTHREAD_MUTEX_INITIALIZER; /* Only used for sorting/searchin a songvec, not general purpose compares */ static int songvec_cmp(const void *s1, const void *s2) { - const Song *a = ((const Song * const *)s1)[0]; - const Song *b = ((const Song * const *)s2)[0]; + const struct song *a = ((const struct song * const *)s1)[0]; + const struct song *b = ((const struct song * const *)s2)[0]; return strcmp(a->url, b->url); } static size_t sv_size(struct songvec *sv) { - return sv->nr * sizeof(Song *); + return sv->nr * sizeof(struct song *); } void songvec_sort(struct songvec *sv) { pthread_mutex_lock(&nr_lock); - qsort(sv->base, sv->nr, sizeof(Song *), songvec_cmp); + qsort(sv->base, sv->nr, sizeof(struct song *), songvec_cmp); pthread_mutex_unlock(&nr_lock); } -Song * +struct song * songvec_find(const struct songvec *sv, const char *url) { int i; - Song *ret = NULL; + struct song *ret = NULL; pthread_mutex_lock(&nr_lock); for (i = sv->nr; --i >= 0; ) { @@ -40,7 +41,8 @@ songvec_find(const struct songvec *sv, const char *url) return ret; } -int songvec_delete(struct songvec *sv, const Song *del) +int +songvec_delete(struct songvec *sv, const struct song *del) { int i; @@ -54,7 +56,7 @@ int songvec_delete(struct songvec *sv, const Song *del) sv->base = NULL; } else { memmove(&sv->base[i], &sv->base[i + 1], - (sv->nr - i + 1) * sizeof(Song *)); + (sv->nr - i + 1) * sizeof(struct song *)); sv->base = xrealloc(sv->base, sv_size(sv)); } break; @@ -64,7 +66,8 @@ int songvec_delete(struct songvec *sv, const Song *del) return i; } -void songvec_add(struct songvec *sv, Song *add) +void +songvec_add(struct songvec *sv, struct song *add) { pthread_mutex_lock(&nr_lock); ++sv->nr; @@ -86,13 +89,13 @@ void songvec_destroy(struct songvec *sv) int songvec_for_each(const struct songvec *sv, - int (*fn)(Song *, void *), void *arg) + int (*fn)(struct song *, void *), void *arg) { size_t i; pthread_mutex_lock(&nr_lock); for (i = 0; i < sv->nr; ++i) { - Song *song = sv->base[i]; + struct song *song = sv->base[i]; assert(song); assert(*song->url); diff --git a/src/songvec.h b/src/songvec.h index 0373ed3e7..14e08d773 100644 --- a/src/songvec.h +++ b/src/songvec.h @@ -1,27 +1,28 @@ #ifndef SONGVEC_H #define SONGVEC_H -#include "song.h" #include "os_compat.h" struct songvec { - Song **base; + struct song **base; size_t nr; }; void songvec_sort(struct songvec *sv); -Song * +struct song * songvec_find(const struct songvec *sv, const char *url); -int songvec_delete(struct songvec *sv, const Song *del); +int +songvec_delete(struct songvec *sv, const struct song *del); -void songvec_add(struct songvec *sv, Song *add); +void +songvec_add(struct songvec *sv, struct song *add); void songvec_destroy(struct songvec *sv); int songvec_for_each(const struct songvec *sv, - int (*fn)(Song *, void *), void *arg); + int (*fn)(struct song *, void *), void *arg); #endif /* SONGVEC_H */ diff --git a/src/stats.c b/src/stats.c index ee0854e16..17126cbdb 100644 --- a/src/stats.c +++ b/src/stats.c @@ -21,6 +21,7 @@ #include "directory.h" #include "tag.h" +#include "song.h" #include "client.h" #include "player_control.h" #include "strset.h" @@ -39,7 +40,8 @@ struct visit_data { struct strset *set; }; -static int visit_tag_items(Song *song, void *_data) +static int +visit_tag_items(struct song *song, void *_data) { const struct visit_data *data = _data; unsigned i; diff --git a/src/storedPlaylist.c b/src/storedPlaylist.c index 0f10268d0..46caa0a99 100644 --- a/src/storedPlaylist.c +++ b/src/storedPlaylist.c @@ -17,6 +17,7 @@ */ #include "storedPlaylist.h" +#include "song.h" #include "path.h" #include "utils.h" #include "ls.h" @@ -107,7 +108,7 @@ List *loadStoredPlaylist(const char *utf8path) while (myFgets(buffer, sizeof(buffer), file)) { char *s = buffer; - Song *song; + struct song *song; if (*s == PLAYLIST_COMMENT) continue; @@ -260,7 +261,7 @@ removeOneSongFromStoredPlaylistByPath(const char *utf8path, int pos) } enum playlist_result -appendSongToStoredPlaylistByPath(const char *utf8path, Song *song) +appendSongToStoredPlaylistByPath(const char *utf8path, struct song *song) { FILE *file; char *s; diff --git a/src/storedPlaylist.h b/src/storedPlaylist.h index 964669d35..575ca84f4 100644 --- a/src/storedPlaylist.h +++ b/src/storedPlaylist.h @@ -19,10 +19,11 @@ #ifndef STORED_PLAYLIST_H #define STORED_PLAYLIST_H -#include "song.h" #include "list.h" #include "playlist.h" +struct song; + List *loadStoredPlaylist(const char *utf8path); enum playlist_result @@ -35,7 +36,7 @@ enum playlist_result removeOneSongFromStoredPlaylistByPath(const char *utf8path, int pos); enum playlist_result -appendSongToStoredPlaylistByPath(const char *utf8path, Song *song); +appendSongToStoredPlaylistByPath(const char *utf8path, struct song *song); enum playlist_result renameStoredPlaylist(const char *utf8from, const char *utf8to); diff --git a/src/update.c b/src/update.c index 13228d6ac..33253065f 100644 --- a/src/update.c +++ b/src/update.c @@ -19,6 +19,7 @@ #include "update.h" #include "directory.h" +#include "song.h" #include "log.h" #include "ls.h" #include "path.h" @@ -45,7 +46,7 @@ static const int update_task_id_max = 1 << 15; static int update_task_id; -static Song *delete; +static struct song *delete; static struct condition delete_cond; @@ -63,7 +64,7 @@ directory_set_stat(struct directory *dir, const struct stat *st) } static void -delete_song(struct directory *dir, Song *del) +delete_song(struct directory *dir, struct song *del) { /* first, prevent traversers in main task from getting this */ songvec_delete(&dir->songs, del); @@ -87,7 +88,8 @@ struct delete_data { }; /* passed to songvec_for_each */ -static int delete_song_if_removed(Song *song, void *_data) +static int +delete_song_if_removed(struct song *song, void *_data) { struct delete_data *data = _data; @@ -196,7 +198,7 @@ addToDirectory(struct directory *directory, const char *name) if (S_ISREG(st.st_mode) && hasMusicSuffix(name, 0) && isMusic(name, NULL, 0)) { - Song *song; + struct song *song; const char *shortname = mpd_basename(name); if (!(song = newSong(shortname, directory))) @@ -216,7 +218,7 @@ addToDirectory(struct directory *directory, const char *name) static enum update_return updateInDirectory(struct directory *directory, const char *name) { - Song *song; + struct song *song; struct stat st; if (myStat(name, &st)) @@ -313,7 +315,7 @@ addDirectoryPathToDB(const char *utf8path) char *parent; struct directory *parentDirectory; struct directory *directory; - Song *conflicting; + struct song *conflicting; parent = parent_path(path_max_tmp, utf8path); @@ -372,7 +374,7 @@ static enum update_return updatePath(const char *utf8path) { struct directory *directory; struct directory *parentDirectory; - Song *song; + struct song *song; char *path = sanitizePathDup(utf8path); time_t mtime; enum update_return ret = UPDATE_RETURN_NOUPDATE; |