Commit fc87d888 authored by Felix Paul Kühne's avatar Felix Paul Kühne

media player: fix a bunch of memory leaks when interating track descriptions (closes #15403)

parent b8083fc9
......@@ -310,14 +310,15 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
if (count <= 0)
return @[];
libvlc_track_description_t *currentTrack = libvlc_video_get_track_description(_playerInstance);
libvlc_track_description_t *firstTrack = libvlc_video_get_track_description(_playerInstance);
libvlc_track_description_t *currentTrack = firstTrack;
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:@(currentTrack->psz_name)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
libvlc_track_description_list_release(firstTrack);
return [NSArray arrayWithArray: tempArray];
}
......@@ -327,14 +328,15 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
if (count <= 0)
return @[];
libvlc_track_description_t *currentTrack = libvlc_video_get_track_description(_playerInstance);
libvlc_track_description_t *firstTrack = libvlc_video_get_track_description(_playerInstance);
libvlc_track_description_t *currentTrack = firstTrack;
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:@(currentTrack->i_id)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
libvlc_track_description_list_release(firstTrack);
return [NSArray arrayWithArray: tempArray];
}
......@@ -367,14 +369,15 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
if (count <= 0)
return @[];
libvlc_track_description_t *currentTrack = libvlc_video_get_spu_description(_playerInstance);
libvlc_track_description_t *firstTrack = libvlc_video_get_spu_description(_playerInstance);
libvlc_track_description_t *currentTrack = firstTrack;
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:@(currentTrack->psz_name)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
libvlc_track_description_list_release(firstTrack);
return [NSArray arrayWithArray: tempArray];
}
......@@ -384,14 +387,15 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
if (count <= 0)
return @[];
libvlc_track_description_t *currentTrack = libvlc_video_get_spu_description(_playerInstance);
libvlc_track_description_t *firstTrack = libvlc_video_get_spu_description(_playerInstance);
libvlc_track_description_t *currentTrack = firstTrack;
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:@(currentTrack->i_id)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
libvlc_track_description_list_release(firstTrack);
return [NSArray arrayWithArray: tempArray];
}
......@@ -635,15 +639,16 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
libvlc_track_description_t *tracks = libvlc_video_get_chapter_description(_playerInstance, title);
libvlc_track_description_t *firstTrack = libvlc_video_get_chapter_description(_playerInstance, title);
libvlc_track_description_t *currentTrack = firstTrack;
#pragma clang diagnostic push
NSMutableArray *tempArray = [NSMutableArray array];
for (NSInteger i = 0; i < count ; i++) {
[tempArray addObject:@(tracks->psz_name)];
tracks = tracks->p_next;
[tempArray addObject:@(currentTrack->psz_name)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(tracks);
libvlc_track_description_list_release(firstTrack);
return [NSArray arrayWithArray:tempArray];
}
......@@ -683,24 +688,25 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
libvlc_track_description_t *tracks = libvlc_video_get_title_description(_playerInstance);
libvlc_track_description_t *firstTrack = libvlc_video_get_title_description(_playerInstance);
libvlc_track_description_t *currentTrack = firstTrack;
#pragma clang diagnostic pop
if (!tracks)
if (!currentTrack)
return [NSArray array];
NSMutableArray *tempArray = [NSMutableArray array];
while (1) {
if (tracks->psz_name != nil)
[tempArray addObject:@(tracks->psz_name)];
if (tracks->p_next)
tracks = tracks->p_next;
if (currentTrack->psz_name != nil)
[tempArray addObject:@(currentTrack->psz_name)];
if (currentTrack->p_next)
currentTrack = currentTrack->p_next;
else
break;
}
libvlc_track_description_list_release(tracks);
libvlc_track_description_list_release(firstTrack);
return [NSArray arrayWithArray: tempArray];
}
......@@ -816,14 +822,15 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
if (count <= 0)
return @[];
libvlc_track_description_t *currentTrack = libvlc_audio_get_track_description(_playerInstance);
libvlc_track_description_t *firstTrack = libvlc_audio_get_track_description(_playerInstance);
libvlc_track_description_t *currentTrack = firstTrack;
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:@(currentTrack->psz_name)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
libvlc_track_description_list_release(firstTrack);
return [NSArray arrayWithArray: tempArray];
}
......@@ -833,14 +840,15 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
if (count <= 0)
return @[];
libvlc_track_description_t *currentTrack = libvlc_audio_get_track_description(_playerInstance);
libvlc_track_description_t *firstTrack = libvlc_audio_get_track_description(_playerInstance);
libvlc_track_description_t *currentTrack = firstTrack;
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:@(currentTrack->i_id)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
libvlc_track_description_list_release(firstTrack);
return [NSArray arrayWithArray: tempArray];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment