mirror of
https://code.videolan.org/videolan/vlc
synced 2024-08-18 23:45:06 +02:00
macosx: iterate on internal tracks API
This way, it is simpler and can no longer break in case the tracks listing changes while iterating
This commit is contained in:
parent
4dafd8604a
commit
21e28d61ff
@ -867,27 +867,18 @@
|
||||
#pragma mark - track handling
|
||||
- (void)updateTrackHandlingMenus:(NSNotification *)aNotification
|
||||
{
|
||||
size_t numberOfTracks = _playerController.numberOfAudioTracks;
|
||||
NSMutableArray *tracks = [[NSMutableArray alloc] initWithCapacity:numberOfTracks];
|
||||
for (size_t x = 0; x < numberOfTracks; x++) {
|
||||
[tracks addObject:[_playerController audioTrackAtIndex:x]];
|
||||
}
|
||||
NSArray *tracks = _playerController.audioTracks;
|
||||
NSUInteger numberOfTracks = tracks.count;
|
||||
[self rebuildTracksMenu:_audiotrackMenu withMetadata:tracks count:numberOfTracks category:AUDIO_ES];
|
||||
_audiotrack.enabled = numberOfTracks > 0 ? YES : NO;
|
||||
|
||||
numberOfTracks = _playerController.numberOfVideoTracks;
|
||||
tracks = [[NSMutableArray alloc] initWithCapacity:numberOfTracks];
|
||||
for (size_t x = 0; x < numberOfTracks; x++) {
|
||||
[tracks addObject:[_playerController videoTrackAtIndex:x]];
|
||||
}
|
||||
tracks = _playerController.videoTracks;
|
||||
numberOfTracks = tracks.count;
|
||||
[self rebuildTracksMenu:_videotrackMenu withMetadata:tracks count:numberOfTracks category:VIDEO_ES];
|
||||
_videotrack.enabled = numberOfTracks > 0 ? YES : NO;
|
||||
|
||||
numberOfTracks = _playerController.numberOfSubtitleTracks;
|
||||
tracks = [[NSMutableArray alloc] initWithCapacity:numberOfTracks];
|
||||
for (size_t x = 0; x < numberOfTracks; x++) {
|
||||
[tracks addObject:[_playerController subtitleTrackAtIndex:x]];
|
||||
}
|
||||
tracks = _playerController.subtitleTracks;
|
||||
numberOfTracks = tracks.count;
|
||||
[self rebuildTracksMenu:_subtitle_tracksMenu withMetadata:tracks count:numberOfTracks category:SPU_ES];
|
||||
_subtitle_track.enabled = numberOfTracks > 0 ? YES : NO;
|
||||
}
|
||||
|
@ -640,37 +640,22 @@ extern NSString *VLCPlayerMuteChanged;
|
||||
- (void)selectNextTrackForCategory:(enum es_format_category_e)category;
|
||||
|
||||
/**
|
||||
* the number of audio tracks
|
||||
* @note listen to VLCPlayerTrackListChanged to be notified if this value changes
|
||||
* an array holding instances of VLCTrackMetaData describing the available audio tracks for the current media
|
||||
* @note listen to VLCPlayerTrackListChanged to be notified of changes to the list
|
||||
*/
|
||||
@property (readonly) size_t numberOfAudioTracks;
|
||||
@property (readonly, nullable) NSArray<VLCTrackMetaData *>* audioTracks;
|
||||
|
||||
/**
|
||||
* get a metadata copy of a certain audio track at @param index
|
||||
* an array holding instances of VLCTrackMetaData describing the available video tracks for the current media
|
||||
* @note listen to VLCPlayerTrackListChanged to be notified of changes to the list
|
||||
*/
|
||||
- (VLCTrackMetaData *)audioTrackAtIndex:(size_t)index;
|
||||
@property (readonly, nullable) NSArray<VLCTrackMetaData *>* videoTracks;
|
||||
|
||||
/**
|
||||
* the number of video tracks
|
||||
* @note listen to VLCPlayerTrackListChanged to be notified if this value changes
|
||||
* an array holding instances of VLCTrackMetaData describing the available subtitle tracks for the current media
|
||||
* @note listen to VLCPlayerTrackListChanged to be notified of changes to the list
|
||||
*/
|
||||
@property (readonly) size_t numberOfVideoTracks;
|
||||
|
||||
/**
|
||||
* get a metadata copy of a certain video track at @param index
|
||||
*/
|
||||
- (VLCTrackMetaData *)videoTrackAtIndex:(size_t)index;
|
||||
|
||||
/**
|
||||
* the number of subtitle tracks
|
||||
* @note listen to VLCPlayerTrackListChanged to be notified if this value changes
|
||||
*/
|
||||
@property (readonly) size_t numberOfSubtitleTracks;
|
||||
|
||||
/**
|
||||
* get a metadata copy of a certain subtitle track at @param index
|
||||
*/
|
||||
- (VLCTrackMetaData *)subtitleTrackAtIndex:(size_t)index;
|
||||
@property (readonly, nullable) NSArray<VLCTrackMetaData *>* subtitleTracks;
|
||||
|
||||
#pragma mark - video output properties
|
||||
|
||||
|
@ -1302,66 +1302,45 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
|
||||
vlc_player_Unlock(_p_player);
|
||||
}
|
||||
|
||||
- (size_t)numberOfAudioTracks
|
||||
- (NSArray<VLCTrackMetaData *> *)tracksForCategory:(enum es_format_category_e)category
|
||||
{
|
||||
size_t ret = 0;
|
||||
size_t numberOfTracks = 0;
|
||||
NSMutableArray *tracks;
|
||||
|
||||
vlc_player_Lock(_p_player);
|
||||
ret = vlc_player_GetTrackCount(_p_player, AUDIO_ES);
|
||||
numberOfTracks = vlc_player_GetTrackCount(_p_player, category);
|
||||
if (numberOfTracks == 0) {
|
||||
vlc_player_Unlock(_p_player);
|
||||
return nil;
|
||||
}
|
||||
|
||||
tracks = [[NSMutableArray alloc] initWithCapacity:numberOfTracks];
|
||||
for (size_t x = 0; x < numberOfTracks; x++) {
|
||||
VLCTrackMetaData *trackMetadata = [[VLCTrackMetaData alloc] init];
|
||||
const struct vlc_player_track *track = vlc_player_GetTrackAt(_p_player, category, x);
|
||||
trackMetadata.esID = track->es_id;
|
||||
trackMetadata.name = toNSStr(track->name);
|
||||
trackMetadata.selected = track->selected;
|
||||
[tracks addObject:trackMetadata];
|
||||
}
|
||||
vlc_player_Unlock(_p_player);
|
||||
return ret;
|
||||
}
|
||||
- (VLCTrackMetaData *)audioTrackAtIndex:(size_t)index
|
||||
{
|
||||
VLCTrackMetaData *trackMetadata = [[VLCTrackMetaData alloc] init];
|
||||
vlc_player_Lock(_p_player);
|
||||
const struct vlc_player_track *track = vlc_player_GetTrackAt(_p_player, AUDIO_ES, index);
|
||||
trackMetadata.esID = track->es_id;
|
||||
trackMetadata.name = toNSStr(track->name);
|
||||
trackMetadata.selected = track->selected;
|
||||
vlc_player_Unlock(_p_player);
|
||||
return trackMetadata;
|
||||
|
||||
return [tracks copy];
|
||||
}
|
||||
|
||||
- (size_t)numberOfVideoTracks
|
||||
- (NSArray<VLCTrackMetaData *> *)audioTracks
|
||||
{
|
||||
size_t ret = 0;
|
||||
vlc_player_Lock(_p_player);
|
||||
ret = vlc_player_GetTrackCount(_p_player, VIDEO_ES);
|
||||
vlc_player_Unlock(_p_player);
|
||||
return ret;
|
||||
return [self tracksForCategory:AUDIO_ES];
|
||||
}
|
||||
|
||||
- (VLCTrackMetaData *)videoTrackAtIndex:(size_t)index
|
||||
- (NSArray<VLCTrackMetaData *> *)videoTracks
|
||||
{
|
||||
VLCTrackMetaData *trackMetadata = [[VLCTrackMetaData alloc] init];
|
||||
vlc_player_Lock(_p_player);
|
||||
const struct vlc_player_track *track = vlc_player_GetTrackAt(_p_player, VIDEO_ES, index);
|
||||
trackMetadata.esID = track->es_id;
|
||||
trackMetadata.name = toNSStr(track->name);
|
||||
trackMetadata.selected = track->selected;
|
||||
vlc_player_Unlock(_p_player);
|
||||
return trackMetadata;
|
||||
return [self tracksForCategory:VIDEO_ES];
|
||||
}
|
||||
|
||||
- (size_t)numberOfSubtitleTracks
|
||||
- (NSArray<VLCTrackMetaData *> *)subtitleTracks
|
||||
{
|
||||
size_t ret = 0;
|
||||
vlc_player_Lock(_p_player);
|
||||
ret = vlc_player_GetTrackCount(_p_player, SPU_ES);
|
||||
vlc_player_Unlock(_p_player);
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (VLCTrackMetaData *)subtitleTrackAtIndex:(size_t)index
|
||||
{
|
||||
VLCTrackMetaData *trackMetadata = [[VLCTrackMetaData alloc] init];
|
||||
vlc_player_Lock(_p_player);
|
||||
const struct vlc_player_track *track = vlc_player_GetTrackAt(_p_player, SPU_ES, index);
|
||||
trackMetadata.esID = track->es_id;
|
||||
trackMetadata.name = toNSStr(track->name);
|
||||
trackMetadata.selected = track->selected;
|
||||
vlc_player_Unlock(_p_player);
|
||||
return trackMetadata;
|
||||
return [self tracksForCategory:SPU_ES];
|
||||
}
|
||||
|
||||
- (void)ABLoopStateChanged:(enum vlc_player_abloop)abLoopState
|
||||
|
Loading…
Reference in New Issue
Block a user