vlc | branch: master | Thomas Guillem <[email protected]> | Thu May 9 16:57:01 2019 +0200| [65db330108f44381524058a7ead61621fdbc5d68] | committer: Thomas Guillem
vout: add vout_CreateDummy > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=65db330108f44381524058a7ead61621fdbc5d68 --- src/video_output/video_output.c | 80 +++++++++++++++++++++++++++++++++++++--- src/video_output/vout_internal.h | 4 ++ 2 files changed, 78 insertions(+), 6 deletions(-) diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index d09e88f281..6e8c8608eb 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -217,11 +217,13 @@ static void vout_UpdateWindowSize(vout_thread_t *vout) void vout_GetResetStatistic(vout_thread_t *vout, unsigned *restrict displayed, unsigned *restrict lost) { + assert(!vout->p->dummy); vout_statistic_GetReset( &vout->p->statistic, displayed, lost ); } bool vout_IsEmpty(vout_thread_t *vout) { + assert(!vout->p->dummy); picture_t *picture = picture_fifo_Peek(vout->p->decoder_fifo); if (picture) picture_Release(picture); @@ -231,6 +233,7 @@ bool vout_IsEmpty(vout_thread_t *vout) void vout_DisplayTitle(vout_thread_t *vout, const char *title) { + assert(!vout->p->dummy); assert(title); if (!vout->p->title.show) @@ -242,6 +245,7 @@ void vout_DisplayTitle(vout_thread_t *vout, const char *title) void vout_MouseState(vout_thread_t *vout, const vlc_mouse_t *mouse) { + assert(!vout->p->dummy); assert(mouse); vout_control_cmd_t cmd; vout_control_cmd_Init(&cmd, VOUT_CONTROL_MOUSE_STATE); @@ -253,6 +257,7 @@ void vout_MouseState(vout_thread_t *vout, const vlc_mouse_t *mouse) void vout_PutSubpicture( vout_thread_t *vout, subpicture_t *subpic ) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vlc_mutex_lock(&sys->spu_lock); if (sys->spu != NULL) @@ -264,6 +269,7 @@ void vout_PutSubpicture( vout_thread_t *vout, subpicture_t *subpic ) int vout_RegisterSubpictureChannel( vout_thread_t *vout ) { + assert(!vout->p->dummy); int channel = VOUT_SPU_CHANNEL_AVAIL_FIRST; vlc_mutex_lock(&vout->p->spu_lock); @@ -276,6 +282,7 @@ int vout_RegisterSubpictureChannel( vout_thread_t *vout ) void vout_SetSubpictureClock( vout_thread_t *vout, vlc_clock_t *clock ) { + assert(!vout->p->dummy); vlc_mutex_lock(&vout->p->spu_lock); if (vout->p->spu) spu_clock_Set(vout->p->spu, clock); @@ -285,6 +292,7 @@ void vout_SetSubpictureClock( vout_thread_t *vout, vlc_clock_t *clock ) void vout_FlushSubpictureChannel( vout_thread_t *vout, int channel ) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vlc_mutex_lock(&sys->spu_lock); if (sys->spu != NULL) @@ -295,6 +303,7 @@ void vout_FlushSubpictureChannel( vout_thread_t *vout, int channel ) void vout_SetSpuHighlight( vout_thread_t *vout, const vlc_spu_highlight_t *spu_hl ) { + assert(!vout->p->dummy); vlc_mutex_lock(&vout->p->spu_lock); if (vout->p->spu) spu_SetHighlight(vout->p->spu, spu_hl); @@ -312,6 +321,7 @@ void vout_SetSpuHighlight( vout_thread_t *vout, */ picture_t *vout_GetPicture(vout_thread_t *vout) { + assert(!vout->p->dummy); picture_t *picture = picture_pool_Wait(vout->p->decoder_pool); if (likely(picture != NULL)) { picture_Reset(picture); @@ -330,6 +340,7 @@ picture_t *vout_GetPicture(vout_thread_t *vout) */ void vout_PutPicture(vout_thread_t *vout, picture_t *picture) { + assert(!vout->p->dummy); picture->p_next = NULL; picture_fifo_Push(vout->p->decoder_fifo, picture); vout_control_Wake(&vout->p->control); @@ -341,6 +352,7 @@ int vout_GetSnapshot(vout_thread_t *vout, video_format_t *fmt, const char *type, vlc_tick_t timeout) { + assert(!vout->p->dummy); picture_t *picture = vout_snapshot_Get(vout->p->snapshot, timeout); if (!picture) { msg_Err(vout, "Failed to grab a snapshot"); @@ -372,6 +384,7 @@ int vout_GetSnapshot(vout_thread_t *vout, /* vout_Control* are usable by anyone at anytime */ void vout_ChangeFullscreen(vout_thread_t *vout, const char *id) { + assert(!vout->p->dummy); vlc_mutex_lock(&vout->p->window_lock); vout_window_SetFullScreen(vout->p->display_cfg.window, id); vlc_mutex_unlock(&vout->p->window_lock); @@ -379,6 +392,7 @@ void vout_ChangeFullscreen(vout_thread_t *vout, const char *id) void vout_ChangeWindowed(vout_thread_t *vout) { + assert(!vout->p->dummy); vlc_mutex_lock(&vout->p->window_lock); vout_window_UnsetFullScreen(vout->p->display_cfg.window); /* Attempt to reset the intended window size */ @@ -388,6 +402,7 @@ void vout_ChangeWindowed(vout_thread_t *vout) void vout_ChangeWindowState(vout_thread_t *vout, unsigned st) { + assert(!vout->p->dummy); vlc_mutex_lock(&vout->p->window_lock); vout_window_SetState(vout->p->display_cfg.window, st); vlc_mutex_unlock(&vout->p->window_lock); @@ -396,6 +411,7 @@ void vout_ChangeWindowState(vout_thread_t *vout, unsigned st) void vout_ChangeDisplaySize(vout_thread_t *vout, unsigned width, unsigned height) { + assert(!vout->p->dummy); /* DO NOT call this outside the vout window callbacks */ vout_control_cmd_t cmd; @@ -410,6 +426,7 @@ void vout_ChangeDisplaySize(vout_thread_t *vout, void vout_ChangeDisplayFilled(vout_thread_t *vout, bool is_filled) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vlc_mutex_lock(&sys->window_lock); sys->display_cfg.is_display_filled = is_filled; @@ -423,6 +440,7 @@ void vout_ChangeDisplayFilled(vout_thread_t *vout, bool is_filled) void vout_ChangeZoom(vout_thread_t *vout, unsigned num, unsigned den) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); if (num != 0 && den != 0) { vlc_ureduce(&num, &den, num, den, 0); @@ -454,6 +472,7 @@ void vout_ChangeSampleAspectRatio(vout_thread_t *vout, unsigned num, unsigned den) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vlc_mutex_lock(&sys->window_lock); sys->source.dar.num = num; @@ -469,6 +488,7 @@ void vout_ChangeSampleAspectRatio(vout_thread_t *vout, void vout_ChangeCropRatio(vout_thread_t *vout, unsigned num, unsigned den) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vlc_mutex_lock(&sys->window_lock); if (num != 0 && den != 0) { @@ -489,6 +509,7 @@ void vout_ChangeCropWindow(vout_thread_t *vout, int x, int y, int width, int height) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vout_control_cmd_t cmd; if (x < 0) @@ -522,6 +543,7 @@ void vout_ChangeCropBorder(vout_thread_t *vout, int left, int top, int right, int bottom) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vout_control_cmd_t cmd; if (left < 0) @@ -553,12 +575,14 @@ void vout_ChangeCropBorder(vout_thread_t *vout, void vout_ControlChangeFilters(vout_thread_t *vout, const char *filters) { + assert(!vout->p->dummy); vout_control_PushString(&vout->p->control, VOUT_CONTROL_CHANGE_FILTERS, filters); } void vout_ControlChangeSubSources(vout_thread_t *vout, const char *filters) { + assert(!vout->p->dummy); vlc_mutex_lock(&vout->p->spu_lock); if (likely(vout->p->spu != NULL)) spu_ChangeSources(vout->p->spu, filters); @@ -567,6 +591,7 @@ void vout_ControlChangeSubSources(vout_thread_t *vout, const char *filters) void vout_ControlChangeSubFilters(vout_thread_t *vout, const char *filters) { + assert(!vout->p->dummy); vlc_mutex_lock(&vout->p->spu_lock); if (likely(vout->p->spu != NULL)) spu_ChangeFilters(vout->p->spu, filters); @@ -575,6 +600,7 @@ void vout_ControlChangeSubFilters(vout_thread_t *vout, const char *filters) void vout_ChangeSubMargin(vout_thread_t *vout, int margin) { + assert(!vout->p->dummy); if (unlikely(vout->p->spu == NULL)) return; @@ -587,6 +613,7 @@ void vout_ChangeViewpoint(vout_thread_t *vout, const vlc_viewpoint_t *p_viewpoint) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vout_control_cmd_t cmd; vlc_mutex_lock(&sys->window_lock); @@ -1232,6 +1259,8 @@ static int ThreadDisplayPicture(vout_thread_t *vout, vlc_tick_t *deadline) void vout_ChangePause(vout_thread_t *vout, bool is_paused, vlc_tick_t date) { + assert(!vout->p->dummy); + vout_control_Hold(&vout->p->control); assert(!vout->p->pause.is_on || !is_paused); @@ -1292,6 +1321,7 @@ static void vout_FlushUnlocked(vout_thread_t *vout, bool below, void vout_Flush(vout_thread_t *vout, vlc_tick_t date) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); assert(vout->p->original.i_chroma != 0); @@ -1302,6 +1332,7 @@ void vout_Flush(vout_thread_t *vout, vlc_tick_t date) void vout_NextPicture(vout_thread_t *vout, vlc_tick_t *duration) { + assert(!vout->p->dummy); *duration = 0; vout_control_Hold(&vout->p->control); @@ -1324,6 +1355,7 @@ void vout_NextPicture(vout_thread_t *vout, vlc_tick_t *duration) void vout_ChangeDelay(vout_thread_t *vout, vlc_tick_t delay) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vout_control_Hold(&sys->control); vlc_clock_SetDelay(vout->p->clock, delay); @@ -1334,6 +1366,7 @@ void vout_ChangeDelay(vout_thread_t *vout, vlc_tick_t delay) void vout_ChangeRate(vout_thread_t *vout, float rate) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vout_control_Hold(&sys->control); sys->rate = rate; @@ -1342,6 +1375,7 @@ void vout_ChangeRate(vout_thread_t *vout, float rate) void vout_ChangeSpuDelay(vout_thread_t *vout, vlc_tick_t delay) { + assert(!vout->p->dummy); vlc_mutex_lock(&vout->p->spu_lock); if (vout->p->spu) spu_clock_SetDelay(vout->p->spu, delay); @@ -1351,6 +1385,7 @@ void vout_ChangeSpuDelay(vout_thread_t *vout, vlc_tick_t delay) void vout_ChangeSpuRate(vout_thread_t *vout, float rate) { + assert(!vout->p->dummy); vlc_mutex_lock(&vout->p->spu_lock); vout->p->spu_rate = rate; vlc_mutex_unlock(&vout->p->spu_lock); @@ -1408,6 +1443,7 @@ static void ThreadProcessMouseState(vout_thread_t *vout, static int vout_Start(vout_thread_t *vout, const vout_configuration_t *cfg) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); sys->mouse_event = cfg->mouse_event; sys->mouse_opaque = cfg->mouse_opaque; @@ -1525,6 +1561,7 @@ error: void vout_Cancel(vout_thread_t *vout, bool canceled) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vout_control_Hold(&sys->control); if (sys->decoder_pool != NULL) @@ -1707,6 +1744,7 @@ void vout_Pause(vout_thread_t *vout) void vout_Stop(vout_thread_t *vout) { vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); vout_StopDisplay(vout); @@ -1723,6 +1761,7 @@ void vout_Close(vout_thread_t *vout) assert(vout); vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); if (sys->original.i_chroma != 0) vout_Stop(vout); @@ -1747,6 +1786,12 @@ void vout_Release(vout_thread_t *vout) if (atomic_fetch_sub_explicit(&sys->refs, 1, memory_order_release)) return; + if (sys->dummy) + { + vlc_object_delete(VLC_OBJECT(vout)); + return; + } + free(vout->p->splitter_name); /* Destroy the locks */ @@ -1768,7 +1813,7 @@ void vout_Release(vout_thread_t *vout) vlc_object_delete(VLC_OBJECT(vout)); } -vout_thread_t *vout_Create(vlc_object_t *object) +static vout_thread_t *vout_CreateCommon(vlc_object_t *object) { /* Allocate descriptor */ vout_thread_t *vout = vlc_custom_create(object, @@ -1777,6 +1822,33 @@ vout_thread_t *vout_Create(vlc_object_t *object) if (!vout) return NULL; + vout_CreateVars(vout); + + vout_thread_sys_t *sys = (vout_thread_sys_t *)&vout[1]; + + vout->p = sys; + return vout; +} + +vout_thread_t *vout_CreateDummy(vlc_object_t *object) +{ + vout_thread_t *vout = vout_CreateCommon(object); + if (!vout) + return NULL; + + vout_thread_sys_t *sys = vout->p; + sys->dummy = true; + return vout; +} + +vout_thread_t *vout_Create(vlc_object_t *object) +{ + vout_thread_t *vout = vout_CreateCommon(object); + if (!vout) + return NULL; + vout_thread_sys_t *sys = vout->p; + sys->dummy = false; + /* Register the VLC variable and callbacks. On the one hand, the variables * must be ready early on because further initializations below depend on * some of them. On the other hand, the callbacks depend on said @@ -1784,13 +1856,8 @@ vout_thread_t *vout_Create(vlc_object_t *object) * visible and callbacks not triggerable before this function returns the * fully initialized object to its caller. */ - vout_CreateVars(vout); vout_IntfInit(vout); - vout_thread_sys_t *sys = (vout_thread_sys_t *)&vout[1]; - - vout->p = sys; - /* Get splitter name if present */ sys->splitter_name = config_GetType("video-splitter") ? var_InheritString(vout, "video-splitter") : NULL; @@ -1863,6 +1930,7 @@ int vout_Request(const vout_configuration_t *cfg, input_thread_t *input) vout_thread_t *vout = cfg->vout; vout_thread_sys_t *sys = vout->p; + assert(!sys->dummy); assert(vout != NULL); assert(cfg->fmt != NULL); assert(cfg->clock != NULL); diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h index 28d8c05e28..5c876db393 100644 --- a/src/video_output/vout_internal.h +++ b/src/video_output/vout_internal.h @@ -64,6 +64,8 @@ enum vout_crop_mode { /* */ struct vout_thread_sys_t { + bool dummy; + /* Splitter module if used */ char *splitter_name; @@ -193,6 +195,8 @@ struct vout_thread_sys_t */ vout_thread_t *vout_Create(vlc_object_t *obj) VLC_USED; +vout_thread_t *vout_CreateDummy(vlc_object_t *obj) VLC_USED; + /** * Returns a suitable vout or release the given one. * _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
