diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-01-30 18:29:22 +0100 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-01-30 18:29:22 +0100 |
commit | 3a68e7c2ca41e9c13e4930ce644418ab75681765 (patch) | |
tree | 9b22cbcacead5277a2a8c5d11621d3e5944831c5 | |
parent | a4f7dc1214eefa15a4a9bb2f166ea7b09b4985b2 (diff) |
icy-metadata support for mp3 streams
-rw-r--r-- | deadbeef.h | 1 | ||||
-rw-r--r-- | playlist.c | 20 | ||||
-rw-r--r-- | playlist.h | 9 | ||||
-rw-r--r-- | plugins.c | 1 | ||||
-rw-r--r-- | plugins/mpgmad/mpgmad.c | 16 | ||||
-rw-r--r-- | plugins/vfs_curl/vfs_curl.c | 4 |
6 files changed, 46 insertions, 5 deletions
@@ -329,6 +329,7 @@ typedef struct { void (*pl_add_meta) (DB_playItem_t *it, const char *key, const char *value); const char *(*pl_find_meta) (DB_playItem_t *song, const char *meta); void (*pl_delete_all_meta) (DB_playItem_t *it); + void (*pl_replace_meta) (DB_playItem_t *it, const char *key, const char *value); void (*pl_set_item_duration) (DB_playItem_t *it, float duration); float (*pl_get_item_duration) (DB_playItem_t *it); void (*pl_sort) (int iter, int id, const char *format, int ascending); @@ -1189,6 +1189,26 @@ pl_add_meta (playItem_t *it, const char *key, const char *value) { } void +pl_replace_meta (playItem_t *it, const char *key, const char *value) { + // check if it's already set + metaInfo_t *m = it->meta; + while (m) { + if (!strcasecmp (key, m->key)) { + break;; + } + m = m->next; + } + if (m) { + free (m->value); + m->value = strdup (value); + return; + } + else { + pl_add_meta (it, key, value); + } +} + +void pl_format_item_display_name (playItem_t *it, char *str, int len) { const char *artist = pl_find_meta (it, "artist"); const char *title = pl_find_meta (it, "title"); @@ -126,13 +126,16 @@ pl_randomsong (void); void pl_add_meta (playItem_t *it, const char *key, const char *value); -void -pl_format_item_display_name (playItem_t *it, char *str, int len); - const char * pl_find_meta (playItem_t *it, const char *key); void +pl_replace_meta (playItem_t *it, const char *key, const char *value); + +void +pl_format_item_display_name (playItem_t *it, char *str, int len); + +void pl_delete_all_meta (playItem_t *it); // returns index of 1st deleted item @@ -138,6 +138,7 @@ static DB_functions_t deadbeef_api = { // metainfo .pl_add_meta = (void (*) (DB_playItem_t *, const char *, const char *))pl_add_meta, .pl_find_meta = (const char *(*) (DB_playItem_t *, const char *))pl_find_meta, + .pl_replace_meta = (void (*) (DB_playItem_t *, const char *, const char *))pl_replace_meta, .pl_delete_all_meta = (void (*) (DB_playItem_t *it))pl_delete_all_meta, // cuesheet support .pl_insert_cue_from_buffer = (DB_playItem_t *(*) (DB_playItem_t *after, DB_playItem_t *origin, const uint8_t *buffer, int buffersize, int numsamples, int samplerate))pl_insert_cue_from_buffer, diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c index f02c9506..ea09cc8e 100644 --- a/plugins/mpgmad/mpgmad.c +++ b/plugins/mpgmad/mpgmad.c @@ -87,6 +87,7 @@ typedef struct { int avg_samplerate; int avg_samples_per_frame; int nframes; + int last_comment_update; } buffer_t; static buffer_t buffer; @@ -830,6 +831,21 @@ cmp3_stream_frame (void) { deadbeef->streamer_set_bitrate (frame.header.bitrate/1000); break; } + + if (!eof) { + if (buffer.file->vfs->streaming && buffer.currentsample - buffer.last_comment_update > 5 * plugin.info.samplerate) { + int idx = deadbeef->pl_get_idx_of (buffer.it); + if (idx >= 0) { + buffer.last_comment_update = buffer.currentsample; + const char *vfs_tit = deadbeef->fget_content_name (buffer.file); + if (vfs_tit) { + deadbeef->pl_replace_meta (buffer.it, "title", vfs_tit); + deadbeef->sendmessage (M_TRACKCHANGED, 0, idx, 0); + } + } + } + } + return eof; } diff --git a/plugins/vfs_curl/vfs_curl.c b/plugins/vfs_curl/vfs_curl.c index 181e052b..ca30024b 100644 --- a/plugins/vfs_curl/vfs_curl.c +++ b/plugins/vfs_curl/vfs_curl.c @@ -24,8 +24,8 @@ #include <curl/curlver.h> #include "../../deadbeef.h" -#define trace(...) { fprintf(stderr, __VA_ARGS__); } -//#define trace(fmt,...) +//#define trace(...) { fprintf(stderr, __VA_ARGS__); } +#define trace(fmt,...) #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)>(y)?(x):(y)) |