video: fix prototype and cleanup at exit

This commit is contained in:
David Fort 2018-01-23 16:09:21 +01:00
parent a07efb73ec
commit 6e022ae07c
2 changed files with 36 additions and 4 deletions

View File

@ -215,6 +215,7 @@ error_frames:
}
void xf_video_geometry_init(xfContext *xfc, GeometryClientContext *geom)
{
xfc->geometry = geom;
@ -611,6 +612,30 @@ static UINT xf_video_VideoData(VideoClientContext* context, TSMM_VIDEO_DATA *dat
return CHANNEL_RC_OK;
}
static void xf_video_free(xfVideoContext *xfVideo)
{
xfVideo->xfc->video->VideoData = NULL;
EnterCriticalSection(&xfVideo->framesLock);
while (Queue_Count(xfVideo->frames))
{
xfVideoFrame *frame = Queue_Dequeue(xfVideo->frames);
if (frame)
xf_video_frame_free(&frame);
}
Queue_Free(xfVideo->frames);
LeaveCriticalSection(&xfVideo->framesLock);
DeleteCriticalSection(&xfVideo->framesLock);
if (xfVideo->currentPresentation)
xfPresentationContext_unref(xfVideo->currentPresentation);
BufferPool_Free(xfVideo->surfacePool);
free(xfVideo);
}
void xf_video_control_init(xfContext *xfc, VideoClientContext *video)
{
@ -619,13 +644,19 @@ void xf_video_control_init(xfContext *xfc, VideoClientContext *video)
video->PresentationRequest = xf_video_PresentationRequest;
}
void xf_video_control_uninit(xfContext *xfc, VideoClientContext *video)
{
xf_video_free(xfc->xfVideo);
}
void xf_video_data_init(xfContext *xfc, VideoClientContext *video)
{
video->VideoData = xf_video_VideoData;
PubSub_SubscribeTimer(xfc->context.pubSub, (pTimerEventHandler)xf_video_timer);
}
void xf_video_data_uninit(xfVideoContext *xfVideo)
void xf_video_data_uninit(xfContext *xfc, VideoClientContext *context)
{
PubSub_UnsubscribeTimer(xfVideo->xfc->context.pubSub, (pTimerEventHandler)xf_video_timer);
PubSub_UnsubscribeTimer(xfc->context.pubSub, (pTimerEventHandler)xf_video_timer);
}

View File

@ -29,11 +29,12 @@ typedef struct _xfVideoContext xfVideoContext;
void xf_video_geometry_init(xfContext *xfc, GeometryClientContext *geom);
void xf_video_control_init(xfContext *xfc, VideoClientContext *video);
void xf_video_control_uninit(xfContext *xfc, VideoClientContext *video);
void xf_video_data_init(xfContext *xfc, VideoClientContext *video);
void xf_video_data_uninit(xfVideoContext *xfVideo);
void xf_video_data_uninit(xfContext *xfc, VideoClientContext *context);
xfVideoContext *xf_video_new();
xfVideoContext *xf_video_new(xfContext *xfc);
#endif /* CLIENT_X11_XF_VIDEO_H_ */