diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-05-29 15:29:13 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-05-29 15:29:13 +0200 |
commit | 0ec695a74b06e9586afa1205b1fd5a9c9b097925 (patch) | |
tree | 92d583169f613ddc596ce115c1279240b58b832c | |
parent | e0bb51aaba50aa5ac891dff720ac9574e24c51c4 (diff) | |
parent | 18dbba1a8b1ced0f84cb7340310fa37a2a92030e (diff) |
Merge branch 'master' into devel
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | playlist.c | 78 | ||||
-rw-r--r-- | playlist.h | 3 | ||||
-rw-r--r-- | plugins/artwork/artwork.c | 4 | ||||
-rw-r--r-- | plugins/gtkui/coverart.c | 10 | ||||
-rw-r--r-- | plugins/wavpack/wavpack.c | 19 |
6 files changed, 81 insertions, 35 deletions
@@ -31,6 +31,8 @@ version 0.4.1 added %C(composer) expansion to title formatting fixed few theming/colors issues fixed replaygain field parsing when reading cuesheets and r.g. peak scale handling (David Bryant) + added support for WavPack correction files (David Bryant) + fixed loading of album art embedded in ID3v2 version 0.4.0 multiple tabbed playlists @@ -302,20 +302,13 @@ plt_add (int before, const char *title) { fprintf (stderr, "playlist rename failed: %s\n", strerror (errno)); } } -#if 0 - // need to delete old playlist file if exists - char path[PATH_MAX]; - if (snprintf (path, sizeof (path), "%s/playlists/%d.dbpl", dbconfdir, playlists_count-1) <= sizeof (path)) { - unlink (path); - } -#endif - pl_save_current (); } } PLT_UNLOCK; plt_gen_conf (); if (!plt_loading) { + pl_save_n (before); deadbeef->conf_save (); plug_trigger_event (DB_EV_PLAYLISTSWITCH, 0); } @@ -539,17 +532,26 @@ plt_move (int from, int to) { char temp[PATH_MAX]; if (snprintf (path1, sizeof (path1), "%s/playlists/%d.dbpl", dbconfdir, from) > sizeof (path1)) { fprintf (stderr, "error: failed to make path string for playlist file\n"); + PLT_UNLOCK; return; } if (snprintf (temp, sizeof (temp), "%s/playlists/temp.dbpl", dbconfdir) > sizeof (temp)) { fprintf (stderr, "error: failed to make path string for playlist file\n"); + PLT_UNLOCK; return; } - trace ("move %s->%s\n", path1, temp); - int err = rename (path1, temp); - if (err != 0) { - fprintf (stderr, "playlist rename %s->%s failed: %s\n", path1, temp, strerror (errno)); - return; + + struct stat st; + int err = stat (path1, &st); + if (!err) { + trace ("move %s->%s\n", path1, temp); + + int err = rename (path1, temp); + if (err != 0) { + fprintf (stderr, "playlist rename %s->%s failed: %s\n", path1, temp, strerror (errno)); + PLT_UNLOCK; + return; + } } // remove 'from' from list @@ -580,10 +582,13 @@ plt_move (int from, int to) { fprintf (stderr, "error: failed to make path string for playlist file\n"); continue; } - trace ("move %s->%s\n", path2, path1); - int err = rename (path2, path1); - if (err != 0) { - fprintf (stderr, "playlist rename %s->%s failed: %s\n", path2, path1, strerror (errno)); + int err = stat (path2, &st); + if (!err) { + trace ("move %s->%s\n", path2, path1); + int err = rename (path2, path1); + if (err != 0) { + fprintf (stderr, "playlist rename %s->%s failed: %s\n", path2, path1, strerror (errno)); + } } } // open new gap @@ -598,10 +603,13 @@ plt_move (int from, int to) { fprintf (stderr, "error: failed to make path string for playlist file\n"); continue; } - trace ("move %s->%s\n", path1, path2); - int err = rename (path1, path2); - if (err != 0) { - fprintf (stderr, "playlist rename %s->%s failed: %s\n", path1, path2, strerror (errno)); + int err = stat (path1, &st); + if (!err) { + trace ("move %s->%s\n", path1, path2); + int err = rename (path1, path2); + if (err != 0) { + fprintf (stderr, "playlist rename %s->%s failed: %s\n", path1, path2, strerror (errno)); + } } } // move temp file @@ -609,10 +617,13 @@ plt_move (int from, int to) { fprintf (stderr, "error: failed to make path string for playlist file\n"); } else { - trace ("move %s->%s\n", temp, path1); - int err = rename (temp, path1); - if (err != 0) { - fprintf (stderr, "playlist rename %s->%s failed: %s\n", temp, path1, strerror (errno)); + int err = stat (path1, &st); + if (!err) { + trace ("move %s->%s\n", temp, path1); + int err = rename (temp, path1); + if (err != 0) { + fprintf (stderr, "playlist rename %s->%s failed: %s\n", temp, path1, strerror (errno)); + } } } @@ -1927,7 +1938,7 @@ save_fail: } int -pl_save_current (void) { +pl_save_n (int n) { char path[PATH_MAX]; if (snprintf (path, sizeof (path), "%s/playlists", dbconfdir) > sizeof (path)) { fprintf (stderr, "error: failed to make path string for playlists folder\n"); @@ -1937,11 +1948,10 @@ pl_save_current (void) { mkdir (path, 0755); PLT_LOCK; - int curr = plt_get_curr (); int err = 0; plt_loading = 1; - if (snprintf (path, sizeof (path), "%s/playlists/%d.dbpl", dbconfdir, curr) > sizeof (path)) { + if (snprintf (path, sizeof (path), "%s/playlists/%d.dbpl", dbconfdir, n) > sizeof (path)) { fprintf (stderr, "error: failed to make path string for playlist file\n"); PLT_UNLOCK; return -1; @@ -1953,6 +1963,11 @@ pl_save_current (void) { } int +pl_save_current (void) { + return pl_save_n (plt_get_curr ()); +} + +int pl_save_all (void) { trace ("pl_save_all\n"); char path[PATH_MAX]; @@ -2229,10 +2244,13 @@ pl_load_all (void) { } else { fprintf (stderr, "INFO: from file %s\n", path); - err = pl_load (path); + int load_err = pl_load (path); + if (load_err != 0) { + fprintf (stderr, "WARNING: failed to load playlist '%s' (%s)\n", it->value, path); + } } it = conf_find ("playlist.tab.", it); - fprintf (stderr, "conf_find returned %p\n", it); + trace ("conf_find returned %p (%s)\n", it, it ? it->value : "null"); i++; } plt_set_curr (0); @@ -214,6 +214,9 @@ int pl_save (const char *fname); int +pl_save_n (int n); + +int pl_save_current (void); int diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c index 88052e6e..8bd336ad 100644 --- a/plugins/artwork/artwork.c +++ b/plugins/artwork/artwork.c @@ -229,7 +229,7 @@ id3v2_skip_str (int enc, uint8_t *ptr, uint8_t *end) { } else { while (ptr < end-1 && (ptr[0] || ptr[1])) { - ptr++; + ptr += 2; } ptr += 2; if (ptr >= end) { @@ -437,7 +437,7 @@ fetcher_thread (void *none) char* get_album_art (const char *fname, const char *artist, const char *album, artwork_callback callback, void *user_data) { - trace ("get_album_art: %s (%s - %s)\n", fname, artist, album); +// trace ("get_album_art: %s (%s - %s)\n", fname, artist, album); char path [1024]; if (!album) { diff --git a/plugins/gtkui/coverart.c b/plugins/gtkui/coverart.c index d5f34c26..7fb50554 100644 --- a/plugins/gtkui/coverart.c +++ b/plugins/gtkui/coverart.c @@ -142,16 +142,24 @@ loading_thread (void *none) { } // GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (queue->fname, NULL); - GError *error; + GError *error = NULL; GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_scale (queue->fname, queue->width, queue->width, TRUE, &error); if (!pixbuf) { unlink (queue->fname); fprintf (stderr, "gdk_pixbuf_new_from_file_at_scale %s %d failed, error: %s\n", queue->fname, queue->width, error->message); + if (error) { + g_error_free (error); + error = NULL; + } pixbuf = gdk_pixbuf_new_from_file_at_scale (DEFAULT_COVER_PATH, queue->width, queue->width, TRUE, &error); if (!pixbuf) { fprintf (stderr, "gdk_pixbuf_new_from_file_at_scale %s %d failed, error: %s\n", DEFAULT_COVER_PATH, queue->width, error->message); } } + if (error) { + g_error_free (error); + error = NULL; + } if (!pixbuf) { // make default empty image pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 2, 2); diff --git a/plugins/wavpack/wavpack.c b/plugins/wavpack/wavpack.c index e2f9e43b..861dec75 100644 --- a/plugins/wavpack/wavpack.c +++ b/plugins/wavpack/wavpack.c @@ -34,7 +34,7 @@ static DB_functions_t *deadbeef; typedef struct { DB_fileinfo_t info; - DB_FILE *file; + DB_FILE *file, *c_file; WavpackContext *ctx; int startsample; int endsample; @@ -105,8 +105,19 @@ wv_init (DB_fileinfo_t *_info, DB_playItem_t *it) { if (!info->file) { return -1; } + + char *c_fname = alloca (strlen (it->fname) + 2); + if (c_fname) { + strcpy (c_fname, it->fname); + strcat (c_fname, "c"); + info->c_file = deadbeef->fopen (c_fname); + } + else { + fprintf (stderr, "wavpack warning: failed to alloc memory for correction file name\n"); + } + char error[80]; - info->ctx = WavpackOpenFileInputEx (&wsr, info->file, NULL, error, OPEN_2CH_MAX/*|OPEN_WVC*/, 0); + info->ctx = WavpackOpenFileInputEx (&wsr, info->file, info->c_file, error, OPEN_2CH_MAX, 0); if (!info->ctx) { fprintf (stderr, "wavpack error: %s\n", error); return -1; @@ -138,6 +149,10 @@ wv_free (DB_fileinfo_t *_info) { deadbeef->fclose (info->file); info->file = NULL; } + if (info->c_file) { + deadbeef->fclose (info->c_file); + info->c_file = NULL; + } if (info->ctx) { WavpackCloseFile (info->ctx); info->ctx = NULL; |