diff options
author | Alexey Yakovenko <waker@users.sourceforge.net> | 2014-06-24 20:14:39 +0200 |
---|---|---|
committer | Alexey Yakovenko <waker@users.sourceforge.net> | 2014-06-24 20:14:39 +0200 |
commit | 8c9370dc472a9abf272894872da22452bdf5b018 (patch) | |
tree | 913fdcc6f2c2ef5c8c76c4260584ea02e91481a9 | |
parent | 7c1364b0e5c24cad204b69b1ceb2fc2758548d17 (diff) |
added new "open2" decoder plugin API, see deadbeef.h for details
-rw-r--r-- | deadbeef.h | 12 | ||||
-rw-r--r-- | streamer.c | 29 |
2 files changed, 27 insertions, 14 deletions
@@ -71,6 +71,7 @@ extern "C" { // api version history: // 9.9 -- devel +// 1.7 -- deadbeef-0.6.2 // 1.6 -- deadbeef-0.6.1 // 1.5 -- deadbeef-0.6 // 1.4 -- deadbeef-0.5.5 @@ -91,7 +92,7 @@ extern "C" { // 0.1 -- deadbeef-0.2.0 #define DB_API_VERSION_MAJOR 1 -#define DB_API_VERSION_MINOR 6 +#define DB_API_VERSION_MINOR 7 #define DDB_DEPRECATED(x) @@ -1252,6 +1253,15 @@ typedef struct DB_decoder_s { // NULL terminated array of all supported prefixes (UADE support needs that) // e.g. "mod.song_title" const char **prefixes; + +#if (DDB_API_LEVEL >= 7) + // This function's purpose is to open the file, so that the file handle is + // immediately accessible via DB_fileinfo_t, and can be used with fabort. + // If a plugin is using open2, it should not reopen the file from init. + // Plugins _must_ implement open even if open2 is present, + // because existing code may rely on it. + DB_fileinfo_t *(*open2) (uint32_t hints, DB_playItem_t *it); +#endif } DB_decoder_t; // output plugin @@ -186,19 +186,11 @@ streamer_unlock (void) { static void streamer_abort_files (void) { - trace ("\033[0;33mstreamer_abort_files\033[37;0m\n"); DB_FILE *file = fileinfo_file; DB_FILE *newfile = new_fileinfo_file; DB_FILE *strfile = streamer_file; - - // this situation occurs during decoder->init - // we still don't have the filehandle acquired from the streamer thread, - // but the file is open already - if (!newfile && !new_fileinfo_file && new_fileinfo) { - mutex_lock (decodemutex); - newfile = new_fileinfo->file; - mutex_unlock (decodemutex); - } + trace ("\033[0;33mstreamer_abort_files\033[37;0m\n"); + trace ("%p %p %p\n", file, newfile, strfile); if (file) { deadbeef->fabort (file); @@ -907,6 +899,14 @@ is_remote_stream (playItem_t *it) { return remote; } +static DB_fileinfo_t *dec_open (DB_decoder_t *dec, uint32_t hints, playItem_t *it) { + if (dec->plugin.api_vminor >= 7 && dec->open2) { + DB_fileinfo_t *fi = dec->open2 (hints, DB_PLAYITEM (it)); + return fi; + } + return dec->open (hints); +} + // that must be called after last sample from str_playing_song was done reading static int streamer_set_current (playItem_t *it) { @@ -1209,7 +1209,10 @@ m3u_error: trace ("\033[0;33minit decoder for %s (%s)\033[37;0m\n", pl_find_meta (it, ":URI"), dec->plugin.id); mutex_lock (decodemutex); - new_fileinfo = dec->open (0); + new_fileinfo = dec_open (dec, 0, it); + if (new_fileinfo->file) { + new_fileinfo_file = new_fileinfo->file; + } mutex_unlock (decodemutex); if (new_fileinfo && dec->init (new_fileinfo, DB_PLAYITEM (it)) != 0) { trace ("\033[0;31mfailed to init decoder\033[37;0m\n"); @@ -1568,7 +1571,7 @@ streamer_thread (void *ctx) { seekpos = -1; if (seek >= 0 && pl_get_item_duration (playing_track) > 0) { playpos = seek; - trace ("seeking to %d\n", seek); + trace ("seeking to %f\n", seek); float pos = seek; if (playing_track != streaming_track) { @@ -1606,7 +1609,7 @@ streamer_thread (void *ctx) { } pl_unlock (); if (dec) { - fileinfo = dec->open (0); + fileinfo = dec_open (dec, 0, streaming_track); mutex_unlock (decodemutex); if (fileinfo && dec->init (fileinfo, DB_PLAYITEM (streaming_track)) != 0) { mutex_lock (decodemutex); |