Skip to content

Commit

Permalink
Merge remote-tracking branch 'deadbeef/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba160 committed Oct 29, 2020
2 parents d0f650f + f823ad2 commit 05f1a51
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 34 deletions.
2 changes: 0 additions & 2 deletions osx/xcodeconfig/gtk3.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions plugins/aac/aac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/alac/alac_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion plugins/cocoaui/CoverManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
49 changes: 36 additions & 13 deletions plugins/cocoaui/CoverManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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),
Expand All @@ -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];
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/dumb/dumb-kode54/src/it/reads3m.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 9 additions & 13 deletions plugins/gtkui/fileman.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 05f1a51

Please sign in to comment.