From 76f14028b56a1cdb6627b0db0e6af0a74a9b76f3 Mon Sep 17 00:00:00 2001 From: waker Date: Fri, 17 Jun 2011 20:54:11 +0200 Subject: merge new APIs for 0.5.2 from devel --- deadbeef.h | 13 ++++++++++++- metacache.c | 12 ++++++++++++ metacache.h | 6 ++++++ playlist.c | 28 ++++++++++++++++++++++------ playlist.h | 10 ++++++++++ plugins.c | 13 ++++++++++++- 6 files changed, 74 insertions(+), 8 deletions(-) diff --git a/deadbeef.h b/deadbeef.h index 8b7de00a..3605c09b 100644 --- a/deadbeef.h +++ b/deadbeef.h @@ -76,7 +76,7 @@ extern "C" { // 0.1 -- deadbeef-0.2.0 #define DB_API_VERSION_MAJOR 1 -#define DB_API_VERSION_MINOR 1 +#define DB_API_VERSION_MINOR 2 #define DDB_PLUGIN_SET_API_VERSION\ .plugin.api_vmajor = DB_API_VERSION_MAJOR,\ @@ -725,6 +725,17 @@ typedef struct { int (*dsp_preset_load) (const char *fname, struct ddb_dsp_context_s **head); int (*dsp_preset_save) (const char *fname, struct ddb_dsp_context_s *head); void (*dsp_preset_free) (struct ddb_dsp_context_s *head); + + // new 1.2 APIs + ddb_playlist_t *(*plt_alloc) (const char *title); + void (*plt_free) (ddb_playlist_t *plt); + //int (*plt_insert) (ddb_playlist_t *plt, int before); + void (*plt_set_fast_mode) (ddb_playlist_t *plt, int fast); + int (*plt_is_fast_mode) (ddb_playlist_t *plt); + const char * (*metacache_add_string) (const char *str); + void (*metacache_remove_string) (const char *str); + void (*metacache_ref) (const char *str); + void (*metacache_unref) (const char *str); } DB_functions_t; enum { diff --git a/metacache.c b/metacache.c index 84acaa91..13616516 100644 --- a/metacache.c +++ b/metacache.c @@ -114,3 +114,15 @@ metacache_remove_string (const char *str) { chain = chain->next; } } + +void +metacache_ref (const char *str) { + uint32_t *refc = (uint32_t)(str-5); + *refc++; +} + +void +metacache_unref (const char *str) { + uint32_t *refc = (uint32_t *)(str-5); + *refc--; +} diff --git a/metacache.h b/metacache.h index b5187c0f..50c5cb7f 100644 --- a/metacache.h +++ b/metacache.h @@ -25,4 +25,10 @@ metacache_add_string (const char *str); void metacache_remove_string (const char *str); +void +metacache_ref (const char *str); + +void +metacache_unref (const char *str); + #endif diff --git a/playlist.c b/playlist.c index 312965fc..68accc38 100644 --- a/playlist.c +++ b/playlist.c @@ -327,6 +327,15 @@ plt_get_sel_count (int plt) { return 0; } +playlist_t * +plt_alloc (const char *title) { + playlist_t *plt = malloc (sizeof (playlist_t)); + memset (plt, 0, sizeof (playlist_t)); + plt->refc = 1; + plt->title = strdup (title); + return plt; +} + int plt_add (int before, const char *title) { assert (before >= 0); @@ -335,10 +344,7 @@ plt_add (int before, const char *title) { fprintf (stderr, "can't create more than 100 playlists. sorry.\n"); return -1; } - playlist_t *plt = malloc (sizeof (playlist_t)); - memset (plt, 0, sizeof (playlist_t)); - plt->refc = 1; - plt->title = strdup (title); + playlist_t *plt = plt_alloc (title); plt_modified (plt); LOCK; @@ -398,7 +404,7 @@ plt_add (int before, const char *title) { conf_save (); messagepump_push (DB_EV_PLAYLISTSWITCHED, 0, 0, 0); } - return playlists_count-1; + return before; } // NOTE: caller must ensure that configuration is saved after that call @@ -980,7 +986,7 @@ plt_process_cue_track (playlist_t *playlist, playItem_t *after, const char *fnam pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKPEAK, atof (replaygain_track_peak)); } it->_flags |= DDB_IS_SUBTRACK | DDB_TAG_CUESHEET; - after = pl_insert_item (after, it); + after = plt_insert_item (playlist, after, it); pl_item_unref (it); *prev = it; return it; @@ -3904,3 +3910,13 @@ plt_init_shuffle_albums (playlist_t *plt, int r) { } pl_unlock (); } + +void +plt_set_fast_mode (playlist_t *plt, int fast) { + plt->fast_mode = (unsigned)fast; +} + +int +plt_is_fast_mode (playlist_t *plt) { + return plt->fast_mode; +} diff --git a/playlist.h b/playlist.h index 23f74459..2f9a9d6a 100644 --- a/playlist.h +++ b/playlist.h @@ -56,6 +56,7 @@ typedef struct playlist_s { int current_row[PL_MAX_ITERATORS]; // current row (cursor) struct DB_metaInfo_s *meta; // linked list storing metainfo int refc; + unsigned fast_mode : 1; } playlist_t; // global playlist control functions @@ -92,6 +93,9 @@ plt_ref (playlist_t *plt); void plt_unref (playlist_t *plt); +playlist_t * +plt_alloc (const char *title); + void plt_free (playlist_t *plt); @@ -437,4 +441,10 @@ pl_get_playlist (playItem_t *it); void plt_init_shuffle_albums (playlist_t *plt, int r); +void +plt_set_fast_mode (playlist_t *plt, int fast); + +int +plt_is_fast_mode (playlist_t *plt); + #endif // __PLAYLIST_H diff --git a/plugins.c b/plugins.c index 92b740a1..ff110913 100644 --- a/plugins.c +++ b/plugins.c @@ -45,6 +45,7 @@ #include "premix.h" #include "dsppreset.h" #include "pltmeta.h" +#include "metacache.h" #define trace(...) { fprintf(stderr, __VA_ARGS__); } //#define trace(fmt,...) @@ -316,7 +317,17 @@ static DB_functions_t deadbeef_api = { // dsp preset management .dsp_preset_load = dsp_preset_load, .dsp_preset_save = dsp_preset_save, - .dsp_preset_free = dsp_preset_free + .dsp_preset_free = dsp_preset_free, + // new 1.2 APIs + .plt_alloc = (ddb_playlist_t *(*)(const char *title))plt_alloc, + .plt_free = (void (*)(ddb_playlist_t *plt))plt_free, + //.plt_insert = plt_insert, + .plt_set_fast_mode = (void (*)(ddb_playlist_t *plt, int fast))plt_set_fast_mode, + .plt_is_fast_mode = (int (*)(ddb_playlist_t *plt))plt_is_fast_mode, + .metacache_add_string = metacache_add_string, + .metacache_remove_string = metacache_remove_string, + .metacache_ref = metacache_ref, + .metacache_unref = metacache_unref, }; DB_functions_t *deadbeef = &deadbeef_api; -- cgit v1.2.3