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;
#include <regex.h>
+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;
}
+void dump_lists(dbindex *db, dbtxn *txn);
void dump_lists(dbindex *db, dbtxn *txn) {
MDB_txn *tx;
MDB_val key, data;
mdb_txn_abort(tx);
}
+void dbindex_dump(dbindex *db);
void dbindex_dump(dbindex *db) {
MDB_txn *tx;
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);
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);
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 {
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);
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;i<dict->count;i++)
if (!strcmp(key, dict->elems[i].key))
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));
return res;
}
-void indexer_destroy(struct indexer *ix) {
+static void indexer_destroy(struct indexer *ix) {
dbdisk_free(ix->disk);
struct dir_node *scan;
*/
// 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;
}
// 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 };
}
}
-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)
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));
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);
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);
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);
}
*/
-void monitor(struct monitor *m) {
+static void monitor(struct monitor *m) {
struct pollfd polla[2];
struct input_event ev;
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;
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;
}
}
-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);
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;
* 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) {
*
* 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");
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) {
}
}
-int audio_init_filter(struct audio_player *ap) {
+static int audio_init_filter(struct audio_player *ap) {
char tmp[256];
int res = -1;
* 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;
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);
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;
#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;
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;
}
// 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);
// 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);
// 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;
-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)
}
// 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();