From: Not Zed Date: Sat, 19 Jun 2021 07:51:39 +0000 (+0930) Subject: Cleaned up most of the prototypes + static qualifiers. X-Git-Url: https://code.zedzone.au/cvs?a=commitdiff_plain;h=aa8e097ce35de99ae33c6fec4821c9c29988a60f;p=playerz Cleaned up most of the prototypes + static qualifiers. --- diff --git a/dbindex.c b/dbindex.c index d022a05..7352251 100644 --- a/dbindex.c +++ b/dbindex.c @@ -877,7 +877,7 @@ fail: return res; } -int dbstrcmp(const char *a, const char *b) { +static int dbstrcmp(const char *a, const char *b) { if (a == NULL) { if (b == NULL) return 0; @@ -1740,6 +1740,8 @@ fail0: #include +int dbfile_searchx(dbindex *db, const char *pattern, dbfile **results, int maxlen); + // TODO: should run over title index instead? int dbfile_searchx(dbindex *db, const char *pattern, dbfile **results, int maxlen) { MDB_txn *tx; @@ -1846,6 +1848,7 @@ fail: } +void dump_lists(dbindex *db, dbtxn *txn); void dump_lists(dbindex *db, dbtxn *txn) { MDB_txn *tx; MDB_val key, data; @@ -1889,6 +1892,7 @@ void dump_lists(dbindex *db, dbtxn *txn) { mdb_txn_abort(tx); } +void dbindex_dump(dbindex *db); void dbindex_dump(dbindex *db) { MDB_txn *tx; diff --git a/dbindex.h b/dbindex.h index b13e12c..4e2b4db 100644 --- a/dbindex.h +++ b/dbindex.h @@ -127,6 +127,9 @@ dbdisk *dbdisk_get(dbtxn *tx, dbindex *db, int diskid); dbdisk *dbdisk_get_uuid(dbtxn *tx, dbindex *db, const char *uuid); void dbdisk_free(dbdisk *d); int dbdisk_add(dbtxn *txn, dbindex *db, dbdisk *d); +int dbdisk_del(dbtxn *tx, dbindex *db, dbdisk *disk); +int dbdisk_del_id(dbtxn *tx, dbindex *db, int diskid); +int dbdisk_mounted(dbdisk *disk); dbfile *dbfile_get(dbtxn *tx, dbindex *db, int fileid); dbfile *dbfile_get_path(dbtxn *tx, dbindex *db, int diskid, const char *path); @@ -157,6 +160,8 @@ dblist *dblist_get(dbtxn *tx, dbindex *db, int id); dblist *dblist_get_name(dbtxn *tx, dbindex *db, const char *name); void dblist_free(dblist *f); +dblist *dblist_init(dbtxn *tx, dbindex *db, const char *name); + dbid_t dblistid_get_name(dbtxn *tx, dbindex *db, const char *name); int dblist_add(dbtxn *txn, dbindex *db, dblist *d); @@ -164,17 +169,26 @@ int dblist_clear(dbtxn *tx, dbindex *db, int listid); int dblist_del(dbtxn *txn, dbindex *db, int listid); int dblist_add_file(MDB_txn *tx, dbindex *db, dblistcursor *info); +int dblist_del_file(MDB_txn *txn, dbindex *db, dblistcursor *list); + +// WIP +int dblist_update(dbtxn *tx, dbindex *db, const char *name, dbid_t *fids, size_t count); +int dblist_shuffle(dbtxn *tx, dbindex *db, const char *name); +int dblist_init_system(dbtxn *tx, dbindex *db); // clear and fill the all and all#shuffle playlist int dblist_update_all(dbtxn *tx, dbindex *db); // delete all lists and run update_all int dblist_reset_all(dbtxn *tx, dbindex *db); + int dbfile_search(dbindex *db, const char *pattern, dbfile **results, int maxlen); // prototyping int dbfile_put_suffix(dbtxn *tx, dbindex *db, const char *suffix, uint32_t fileid); size_t dbfile_search_substring(dbtxn *tx, dbindex *db, const char *sub); +int dbfile_clear_suffix(MDB_txn *tx, dbindex *db); +int dbindex_validate(dbindex *db); /* re-usable scan code try two! */ struct dbscan { @@ -200,6 +214,7 @@ static __inline__ int dbscan_result(dbscan *scan) { return scan->res; } dbdisk *dbscan_disk(dbtxn *tx, dbscan *scan, dbindex *db, dbid_t diskid); dbdisk *dbscan_disk_next(dbscan *scan); dbfile *dbscan_file(dbtxn *tx, dbscan *scan, dbindex *db, dbid_t fileid); +dbfile *dbscan_file_by_disk(dbtxn *tx, dbscan *scan, dbindex *db, dbid_t diskid); dbfile *dbscan_file_next(dbscan *scan); dblist *dbscan_list(dbtxn *tx, dbscan *scan, dbindex *db, dbid_t listid); dblist *dbscan_list_next(dbscan *scan); diff --git a/disk-indexer.c b/disk-indexer.c index e2d8f0e..9b47b00 100644 --- a/disk-indexer.c +++ b/disk-indexer.c @@ -78,7 +78,7 @@ struct AVDictionary { AVDictionaryEntry *elems; }; -const char *pz_dict_get(AVDictionary *dict, const char *key, const char *def) { +static const char *pz_dict_get(AVDictionary *dict, const char *key, const char *def) { if (dict) { for (int i=0;icount;i++) if (!strcmp(key, dict->elems[i].key)) @@ -181,9 +181,9 @@ static void dir_free(struct dir_node *d) { free(d); } -void indexer_destroy(struct indexer *ix); +static void indexer_destroy(struct indexer *ix); -int indexer_init(struct indexer *ix, dbindex *db, const char *path, const char *uuid) { +static int indexer_init(struct indexer *ix, dbindex *db, const char *path, const char *uuid) { int res; memset(ix, 0, sizeof(*ix)); @@ -236,7 +236,7 @@ int indexer_init(struct indexer *ix, dbindex *db, const char *path, const char * return res; } -void indexer_destroy(struct indexer *ix) { +static void indexer_destroy(struct indexer *ix) { dbdisk_free(ix->disk); struct dir_node *scan; @@ -283,7 +283,7 @@ in-place: */ // Add or update file -int indexer_add_file(struct indexer *ix, struct stat *st, const char *filepath, const char *diskpath, ez_tree *files) { +static int indexer_add_file(struct indexer *ix, struct stat *st, const char *filepath, const char *diskpath, ez_tree *files) { dbfile *o = NULL, *f; int res; @@ -351,7 +351,7 @@ static void indexer_info(struct indexer *ix) { } // scan a disk -int indexer_scan(struct indexer *ix) { +static int indexer_scan(struct indexer *ix) { struct dir_node *scan = NULL; int count = 0, res = 0; ez_tree files = { 0 }; diff --git a/disk-monitor.c b/disk-monitor.c index aea79d7..3dfcf15 100644 --- a/disk-monitor.c +++ b/disk-monitor.c @@ -167,7 +167,7 @@ static void print_values(const char *dev, blkid_probe p) { } } -void partition_notify(struct monitor *m, enum notify_action action, struct mdisk *md) { +static void partition_notify(struct monitor *m, enum notify_action action, struct mdisk *md) { int res = notify_msg_send(m->indexer, action, 0, &md->disk); if (res) diff --git a/http-monitor.c b/http-monitor.c index db6c49c..2a1fdbb 100644 --- a/http-monitor.c +++ b/http-monitor.c @@ -404,7 +404,7 @@ static int handle_lists(struct ez_httprequest *req, struct ez_httpresponse *rep) return 0; } -void http_addheader(struct ez_http *http, const char *name, const char *value) { +static void http_addheader(struct ez_http *http, const char *name, const char *value) { struct obstack *os = &http->conn->os; ez_pair *location = obstack_alloc(os, sizeof(*location)); diff --git a/index-util.c b/index-util.c index a6a0a9e..12962e9 100644 --- a/index-util.c +++ b/index-util.c @@ -40,7 +40,6 @@ void dbshuffle_init2(dbindex *db); int dbdisk_del_id(dbtxn *txn, dbindex *db, int diskid); -void dbindex_validate(dbindex *db); int dblist_del_file(dbtxn *txn, dbindex *db, struct dblistcursor *list); diff --git a/input-monitor.c b/input-monitor.c index 461bb4d..67d19b7 100644 --- a/input-monitor.c +++ b/input-monitor.c @@ -132,7 +132,7 @@ static int cmp_key(const void *ap, const void *bp) { return needle - hay->code; } -struct monitor *monitor_new(void) { +static struct monitor *monitor_new(void) { struct monitor *m = malloc(sizeof(*m)); m->keyfd = open(INPUT_KB, O_RDONLY); @@ -153,7 +153,7 @@ struct monitor *monitor_new(void) { return NULL; } -void monitor_free(struct monitor *m) { +static void monitor_free(struct monitor *m) { notify_close(m->player); close(m->mousefd); close(m->keyfd); @@ -246,7 +246,7 @@ static void monitor_event(struct monitor *m, struct input_event *ev) { } */ -void monitor(struct monitor *m) { +static void monitor(struct monitor *m) { struct pollfd polla[2]; struct input_event ev; diff --git a/music-player.c b/music-player.c index 9f70b25..299c1ec 100644 --- a/music-player.c +++ b/music-player.c @@ -156,7 +156,7 @@ struct audio_player { int audio_mixer_adjust(struct audio_player *ap, int delta); -struct audio_player *audio_player_new(const char *device) { +static struct audio_player *audio_player_new(const char *device) { struct audio_player *ap = calloc(sizeof(*ap), 1); ap->sample_rate = 48000; @@ -196,7 +196,7 @@ static snd_mixer_elem_t *mixer_master(struct audio_player *ap) { return snd_mixer_find_selem(ap->amixer, sid); } -int audio_mixer_mute(struct audio_player *ap) { +static int audio_mixer_mute(struct audio_player *ap) { snd_mixer_elem_t* elem = mixer_master(ap); int mute; @@ -226,14 +226,14 @@ int audio_mixer_adjust(struct audio_player *ap, int delta) { } } -void audio_close_mixer(struct audio_player *ap) { +static void audio_close_mixer(struct audio_player *ap) { if (ap->amixer) { snd_mixer_close(ap->amixer); ap->amixer = NULL; } } -void audio_player_free(struct audio_player *ap) { +static void audio_player_free(struct audio_player *ap) { audio_close_media(ap); audio_close_pcm(ap); audio_close_mixer(ap); @@ -250,7 +250,7 @@ void audio_player_free(struct audio_player *ap) { free(ap); } -int audio_init_poll(struct audio_player *ap) { +static int audio_init_poll(struct audio_player *ap) { int npoll = 1; int count = 0; @@ -286,7 +286,7 @@ int audio_init_poll(struct audio_player *ap) { * bit 2 = audio output ready * @return -1 on error. */ -int audio_poll(struct audio_player *ap) { +static int audio_poll(struct audio_player *ap) { int res; while (1) { @@ -341,7 +341,7 @@ static unsigned int hw_sample_rate(struct audio_player *ap) { * * FIXME: if this fails it should exit. */ -int audio_init_pcm(struct audio_player *ap) { +static int audio_init_pcm(struct audio_player *ap) { int res; printf("audio_init_pcm\n"); @@ -366,7 +366,7 @@ int audio_init_pcm(struct audio_player *ap) { return audio_init_poll(ap); } -int audio_stop_pcm(struct audio_player *ap) { +static int audio_stop_pcm(struct audio_player *ap) { int res; if (ap->paused) { @@ -394,7 +394,7 @@ void audio_close_pcm(struct audio_player *ap) { } } -int audio_init_filter(struct audio_player *ap) { +static int audio_init_filter(struct audio_player *ap) { char tmp[256]; int res = -1; @@ -476,7 +476,7 @@ fail: * New frame ready. * Set up pointers for pcm output. */ -int audio_init_frame(struct audio_player *ap, AVFrame *iframe, AVFrame *frame) { +static int audio_init_frame(struct audio_player *ap, AVFrame *iframe, AVFrame *frame) { ap->data[0] = (void *)frame->data[0]; ap->nsamples = frame->nb_samples; ap->pos = iframe->pts; @@ -502,7 +502,7 @@ int audio_init_frame(struct audio_player *ap, AVFrame *iframe, AVFrame *frame) { return 0; } -int audio_send_pcm(struct audio_player *ap) { +static int audio_send_pcm(struct audio_player *ap) { snd_pcm_sframes_t sent; sent = snd_pcm_writei(ap->aud, ap->data[0], ap->nsamples); @@ -544,7 +544,7 @@ int audio_close_media(struct audio_player *ap) { return 0; } -int audio_init_media(struct audio_player *ap, const char *path) { +static int audio_init_media(struct audio_player *ap, const char *path) { int res; AVCodec *codec; int audioid; @@ -598,7 +598,7 @@ int audio_init_media(struct audio_player *ap, const char *path) { #include "lmdb.h" -int audio_checkpoint_state(struct audio_player *ap) { +static int audio_checkpoint_state(struct audio_player *ap) { dbtxn *tx = dbindex_begin(ap->index, NULL, 0); int res; @@ -758,17 +758,17 @@ static int audio_advance_file(struct audio_player *ap, dbfile *(*advance)(dbscan return res; } -int audio_next_file(struct audio_player *ap) { +static int audio_next_file(struct audio_player *ap) { return audio_advance_file(ap, dbscan_list_entry_next); } -int audio_prev_file(struct audio_player *ap) { +static int audio_prev_file(struct audio_player *ap) { return audio_advance_file(ap, dbscan_list_entry_prev); } // jump to a file (in a playlist) // TODO: if the playlist is the same should it jump to the next occurance of the file in the list? -int audio_goto_file(struct audio_player *ap, dblistcursor *info) { +static int audio_goto_file(struct audio_player *ap, dblistcursor *info) { int res = -1; // MDB_NOTFOUND dbtxn *tx = dbindex_begin(ap->index, NULL, 1); dbfile *file = NULL; @@ -822,7 +822,7 @@ fail: } // play a specific file right now out of band -int audio_play_now(struct audio_player *ap, int fileid) { +static int audio_play_now(struct audio_player *ap, int fileid) { int res = -1; // MDB_NOTFOUND dbtxn *tx = dbindex_begin(ap->index, NULL, 0); dbfile *file = dbfile_get(tx, ap->index, fileid); @@ -861,7 +861,7 @@ int audio_play_now(struct audio_player *ap, int fileid) { // jukebox // this adds the song to the jukebox playlist but doesn't jump immediately // however ... "next song" will jump over it, so ... sigh -int audio_play_enqueue(struct audio_player *ap, int fileid) { +static int audio_play_enqueue(struct audio_player *ap, int fileid) { int res = -1; // MDB_NOTFOUND dbtxn *tx = dbindex_begin(ap->index, NULL, 0); dbfile *file = dbfile_get(tx, ap->index, fileid); @@ -909,7 +909,7 @@ int audio_play_enqueue(struct audio_player *ap, int fileid) { // first file on restarting server, see if we were playing something last time and start back there // TODO: do something with the position -int audio_restore_state(struct audio_player *ap) { +static int audio_restore_state(struct audio_player *ap) { dbtxn *tx = dbindex_begin(ap->index, NULL, 1); int res = -1; @@ -962,7 +962,7 @@ int audio_restore_state(struct audio_player *ap) { -void audio_player_control(struct audio_player *ap) { +static void audio_player_control(struct audio_player *ap) { int ready = notify_msg_ready(ap->player); if (time(NULL) != ap->playing_state.stamp) @@ -1195,7 +1195,7 @@ void audio_player_control(struct audio_player *ap) { } // TODO: the play queue / play list / etc -void audio_player_loop(struct audio_player *ap) { +static void audio_player_loop(struct audio_player *ap) { AVFrame *frame = av_frame_alloc(); AVFrame *oframe = av_frame_alloc();