[vlc-devel] [PATCH 4/6] WIP: player: save track StrIds instead of legacy int
Thomas Guillem
thomas at gllm.fr
Fri Feb 28 13:47:29 CET 2020
WIP: waiting for ML modifications.
---
src/player/input.c | 53 +---------------------------
src/player/medialib.c | 81 +++++++++++++++----------------------------
src/player/player.h | 3 --
3 files changed, 29 insertions(+), 108 deletions(-)
diff --git a/src/player/input.c b/src/player/input.c
index 59c2d5655ec..13616279ab4 100644
--- a/src/player/input.c
+++ b/src/player/input.c
@@ -438,35 +438,6 @@ vlc_player_input_HandleEsEvent(struct vlc_player_input *input,
}
vlc_player_SendEvent(player, on_track_list_changed,
VLC_PLAYER_LIST_ADDED, &trackpriv->t);
- switch (ev->fmt->i_cat)
- {
- case VIDEO_ES:
- /* If we need to restore a specific track, let's do it upon
- * insertion. The initialization of the default track when
- * we don't have a value will be done when the first track
- * gets selected */
- if (input->ml.restore_states &&
- input->ml.states.current_video_track != -2 &&
- input->ml.states.current_video_track == ev->fmt->i_id)
- vlc_player_SelectTrack(input->player, &trackpriv->t,
- VLC_PLAYER_SELECT_EXCLUSIVE);
- break;
- case AUDIO_ES:
- if (input->ml.restore_states &&
- input->ml.states.current_audio_track != -2 &&
- input->ml.states.current_audio_track == ev->fmt->i_id)
- vlc_player_SelectTrack(input->player, &trackpriv->t,
- VLC_PLAYER_SELECT_EXCLUSIVE);
- break;
- case SPU_ES:
- if (input->ml.restore_states &&
- input->ml.states.current_subtitle_track != -2 &&
- input->ml.states.current_subtitle_track == ev->fmt->i_id)
- vlc_player_SelectTrack(input->player, &trackpriv->t,
- VLC_PLAYER_SELECT_EXCLUSIVE);
- default:
- break;
- }
break;
case VLC_INPUT_ES_DELETED:
{
@@ -499,26 +470,6 @@ vlc_player_input_HandleEsEvent(struct vlc_player_input *input,
vlc_player_SendEvent(player, on_track_selection_changed,
NULL, trackpriv->t.es_id);
}
- switch (ev->fmt->i_cat)
- {
- /* Save the default selected track to know if it changed
- * when the playback stops, in order to save the user's
- * explicitely selected track */
- case VIDEO_ES:
- if (input->ml.default_video_track == -2)
- input->ml.default_video_track = ev->fmt->i_id;
- break;
- case AUDIO_ES:
- if (input->ml.default_audio_track == -2)
- input->ml.default_audio_track = ev->fmt->i_id;
- break;
- case SPU_ES:
- if (input->ml.default_subtitle_track == -2)
- input->ml.default_subtitle_track = ev->fmt->i_id;
- break;
- default:
- break;
- }
break;
case VLC_INPUT_ES_UNSELECTED:
trackpriv = vlc_player_track_vector_FindById(vec, ev->id, NULL);
@@ -921,9 +872,7 @@ vlc_player_input_New(vlc_player_t *player, input_item_t *item)
input->ml.states.current_title = -1;
input->ml.states.current_video_track =
input->ml.states.current_audio_track =
- input->ml.states.current_subtitle_track =
- input->ml.default_video_track = input->ml.default_audio_track =
- input->ml.default_subtitle_track = -2;
+ input->ml.states.current_subtitle_track = -2;
input->ml.states.progress = -1.f;
input->ml.restore = VLC_RESTOREPOINT_NONE;
input->ml.restore_states = false;
diff --git a/src/player/medialib.c b/src/player/medialib.c
index 02249f41ea5..6715c4050dc 100644
--- a/src/player/medialib.c
+++ b/src/player/medialib.c
@@ -75,34 +75,20 @@ vlc_player_input_RestoreMlStates(struct vlc_player_input* input, bool force_pos)
if (input->ml.states.rate != .0f)
vlc_player_ChangeRate(player, input->ml.states.rate);
- /* Tracks are restored upon insertion, except when explicitely disabled */
- if (input->ml.states.current_video_track == -1)
- {
- input->ml.default_video_track = -1;
- input_ControlSync(input->thread, INPUT_CONTROL_SET_ES_AUTOSELECT,
- &(input_control_param_t) {
- .es_autoselect.cat = VIDEO_ES,
- .es_autoselect.enabled = false,
- });
- }
- if (input->ml.states.current_audio_track == -1)
- {
- input->ml.default_audio_track = -1;
- input_ControlSync(input->thread, INPUT_CONTROL_SET_ES_AUTOSELECT,
- &(input_control_param_t) {
- .es_autoselect.cat = AUDIO_ES,
- .es_autoselect.enabled = false,
- });
- }
- if (input->ml.states.current_subtitle_track == -1)
- {
- input->ml.default_subtitle_track = -1;
- input_ControlSync(input->thread, INPUT_CONTROL_SET_ES_AUTOSELECT,
- &(input_control_param_t) {
- .es_autoselect.cat = SPU_ES,
- .es_autoselect.enabled = false,
- });
- }
+
+ const char *video_track_ids = NULL /* input->ml.states.video_track_ids */;
+ const char *audio_track_ids = NULL /* input->ml.states.video_track_ids */;
+ const char *subtitle_track_ids = NULL /* input->ml.states.subtitle_track_ids */;
+
+ if (video_track_ids)
+ vlc_player_input_SelectTracksByStringIds(input, VIDEO_ES,
+ video_track_ids);
+ if (audio_track_ids)
+ vlc_player_input_SelectTracksByStringIds(input, AUDIO_ES,
+ audio_track_ids);
+ if (subtitle_track_ids)
+ vlc_player_input_SelectTracksByStringIds(input, SPU_ES,
+ subtitle_track_ids);
vout_thread_t* vout = vlc_player_vout_Hold(player);
if (vout != NULL)
@@ -304,34 +290,23 @@ vlc_player_UpdateMLStates(vlc_player_t *player, struct vlc_player_input* input)
free(aspect_ratio);
}
- if (input->ml.default_video_track != -2)
- {
- int current_video_track = vlc_player_GetFirstSelectedTrackId(&input->video_track_vector);
- if (input->ml.default_video_track != current_video_track)
- input->ml.states.current_video_track = current_video_track;
- else
- input->ml.states.current_video_track = -2;
- }
-
- if (input->ml.default_audio_track != -2)
- {
- int current_audio_track = vlc_player_GetFirstSelectedTrackId(&input->audio_track_vector);
- if (input->ml.default_audio_track != current_audio_track)
- input->ml.states.current_audio_track = current_audio_track;
- else
- input->ml.states.current_audio_track = -2;
- }
+ char *video_track_ids =
+ vlc_player_input_GetSelectedTrackStringIds(input, VIDEO_ES);
+ char *audio_track_ids =
+ vlc_player_input_GetSelectedTrackStringIds(input, AUDIO_ES);
+ char *subtitle_track_ids =
+ vlc_player_input_GetSelectedTrackStringIds(input, SPU_ES);
- if (input->ml.default_subtitle_track != -2)
- {
- int current_subtitle_track = vlc_player_GetFirstSelectedTrackId(&input->spu_track_vector);
- if (input->ml.default_subtitle_track != current_subtitle_track)
- input->ml.states.current_subtitle_track = current_subtitle_track;
- else
- input->ml.states.current_subtitle_track = -2;
- }
+ /* input->ml.states.video_track_ids = video_track_ids; */
+ /* input->ml.states.audio_track_ids = audio_track_ids; */
+ /* input->ml.states.subtitle_track_ids = subtitle_track_ids; */
vlc_ml_media_set_all_playback_states(ml, media->i_id, &input->ml.states);
+
+ free(video_track_ids);
+ free(audio_track_ids);
+ free(subtitle_track_ids);
+
vlc_ml_release(&input->ml.states);
vlc_ml_release(media);
}
diff --git a/src/player/player.h b/src/player/player.h
index 2583ab84363..4ba6e061fa6 100644
--- a/src/player/player.h
+++ b/src/player/player.h
@@ -108,9 +108,6 @@ struct vlc_player_input
struct
{
vlc_ml_playback_states_all states;
- int default_video_track;
- int default_audio_track;
- int default_subtitle_track;
enum
{
VLC_RESTOREPOINT_TITLE,
--
2.20.1
More information about the vlc-devel
mailing list