diff --git a/osx/xcodeconfig/gtk3.xcconfig b/osx/xcodeconfig/gtk3.xcconfig index c87ad6c425..29d2c27235 100644 --- a/osx/xcodeconfig/gtk3.xcconfig +++ b/osx/xcodeconfig/gtk3.xcconfig @@ -12,5 +12,3 @@ GTK3_CFLAGS = -I/usr/local/Cellar/libffi/3.3/include -I/usr/local/Cellar/gtk+3/3.24.21/include/gtk-3.0 -I/usr/local/Cellar/glib/2.64.4/include/gio-unix-2.0 -I/usr/local/Cellar/cairo/1.16.0_3/include/cairo -I/usr/local/Cellar/libepoxy/1.5.4_1/include -I/usr/local/Cellar/pango/1.44.7/include/pango-1.0 -I/usr/local/Cellar/fribidi/1.0.10/include/fribidi -I/usr/local/Cellar/harfbuzz/2.6.8/include/harfbuzz -I/usr/local/Cellar/graphite2/1.3.14/include -I/usr/local/Cellar/atk/2.36.0/include/atk-1.0 -I/usr/local/Cellar/cairo/1.16.0_3/include/cairo -I/usr/local/Cellar/pixman/0.40.0/include/pixman-1 -I/usr/local/Cellar/fontconfig/2.13.1/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/libpng/1.6.37/include/libpng16 -I/usr/local/Cellar/gdk-pixbuf/2.40.0_1/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/glib/2.64.4/include -I/usr/local/Cellar/glib/2.64.4/include/glib-2.0 -I/usr/local/Cellar/glib/2.64.4/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.44/include GTK3_LDFLAGS = -L/usr/local/Cellar/gtk+3/3.24.21/lib -L/usr/local/Cellar/pango/1.44.7/lib -L/usr/local/Cellar/harfbuzz/2.6.8/lib -L/usr/local/Cellar/atk/2.36.0/lib -L/usr/local/Cellar/cairo/1.16.0_3/lib -L/usr/local/Cellar/gdk-pixbuf/2.40.0_1/lib -L/usr/local/Cellar/glib/2.64.4/lib -L/usr/local/opt/gettext/lib -lgtk-3 -lgdk-3 -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,CoreGraphics -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl - -#include "jansson.xcconfig" diff --git a/plugins/aac/aac.c b/plugins/aac/aac.c index fe9116fee0..fd0d8e11a7 100644 --- a/plugins/aac/aac.c +++ b/plugins/aac/aac.c @@ -1022,6 +1022,7 @@ aac_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) { return after; } else if (res > 0) { // mp4 but not aac + deadbeef->fclose (fp); return NULL; } } diff --git a/plugins/alac/alac_plugin.c b/plugins/alac/alac_plugin.c index a4e72251bd..567b84226d 100644 --- a/plugins/alac/alac_plugin.c +++ b/plugins/alac/alac_plugin.c @@ -111,8 +111,7 @@ alacplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) { int bps = 0; float duration = 0; - DB_FILE *file = deadbeef->fopen (deadbeef->pl_find_meta (it, ":URI")); - info->mp4reader.ptrhandle = file; + info->mp4reader.ptrhandle = info->file; mp4_init_ddb_file_callbacks (&info->mp4reader); info->mp4file = mp4p_open(&info->mp4reader); diff --git a/plugins/cocoaui/CoverManager.h b/plugins/cocoaui/CoverManager.h index 8d61732680..b44f60a01a 100644 --- a/plugins/cocoaui/CoverManager.h +++ b/plugins/cocoaui/CoverManager.h @@ -28,7 +28,7 @@ + (CoverManager *)defaultCoverManager; - (CoverManager *)init; -- (NSImage *)defaultCover; +@property (nonatomic,readonly) NSImage *defaultCover; - (NSImage *)getCoverForTrack:(DB_playItem_t *)track withCallbackWhenReady:(void (*) (NSImage *img, void *user_data))callback withUserDataForCallback:(void *)user_data; @end diff --git a/plugins/cocoaui/CoverManager.m b/plugins/cocoaui/CoverManager.m index 0deb984081..c7f181aef5 100644 --- a/plugins/cocoaui/CoverManager.m +++ b/plugins/cocoaui/CoverManager.m @@ -31,15 +31,24 @@ #define CACHE_SIZE 20 -@implementation CoverManager { - ddb_artwork_plugin_t *_artwork_plugin; - NSImage *_defaultCover; +@interface CoverManager() { NSMutableDictionary *_cachedCovers[CACHE_SIZE]; - char *_name_tf; } +@property (nonatomic) ddb_artwork_plugin_t *artwork_plugin; +@property (nonatomic,readwrite) NSImage *defaultCover; +@property (nonatomic) char *name_tf; + +@end + +@implementation CoverManager + - (void)dealloc { deadbeef->tf_free (_name_tf); + _name_tf = NULL; + for (int i = 0; i < CACHE_SIZE; i++) { + _cachedCovers[i] = nil; + } } + (CoverManager *)defaultCoverManager { @@ -61,10 +70,6 @@ - (CoverManager *)init { return self; } -- (NSImage *)defaultCover { - return _defaultCover; -} - - (NSString *)hashForTrack:(DB_playItem_t *)track { ddb_tf_context_t ctx = { ._size = sizeof (ddb_tf_context_t), @@ -73,7 +78,7 @@ - (NSString *)hashForTrack:(DB_playItem_t *)track { }; char buffer[PATH_MAX]; - deadbeef->tf_eval (&ctx, _name_tf, buffer, sizeof (buffer)); + deadbeef->tf_eval (&ctx, self.name_tf, buffer, sizeof (buffer)); return [NSString stringWithUTF8String:buffer]; } @@ -143,12 +148,30 @@ - (void)addCoverForTrack:(ddb_playItem_t *)track withImage:(NSImage *)img { } // NSLog (@"+ %@", hash); - NSMutableDictionary *d = [[NSMutableDictionary alloc] initWithObjectsAndKeys:hash, @"hash", t, @"ts", img, @"img", nil]; + NSMutableDictionary *d = [[NSMutableDictionary alloc] initWithObjectsAndKeys:hash, @"hash", t, @"ts", nil]; + if (img != nil) { + d[@"img"] = img; + } _cachedCovers[i_min] = d; } +- (void)dumpCache { + for (int i = 0; i < CACHE_SIZE; i++) { + NSLog(@"%@", _cachedCovers[i]); + } +} + +- (NSDictionary *)findInCache:(NSString *)key { + for (int i = 0; i < CACHE_SIZE; i++) { + if ([_cachedCovers[i][@"hash"] isEqualToString:key]) { + return _cachedCovers[i]; + } + } + return nil; +} + - (NSImage *)getCoverForTrack:(DB_playItem_t *)track withCallbackWhenReady:(void (*) (NSImage *img, void *user_data))callback withUserDataForCallback:(void *)user_data { - if (!_artwork_plugin) { + if (!self.artwork_plugin) { callback (nil, user_data); return nil; } @@ -165,7 +188,6 @@ - (NSImage *)getCoverForTrack:(DB_playItem_t *)track withCallbackWhenReady:(void } } -// NSLog (@"! %@", hash); ddb_cover_query_t *query = calloc (sizeof (ddb_cover_query_t), 1); query->_size = sizeof (ddb_cover_query_t); query->track = track; @@ -176,7 +198,8 @@ - (NSImage *)getCoverForTrack:(DB_playItem_t *)track withCallbackWhenReady:(void info->real_user_data = user_data; query->user_data = info; - _artwork_plugin->cover_get (query, cover_loaded_callback); + [self addCoverForTrack:query->track withImage:nil]; + self.artwork_plugin->cover_get (query, cover_loaded_callback); return nil; } diff --git a/plugins/dumb/dumb-kode54/src/it/reads3m.c b/plugins/dumb/dumb-kode54/src/it/reads3m.c index 4957f9cfc9..3970b0d92d 100644 --- a/plugins/dumb/dumb-kode54/src/it/reads3m.c +++ b/plugins/dumb/dumb-kode54/src/it/reads3m.c @@ -149,7 +149,7 @@ static int it_s3m_read_sample_data(IT_SAMPLE *sample, int ffi, unsigned char pac long datasize = sample->length; if (sample->flags & IT_SAMPLE_STEREO) datasize <<= 1; - sample->data = malloc(datasize * (sample->flags & IT_SAMPLE_16BIT ? 2 : 1)); + sample->data = calloc(datasize * (sample->flags & IT_SAMPLE_16BIT ? 2 : 1), 1); if (!sample->data) return -1; @@ -177,7 +177,7 @@ static int it_s3m_read_sample_data(IT_SAMPLE *sample, int ffi, unsigned char pac ((signed char *)sample->data)[n] = dumbfile_getc(f); if (dumbfile_error(f)) - return -1; + return 0; if (ffi != 1) { /* Convert to signed. */ @@ -233,7 +233,7 @@ static int it_s3m_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, unsigned char * length = dumbfile_igetw(f); - if (dumbfile_error(f) || !length) + if (dumbfile_error(f)) return -1; pattern->n_rows = 0; diff --git a/plugins/gtkui/fileman.c b/plugins/gtkui/fileman.c index 00d334ee36..1b8b765411 100644 --- a/plugins/gtkui/fileman.c +++ b/plugins/gtkui/fileman.c @@ -315,28 +315,24 @@ set_file_filter (GtkFileChooser *dlg, const char *name) { if (!name) { name = _("Supported sound formats"); } - static char extlist[10000]; - // Build extension list - if (extlist[0] == '\0') { + GtkFileFilter* flt; + + flt = gtk_file_filter_new (); + gtk_file_filter_set_name (flt, name); + + // Add supported extensions DB_decoder_t **codecs = deadbeef->plug_get_decoder_list (); for (int i = 0; codecs[i]; i++) { if (codecs[i]->exts && codecs[i]->insert) { const char **exts = codecs[i]->exts; + char buf[100]; for (int e = 0; exts[e]; e++) { - char buf[100]; - snprintf (buf, sizeof (buf), "*.%s;", exts[e]); - strcat (extlist, buf); + snprintf (buf, sizeof (buf), "*.%s", exts[e]); + gtk_file_filter_add_pattern (flt, buf); } } } - } - - GtkFileFilter* flt; - - flt = gtk_file_filter_new (); - gtk_file_filter_set_name (flt, name); - gtk_file_filter_add_pattern (flt, extlist); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dlg), flt); gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dlg), flt);