Commit afea01e6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

SHM: set true PTS instead of synthetic one (fixes #7579)

parent 9b3b6803
...@@ -117,13 +117,12 @@ static void no_detach (demux_sys_t *); ...@@ -117,13 +117,12 @@ static void no_detach (demux_sys_t *);
struct demux_sys_t struct demux_sys_t
{ {
/* Everything is read-only when timer is armed. */
const void *addr; const void *addr;
size_t length; size_t length;
size_t size; size_t size;
es_out_id_t *es; es_out_id_t *es;
mtime_t pts, interval; mtime_t interval;
/* pts is protected by the lock. The rest is read-only. */
vlc_mutex_t lock;
vlc_timer_t timer; vlc_timer_t timer;
void (*detach) (demux_sys_t *); void (*detach) (demux_sys_t *);
}; };
...@@ -223,7 +222,6 @@ static int Open (vlc_object_t *obj) ...@@ -223,7 +222,6 @@ static int Open (vlc_object_t *obj)
sys->interval = (float)CLOCK_FREQ / rate; sys->interval = (float)CLOCK_FREQ / rate;
if (!sys->interval) if (!sys->interval)
goto error; goto error;
sys->pts = VLC_TS_INVALID;
es_format_t fmt; es_format_t fmt;
es_format_Init (&fmt, VIDEO_ES, chroma); es_format_Init (&fmt, VIDEO_ES, chroma);
...@@ -238,7 +236,6 @@ static int Open (vlc_object_t *obj) ...@@ -238,7 +236,6 @@ static int Open (vlc_object_t *obj)
sys->es = es_out_Add (demux->out, &fmt); sys->es = es_out_Add (demux->out, &fmt);
/* Initializes demux */ /* Initializes demux */
vlc_mutex_init (&sys->lock);
if (vlc_timer_create (&sys->timer, Demux, demux)) if (vlc_timer_create (&sys->timer, Demux, demux))
goto error; goto error;
vlc_timer_schedule (sys->timer, false, 1, sys->interval); vlc_timer_schedule (sys->timer, false, 1, sys->interval);
...@@ -264,7 +261,6 @@ static void Close (vlc_object_t *obj) ...@@ -264,7 +261,6 @@ static void Close (vlc_object_t *obj)
demux_sys_t *sys = demux->p_sys; demux_sys_t *sys = demux->p_sys;
vlc_timer_destroy (sys->timer); vlc_timer_destroy (sys->timer);
vlc_mutex_destroy (&sys->lock);
sys->detach (sys); sys->detach (sys);
free (sys); free (sys);
} }
...@@ -329,15 +325,7 @@ static int Control (demux_t *demux, int query, va_list args) ...@@ -329,15 +325,7 @@ static int Control (demux_t *demux, int query, va_list args)
{ {
bool pausing = va_arg (args, int); bool pausing = va_arg (args, int);
if (!pausing) vlc_timer_schedule (sys->timer, false, !pausing, sys->interval);
{
vlc_mutex_lock (&sys->lock);
sys->pts = VLC_TS_INVALID;
es_out_Control (demux->out, ES_OUT_RESET_PCR);
vlc_mutex_unlock (&sys->lock);
}
vlc_timer_schedule (sys->timer, false,
pausing ? 0 : 1, sys->interval);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -367,17 +355,10 @@ static void Demux (void *data) ...@@ -367,17 +355,10 @@ static void Demux (void *data)
block_t *block = block_Alloc (sys->length); block_t *block = block_Alloc (sys->length);
if (block == NULL) if (block == NULL)
return; return;
memcpy (block->p_buffer, sys->addr, sys->length); memcpy (block->p_buffer, sys->addr, sys->length);
block->i_pts = block->i_dts = mdate ();
/* Send block */ /* Send block */
vlc_mutex_lock (&sys->lock); es_out_Control (demux->out, ES_OUT_SET_PCR, block->i_pts);
if (sys->pts == VLC_TS_INVALID)
sys->pts = mdate ();
block->i_pts = block->i_dts = sys->pts;
es_out_Control (demux->out, ES_OUT_SET_PCR, sys->pts);
es_out_Send (demux->out, sys->es, block); es_out_Send (demux->out, sys->es, block);
sys->pts += sys->interval;
vlc_mutex_unlock (&sys->lock);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment