[vlc-commits] [Git][videolan/vlc][master] 4 commits: vlm: remove custom logger from media
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Nov 28 09:20:37 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
188f0d5b by Romain Vimont at 2023-11-28T08:43:26+00:00
vlm: remove custom logger from media
No message is ever logged for a media.
- - - - -
bbef4e01 by Romain Vimont at 2023-11-28T08:43:26+00:00
vlm: remove unnecessary vlc_object
A vlm_media_sys_t need not be a VLC object.
- - - - -
0ea08262 by Romain Vimont at 2023-11-28T08:43:26+00:00
vlm: remove useless includes
- - - - -
8e97612b by Alaric Senat at 2023-11-28T08:43:26+00:00
vlm: store player finished state in media
This patch stores the finished state in the media context of VLM
directly from the player callback.
The previous check on the player state to determine if the media was
played was insufficient. The player state can go quickly from
`VLC_PLAYER_STATE_STOPPING` to `VLC_PLAYER_STATE_STOPPED` and when it
reaches the `STOPPED` state there is basically no way to know if we are
in the initial state or if we actually finished playing a media.
This was causing a deadlock where the VLM thread loop kept thinking the
player was reset to its initial state and never switched to the next
media.
- - - - -
3 changed files:
- src/input/vlm.c
- src/input/vlm_internal.h
- src/input/vlmshell.c
Changes:
=====================================
src/input/vlm.c
=====================================
@@ -47,9 +47,7 @@
#include "vlm_event.h"
#include <vlc_sout.h>
#include <vlc_url.h>
-#include "../stream_output/stream_output.h"
#include "../libvlc.h"
-#include "input_internal.h"
/*****************************************************************************
* Local prototypes.
@@ -61,15 +59,17 @@ static void player_on_state_changed(vlc_player_t *player,
enum vlc_player_state new_state, void *data)
{
vlm_media_sys_t *p_media = data;
- vlm_t *p_vlm = libvlc_priv( vlc_object_instance(p_media) )->p_vlm;
+ vlm_t *p_vlm = p_media->vlm;
assert( p_vlm );
+ vlm_media_instance_sys_t *instance = NULL;
const char *psz_instance_name = NULL;
for( int i = 0; i < p_media->i_instance; i++ )
{
if( p_media->instance[i]->player == player )
{
- psz_instance_name = p_media->instance[i]->psz_name;
+ instance = p_media->instance[i];
+ psz_instance_name = instance->psz_name;
break;
}
}
@@ -90,6 +90,13 @@ static void player_on_state_changed(vlc_player_t *player,
break;
case VLC_PLAYER_STATE_STOPPING:
vlm_state = vlc_player_GetError(player) ? VLM_ERROR_S : VLM_END_S;
+ if (instance != NULL)
+ {
+ vlc_mutex_lock(&p_vlm->lock);
+ instance->finished = true;
+ vlc_mutex_unlock(&p_vlm->lock);
+ }
+
break;
default:
vlc_assert_unreachable();
@@ -262,10 +269,8 @@ static void* Manage( void* p_object )
{
vlm_media_instance_sys_t *p_instance = p_media->instance[j];
- vlc_player_Lock(p_instance->player);
- if (!vlc_player_IsStarted(p_instance->player))
+ if (p_instance->finished)
{
- vlc_player_Unlock(p_instance->player);
int i_new_input_index;
/* */
@@ -282,7 +287,6 @@ static void* Manage( void* p_object )
}
else
{
- vlc_player_Unlock(p_instance->player);
j++;
}
}
@@ -464,7 +468,6 @@ static int vlm_ControlMediaChange( vlm_t *p_vlm, vlm_media_t *p_cfg )
static int vlm_ControlMediaAdd( vlm_t *p_vlm, vlm_media_t *p_cfg, int64_t *p_id )
{
vlm_media_sys_t *p_media;
- char *header;
if( vlm_MediaDescriptionCheck( p_vlm, p_cfg ) || vlm_ControlMediaGetByName( p_vlm, p_cfg->psz_name ) )
{
@@ -472,25 +475,11 @@ static int vlm_ControlMediaAdd( vlm_t *p_vlm, vlm_media_t *p_cfg, int64_t *p_id
return VLC_EGENERIC;
}
- p_media = vlc_custom_create( VLC_OBJECT(p_vlm), sizeof( *p_media ),
- "media" );
+ p_media = malloc(sizeof(*p_media));
if( !p_media )
return VLC_ENOMEM;
- if( asprintf( &header, _("Media: %s"), p_cfg->psz_name ) == -1 )
- {
- vlc_object_delete(p_media);
- return VLC_ENOMEM;
- }
-
- p_media->obj.logger = vlc_LogHeaderCreate( p_media->obj.logger, header );
- free( header );
-
- if( p_media->obj.logger == NULL )
- {
- vlc_object_delete(p_media);
- return VLC_ENOMEM;
- }
+ p_media->vlm = p_vlm;
vlm_media_Copy( &p_media->cfg, p_cfg );
p_media->cfg.id = p_vlm->i_id++;
@@ -525,8 +514,7 @@ static int vlm_ControlMediaDel( vlm_t *p_vlm, int64_t id )
vlm_media_Clean( &p_media->cfg );
TAB_REMOVE( p_vlm->i_media, p_vlm->media, p_media );
- vlc_LogDestroy( p_media->obj.logger );
- vlc_object_delete(p_media);
+ free(p_media);
return VLC_SUCCESS;
}
@@ -601,11 +589,8 @@ static vlm_media_instance_sys_t *vlm_MediaInstanceNew( vlm_media_sys_t *p_media,
goto error;
p_instance->i_index = 0;
- p_instance->p_parent = vlc_object_create( p_media, sizeof (vlc_object_t) );
- if (!p_instance->p_parent)
- goto error;
- p_instance->player = vlc_player_New(p_instance->p_parent,
+ p_instance->player = vlc_player_New(VLC_OBJECT(p_media->vlm),
VLC_PLAYER_LOCK_NORMAL, NULL, NULL);
if (!p_instance->player)
goto error;
@@ -625,8 +610,6 @@ static vlm_media_instance_sys_t *vlm_MediaInstanceNew( vlm_media_sys_t *p_media,
error:
if (p_instance->player)
vlc_player_Delete(p_instance->player);
- if (p_instance->p_parent)
- vlc_object_delete(p_instance->p_parent);
if (p_instance->p_item)
input_item_Release(p_instance->p_item);
free(p_instance->psz_name);
@@ -646,7 +629,6 @@ static void vlm_MediaInstanceDelete( vlm_t *p_vlm, int64_t id, vlm_media_instanc
if (had_media)
vlm_SendEventMediaInstanceStopped( p_vlm, id, p_media->cfg.psz_name );
- vlc_object_delete(p_instance->p_parent);
TAB_REMOVE( p_media->i_instance, p_media->instance, p_instance );
input_item_Release( p_instance->p_item );
@@ -723,6 +705,7 @@ static int vlm_ControlMediaInstanceStart( vlm_t *p_vlm, int64_t id, const char *
vlc_player_SetCurrentMedia(player, p_instance->p_item);
vlc_player_Start(player);
vlc_player_Unlock(player);
+ p_instance->finished = false;
vlm_SendEventMediaInstanceStarted( p_vlm, id, p_media->cfg.psz_name );
=====================================
src/input/vlm_internal.h
=====================================
@@ -25,7 +25,6 @@
#include <vlc_vlm.h>
#include <vlc_player.h>
-#include "input_interface.h"
/* Private */
typedef struct
@@ -36,17 +35,16 @@ typedef struct
/* "playlist" index */
int i_index;
- vlc_object_t *p_parent;
input_item_t *p_item;
vlc_player_t *player;
vlc_player_listener_id *listener;
-
+ bool finished;
} vlm_media_instance_sys_t;
typedef struct
{
- struct vlc_object_t obj;
+ vlm_t *vlm;
vlm_media_t cfg;
/* actual input instances */
=====================================
src/input/vlmshell.c
=====================================
@@ -45,15 +45,12 @@
#include <fcntl.h>
#include <sys/stat.h>
-#include "input_internal.h"
#include <vlc_stream.h>
#include "vlm_internal.h"
#include <vlc_charset.h>
#include <vlc_fs.h>
#include <vlc_sout.h>
#include <vlc_memstream.h>
-#include "../stream_output/stream_output.h"
-#include "../libvlc.h"
/*****************************************************************************
* Local prototypes.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e957881f713b057b3841a44ec023c404544748d7...8e97612b58c1f7fd687cceca7ae76578214f7792
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e957881f713b057b3841a44ec023c404544748d7...8e97612b58c1f7fd687cceca7ae76578214f7792
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