diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/aac/aac.c | 26 | ||||
-rw-r--r-- | plugins/adplug/adplug-db.cpp | 12 | ||||
-rw-r--r-- | plugins/cdda/cdda.c | 12 | ||||
-rw-r--r-- | plugins/dca/dcaplug.c | 8 | ||||
-rw-r--r-- | plugins/ffap/ffap.c | 8 | ||||
-rw-r--r-- | plugins/ffmpeg/ffmpeg.c | 26 | ||||
-rw-r--r-- | plugins/flac/flac.c | 24 | ||||
-rw-r--r-- | plugins/gme/cgme.c | 18 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 2 | ||||
-rw-r--r-- | plugins/gtkui/mainplaylist.c | 6 | ||||
-rw-r--r-- | plugins/gtkui/plcommon.c | 11 | ||||
-rw-r--r-- | plugins/gtkui/trkproperties.c | 142 | ||||
-rw-r--r-- | plugins/mpgmad/mpgmad.c | 16 | ||||
-rw-r--r-- | plugins/musepack/musepack.c | 30 | ||||
-rw-r--r-- | plugins/notify/notify.c | 2 | ||||
-rw-r--r-- | plugins/shellexec/shellexec.c | 2 | ||||
-rw-r--r-- | plugins/sid/csid.cpp | 12 | ||||
-rw-r--r-- | plugins/sndfile/sndfile.c | 8 | ||||
-rw-r--r-- | plugins/tta/ttaplug.c | 16 | ||||
-rw-r--r-- | plugins/vorbis/vorbis.c | 35 | ||||
-rw-r--r-- | plugins/vtx/vtx.c | 9 | ||||
-rw-r--r-- | plugins/wavpack/wavpack.c | 12 | ||||
-rw-r--r-- | plugins/wildmidi/wildmidiplug.c | 8 |
23 files changed, 197 insertions, 248 deletions
diff --git a/plugins/aac/aac.c b/plugins/aac/aac.c index ca76340a..332870e0 100644 --- a/plugins/aac/aac.c +++ b/plugins/aac/aac.c @@ -384,7 +384,7 @@ static int aac_init (DB_fileinfo_t *_info, DB_playItem_t *it) { aac_info_t *info = (aac_info_t *)_info; - info->file = deadbeef->fopen (it->fname); + info->file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!info->file) { return -1; } @@ -424,7 +424,7 @@ aac_init (DB_fileinfo_t *_info, DB_playItem_t *it) { if (!info->file->vfs->is_streaming ()) { #ifdef USE_MP4FF - trace ("aac_init: mp4ff_open_read %s\n", it->fname); + trace ("aac_init: mp4ff_open_read %s\n", deadbeef->pl_find_meta (it, ":URI")); info->mp4file = mp4ff_open_read (&info->mp4reader); if (info->mp4file) { int ntracks = mp4ff_total_tracks (info->mp4file); @@ -493,8 +493,8 @@ aac_init (DB_fileinfo_t *_info, DB_playItem_t *it) { } } #else - trace ("aac_init: MP4ReadProvider %s\n", it->fname); - info->mp4file = MP4ReadProvider (it->fname, 0, &info->mp4reader); + trace ("aac_init: MP4ReadProvider %s\n", deadbeef->pl_find_meta (it, ":URI")); + info->mp4file = MP4ReadProvider (deadbeef->pl_find_meta (it, ":URI"), 0, &info->mp4reader); info->mp4track = MP4FindTrackId(info->mp4file, 0, "audio", 0); trace ("aac_init: MP4FindTrackId returned %d\n", info->mp4track); if (info->mp4track >= 0) { @@ -991,24 +991,20 @@ aac_load_tags (DB_playItem_t *it, mp4ff_t *mp4) { free (s); } } - it->replaygain_track_gain = 0; - it->replaygain_track_peak = 1; - it->replaygain_album_gain = 0; - it->replaygain_album_peak = 1; if (mp4ff_meta_find_by_name(mp4, "replaygain_track_gain", &s)) { - it->replaygain_track_gain = atof (s); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKGAIN, atof (s)); free (s); } if (mp4ff_meta_find_by_name(mp4, "replaygain_track_peak", &s)) { - it->replaygain_track_peak = atof (s); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKPEAK, atof (s)); free (s); } if (mp4ff_meta_find_by_name(mp4, "replaygain_album_gain", &s)) { - it->replaygain_album_gain = atof (s); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMGAIN, atof (s)); free (s); } if (mp4ff_meta_find_by_name(mp4, "replaygain_album_peak", &s)) { - it->replaygain_album_peak = atof (s); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMPEAK, atof (s)); free (s); } deadbeef->pl_add_meta (it, "title", NULL); @@ -1019,7 +1015,7 @@ aac_load_tags (DB_playItem_t *it, mp4ff_t *mp4) { int aac_read_metadata (DB_playItem_t *it) { #ifdef USE_MP4FF - DB_FILE *fp = deadbeef->fopen (it->fname); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp) { return -1; } @@ -1112,9 +1108,7 @@ aac_insert (DB_playItem_t *after, const char *fname) { } } - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); it->filetype = ftype; deadbeef->pl_set_item_duration (it, duration); trace ("duration: %f sec\n", duration); diff --git a/plugins/adplug/adplug-db.cpp b/plugins/adplug/adplug-db.cpp index 1f096727..973da0da 100644 --- a/plugins/adplug/adplug-db.cpp +++ b/plugins/adplug/adplug-db.cpp @@ -82,13 +82,13 @@ adplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) { int channels = 2; info->opl = new CEmuopl (samplerate, bps == 16 ? true : false, channels == 2); // opl->settype (Copl::TYPE_OPL2); - info->decoder = CAdPlug::factory (it->fname, info->opl, CAdPlug::players); + info->decoder = CAdPlug::factory (deadbeef->pl_find_meta (it, ":URI"), info->opl, CAdPlug::players); if (!info->decoder) { - trace ("adplug: failed to open %s\n", it->fname); + trace ("adplug: failed to open %s\n", deadbeef->pl_find_meta (it, ":URI")); return -1; } - info->subsong = it->tracknum; + info->subsong = deadbeef->pl_find_meta_int (it, ":TRACKNUM", 0); info->decoder->rewind (info->subsong); float dur = deadbeef->pl_get_item_duration (it); info->totalsamples = dur * samplerate; @@ -264,11 +264,9 @@ adplug_insert (DB_playItem_t *after, const char *fname) { if (dur < 0.1) { continue; } - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (adplug_plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, adplug_plugin.plugin.id); it->filetype = adplug_get_extension (fname); - it->tracknum = i; + deadbeef->pl_set_meta_int (it, ":TRACKNUM", i); deadbeef->pl_set_item_duration (it, dur); #if 0 // add metainfo diff --git a/plugins/cdda/cdda.c b/plugins/cdda/cdda.c index 2fe26360..1a2a0ec6 100644 --- a/plugins/cdda/cdda.c +++ b/plugins/cdda/cdda.c @@ -79,18 +79,18 @@ static int cda_init (DB_fileinfo_t *_info, DB_playItem_t *it) { cdda_info_t *info = (cdda_info_t *)_info; - trace ("cdda: init %s\n", it->fname); + trace ("cdda: init %s\n", deadbeef->pl_find_meta (it, ":URI")); - size_t l = strlen (it->fname); + size_t l = strlen (deadbeef->pl_find_meta (it, ":URI")); char location[l+1]; - memcpy (location, it->fname, l+1); + memcpy (location, deadbeef->pl_find_meta (it, ":URI"), l+1); char *nr = strchr (location, '#'); if (nr) { *nr = 0; nr++; } else { - trace ("cdda: bad name: %s\n", it->fname); + trace ("cdda: bad name: %s\n", deadbeef->pl_find_meta (it, ":URI")); return -1; } int track_nr = atoi (nr); @@ -285,9 +285,7 @@ insert_single_track (CdIo_t* cdio, DB_playItem_t *after, const char* file, int t int sector_count = cdio_get_track_sec_count (cdio, track_nr); - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (tmp); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (tmp, plugin.plugin.id); it->filetype = "cdda"; deadbeef->pl_set_item_duration (it, (float)sector_count / 75.0); diff --git a/plugins/dca/dcaplug.c b/plugins/dca/dcaplug.c index c14032e1..034e5fdc 100644 --- a/plugins/dca/dcaplug.c +++ b/plugins/dca/dcaplug.c @@ -356,9 +356,9 @@ static int dts_init (DB_fileinfo_t *_info, DB_playItem_t *it) { ddb_dca_state_t *info = (ddb_dca_state_t *)_info; - info->file = deadbeef->fopen (it->fname); + info->file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!info->file) { - trace ("dca: failed to open %s\n", it->fname); + trace ("dca: failed to open %s\n", deadbeef->pl_find_meta (it, ":URI")); return -1; } @@ -606,9 +606,7 @@ dts_insert (DB_playItem_t *after, const char *fname) { dur = (float)totalsamples / state.sample_rate; } - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); it->filetype = filetype; deadbeef->pl_set_item_duration (it, dur); diff --git a/plugins/ffap/ffap.c b/plugins/ffap/ffap.c index 2559ea27..4c414a9f 100644 --- a/plugins/ffap/ffap.c +++ b/plugins/ffap/ffap.c @@ -690,7 +690,7 @@ ffap_init (DB_fileinfo_t *_info, DB_playItem_t *it) { ape_info_t *info = (ape_info_t*)_info; - info->fp = deadbeef->fopen (it->fname); + info->fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!info->fp) { return -1; } @@ -1764,9 +1764,7 @@ ffap_insert (DB_playItem_t *after, const char *fname) { float duration = ape_ctx.totalsamples / (float)ape_ctx.samplerate; DB_playItem_t *it = NULL; - it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); it->filetype = "APE"; deadbeef->pl_set_item_duration (it, duration); @@ -1912,7 +1910,7 @@ ffap_seek (DB_fileinfo_t *_info, float seconds) { static int ffap_read_metadata (DB_playItem_t *it) { - DB_FILE *fp = deadbeef->fopen (it->fname); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp) { return -1; } diff --git a/plugins/ffmpeg/ffmpeg.c b/plugins/ffmpeg/ffmpeg.c index 8d718546..2eaf1cb9 100644 --- a/plugins/ffmpeg/ffmpeg.c +++ b/plugins/ffmpeg/ffmpeg.c @@ -103,19 +103,19 @@ ffmpeg_open (uint32_t hints) { static int ffmpeg_init (DB_fileinfo_t *_info, DB_playItem_t *it) { ffmpeg_info_t *info = (ffmpeg_info_t *)_info; - trace ("ffmpeg init %s\n", it->fname); + trace ("ffmpeg init %s\n", deadbeef->pl_find_meta (it, ":URI")); // prepare to decode the track // return -1 on failure int ret; - int l = strlen (it->fname); + int l = strlen (deadbeef->pl_find_meta (it, ":URI")); char *uri = alloca (l + sizeof (FF_PROTOCOL_NAME) + 1); int i; // construct uri memcpy (uri, FF_PROTOCOL_NAME, sizeof (FF_PROTOCOL_NAME)-1); memcpy (uri + sizeof (FF_PROTOCOL_NAME)-1, ":", 1); - memcpy (uri + sizeof (FF_PROTOCOL_NAME), it->fname, l); + memcpy (uri + sizeof (FF_PROTOCOL_NAME), deadbeef->pl_find_meta (it, ":URI"), l); uri[sizeof (FF_PROTOCOL_NAME) + l] = 0; trace ("ffmpeg: uri: %s\n", uri); @@ -150,10 +150,10 @@ ffmpeg_init (DB_fileinfo_t *_info, DB_playItem_t *it) { if (info->codec == NULL) { - trace ("ffmpeg can't decode %s\n", it->fname); + trace ("ffmpeg can't decode %s\n", deadbeef->pl_find_meta (it, ":URI")); return -1; } - trace ("ffmpeg can decode %s\n", it->fname); + trace ("ffmpeg can decode %s\n", deadbeef->pl_find_meta (it, ":URI")); trace ("ffmpeg: codec=%s, stream=%d\n", info->codec->name, i); if (avcodec_open (info->ctx, info->codec) < 0) { @@ -537,13 +537,11 @@ ffmpeg_insert (DB_playItem_t *after, const char *fname) { int totalsamples = fctx->duration * samplerate / AV_TIME_BASE; - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); // FIXME: get proper codec it->filetype = filetypes[FT_UNKNOWN]; - if (!deadbeef->is_local_file (it->fname)) { + if (!deadbeef->is_local_file (deadbeef->pl_find_meta (it, ":URI"))) { deadbeef->pl_set_item_duration (it, -1); } else { @@ -555,7 +553,7 @@ ffmpeg_insert (DB_playItem_t *after, const char *fname) { int64_t fsize = -1; - DB_FILE *fp = deadbeef->fopen (it->fname); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (fp) { if (!fp->vfs->is_streaming ()) { fsize = deadbeef->fgetlength (fp); @@ -693,19 +691,19 @@ ffmpeg_stop (void) { int ffmpeg_read_metadata (DB_playItem_t *it) { - trace ("ffmpeg_read_metadata: fname %s\n", it->fname); + trace ("ffmpeg_read_metadata: fname %s\n", deadbeef->pl_find_meta (it, ":URI")); AVCodec *codec = NULL; AVCodecContext *ctx = NULL; AVFormatContext *fctx = NULL; int ret; - int l = strlen (it->fname); + int l = strlen (deadbeef->pl_find_meta (it, ":URI")); char *uri = alloca (l + sizeof (FF_PROTOCOL_NAME) + 1); int i; // construct uri memcpy (uri, FF_PROTOCOL_NAME, sizeof (FF_PROTOCOL_NAME)-1); memcpy (uri + sizeof (FF_PROTOCOL_NAME)-1, ":", 1); - memcpy (uri + sizeof (FF_PROTOCOL_NAME), it->fname, l); + memcpy (uri + sizeof (FF_PROTOCOL_NAME), deadbeef->pl_find_meta (it, ":URI"), l); uri[sizeof (FF_PROTOCOL_NAME) + l] = 0; trace ("ffmpeg: uri: %s\n", uri); @@ -728,7 +726,7 @@ ffmpeg_read_metadata (DB_playItem_t *it) { } if (codec == NULL) { - trace ("ffmpeg can't decode %s\n", it->fname); + trace ("ffmpeg can't decode %s\n", deadbeef->pl_find_meta (it, ":URI")); av_close_input_file(fctx); return -1; } diff --git a/plugins/flac/flac.c b/plugins/flac/flac.c index 44311762..16514a90 100644 --- a/plugins/flac/flac.c +++ b/plugins/flac/flac.c @@ -204,10 +204,10 @@ cflac_open (uint32_t hints) { static int cflac_init (DB_fileinfo_t *_info, DB_playItem_t *it) { - trace ("cflac_init %s\n", it->fname); + trace ("cflac_init %s\n", deadbeef->pl_find_meta (it, ":URI")); flac_info_t *info = (flac_info_t *)_info; - info->file = deadbeef->fopen (it->fname); + info->file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!info->file) { trace ("cflac_init failed to open file\n"); return -1; @@ -215,8 +215,8 @@ cflac_init (DB_fileinfo_t *_info, DB_playItem_t *it) { info->flac_critical_error = 0; - const char *ext = it->fname + strlen (it->fname); - while (ext > it->fname && *ext != '/' && *ext != '.') { + const char *ext = deadbeef->pl_find_meta (it, ":URI") + strlen (deadbeef->pl_find_meta (it, ":URI")); + while (ext > deadbeef->pl_find_meta (it, ":URI") && *ext != '/' && *ext != '.') { ext--; } if (*ext == '.') { @@ -537,16 +537,16 @@ cflac_add_metadata (DB_playItem_t *it, char *s, int length) { deadbeef->pl_add_meta (it, "cuesheet", s + 9); } else if (!strncasecmp (s, "replaygain_album_gain=", 22)) { - it->replaygain_album_gain = atof (s + 22); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMGAIN, atof (s+22)); } else if (!strncasecmp (s, "replaygain_album_peak=", 22)) { - it->replaygain_album_peak = atof (s + 22); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMPEAK, atof (s+22)); } else if (!strncasecmp (s, "replaygain_track_gain=", 22)) { - it->replaygain_track_gain = atof (s + 22); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKGAIN, atof (s+22)); } else if (!strncasecmp (s, "replaygain_track_peak=", 22)) { - it->replaygain_track_peak = atof (s + 22); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKPEAK, atof (s+22)); } else { const char *eq = strchr (s, '='); @@ -663,9 +663,7 @@ cflac_insert (DB_playItem_t *after, const char *fname) { // read all metadata FLAC__stream_decoder_set_md5_checking(decoder, 0); FLAC__stream_decoder_set_metadata_respond_all (decoder); - it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); info.it = it; if (skip > 0) { deadbeef->fseek (info.file, skip, SEEK_SET); @@ -757,7 +755,7 @@ cflac_read_metadata (DB_playItem_t *it) { trace ("cflac_read_metadata: FLAC__metadata_chain_new failed\n"); return -1; } - FLAC__bool res = FLAC__metadata_chain_read (chain, it->fname); + FLAC__bool res = FLAC__metadata_chain_read (chain, deadbeef->pl_find_meta (it, ":URI")); if (!res) { trace ("cflac_read_metadata: FLAC__metadata_chain_read failed\n"); goto error; @@ -822,7 +820,7 @@ cflac_write_metadata (DB_playItem_t *it) { trace ("cflac_write_metadata: FLAC__metadata_chain_new failed\n"); return -1; } - FLAC__bool res = FLAC__metadata_chain_read (chain, it->fname); + FLAC__bool res = FLAC__metadata_chain_read (chain, deadbeef->pl_find_meta (it, ":URI")); if (!res) { trace ("cflac_write_metadata: FLAC__metadata_chain_read failed\n"); goto error; diff --git a/plugins/gme/cgme.c b/plugins/gme/cgme.c index 3934f930..5b6a436f 100644 --- a/plugins/gme/cgme.c +++ b/plugins/gme/cgme.c @@ -113,18 +113,18 @@ cgme_init (DB_fileinfo_t *_info, DB_playItem_t *it) { int samplerate = deadbeef->conf_get_int ("synth.samplerate", 44100); gme_err_t res; - const char *ext = strrchr (it->fname, '.'); + const char *ext = strrchr (deadbeef->pl_find_meta (it, ":URI"), '.'); if (ext && !strcasecmp (ext, ".vgz")) { trace ("opening gzipped vgm...\n"); char *buffer; int sz; - if (!read_gzfile (it->fname, &buffer, &sz)) { + if (!read_gzfile (deadbeef->pl_find_meta (it, ":URI"), &buffer, &sz)) { res = gme_open_data (buffer, sz, &info->emu, samplerate); free (buffer); } } else { - DB_FILE *f = deadbeef->fopen (it->fname); + DB_FILE *f = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); int64_t sz = deadbeef->fgetlength (f); if (sz <= 0) { deadbeef->fclose (f); @@ -151,14 +151,14 @@ cgme_init (DB_fileinfo_t *_info, DB_playItem_t *it) { return -1; } gme_mute_voices (info->emu, info->cgme_voicemask); - gme_start_track (info->emu, it->tracknum); + gme_start_track (info->emu, deadbeef->pl_find_meta_int (it, ":TRACKNUM", 0)); #ifdef GME_VERSION_055 gme_info_t *inf; - gme_track_info (info->emu, &inf, it->tracknum); + gme_track_info (info->emu, &inf, deadbeef->pl_find_meta_int (it, ":TRACKNUM", 0)); #else track_info_t _inf; - gme_track_info (info->emu, &inf, it->tracknum); + gme_track_info (info->emu, &inf, deadbeef->pl_find_meta_int (it, ":TRACKNUM", 0)); track_info_t *inf = &_inf; #endif @@ -298,9 +298,7 @@ cgme_insert (DB_playItem_t *after, const char *fname) { track_info_t *inf = &_inf; #endif if (!ret) { - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); char str[1024]; if (inf->song[0]) { snprintf (str, 1024, "%d %s - %s", i, inf->game, inf->song); @@ -309,7 +307,7 @@ cgme_insert (DB_playItem_t *after, const char *fname) { snprintf (str, 1024, "%d %s - ?", i, inf->game); } trace ("track subtune %d %s, length=%d\n", i, str, inf->length); - it->tracknum = i; + deadbeef->pl_set_meta_int (it, ":TRACKNUM", i); // add metadata cgme_add_meta (it, "system", inf->system); diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 539b6eb7..b25317d7 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -1081,7 +1081,7 @@ gtkui_add_file_info_cb (DB_playItem_t *it, void *data) { if (progress_is_aborted ()) { return -1; } - g_idle_add (gtkui_set_progress_text_idle, it->fname); + g_idle_add (gtkui_set_progress_text_idle, (gpointer)deadbeef->pl_find_meta (it, ":URI")); return 0; } diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c index fc86a058..9342f257 100644 --- a/plugins/gtkui/mainplaylist.c +++ b/plugins/gtkui/mainplaylist.c @@ -127,9 +127,9 @@ gboolean playlist_tooltip_handler (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer unused) { GtkWidget *pl = lookup_widget (mainwin, "playlist"); - DB_playItem_t *item = (DB_playItem_t *)ddb_listview_get_iter_from_coord (DDB_LISTVIEW (pl), 0, y); - if (item && item->fname) { - gtk_tooltip_set_text (tooltip, item->fname); + DB_playItem_t *it = (DB_playItem_t *)ddb_listview_get_iter_from_coord (DDB_LISTVIEW (pl), 0, y); + if (it) { + gtk_tooltip_set_text (tooltip, deadbeef->pl_find_meta (it, ":URI")); return TRUE; } return FALSE; diff --git a/plugins/gtkui/plcommon.c b/plugins/gtkui/plcommon.c index 53965295..bffaa6c9 100644 --- a/plugins/gtkui/plcommon.c +++ b/plugins/gtkui/plcommon.c @@ -120,7 +120,7 @@ void draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListview if (!album || !*album) { album = deadbeef->pl_find_meta (group_it, "title"); } - GdkPixbuf *pixbuf = get_cover_art (((DB_playItem_t *)group_it)->fname, artist, album, art_width); + GdkPixbuf *pixbuf = get_cover_art (deadbeef->pl_find_meta (((DB_playItem_t *)group_it), ":URI"), artist, album, art_width); if (pixbuf) { int pw = gdk_pixbuf_get_width (pixbuf); int ph = gdk_pixbuf_get_height (pixbuf); @@ -238,14 +238,15 @@ main_reload_metadata_activate DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (menuitem), "ps")); DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN); while (it) { - if (deadbeef->pl_is_selected (it) && deadbeef->is_local_file (it->fname) && it->decoder_id) { + const char *decoder_id = deadbeef->pl_find_meta (it, ":DECODER"); + if (deadbeef->pl_is_selected (it) && deadbeef->is_local_file (deadbeef->pl_find_meta (it, ":URI")) && decoder_id) { uint32_t f = deadbeef->pl_get_item_flags (it); if (!(f & DDB_IS_SUBTRACK)) { f &= ~DDB_TAG_MASK; deadbeef->pl_set_item_flags (it, f); DB_decoder_t **decoders = deadbeef->plug_get_decoder_list (); for (int i = 0; decoders[i]; i++) { - if (!strcmp (decoders[i]->plugin.id, it->decoder_id)) { + if (!strcmp (decoders[i]->plugin.id, decoder_id)) { if (decoders[i]->read_metadata) { decoders[i]->read_metadata (it); } @@ -337,8 +338,8 @@ on_remove_from_disk_activate (GtkMenuItem *menuitem, DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN); while (it) { - if (deadbeef->pl_is_selected (it) && deadbeef->is_local_file (it->fname)) { - unlink (it->fname); + if (deadbeef->pl_is_selected (it) && deadbeef->is_local_file (deadbeef->pl_find_meta (it, ":URI"))) { + unlink (deadbeef->pl_find_meta (it, ":URI")); } DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN); deadbeef->pl_item_unref (it); diff --git a/plugins/gtkui/trkproperties.c b/plugins/gtkui/trkproperties.c index 49be5b81..889e4984 100644 --- a/plugins/gtkui/trkproperties.c +++ b/plugins/gtkui/trkproperties.c @@ -49,7 +49,7 @@ static DB_playItem_t **tracks; static int numtracks; static int -build_key_list (const char ***pkeys) { +build_key_list (const char ***pkeys, int props) { int sz = 20; const char **keys = malloc (sizeof (const char *) * sz); if (!keys) { @@ -63,7 +63,7 @@ build_key_list (const char ***pkeys) { for (int i = 0; i < numtracks; i++) { DB_metaInfo_t *meta = deadbeef->pl_get_metadata (tracks[i]); while (meta) { - if (meta->key[0] != ':') { + if ((props && meta->key[0] == ':') || (!props && meta->key[0] != ':')) { int k = 0; for (; k < n; k++) { if (meta->key == keys[k]) { @@ -91,7 +91,17 @@ build_key_list (const char ***pkeys) { } static int -get_field_value (char *out, int size, const char *key) { +equals_ptr (const char *a, const char *b) { + return a == b; +} + +static int +equals_value (const char *a, const char *b) { + return !strcmp (a, b); +} + +static int +get_field_value (char *out, int size, const char *key, const char *(*getter)(DB_playItem_t *it, const char *key), int (*equals)(const char *a, const char *b)) { int multiple = 0; *out = 0; if (numtracks == 0) { @@ -101,14 +111,14 @@ get_field_value (char *out, int size, const char *key) { const char **prev = malloc (sizeof (const char *) * numtracks); memset (prev, 0, sizeof (const char *) * numtracks); for (int i = 0; i < numtracks; i++) { - const char *val = deadbeef->pl_find_meta (tracks[i], key); + const char *val = getter (tracks[i], key); if (val && val[0] == 0) { val = NULL; } if (i > 0) { int n = 0; for (; n < i; n++) { - if (prev[n] == val) { + if (equals (prev[n], val)) { break; } } @@ -134,7 +144,8 @@ get_field_value (char *out, int size, const char *key) { } } if (size <= 1) { - strcpy (out-2, "…"); + gchar *prev = g_utf8_prev_char (out-4); + strcpy (prev, "..."); } free (prev); return multiple; @@ -229,23 +240,38 @@ static const char *types[] = { NULL }; +static const char *hc_props[] = { + ":URI", "Location", + ":TRACKNUM", "Subtrack Index", + ":DURATION", "Duration", + ":TAGS", "Tag Type(s)", + ":HAS_EMBEDDED_CUESHEET", "Embedded Cuesheet", + ":DECODER", "Codec", + NULL +}; + static inline float amp_to_db (float amp) { return 20*log10 (amp); } void -add_field (GtkListStore *store, const char *key, const char *title) { +add_field (GtkListStore *store, const char *key, const char *title, int is_prop) { // get value to edit const char mult[] = _("[Multiple values] "); char val[1000]; size_t ml = strlen (mult); memcpy (val, mult, ml+1); - int n = get_field_value (val + ml, sizeof (val) - ml, key); + int n = get_field_value (val + ml, sizeof (val) - ml, key, deadbeef->pl_find_meta, equals_ptr); GtkTreeIter iter; gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, title, 1, n ? val : val + ml, 2, key, 3, n ? 1 : 0, -1); + if (!is_prop) { + gtk_list_store_set (store, &iter, 0, title, 1, n ? val : val + ml, 2, key, 3, n ? 1 : 0, -1); + } + else { + gtk_list_store_set (store, &iter, 0, title, 1, n ? val : val + ml, -1); + } } void @@ -257,17 +283,14 @@ trkproperties_fill_metadata (void) { gtk_list_store_clear (store); deadbeef->pl_lock (); - struct timeval tm1; - gettimeofday (&tm1, NULL); - const char **keys = NULL; - int nkeys = build_key_list (&keys); + int nkeys = build_key_list (&keys, 0); int k; // add "standard" fields for (int i = 0; types[i]; i += 2) { - add_field (store, types[i], _(types[i+1])); + add_field (store, types[i], _(types[i+1]), 0); } // add all other fields @@ -286,70 +309,35 @@ trkproperties_fill_metadata (void) { if (!types[i]) { snprintf (title, sizeof (title), "<%s>", keys[k]); } - add_field (store, keys[k], title); + add_field (store, keys[k], title, 0); } if (keys) { free (keys); } - // unknown fields and properties - if (numtracks == 1) { - DB_playItem_t *track = tracks[0]; - - DB_metaInfo_t *meta = deadbeef->pl_get_metadata (track); - while (meta) { - if (meta->key[0] == ':') { - int l = strlen (meta->key)-1; - char title[l+3]; - snprintf (title, sizeof (title), "<%s>", meta->key+1); - const char *value = meta->value; - - GtkTreeIter iter; - gtk_list_store_append (propstore, &iter); - gtk_list_store_set (propstore, &iter, 0, title, 1, value, -1); - meta = meta->next; - continue; + // hardcoded properties + for (int i = 0; hc_props[i]; i += 2) { + add_field (propstore, hc_props[i], _(hc_props[i+1]), 1); + } + // properties + keys = NULL; + nkeys = build_key_list (&keys, 1); + for (int k = 0; k < nkeys; k++) { + int i; + for (i = 0; hc_props[i]; i += 2) { + if (!strcmp (keys[k], hc_props[i])) { + break; } - meta = meta->next; } - - // properties - char temp[200]; - GtkTreeIter iter; - gtk_list_store_clear (propstore); - gtk_list_store_append (propstore, &iter); - gtk_list_store_set (propstore, &iter, 0, _("Location"), 1, track->fname, -1); - gtk_list_store_append (propstore, &iter); - snprintf (temp, sizeof (temp), "%d", track->tracknum); - gtk_list_store_set (propstore, &iter, 0, _("Subtrack Index"), 1, temp, -1); - gtk_list_store_append (propstore, &iter); - deadbeef->pl_format_time (deadbeef->pl_get_item_duration (track), temp, sizeof (temp)); - gtk_list_store_set (propstore, &iter, 0, _("Duration"), 1, temp, -1); - gtk_list_store_append (propstore, &iter); - deadbeef->pl_format_title (track, -1, temp, sizeof (temp), -1, "%T"); - gtk_list_store_set (propstore, &iter, 0, _("Tag Type(s)"), 1, temp, -1); - gtk_list_store_append (propstore, &iter); - gtk_list_store_set (propstore, &iter, 0, _("Embedded Cuesheet"), 1, (deadbeef->pl_get_item_flags (track) & DDB_HAS_EMBEDDED_CUESHEET) ? _("Yes") : _("No"), -1); - gtk_list_store_append (propstore, &iter); - gtk_list_store_set (propstore, &iter, 0, _("Codec"), 1, track->decoder_id, -1); - - gtk_list_store_append (propstore, &iter); - snprintf (temp, sizeof (temp), "%0.2f dB", track->replaygain_album_gain); - gtk_list_store_set (propstore, &iter, 0, "ReplayGain Album Gain", 1, temp, -1); - gtk_list_store_append (propstore, &iter); - snprintf (temp, sizeof (temp), "%0.6f", track->replaygain_album_peak); - gtk_list_store_set (propstore, &iter, 0, "ReplayGain Album Peak", 1, temp, -1); - - gtk_list_store_append (propstore, &iter); - snprintf (temp, sizeof (temp), "%0.2f dB", track->replaygain_track_gain); - gtk_list_store_set (propstore, &iter, 0, "ReplayGain Track Gain", 1, temp, -1); - gtk_list_store_append (propstore, &iter); - snprintf (temp, sizeof (temp), "%0.6f", track->replaygain_track_peak); - gtk_list_store_set (propstore, &iter, 0, "ReplayGain Track Peak", 1, temp, -1); - - struct timeval tm2; - gettimeofday (&tm2, NULL); - int ms = (tm2.tv_sec*1000+tm2.tv_usec/1000) - (tm1.tv_sec*1000+tm1.tv_usec/1000); + if (hc_props[i]) { + continue; + } + char title[1000]; + snprintf (title, sizeof (title), "<%s>", keys[k]+1); + add_field (propstore, keys[k], title, 1); + } + if (keys) { + free (keys); } deadbeef->pl_unlock (); @@ -402,13 +390,14 @@ show_track_properties_dlg (DB_playItem_t *it) { int is_subtrack = deadbeef->pl_get_item_flags (it) & DDB_IS_SUBTRACK; - if (!is_subtrack && deadbeef->is_local_file (it->fname)) { + if (!is_subtrack && deadbeef->is_local_file (deadbeef->pl_find_meta (it, ":URI"))) { // get decoder plugin by id DB_decoder_t *dec = NULL; - if (it->decoder_id) { + const char *decoder_id = deadbeef->pl_find_meta (it, ":DECODER"); + if (decoder_id) { DB_decoder_t **decoders = deadbeef->plug_get_decoder_list (); for (int i = 0; decoders[i]; i++) { - if (!strcmp (decoders[i]->plugin.id, it->decoder_id)) { + if (!strcmp (decoders[i]->plugin.id, decoder_id)) { dec = decoders[i]; break; } @@ -512,12 +501,13 @@ on_write_tags_clicked (GtkButton *button, gtk_tree_model_foreach (model, set_metadata_cb, NULL); for (int t = 0; t < numtracks; t++) { DB_playItem_t *track = tracks[t]; - if (track && track->decoder_id) { + const char *decoder_id = deadbeef->pl_find_meta (track, ":DECODER"); + if (track && decoder_id) { // find decoder DB_decoder_t *dec = NULL; DB_decoder_t **decoders = deadbeef->plug_get_decoder_list (); for (int i = 0; decoders[i]; i++) { - if (!strcmp (decoders[i]->plugin.id, track->decoder_id)) { + if (!strcmp (decoders[i]->plugin.id, decoder_id)) { dec = decoders[i]; if (dec->write_metadata) { dec->write_metadata (track); diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c index 51ac0115..2632a453 100644 --- a/plugins/mpgmad/mpgmad.c +++ b/plugins/mpgmad/mpgmad.c @@ -646,7 +646,7 @@ cmp3_init (DB_fileinfo_t *_info, DB_playItem_t *it) { mpgmad_info_t *info = (mpgmad_info_t *)_info; _info->plugin = &plugin; memset (&info->buffer, 0, sizeof (info->buffer)); - info->buffer.file = deadbeef->fopen (it->fname); + info->buffer.file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!info->buffer.file) { return -1; } @@ -719,7 +719,7 @@ cmp3_init (DB_fileinfo_t *_info, DB_playItem_t *it) { trace ("duration=%f, endsample=%d, totalsamples=%d\n", info->buffer.duration, info->buffer.endsample, info->buffer.totalsamples); } if (info->buffer.samplerate == 0) { - trace ("bad mpeg file: %f\n", it->fname); + trace ("bad mpeg file: %f\n", deadbeef->pl_find_meta (it, ":URI")); return -1; } _info->fmt.bps = info->buffer.bitspersample; @@ -1192,13 +1192,11 @@ cmp3_insert (DB_playItem_t *after, const char *fname) { return NULL; } if (fp->vfs->is_streaming ()) { - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); deadbeef->fclose (fp); deadbeef->pl_add_meta (it, "title", NULL); deadbeef->pl_set_item_duration (it, -1); - it->filetype = NULL;//filetypes[0]; + it->filetype = NULL; after = deadbeef->pl_insert_item (after, it); deadbeef->pl_item_unref (it); return after; @@ -1259,9 +1257,7 @@ cmp3_insert (DB_playItem_t *after, const char *fname) { break; } } - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); deadbeef->rewind (fp); // reset tags @@ -1295,7 +1291,7 @@ cmp3_insert (DB_playItem_t *after, const char *fname) { int cmp3_read_metadata (DB_playItem_t *it) { - DB_FILE *fp = deadbeef->fopen (it->fname); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp) { return -1; } diff --git a/plugins/musepack/musepack.c b/plugins/musepack/musepack.c index 93a59376..26eede96 100644 --- a/plugins/musepack/musepack.c +++ b/plugins/musepack/musepack.c @@ -97,7 +97,7 @@ musepack_init (DB_fileinfo_t *_info, DB_playItem_t *it) { info->reader.get_size = musepack_vfs_get_size; info->reader.canseek = musepack_vfs_canseek; - DB_FILE *fp = deadbeef->fopen (it->fname); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp) { return -1; } @@ -377,11 +377,9 @@ musepack_insert (DB_playItem_t *after, const char *fname) { int i; for (i = 0; i < nchapters; i++) { const mpc_chap_info *ch = mpc_demux_chap (demux, i); - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); it->filetype = "MusePack"; - it->tracknum = i; + deadbeef->pl_set_meta_int (it, ":TRACKNUM", i); it->startsample = ch->sample; it->endsample = totalsamples-1; float gain = gain_title, peak = peak_title; @@ -391,10 +389,10 @@ musepack_insert (DB_playItem_t *after, const char *fname) { if (ch->peak != 0) { peak = pow (10, ch->peak / (20.0 * 256.0)) / (1<<15); } - it->replaygain_album_gain = gain_album; - it->replaygain_album_peak = peak_album; - it->replaygain_track_gain = gain_title; - it->replaygain_track_peak = peak_title; + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMGAIN, gain_album); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMPEAK, peak_album); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKGAIN, gain_title); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKPEAK, peak_title); deadbeef->pl_set_item_flags (it, DDB_IS_SUBTRACK); if (!prev) { meta = deadbeef->pl_item_alloc (); @@ -432,17 +430,15 @@ musepack_insert (DB_playItem_t *after, const char *fname) { return after; } - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); it->filetype = "MusePack"; deadbeef->pl_set_item_duration (it, dur); /*int apeerr = */deadbeef->junk_apev2_read (it, fp); - it->replaygain_album_gain = gain_album; - it->replaygain_album_peak = peak_album; - it->replaygain_track_gain = gain_title; - it->replaygain_track_peak = peak_title; + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMGAIN, gain_album); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMPEAK, peak_album); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKGAIN, gain_title); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKPEAK, peak_title); deadbeef->fclose (fp); @@ -486,7 +482,7 @@ musepack_insert (DB_playItem_t *after, const char *fname) { } static int musepack_read_metadata (DB_playItem_t *it) { - DB_FILE *fp = deadbeef->fopen (it->fname); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp) { return -1; } diff --git a/plugins/notify/notify.c b/plugins/notify/notify.c index ea382b16..6bd42ab8 100644 --- a/plugins/notify/notify.c +++ b/plugins/notify/notify.c @@ -200,7 +200,7 @@ static void show_notification (DB_playItem_t *track) { if (deadbeef->conf_get_int("notify.albumart", 0) && artwork_plugin) { const char *album = deadbeef->pl_find_meta (track, "album"); const char *artist = deadbeef->pl_find_meta (track, "artist"); - v_iconname = artwork_plugin->get_album_art (track->fname, artist, album, deadbeef->conf_get_int ("notify.albumart_size", 64), cover_avail_callback, NULL); + v_iconname = artwork_plugin->get_album_art (deadbeef->pl_find_meta (track, ":URI"), artist, album, deadbeef->conf_get_int ("notify.albumart_size", 64), cover_avail_callback, NULL); } if (!v_iconname) { v_iconname = strdup ("deadbeef"); diff --git a/plugins/shellexec/shellexec.c b/plugins/shellexec/shellexec.c index f61d255f..a2c60af4 100644 --- a/plugins/shellexec/shellexec.c +++ b/plugins/shellexec/shellexec.c @@ -102,7 +102,7 @@ shx_callback (Shx_action_t *action, DB_playItem_t *it) static DB_plugin_action_t * shx_get_actions (DB_playItem_t *it) { - int is_local = it ? deadbeef->is_local_file (it->fname) : 1; + int is_local = it ? deadbeef->is_local_file (deadbeef->pl_find_meta (it, ":URI")) : 1; Shx_action_t *action; for (action = actions; action; action = (Shx_action_t *)action->parent.next) diff --git a/plugins/sid/csid.cpp b/plugins/sid/csid.cpp index 6583761e..2e8d00a8 100644 --- a/plugins/sid/csid.cpp +++ b/plugins/sid/csid.cpp @@ -302,7 +302,7 @@ csid_init (DB_fileinfo_t *_info, DB_playItem_t *it) { // libsidplay crashes if file doesn't exist // so i have to check it here - DB_FILE *fp = deadbeef->fopen (it->fname); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp ){ return -1; } @@ -321,9 +321,9 @@ csid_init (DB_fileinfo_t *_info, DB_playItem_t *it) { info->resid->sampling (samplerate); info->duration = deadbeef->pl_get_item_duration (it); - info->tune = new SidTune (it->fname); + info->tune = new SidTune (deadbeef->pl_find_meta (it, ":URI")); - info->tune->selectSong (it->tracknum+1); + info->tune->selectSong (deadbeef->pl_find_meta_int (it, ":TRACKNUM", 0)+1); sid2_config_t conf; conf = info->sidplay->config (); conf.frequency = samplerate; @@ -514,10 +514,8 @@ csid_insert (DB_playItem_t *after, const char *fname) { for (int s = 0; s < tunes; s++) { trace ("select %d...\n", s); if (tune->selectSong (s+1)) { - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (sid_plugin.plugin.id); - it->fname = strdup (fname); - it->tracknum = s; + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, sid_plugin.plugin.id); + deadbeef->pl_set_meta_int (it, ":TRACKNUM", s); SidTuneInfo sidinfo; tune->getInfo (sidinfo); int i = sidinfo.numberOfInfoStrings; diff --git a/plugins/sndfile/sndfile.c b/plugins/sndfile/sndfile.c index 85c96907..57d09763 100644 --- a/plugins/sndfile/sndfile.c +++ b/plugins/sndfile/sndfile.c @@ -155,9 +155,9 @@ sndfile_init (DB_fileinfo_t *_info, DB_playItem_t *it) { sndfile_info_t *info = (sndfile_info_t*)_info; SF_INFO inf; - DB_FILE *fp = deadbeef->fopen (it->fname); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp) { - trace ("sndfile: failed to open %s\n", it->fname); + trace ("sndfile: failed to open %s\n", deadbeef->pl_find_meta (it, ":URI")); return -1; } int fsize = deadbeef->fgetlength (fp); @@ -315,9 +315,7 @@ sndfile_insert (DB_playItem_t *after, const char *fname) { deadbeef->fclose (info.file); float duration = (float)totalsamples / samplerate; - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); it->filetype = "wav"; deadbeef->pl_set_item_duration (it, duration); diff --git a/plugins/tta/ttaplug.c b/plugins/tta/ttaplug.c index cded5264..22df3ad0 100644 --- a/plugins/tta/ttaplug.c +++ b/plugins/tta/ttaplug.c @@ -61,14 +61,14 @@ static int tta_init (DB_fileinfo_t *_info, DB_playItem_t *it) { tta_info_t *info = (tta_info_t *)_info; - trace ("open_tta_file %s\n", it->fname); - if (open_tta_file (it->fname, &info->tta, 0) != 0) { - fprintf (stderr, "tta: failed to open %s\n", it->fname); + trace ("open_tta_file %s\n", deadbeef->pl_find_meta (it, ":URI")); + if (open_tta_file (deadbeef->pl_find_meta (it, ":URI"), &info->tta, 0) != 0) { + fprintf (stderr, "tta: failed to open %s\n", deadbeef->pl_find_meta (it, ":URI")); return -1; } if (player_init (&info->tta) != 0) { - fprintf (stderr, "tta: failed to init player for %s\n", it->fname); + fprintf (stderr, "tta: failed to init player for %s\n", deadbeef->pl_find_meta (it, ":URI")); return -1; } @@ -90,7 +90,7 @@ tta_init (DB_fileinfo_t *_info, DB_playItem_t *it) { info->startsample = 0; info->endsample = (info->tta.DATALENGTH)-1; } - trace ("open_tta_file %s success!\n", it->fname); + trace ("open_tta_file %s success!\n", deadbeef->pl_find_meta (it, ":URI")); return 0; } @@ -193,9 +193,7 @@ tta_insert (DB_playItem_t *after, const char *fname) { int totalsamples = tta.DATALENGTH; double dur = tta.LENGTH; - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); it->filetype = "TTA"; deadbeef->pl_set_item_duration (it, dur); @@ -252,7 +250,7 @@ tta_insert (DB_playItem_t *after, const char *fname) { } static int tta_read_metadata (DB_playItem_t *it) { - DB_FILE *fp = deadbeef->fopen (it->fname); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp) { return -1; } diff --git a/plugins/vorbis/vorbis.c b/plugins/vorbis/vorbis.c index b450530c..553df92d 100644 --- a/plugins/vorbis/vorbis.c +++ b/plugins/vorbis/vorbis.c @@ -130,16 +130,16 @@ update_vorbis_comments (DB_playItem_t *it, vorbis_comment *vc, int refresh_playl deadbeef->pl_add_meta (it, "cuesheet", s + 9); } else if (!strncasecmp (s, "replaygain_album_gain=", 22)) { - it->replaygain_album_gain = atof (s + 22); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMGAIN, atof (s+22)); } else if (!strncasecmp (s, "replaygain_album_peak=", 22)) { - it->replaygain_album_peak = atof (s + 22); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMPEAK, atof (s+22)); } else if (!strncasecmp (s, "replaygain_track_gain=", 22)) { - it->replaygain_track_gain = atof (s + 22); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKGAIN, atof (s+22)); } else if (!strncasecmp (s, "replaygain_track_peak=", 22)) { - it->replaygain_track_peak = atof (s + 22); + deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKPEAK, atof (s+22)); } } } @@ -174,12 +174,13 @@ cvorbis_init (DB_fileinfo_t *_info, DB_playItem_t *it) { info->cur_bit_stream = -1; } else { - info->cur_bit_stream = it->tracknum; + int tracknum = deadbeef->pl_find_meta_int (it, ":TRACKNUM", -1); + info->cur_bit_stream = tracknum; } info->ptrack = it; deadbeef->pl_item_ref (it); - info->info.file = deadbeef->fopen (it->fname); + info->info.file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!info->info.file) { trace ("ogg: failed to open file %s\n", it->fname); return -1; @@ -434,8 +435,7 @@ cvorbis_insert (DB_playItem_t *after, const char *fname) { } int64_t fsize = deadbeef->fgetlength (fp); if (fp->vfs->is_streaming ()) { - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); it->filetype = "OggVorbis"; deadbeef->pl_set_item_duration (it, -1); deadbeef->pl_add_meta (it, "title", NULL); @@ -471,11 +471,9 @@ cvorbis_insert (DB_playItem_t *after, const char *fname) { float duration = ov_time_total (&vorbis_file, stream); int totalsamples = ov_pcm_total (&vorbis_file, stream); - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); it->filetype = "OggVorbis"; - it->tracknum = stream; + deadbeef->pl_set_meta_int (it, ":TRACKNUM", stream); deadbeef->pl_set_item_duration (it, duration); if (nstreams > 1) { it->startsample = currentsample; @@ -549,7 +547,7 @@ cvorbis_read_metadata (DB_playItem_t *it) { OggVorbis_File vorbis_file; vorbis_info *vi = NULL; - fp = deadbeef->fopen (it->fname); + fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp) { trace ("cvorbis_read_metadata: failed to fopen %s\n", it->fname); return -1; @@ -569,14 +567,15 @@ cvorbis_read_metadata (DB_playItem_t *it) { trace ("cvorbis_read_metadata: ov_open_callbacks returned %d\n", res); goto error; } - vi = ov_info (&vorbis_file, it->tracknum); + int tracknum = deadbeef->pl_find_meta_int (it, ":TRACKNUM", -1); + vi = ov_info (&vorbis_file, tracknum); if (!vi) { // not a vorbis stream trace ("cvorbis_read_metadata: failed to ov_open %s\n", it->fname); goto error; } // metainfo - vorbis_comment *vc = ov_comment (&vorbis_file, it->tracknum); + vorbis_comment *vc = ov_comment (&vorbis_file, tracknum); if (vc) { update_vorbis_comments (it, vc, 0); } @@ -612,7 +611,7 @@ cvorbis_write_metadata (DB_playItem_t *it) { trace ("cvorbis_write_metadata: vcedit_new_state failed\n"); return -1; } - fp = fopen (it->fname, "rb"); + fp = fopen (deadbeef->pl_find_meta (it, ":URI"), "rb"); if (!fp) { trace ("cvorbis_write_metadata: failed to read metadata from %s\n", it->fname); goto error; @@ -683,7 +682,7 @@ cvorbis_write_metadata (DB_playItem_t *it) { vorbis_comment_add (vc, f->data); } - snprintf (outname, sizeof (outname), "%s.temp.ogg", it->fname); + snprintf (outname, sizeof (outname), "%s.temp.ogg", deadbeef->pl_find_meta (it, ":URI")); out = fopen (outname, "w+b"); if (!out) { @@ -714,7 +713,7 @@ error: } if (!err) { - rename (outname, it->fname); + rename (outname, deadbeef->pl_find_meta (it, ":URI")); } else if (out) { unlink (outname); diff --git a/plugins/vtx/vtx.c b/plugins/vtx/vtx.c index 79eb8cb2..27777981 100644 --- a/plugins/vtx/vtx.c +++ b/plugins/vtx/vtx.c @@ -62,9 +62,9 @@ vtx_init (DB_fileinfo_t *_info, DB_playItem_t *it) { size_t sz = 0; char *buf = NULL; - DB_FILE *fp = deadbeef->fopen (it->fname); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp) { - trace ("vtx: failed to open file %s\n", it->fname); + trace ("vtx: failed to open file %s\n", deadbeef->pl_find_meta (it, ":URI")); return -1; } @@ -258,10 +258,7 @@ vtx_insert (DB_playItem_t *after, const char *fname) { } trace ("vtx: datasize: %d\n", hdr->regdata_size); - DB_playItem_t *it = deadbeef->pl_item_alloc (); - - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); it->filetype = filetypes[0]; int numframes = hdr->regdata_size / AY_FRAME_SIZE; diff --git a/plugins/wavpack/wavpack.c b/plugins/wavpack/wavpack.c index 44177f05..6646183b 100644 --- a/plugins/wavpack/wavpack.c +++ b/plugins/wavpack/wavpack.c @@ -125,15 +125,15 @@ wv_open (uint32_t hints) { static int wv_init (DB_fileinfo_t *_info, DB_playItem_t *it) { wvctx_t *info = (wvctx_t *)_info; - info->file = deadbeef->fopen (it->fname); + info->file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!info->file) { return -1; } #ifndef TINYWV - char *c_fname = alloca (strlen (it->fname) + 2); + char *c_fname = alloca (strlen (deadbeef->pl_find_meta (it, ":URI")) + 2); if (c_fname) { - strcpy (c_fname, it->fname); + strcpy (c_fname, deadbeef->pl_find_meta (it, ":URI")); strcat (c_fname, "c"); info->c_file = deadbeef->fopen (c_fname); } @@ -295,9 +295,7 @@ wv_insert (DB_playItem_t *after, const char *fname) { int samplerate = WavpackGetSampleRate (ctx); float duration = (float)totalsamples / samplerate; - DB_playItem_t *it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (plugin.plugin.id); - it->fname = strdup (fname); + DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id); it->filetype = "wv"; deadbeef->pl_set_item_duration (it, duration); trace ("wv: totalsamples=%d, samplerate=%d, duration=%f\n", totalsamples, samplerate, duration); @@ -370,7 +368,7 @@ wv_insert (DB_playItem_t *after, const char *fname) { int wv_read_metadata (DB_playItem_t *it) { - DB_FILE *fp = deadbeef->fopen (it->fname); + DB_FILE *fp = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); if (!fp) { return -1; } diff --git a/plugins/wildmidi/wildmidiplug.c b/plugins/wildmidi/wildmidiplug.c index 4136745d..ca26e497 100644 --- a/plugins/wildmidi/wildmidiplug.c +++ b/plugins/wildmidi/wildmidiplug.c @@ -52,9 +52,9 @@ int wmidi_init (DB_fileinfo_t *_info, DB_playItem_t *it) { wmidi_info_t *info = (wmidi_info_t *)_info; - info->m = WildMidi_Open (it->fname); + info->m = WildMidi_Open (deadbeef->pl_find_meta (it, ":URI")); if (!info->m) { - trace ("wmidi: failed to open %s\n", it->fname); + trace ("wmidi: failed to open %s\n", deadbeef->pl_find_meta (it, ":URI")); return -1; } @@ -117,9 +117,7 @@ wmidi_insert (DB_playItem_t *after, const char *fname) { } struct _WM_Info *inf = WildMidi_GetInfo (m); - it = deadbeef->pl_item_alloc (); - it->decoder_id = deadbeef->plug_get_decoder_id (wmidi_plugin.plugin.id); - it->fname = strdup (fname); + it = deadbeef->pl_item_alloc_init (fname, wmidi_plugin.plugin.id); deadbeef->pl_add_meta (it, "title", NULL); deadbeef->pl_set_item_duration (it, inf->approx_total_samples / 44100.f); it->filetype = "MID"; |