[vlc-commits] [Git][videolan/vlc][master] macosx: Update recent-media caches independently of main media caches
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Fri Oct 2 11:16:30 UTC 2026
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
39ff9b62 by Claudio Cambra at 2026-10-02T13:06:58+02:00
macosx: Update recent-media caches independently of main media caches
Updates and deletions in the recent-media caches were ignored when the main audio/video lists had not been loaded, leaving outdated or deleted entries visible in “Recently Played.” These changes are now handled independently, and the corresponding notifications are emitted
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1 changed file:
- modules/gui/macosx/library/VLCLibraryModel.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryModel.m
=====================================
@@ -1259,8 +1259,8 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
const NSUInteger recentsIndex = cachedRecents ? [cachedRecents indexOfObjectPassingTest:idCheckBlock] : NSNotFound;
const NSUInteger videoIndex = cachedVideos ? [cachedVideos indexOfObjectPassingTest:idCheckBlock] : NSNotFound;
- if (videoIndex != NSNotFound) {
- // Found in video cache - search shows for episode match
+ if (videoIndex != NSNotFound || recentsIndex != NSNotFound) {
+ // Search shows for a matching episode.
NSInteger showIndex = NSNotFound;
NSInteger episodeIndex = NSNotFound;
NSUInteger currentShowIndex = 0;
@@ -1289,15 +1289,15 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
return;
}
- // Not in video cache, check audio cache
+ // Not in either video cache, check the audio caches.
NSArray<VLCMediaLibraryMediaItem *> * const cachedRecentAudios = self.cachedRecentAudioMedia;
NSArray<VLCMediaLibraryMediaItem *> * const cachedAudios = self.cachedAudioMedia;
const NSUInteger recentAudiosIndex = cachedRecentAudios ? [cachedRecentAudios indexOfObjectPassingTest:idCheckBlock] : NSNotFound;
const NSUInteger audioIndex = cachedAudios ? [cachedAudios indexOfObjectPassingTest:idCheckBlock] : NSNotFound;
- if (audioIndex != NSNotFound) {
- // Found in audio cache - create mutable copies for modification
+ if (audioIndex != NSNotFound || recentAudiosIndex != NSNotFound) {
+ // Found in an audio cache - create mutable copies for modification.
NSMutableArray<VLCMediaLibraryMediaItem *> * const recentAudiosMutable = cachedRecentAudios.mutableCopy;
NSMutableArray<VLCMediaLibraryMediaItem *> * const audioMutable = cachedAudios.mutableCopy;
@@ -1333,13 +1333,15 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
const NSUInteger showIndex,
const NSUInteger __unused showEpisodeIndex
) {
- if (cachedMediaArray == nil || cachedMediaIndex == NSNotFound) {
+ if (cachedMediaIndex == NSNotFound && recentMediaIndex == NSNotFound) {
NSLog(@"Could not handle update for media library item with id %lld in model", itemId);
return;
}
// Notify what happened
- [cachedMediaArray replaceObjectAtIndex:cachedMediaIndex withObject:mediaItem];
+ if (cachedMediaIndex != NSNotFound) {
+ [cachedMediaArray replaceObjectAtIndex:cachedMediaIndex withObject:mediaItem];
+ }
if (recentMediaArray != nil && recentMediaIndex != NSNotFound) {
[recentMediaArray replaceObjectAtIndex:recentMediaIndex withObject:mediaItem];
@@ -1404,14 +1406,17 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
const NSUInteger __unused showEpisodeIndex
) {
- if (cachedMediaArray == nil || cachedMediaIndex == NSNotFound) {
+ if (cachedMediaIndex == NSNotFound && recentMediaIndex == NSNotFound) {
NSLog(@"Could not handle deletion for media library item with id %lld in model", itemId);
return;
}
- VLCMediaLibraryMediaItem * const mediaItem = cachedMediaArray[cachedMediaIndex];
+ VLCMediaLibraryMediaItem * const mediaItem = cachedMediaIndex != NSNotFound
+ ? cachedMediaArray[cachedMediaIndex] : recentMediaArray[recentMediaIndex];
// Notify what happened
- [cachedMediaArray removeObjectAtIndex:cachedMediaIndex];
+ if (cachedMediaIndex != NSNotFound) {
+ [cachedMediaArray removeObjectAtIndex:cachedMediaIndex];
+ }
if (recentMediaArray != nil && recentMediaIndex != NSNotFound) {
[recentMediaArray removeObjectAtIndex:recentMediaIndex];
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/39ff9b62951cdae21eae799097223067b7cb544e
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/39ff9b62951cdae21eae799097223067b7cb544e
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list