A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 90 lines 3.2 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * Copyright (C) 2020 by William Wilgus 11 * 12 * This program is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; either version 2 15 * of the License, or (at your option) any later version. 16 * 17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 * KIND, either express or implied. 19 * 20 ****************************************************************************/ 21#ifndef OPEN_PLUGIN_H 22#define OPEN_PLUGIN_H 23 24/* Open_plugin module 25 * OP stores and retrieves plugin path and parameters by key 26 * from a dictionary file 27 * 28 * plugins can load other plugins 29 * return rb->plugin_open(path, parameter); 30 */ 31 32#ifndef __PCTOOL__ 33/* open_plugin path lookup */ 34#define OPEN_PLUGIN_DAT PLUGIN_DIR "/plugin.dat" 35#define OPEN_RBPLUGIN_DAT PLUGIN_DIR "/rb_plugins.dat" 36#define OPEN_PLUGIN_BUFSZ MAX_PATH 37#define OPEN_PLUGIN_NAMESZ 32 38 39enum { 40 OPEN_PLUGIN_LANG_INVALID = (-1), 41 OPEN_PLUGIN_LANG_IGNORE = (-2), 42 OPEN_PLUGIN_LANG_IGNOREALL = (-3), 43 OPEN_PLUGIN_INVALID_ENTRY = (-1), 44 OPEN_PLUGIN_NOT_FOUND = (-2), 45 OPEN_PLUGIN_NEEDS_FLUSHED = (-3), 46}; 47 48struct open_plugin_entry_t 49{ 50/* hash lang_id checksum need to be the first items */ 51 uint32_t hash; 52 int32_t lang_id; 53 uint32_t checksum; 54 char name[OPEN_PLUGIN_NAMESZ+1]; 55 /*char key[OPEN_PLUGIN_BUFSZ+1];*/ 56 char path[OPEN_PLUGIN_BUFSZ+1]; 57 char param[OPEN_PLUGIN_BUFSZ+1]; 58}; 59 60#define OPEN_PLUGIN_CHECKSUM (uint32_t) \ 61( \ 62 (sizeof(struct open_plugin_entry_t) << 16) + \ 63 offsetof(struct open_plugin_entry_t, hash) + \ 64 offsetof(struct open_plugin_entry_t, lang_id) + \ 65 offsetof(struct open_plugin_entry_t, checksum) + \ 66 offsetof(struct open_plugin_entry_t, name) + \ 67 offsetof(struct open_plugin_entry_t, path) + \ 68 offsetof(struct open_plugin_entry_t, param)) 69 70#define OPEN_PLUGIN_SEED 0x811C9DC5; //seed, 2166136261; 71inline static void open_plugin_get_hash(const char *key, uint32_t *hash) 72{ 73 /* Calculate modified FNV1a hash of string */ 74 const uint32_t p = 16777619; 75 *hash = OPEN_PLUGIN_SEED; 76 while(*key) 77 *hash = (*key++ ^ *hash) * p; 78} 79 80#ifndef PLUGIN 81struct open_plugin_entry_t* open_plugin_get_entry(void); 82uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *parameter); 83int open_plugin_load_entry(const char *key); 84void open_plugin_browse(const char *key); 85int open_plugin_run(const char *key); 86void open_plugin_cache_flush(void); /* flush to disk */ 87#endif 88 89#endif /*ndef __PCTOOL__ */ 90#endif /* OPEN_PLUGIN_H */