[vlc-commits] [Git][videolan/vlc][master] player: move SetMediaStoppedAction() to the playlist
Thomas Guillem (@tguillem)
gitlab at videolan.org
Fri Mar 1 16:20:17 UTC 2024
Thomas Guillem pushed to branch master at VideoLAN / VLC
Commits:
3657a537 by Thomas Guillem at 2024-03-01T15:59:57+00:00
player: move SetMediaStoppedAction() to the playlist
The playlist is more suited to handle what to do after a playback.
This will allow to simplify the vlc_player_t media provider by removing
its callback that was sent depending on the media_stopped_action.
Thanks to Pierre for the Qt part of this commit.
Co-authored-by: Pierre Lamot <pierre at videolabs.io>
Related to #28524
- - - - -
23 changed files:
- include/vlc_player.h
- include/vlc_playlist.h
- modules/gui/macosx/menus/VLCMainMenu.m
- modules/gui/macosx/playlist/VLCPlayerController.h
- modules/gui/macosx/playlist/VLCPlayerController.m
- modules/gui/macosx/playlist/VLCPlaylistController.h
- modules/gui/macosx/playlist/VLCPlaylistController.m
- modules/gui/qt/menus/menus.cpp
- modules/gui/qt/player/player_controller.cpp
- modules/gui/qt/player/player_controller.hpp
- modules/gui/qt/player/player_controller_p.hpp
- modules/gui/qt/playlist/playlist_controller.cpp
- modules/gui/qt/playlist/playlist_controller.hpp
- modules/gui/qt/playlist/playlist_controller_p.hpp
- src/interface/interface.c
- src/libvlccore.sym
- src/player/input.c
- src/player/player.c
- src/player/player.h
- src/playlist/notify.c
- src/playlist/player.c
- src/playlist/playlist.c
- src/playlist/playlist.h
Changes:
=====================================
include/vlc_player.h
=====================================
@@ -87,22 +87,6 @@ enum vlc_player_lock_type
VLC_PLAYER_LOCK_REENTRANT,
};
-/**
- * Action when the player is stopped
- *
- * @see vlc_player_SetMediaStoppedAction()
- */
-enum vlc_player_media_stopped_action {
- /** Continue (or stop if there is no next media), default behavior */
- VLC_PLAYER_MEDIA_STOPPED_CONTINUE,
- /** Pause when reaching the end of file */
- VLC_PLAYER_MEDIA_STOPPED_PAUSE,
- /** Stop, even if there is a next media to play */
- VLC_PLAYER_MEDIA_STOPPED_STOP,
- /** Exit VLC */
- VLC_PLAYER_MEDIA_STOPPED_EXIT,
-};
-
/**
* Callbacks for the owner of the player.
*
@@ -186,16 +170,6 @@ vlc_player_Unlock(vlc_player_t *player);
VLC_API void
vlc_player_CondWait(vlc_player_t *player, vlc_cond_t *cond);
-/**
- * Setup an action when a media is stopped
- *
- * @param player locked player instance
- * @param action action to do when a media is stopped
- */
-VLC_API void
-vlc_player_SetMediaStoppedAction(vlc_player_t *player,
- enum vlc_player_media_stopped_action action);
-
/**
* Ask to start in a paused state
*
@@ -3143,18 +3117,6 @@ struct vlc_player_cbs
enum vlc_player_abloop new_state, vlc_tick_t time, double pos,
void *data);
- /**
- * Called when media stopped action has changed
- *
- * @see vlc_player_SetMediaStoppedAction()
- *
- * @param player locked player instance
- * @param new_action action to execute when a media is stopped
- * @param data opaque pointer set by vlc_player_AddListener()
- */
- void (*on_media_stopped_action_changed)(vlc_player_t *player,
- enum vlc_player_media_stopped_action new_action, void *data);
-
/**
* Called when the media meta and/or info has changed
*
=====================================
include/vlc_playlist.h
=====================================
@@ -154,6 +154,22 @@ struct vlc_playlist_sort_criterion
enum vlc_playlist_sort_order order;
};
+/**
+ * Action when a media is stopped
+ *
+ * @see vlc_playlist_SetMediaStoppedAction()
+ */
+enum vlc_playlist_media_stopped_action {
+ /** Continue (or stop if there is no next media), default behavior */
+ VLC_PLAYLIST_MEDIA_STOPPED_CONTINUE,
+ /** Pause when reaching the end of file */
+ VLC_PLAYLIST_MEDIA_STOPPED_PAUSE,
+ /** Stop, even if there is a next media to play */
+ VLC_PLAYLIST_MEDIA_STOPPED_STOP,
+ /** Exit VLC */
+ VLC_PLAYLIST_MEDIA_STOPPED_EXIT,
+};
+
/**
* Playlist callbacks.
*
@@ -292,6 +308,19 @@ struct vlc_playlist_callbacks
void
(*on_has_next_changed)(vlc_playlist_t *playlist,
bool has_next, void *userdata);
+
+ /**
+ * Called when the stopped action has changed
+ *
+ * @see vlc_playlist_SetMediaStoppedAction()
+ *
+ * \param playlist the playlist
+ * @param new_action action to execute when a media is stopped
+ * \param userdata userdata provided to AddListener()
+ */
+ void (*on_media_stopped_action_changed)(vlc_playlist_t *playlist,
+ enum vlc_playlist_media_stopped_action new_action,
+ void *userdata);
};
/* Playlist items */
@@ -401,6 +430,16 @@ VLC_API void
vlc_playlist_RemoveListener(vlc_playlist_t *playlist,
vlc_playlist_listener_id *id);
+/**
+ * Setup an action when a media is stopped
+ *
+ * @param playlist the playlist, locked
+ * @param action action to do when a media is stopped
+ */
+VLC_API void
+vlc_playlist_SetMediaStoppedAction(vlc_playlist_t *playlist,
+ enum vlc_playlist_media_stopped_action action);
+
/**
* Return the number of items.
*
=====================================
modules/gui/macosx/menus/VLCMainMenu.m
=====================================
@@ -890,10 +890,10 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
- (IBAction)quitAfterPlayback:(id)sender
{
- if (_playerController.actionAfterStop != VLC_PLAYER_MEDIA_STOPPED_EXIT) {
- _playerController.actionAfterStop = VLC_PLAYER_MEDIA_STOPPED_EXIT;
+ if (_playlistController.actionAfterStop != VLC_PLAYLIST_MEDIA_STOPPED_EXIT) {
+ _playlistController.actionAfterStop = VLC_PLAYLIST_MEDIA_STOPPED_EXIT;
} else {
- _playerController.actionAfterStop = VLC_PLAYER_MEDIA_STOPPED_CONTINUE;
+ _playlistController.actionAfterStop = VLC_PLAYLIST_MEDIA_STOPPED_CONTINUE;
}
}
@@ -1964,7 +1964,7 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
enum vlc_playlist_playback_order playbackOrder = [_playlistController playbackOrder];
[mi setState: playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM ? NSOnState : NSOffState];
} else if (mi == _quitAfterPB) {
- BOOL state = _playerController.actionAfterStop == VLC_PLAYER_MEDIA_STOPPED_EXIT;
+ BOOL state = _playlistController.actionAfterStop == VLC_PLAYLIST_MEDIA_STOPPED_EXIT;
[mi setState: state ? NSOnState : NSOffState];
} else if (mi == _fwd || mi == _bwd || mi == _jumpToTime) {
enabled = _playerController.seekable;
=====================================
modules/gui/macosx/playlist/VLCPlayerController.h
=====================================
@@ -298,13 +298,6 @@ extern const CGFloat VLCVolumeDefault;
*/
- (int)disableABLoop;
-/**
- * Define the action to perform after playback of the current media stopped (for any reason)
- * Options are: continue with next time, pause on last frame, stop even if there is a next item and quit VLC
- * @see the vlc_player_media_stopped_action enum for details
- */
- at property (readwrite, nonatomic) enum vlc_player_media_stopped_action actionAfterStop;
-
/**
* Move on to the next video frame and pause
* @warning this relies on a gross hack in the core and will work for 20 consecutive frames maximum only
=====================================
modules/gui/macosx/playlist/VLCPlayerController.m
=====================================
@@ -129,7 +129,6 @@ const CGFloat VLCVolumeDefault = 1.;
- (void)programListChanged;
- (void)programSelectionChanged:(int)selectedID;
- (void)ABLoopStateChanged:(enum vlc_player_abloop)abLoopState;
-- (void)stopActionChanged:(enum vlc_player_media_stopped_action)stoppedAction;
- (void)metaDataChangedForInput:(input_item_t *)inputItem;
- (void)voutListUpdated;
@@ -430,17 +429,6 @@ static void cb_player_atobloop_changed(vlc_player_t *p_player,
});
}
-static void cb_player_media_stopped_action_changed(vlc_player_t *p_player,
- enum vlc_player_media_stopped_action newAction,
- void *p_data)
-{
- VLC_UNUSED(p_player);
- dispatch_async(dispatch_get_main_queue(), ^{
- VLCPlayerController *playerController = (__bridge VLCPlayerController *)p_data;
- [playerController stopActionChanged:newAction];
- });
-}
-
static void cb_player_item_meta_changed(vlc_player_t *p_player,
input_item_t *p_mediaItem,
void *p_data)
@@ -501,7 +489,6 @@ static const struct vlc_player_cbs player_callbacks = {
.on_signal_changed = NULL,
.on_statistics_changed = cb_player_stats_changed,
.on_atobloop_changed = cb_player_atobloop_changed,
- .on_media_stopped_action_changed = cb_player_media_stopped_action_changed,
.on_media_meta_changed = cb_player_item_meta_changed,
.on_media_epg_changed = NULL,
.on_media_subitems_changed = NULL,
@@ -725,18 +712,6 @@ static int BossCallback(vlc_object_t *p_this,
vlc_player_Unlock(_p_player);
}
-- (void)stopActionChanged:(enum vlc_player_media_stopped_action)stoppedAction
-{
- _actionAfterStop = stoppedAction;
-}
-
-- (void)setActionAfterStop:(enum vlc_player_media_stopped_action)actionAfterStop
-{
- vlc_player_Lock(_p_player);
- vlc_player_SetMediaStoppedAction(_p_player, actionAfterStop);
- vlc_player_Unlock(_p_player);
-}
-
- (void)metaDataChangedForInput:(input_item_t *)inputItem
{
[_defaultNotificationCenter postNotificationName:VLCPlayerMetadataChangedForCurrentMedia
=====================================
modules/gui/macosx/playlist/VLCPlaylistController.h
=====================================
@@ -106,6 +106,14 @@ extern NSString *VLCPlaylistItemsRemoved;
@property (readwrite) BOOL libraryPlaylistMode;
+/**
+ * Define the action to perform after playback of the current media stopped (for any reason)
+ * Options are: continue with next time, pause on last frame, stop even if there is a next item and quit VLC
+ * @see the vlc_playlist_media_stopped_action enum for details
+ */
+ at property (readwrite, nonatomic) enum vlc_playlist_media_stopped_action actionAfterStop;
+
+
/**
* Simplified version to add new items to the end of the current playlist
* @param array array of items. Each item is an instance of VLCOpenInputMetadata.
=====================================
modules/gui/macosx/playlist/VLCPlaylistController.m
=====================================
@@ -60,6 +60,7 @@ NSString *VLCPlaylistItemsRemoved = @"VLCPlaylistItemsRemoved";
- (void)currentPlaylistItemIndexChanged:(size_t)index;
- (void)playlistHasPreviousItem:(BOOL)hasPrevious;
- (void)playlistHasNextItem:(BOOL)hasNext;
+- (void)stopActionChanged:(enum vlc_playlist_media_stopped_action)stoppedAction;
@end
@@ -194,6 +195,18 @@ cb_playlist_has_next_changed(vlc_playlist_t *playlist,
});
}
+static void
+cb_playlist_media_stopped_action_changed(vlc_playlist_t *p_playlist,
+ enum vlc_playlist_media_stopped_action newAction,
+ void *p_data)
+{
+ VLC_UNUSED(p_playlist);
+ dispatch_async(dispatch_get_main_queue(), ^{
+ VLCPlaylistController *playlistController = (__bridge VLCPlaylistController *)p_data;
+ [playlistController stopActionChanged:newAction];
+ });
+}
+
static const struct vlc_playlist_callbacks playlist_callbacks = {
cb_playlist_items_reset,
cb_playlist_items_added,
@@ -205,6 +218,7 @@ static const struct vlc_playlist_callbacks playlist_callbacks = {
cb_playlist_current_item_index_changed,
cb_playlist_has_prev_changed,
cb_playlist_has_next_changed,
+ cb_playlist_media_stopped_action_changed,
};
#pragma mark -
@@ -690,6 +704,18 @@ static const struct vlc_playlist_callbacks playlist_callbacks = {
return ret;
}
+- (void)stopActionChanged:(enum vlc_playlist_media_stopped_action)stoppedAction
+{
+ _actionAfterStop = stoppedAction;
+}
+
+- (void)setActionAfterStop:(enum vlc_playlist_media_stopped_action)actionAfterStop
+{
+ vlc_playlist_Lock(_p_playlist);
+ vlc_playlist_SetMediaStoppedAction(_p_playlist, actionAfterStop);
+ vlc_playlist_Unlock(_p_playlist);
+}
+
@end
@implementation VLCPlaylistExportModuleDescription
=====================================
modules/gui/qt/menus/menus.cpp
=====================================
@@ -215,10 +215,14 @@ void VLCMenuBar::FileMenu(qt_intf_t *p_intf, QMenu *menu)
":/menu/stream.svg", &DialogsProvider::openAndStreamingDialogs, "Ctrl+S" );
menu->addSeparator();
- action = addMPLStaticEntry( p_intf, menu, qtr( "Quit at the end of playlist" ), "",
- &PlaylistController::playAndExitChanged );
+ action = menu->addAction( qtr( "Quit at the end of playlist" ), [playlist = THEMPL](bool checked){
+ if (checked)
+ playlist->setMediaStopAction(PlaylistController::MEDIA_STOPPED_EXIT);
+ else
+ playlist->setMediaStopAction(PlaylistController::MEDIA_STOPPED_CONTINUE);
+ });
action->setCheckable( true );
- action->setChecked( THEMPL->isPlayAndExit() );
+ action->setChecked( THEMPL->getMediaStopAction() == PlaylistController::MEDIA_STOPPED_EXIT);
if( mi && mi->getSysTray() )
{
=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -746,15 +746,6 @@ static void on_player_atobloop_changed(vlc_player_t *, enum vlc_player_abloop st
});
}
-static void on_player_media_stopped_action_changed(vlc_player_t *, enum vlc_player_media_stopped_action new_action, void *data)
-{
- PlayerControllerPrivate* that = static_cast<PlayerControllerPrivate*>(data);
- that->callAsync([that,new_action] () {
- that->m_mediaStopAction = static_cast<PlayerController::MediaStopAction>(new_action);
- emit that->q_func()->mediaStopActionChanged(that->m_mediaStopAction);
- });
-}
-
static void on_player_media_meta_changed(vlc_player_t *, input_item_t *media, void *data)
{
PlayerControllerPrivate* that = static_cast<PlayerControllerPrivate*>(data);
@@ -1049,7 +1040,6 @@ static const struct vlc_player_cbs player_cbs = {
on_player_signal_changed,
on_player_stats_changed,
on_player_atobloop_changed,
- on_player_media_stopped_action_changed,
on_player_media_meta_changed,
on_player_media_epg_changed,
on_player_subitems_changed,
@@ -1207,13 +1197,6 @@ void PlayerController::setRate( float new_rate )
vlc_player_ChangeRate( d->m_player, new_rate );
}
-void PlayerController::setMediaStopAction(PlayerController::MediaStopAction action)
-{
- Q_D(PlayerController);
- vlc_player_locker lock{ d->m_player };
- vlc_player_SetMediaStoppedAction( d->m_player, static_cast<vlc_player_media_stopped_action>(action) );
-}
-
void PlayerController::slower()
{
Q_D(PlayerController);
@@ -2091,7 +2074,6 @@ PRIMITIVETYPE_GETTER(bool, canRestorePlayback, m_canRestorePlayback);
PRIMITIVETYPE_GETTER(float, getSubtitleFPS, m_subtitleFPS)
PRIMITIVETYPE_GETTER(bool, hasVideoOutput, m_hasVideo)
PRIMITIVETYPE_GETTER(float, getBuffering, m_buffering)
-PRIMITIVETYPE_GETTER(PlayerController::MediaStopAction, getMediaStopAction, m_mediaStopAction)
PRIMITIVETYPE_GETTER(float, getVolume, m_volume)
PRIMITIVETYPE_GETTER(bool, isMuted, m_muted)
PRIMITIVETYPE_GETTER(bool, isFullscreen, m_fullscreen)
=====================================
modules/gui/qt/player/player_controller.hpp
=====================================
@@ -95,15 +95,6 @@ public:
};
Q_ENUM(PlayingState)
- enum MediaStopAction
- {
- MEDIA_STOPPED_CONTINUE = VLC_PLAYER_MEDIA_STOPPED_CONTINUE,
- MEDIA_STOPPED_PAUSE = VLC_PLAYER_MEDIA_STOPPED_PAUSE,
- MEDIA_STOPPED_STOP = VLC_PLAYER_MEDIA_STOPPED_STOP,
- MEDIA_STOPPED_EXIT = VLC_PLAYER_MEDIA_STOPPED_EXIT
- };
- Q_ENUM(MediaStopAction)
-
enum Telekeys{
TELE_RED = VLC_PLAYER_TELETEXT_KEY_RED,
TELE_GREEN = VLC_PLAYER_TELETEXT_KEY_GREEN,
@@ -119,7 +110,6 @@ public:
Q_PROPERTY(QString name READ getName NOTIFY nameChanged FINAL)
Q_PROPERTY(float buffering READ getBuffering NOTIFY bufferingChanged FINAL)
Q_PROPERTY(float rate READ getRate WRITE setRate NOTIFY rateChanged FINAL)
- Q_PROPERTY(MediaStopAction mediaStopAction READ getMediaStopAction WRITE setMediaStopAction NOTIFY mediaStopActionChanged FINAL)
Q_PROPERTY(VLCTick time READ getTime WRITE setTime NOTIFY timeChanged FINAL)
Q_PROPERTY(VLCTick remainingTime READ getRemainingTime NOTIFY remainingTimeChanged FINAL)
@@ -289,8 +279,6 @@ public slots:
float getBuffering() const;
float getRate() const;
void setRate( float );
- MediaStopAction getMediaStopAction() const;
- void setMediaStopAction(MediaStopAction );
VLCTick getTime() const;
void setTime(VLCTick);
VLCTick getRemainingTime() const;
@@ -408,7 +396,6 @@ signals:
void nameChanged( const QString& );
void bufferingChanged( float );
void rateChanged( float );
- void mediaStopActionChanged( MediaStopAction );
void timeChanged( VLCTick );
void remainingTimeChanged( VLCTick );
=====================================
modules/gui/qt/player/player_controller_p.hpp
=====================================
@@ -76,7 +76,6 @@ public:
QString m_name;
float m_buffering = 0.f;
float m_rate = 1.f;
- PlayerController::MediaStopAction m_mediaStopAction = PlayerController::MEDIA_STOPPED_CONTINUE;
VLCTick m_time = 0;
VLCTick m_remainingTime = 0;
=====================================
modules/gui/qt/playlist/playlist_controller.cpp
=====================================
@@ -303,6 +303,23 @@ on_playlist_has_next_changed(vlc_playlist_t *playlist, bool has_next,
});
}
+static void
+on_media_stopped_action_changed(vlc_playlist_t *playlist,
+ enum vlc_playlist_media_stopped_action new_action,
+ void *userdata)
+{
+ PlaylistControllerPrivate *that = static_cast<PlaylistControllerPrivate *>(userdata);
+ that->callAsync([=](){
+ auto action = static_cast<PlaylistController::MediaStopAction>(new_action);
+ if (that->m_playlist != playlist)
+ return;
+ if (that->m_mediaStopAction == action)
+ return;
+ that->m_mediaStopAction = action;
+ emit that->q_func()->mediaStopActionChanged(action);
+ });
+}
+
} // extern "C"
static const struct vlc_playlist_callbacks playlist_callbacks = []{
@@ -317,6 +334,7 @@ static const struct vlc_playlist_callbacks playlist_callbacks = []{
cbs.on_current_index_changed = on_playlist_current_item_changed;
cbs.on_has_next_changed = on_playlist_has_next_changed;
cbs.on_has_prev_changed = on_playlist_has_prev_changed;
+ cbs.on_media_stopped_action_changed = on_media_stopped_action_changed;
return cbs;
}();
@@ -729,19 +747,17 @@ void PlaylistController::setRepeatMode(PlaylistController::PlaybackRepeat mode)
vlc_playlist_SetPlaybackRepeat( d->m_playlist, static_cast<vlc_playlist_playback_repeat>(mode) );
}
-
-bool PlaylistController::isPlayAndExit() const
+PlaylistController::MediaStopAction PlaylistController::getMediaStopAction() const
{
Q_D(const PlaylistController);
- return d->m_isPlayAndExit;
+ return d->m_mediaStopAction;
}
-void PlaylistController::setPlayAndExit(bool enable)
+void PlaylistController::setMediaStopAction(PlaylistController::MediaStopAction action)
{
Q_D(PlaylistController);
vlc_playlist_locker lock{ d->m_playlist };
- vlc_player_t* player = vlc_playlist_GetPlayer( d->m_playlist );
- vlc_player_SetMediaStoppedAction( player, enable ? VLC_PLAYER_MEDIA_STOPPED_EXIT : VLC_PLAYER_MEDIA_STOPPED_CONTINUE );
+ vlc_playlist_SetMediaStoppedAction(d->m_playlist, static_cast<vlc_playlist_media_stopped_action>(action) );
}
bool PlaylistController::isEmpty() const
=====================================
modules/gui/qt/playlist/playlist_controller.hpp
=====================================
@@ -81,6 +81,15 @@ public:
};
Q_ENUM(SortOrder)
+ enum MediaStopAction
+ {
+ MEDIA_STOPPED_CONTINUE = VLC_PLAYLIST_MEDIA_STOPPED_CONTINUE,
+ MEDIA_STOPPED_PAUSE = VLC_PLAYLIST_MEDIA_STOPPED_PAUSE,
+ MEDIA_STOPPED_STOP = VLC_PLAYLIST_MEDIA_STOPPED_STOP,
+ MEDIA_STOPPED_EXIT = VLC_PLAYLIST_MEDIA_STOPPED_EXIT
+ };
+ Q_ENUM(MediaStopAction)
+
Q_PROPERTY(QVariantList sortKeyTitleList READ getSortKeyTitleList CONSTANT FINAL)
Q_PROPERTY(Playlist playlist READ getPlaylist WRITE setPlaylist NOTIFY playlistChanged FINAL)
@@ -91,11 +100,12 @@ public:
Q_PROPERTY(bool hasPrev READ hasPrev NOTIFY hasPrevChanged FINAL)
Q_PROPERTY(bool random READ isRandom WRITE setRandom NOTIFY randomChanged FINAL)
Q_PROPERTY(PlaybackRepeat repeatMode READ getRepeatMode WRITE setRepeatMode NOTIFY repeatModeChanged FINAL)
- Q_PROPERTY(bool playAndExit READ isPlayAndExit WRITE setPlayAndExit NOTIFY playAndExitChanged FINAL)
Q_PROPERTY(bool empty READ isEmpty NOTIFY isEmptyChanged FINAL)
Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
Q_PROPERTY(SortKey sortKey READ getSortKey WRITE setSortKey NOTIFY sortKeyChanged FINAL)
Q_PROPERTY(SortOrder sortOrder READ getSortOrder WRITE setSortOrder NOTIFY sortOrderChanged FINAL)
+ Q_PROPERTY(MediaStopAction mediaStopAction READ getMediaStopAction WRITE setMediaStopAction NOTIFY mediaStopActionChanged FINAL)
+
public:
Q_INVOKABLE void play();
@@ -144,12 +154,12 @@ public slots:
bool isRandom() const;
void setRandom( bool );
+ MediaStopAction getMediaStopAction() const;
+ void setMediaStopAction(MediaStopAction );
+
PlaybackRepeat getRepeatMode() const;
void setRepeatMode( PlaybackRepeat mode );
- bool isPlayAndExit() const;
- void setPlayAndExit(bool );
-
bool isEmpty() const;
int count() const;
@@ -174,7 +184,7 @@ signals:
void hasNextChanged( bool );
void hasPrevChanged( bool );
void randomChanged( bool );
- void playAndExitChanged( bool );
+ void mediaStopActionChanged( MediaStopAction );
void repeatModeChanged( PlaybackRepeat );
void isEmptyChanged( bool empty );
void countChanged(int);
=====================================
modules/gui/qt/playlist/playlist_controller_p.hpp
=====================================
@@ -55,7 +55,7 @@ public:
bool m_hasPrev = false;
PlaylistController::PlaybackRepeat m_repeat = PlaylistController::PLAYBACK_REPEAT_NONE;
bool m_random = false;
- bool m_isPlayAndExit = false;
+ PlaylistController::MediaStopAction m_mediaStopAction = PlaylistController::MEDIA_STOPPED_CONTINUE;
bool m_empty = true;
size_t m_count = 0;
PlaylistController::SortKey m_sortKey = PlaylistController::SORT_KEY_NONE;
=====================================
src/interface/interface.c
=====================================
@@ -68,15 +68,15 @@ PlaylistConfigureFromVariables(vlc_playlist_t *playlist, vlc_object_t *obj)
else
repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE;
- enum vlc_player_media_stopped_action media_stopped_action;
+ enum vlc_playlist_media_stopped_action media_stopped_action;
if (var_InheritBool(obj, "play-and-exit"))
- media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_EXIT;
+ media_stopped_action = VLC_PLAYLIST_MEDIA_STOPPED_EXIT;
else if (var_InheritBool(obj, "play-and-stop"))
- media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_STOP;
+ media_stopped_action = VLC_PLAYLIST_MEDIA_STOPPED_STOP;
else if (var_InheritBool(obj, "play-and-pause"))
- media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_PAUSE;
+ media_stopped_action = VLC_PLAYLIST_MEDIA_STOPPED_PAUSE;
else
- media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_CONTINUE;
+ media_stopped_action = VLC_PLAYLIST_MEDIA_STOPPED_CONTINUE;
bool start_paused = var_InheritBool(obj, "start-paused");
bool playlist_cork = var_InheritBool(obj, "playlist-cork");
@@ -84,12 +84,12 @@ PlaylistConfigureFromVariables(vlc_playlist_t *playlist, vlc_object_t *obj)
vlc_playlist_Lock(playlist);
vlc_playlist_SetPlaybackOrder(playlist, order);
vlc_playlist_SetPlaybackRepeat(playlist, repeat);
+ vlc_playlist_SetMediaStoppedAction(playlist, media_stopped_action);
vlc_player_t *player = vlc_playlist_GetPlayer(playlist);
/* the playlist and the player share the same lock, and this is not an
* implementation detail */
- vlc_player_SetMediaStoppedAction(player, media_stopped_action);
vlc_player_SetStartPaused(player, start_paused);
vlc_player_SetPauseOnCork(player, playlist_cork);
=====================================
src/libvlccore.sym
=====================================
@@ -932,7 +932,6 @@ vlc_player_SetAtoBLoop
vlc_player_SetCategoryDelay
vlc_player_SetCurrentMedia
vlc_player_SetEsIdDelay
-vlc_player_SetMediaStoppedAction
vlc_player_SetRecordingEnabled
vlc_player_SetRenderer
vlc_player_SetStartPaused
@@ -1006,6 +1005,7 @@ vlc_playlist_Pause
vlc_playlist_Resume
vlc_playlist_Preparse
vlc_playlist_Export
+vlc_playlist_SetMediaStoppedAction
vlc_intf_GetMainPlaylist
vlc_media_source_Hold
vlc_media_source_Release
=====================================
src/player/input.c
=====================================
@@ -23,7 +23,6 @@
#endif
#include <vlc_common.h>
-#include <vlc_interface.h>
#include <vlc_memstream.h>
#include "player.h"
@@ -222,7 +221,6 @@ vlc_player_input_HandleState(struct vlc_player_input *input,
&& state != VLC_PLAYER_STATE_STOPPED)
return;
- enum vlc_player_state last_state = input->state;
input->state = state;
/* Override the global state if the player is still playing and has a next
@@ -258,34 +256,14 @@ vlc_player_input_HandleState(struct vlc_player_input *input,
player->last_eos = vlc_tick_now();
if (!player->deleting)
+ {
vlc_player_OpenNextMedia(player);
+ if (player->input)
+ vlc_player_input_Start(player->input);
+ }
if (!player->input)
player->started = false;
- /* If the last input was not even started, always play the next
- * media */
- enum vlc_player_media_stopped_action stopped_action;
- if (last_state == VLC_PLAYER_STATE_STOPPED)
- stopped_action = VLC_PLAYER_MEDIA_STOPPED_CONTINUE;
- else
- stopped_action = player->media_stopped_action;
-
- switch (stopped_action)
- {
- case VLC_PLAYER_MEDIA_STOPPED_EXIT:
- if (player->input && player->started)
- vlc_player_input_Start(player->input);
- else
- libvlc_Quit(vlc_object_instance(player));
- break;
- case VLC_PLAYER_MEDIA_STOPPED_CONTINUE:
- if (player->input && player->started)
- vlc_player_input_Start(player->input);
- break;
- default:
- break;
- }
-
send_event = !player->started;
break;
case VLC_PLAYER_STATE_STOPPING:
=====================================
src/player/player.c
=====================================
@@ -57,7 +57,6 @@ vlc_player_PrepareNextMedia(vlc_player_t *player)
vlc_player_assert_locked(player);
if (!player->media_provider
- || player->media_stopped_action == VLC_PLAYER_MEDIA_STOPPED_STOP
|| player->next_media_requested)
return;
@@ -1217,17 +1216,6 @@ vlc_player_Stop(vlc_player_t *player)
return VLC_SUCCESS;
}
-void
-vlc_player_SetMediaStoppedAction(vlc_player_t *player,
- enum vlc_player_media_stopped_action action)
-{
- vlc_player_assert_locked(player);
- player->media_stopped_action = action;
- var_SetBool(player, "play-and-pause",
- action == VLC_PLAYER_MEDIA_STOPPED_PAUSE);
- vlc_player_SendEvent(player, on_media_stopped_action_changed, action);
-}
-
void
vlc_player_SetStartPaused(vlc_player_t *player, bool start_paused)
{
@@ -1921,7 +1909,6 @@ vlc_player_New(vlc_object_t *parent, enum vlc_player_lock_type lock_type,
vlc_list_init(&player->destructor.inputs);
vlc_list_init(&player->destructor.stopping_inputs);
vlc_list_init(&player->destructor.joinable_inputs);
- player->media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_CONTINUE;
player->start_paused = false;
player->pause_on_cork = false;
player->corked = false;
=====================================
src/player/player.h
=====================================
@@ -239,7 +239,6 @@ struct vlc_player_t
vlc_mutex_t vout_listeners_lock;
vlc_cond_t start_delay_cond;
- enum vlc_player_media_stopped_action media_stopped_action;
bool start_paused;
const struct vlc_player_media_provider *media_provider;
=====================================
src/playlist/notify.c
=====================================
@@ -43,6 +43,8 @@ vlc_playlist_NotifyCurrentState(vlc_playlist_t *playlist,
playlist->has_prev);
vlc_playlist_NotifyListener(playlist, listener, on_has_next_changed,
playlist->has_next);
+ vlc_playlist_NotifyListener(playlist, listener, on_media_stopped_action_changed,
+ playlist->stopped_action);
}
vlc_playlist_listener_id *
=====================================
src/playlist/player.c
=====================================
@@ -22,6 +22,9 @@
# include "config.h"
#endif
+#include <vlc_common.h>
+#include <vlc_interface.h>
+
#include "player.h"
#include "../player/player.h"
@@ -72,6 +75,17 @@ player_on_current_media_changed(vlc_player_t *player, input_item_t *new_media,
vlc_playlist_state_NotifyChanges(playlist, &state);
}
+static void
+on_player_state_changed(vlc_player_t *player,
+ enum vlc_player_state new_state, void *userdata)
+{
+ vlc_playlist_t *playlist = userdata;
+
+ if (new_state == VLC_PLAYER_STATE_STOPPED
+ && playlist->stopped_action == VLC_PLAYLIST_MEDIA_STOPPED_EXIT)
+ libvlc_Quit(vlc_object_instance(player));
+}
+
static void
on_player_media_meta_changed(vlc_player_t *player, input_item_t *media,
void *userdata)
@@ -117,7 +131,17 @@ player_get_next_media(vlc_player_t *player, void *userdata)
{
VLC_UNUSED(player);
vlc_playlist_t *playlist = userdata;
- return vlc_playlist_GetNextMedia(playlist);
+ switch (playlist->stopped_action)
+ {
+ case VLC_PLAYLIST_MEDIA_STOPPED_CONTINUE:
+ case VLC_PLAYLIST_MEDIA_STOPPED_PAUSE:
+ case VLC_PLAYLIST_MEDIA_STOPPED_EXIT:
+ return vlc_playlist_GetNextMedia(playlist);
+ case VLC_PLAYLIST_MEDIA_STOPPED_STOP:
+ return NULL;
+ default:
+ vlc_assert_unreachable();
+ }
}
static const struct vlc_player_media_provider player_media_provider = {
@@ -126,6 +150,7 @@ static const struct vlc_player_media_provider player_media_provider = {
static const struct vlc_player_cbs player_callbacks = {
.on_current_media_changed = player_on_current_media_changed,
+ .on_state_changed = on_player_state_changed,
.on_media_meta_changed = on_player_media_meta_changed,
.on_length_changed = on_player_media_length_changed,
.on_media_subitems_changed = on_player_media_subitems_changed,
@@ -193,3 +218,15 @@ vlc_playlist_Resume(vlc_playlist_t *playlist)
{
vlc_player_Resume(playlist->player);
}
+
+void
+vlc_playlist_SetMediaStoppedAction(vlc_playlist_t *playlist,
+ enum vlc_playlist_media_stopped_action action)
+{
+ vlc_playlist_AssertLocked(playlist);
+ playlist->stopped_action = action;
+ var_SetBool(playlist->player, "play-and-pause",
+ action == VLC_PLAYLIST_MEDIA_STOPPED_PAUSE);
+ vlc_player_InvalidateNextMedia(playlist->player);
+ vlc_playlist_Notify(playlist, on_media_stopped_action_changed, action);
+}
=====================================
src/playlist/playlist.c
=====================================
@@ -43,6 +43,7 @@ vlc_playlist_New(vlc_object_t *parent)
free(playlist);
return NULL;
}
+ playlist->stopped_action = VLC_PLAYLIST_MEDIA_STOPPED_CONTINUE;
vlc_vector_init(&playlist->items);
randomizer_Init(&playlist->randomizer);
=====================================
src/playlist/playlist.h
=====================================
@@ -49,6 +49,7 @@ struct vlc_playlist
{
vlc_player_t *player;
libvlc_int_t *libvlc;
+ enum vlc_playlist_media_stopped_action stopped_action;
bool auto_preparse;
/* all remaining fields are protected by the lock of the player */
struct vlc_player_listener_id *player_listener;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3657a5376af18422b7fac018de947efda2e0edd7
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3657a5376af18422b7fac018de947efda2e0edd7
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list