Skip to content

Commit

Permalink
Do not re-create MLMediaLibrary instance when re-populating parser (S…
Browse files Browse the repository at this point in the history
…hould fix issue karelia#60)
  • Loading branch information
Joerg Jacobsen committed Apr 15, 2015
1 parent b1344b8 commit 0bddaf9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions IMBAppleMediaLibraryParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@

@property (strong) id<IMBAppleMediaLibraryParserDelegate> configuration;

/**
Initializes Apple media library and media source for the receiver.
@discussion
Must be called in the initialization process of the receiver but must not be called before configuration of receiver is set.
*/
- (instancetype)initializeMediaLibrary;

/**
Converts from IMB media type to Apple Media Library media type.
*/
Expand Down
6 changes: 3 additions & 3 deletions IMBAppleMediaLibraryParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ - (NSString *)mediaType
}

/**
Initializes Apple media library and media source for the receiver.
@discussion
Must be called in the initialization process of the receiver but must not be called before configuration of receiver is set.
*/
- (instancetype)initializeMediaLibrary
{
Expand All @@ -96,9 +99,6 @@ - (IMBNode *)unpopulatedTopLevelNode:(NSError **)outError
START_MEASURE(1);
NSError *error = nil;

// (Re-)instantiate media library and media source (in Apple speak), because content might have changed on disk. Note though that this yet doesn't seem to have an effect when media library changes (Apple doesn't seem to update its object cache).
[self initializeMediaLibrary];

MLMediaGroup *rootMediaGroup = [IMBAppleMediaLibraryPropertySynchronizer rootMediaGroupForMediaSource:self.AppleMediaSource];

// Is there a matching media source?
Expand Down
1 change: 1 addition & 0 deletions IMBAppleMediaLibraryParserMessenger.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ - (NSArray *)parserInstancesWithError:(NSError **)outError
IMBAppleMediaLibraryParser *parser = (IMBAppleMediaLibraryParser *)[self newParser];
MLMediaType mediaType = [IMBAppleMediaLibraryParser MLMediaTypeForIMBMediaType:[myClass mediaType]];
parser.configuration = [myClass parserConfigurationFactory](mediaType);
[parser initializeMediaLibrary];
[[myClass parsers] addObject:parser];
});
return [myClass parsers];
Expand Down

0 comments on commit 0bddaf9

Please sign in to comment.