Hopefully fixed metadata parsing for newly added tracks showing up in notifications

CQTexperiment
Christopher Snowhill 2019-12-05 19:04:46 -08:00
parent 90ac083705
commit 61c6cf3285
2 changed files with 56 additions and 1 deletions

View File

@ -49,6 +49,9 @@ typedef enum {
- (void)loadInfoForEntries:(NSArray *)entries;
// To be dispatched on main thread only
- (void)syncLoadInfoForEntries:(NSArray *)entries;
- (NSArray *)acceptableFileTypes;
- (NSArray *)acceptablePlaylistTypes; //Only m3u and pls saving
- (NSArray *)acceptableContainerTypes;

View File

@ -455,7 +455,13 @@ NSMutableDictionary * dictionaryWithPropertiesOfObject(id obj, NSArray * filterL
//Clear the selection
[playlistController setSelectionIndexes:[NSIndexSet indexSet]];
[self performSelectorInBackground:@selector(loadInfoForEntries:) withObject:entries];
NSArray * firstEntry = [NSArray arrayWithObject:[entries objectAtIndex:0]];
NSMutableArray * restOfEntries = [NSMutableArray arrayWithArray:entries];
[restOfEntries removeObjectAtIndex:0];
[self performSelectorOnMainThread:@selector(syncLoadInfoForEntries:) withObject:firstEntry waitUntilDone:YES];
[self performSelectorInBackground:@selector(loadInfoForEntries:) withObject:restOfEntries];
return entries;
}
@ -463,6 +469,52 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc
dispatch_get_current_queue() == queue ? block() : dispatch_sync(queue, block);
}
// To be called on main thread only
- (void)syncLoadInfoForEntries:(NSArray *)entries
{
NSMutableIndexSet *update_indexes = [[NSMutableIndexSet alloc] init];
long i;
i = 0;
for (PlaylistEntry *pe in entries)
{
if ([pe metadataLoaded]) continue;
[update_indexes addIndex:pe.index];
++i;
}
if (!i)
{
[self->playlistController updateTotalTime];
return;
}
{
for (PlaylistEntry *pe in entries)
{
NSMutableDictionary *entryInfo = [NSMutableDictionary dictionaryWithCapacity:20];
NSDictionary *entryProperties = [AudioPropertiesReader propertiesForURL:pe.URL];
if (entryProperties == nil)
continue;
[entryInfo addEntriesFromDictionary:entryProperties];
[entryInfo addEntriesFromDictionary:[AudioMetadataReader metadataForURL:pe.URL]];
[pe setMetadata:entryInfo];
}
}
[self->playlistController updateTotalTime];
{
unsigned long columns = [[[self->playlistView documentView] tableColumns] count];
[self->playlistView.documentView reloadDataForRowIndexes:update_indexes columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,columns-1)]];
}
}
- (void)loadInfoForEntries:(NSArray *)entries
{
NSMutableIndexSet *update_indexes = [[NSMutableIndexSet alloc] init];