mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
Better GstClock for pulsesrc
This clock uses the actual stream time (pa_stream_get_time) to get a more accurate timestamp. Conflicts: ext/pulse/pulsesrc.c
This commit is contained in:
parent
088c4442c4
commit
3bcae19398
1 changed files with 36 additions and 0 deletions
|
@ -104,6 +104,8 @@ static gboolean gst_pulsesrc_negotiate (GstBaseSrc * basesrc);
|
||||||
static GstStateChangeReturn gst_pulsesrc_change_state (GstElement *
|
static GstStateChangeReturn gst_pulsesrc_change_state (GstElement *
|
||||||
element, GstStateChange transition);
|
element, GstStateChange transition);
|
||||||
|
|
||||||
|
static GstClockTime gst_pulsesrc_get_time (GstClock * clock, GstPulseSrc * src);
|
||||||
|
|
||||||
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
|
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
|
||||||
# define FORMATS "{ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, U8 }"
|
# define FORMATS "{ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, U8 }"
|
||||||
#else
|
#else
|
||||||
|
@ -291,6 +293,15 @@ gst_pulsesrc_init (GstPulseSrc * pulsesrc)
|
||||||
/* this should be the default but it isn't yet */
|
/* this should be the default but it isn't yet */
|
||||||
gst_audio_base_src_set_slave_method (GST_AUDIO_BASE_SRC (pulsesrc),
|
gst_audio_base_src_set_slave_method (GST_AUDIO_BASE_SRC (pulsesrc),
|
||||||
GST_AUDIO_BASE_SRC_SLAVE_SKEW);
|
GST_AUDIO_BASE_SRC_SLAVE_SKEW);
|
||||||
|
|
||||||
|
/* override with a custom clock */
|
||||||
|
if (GST_AUDIO_BASE_SRC (pulsesrc)->clock) {
|
||||||
|
gst_object_unref (GST_AUDIO_BASE_SRC (pulsesrc)->clock);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_AUDIO_BASE_SRC (pulsesrc)->clock =
|
||||||
|
gst_audio_clock_new ("GstPulseSrcClock",
|
||||||
|
(GstAudioClockGetTimeFunc) gst_pulsesrc_get_time, pulsesrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1659,3 +1670,28 @@ mainloop_start_failed:
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstClockTime
|
||||||
|
gst_pulsesrc_get_time (GstClock * clock, GstPulseSrc * src)
|
||||||
|
{
|
||||||
|
pa_usec_t time = 0;
|
||||||
|
|
||||||
|
pa_threaded_mainloop_lock (src->mainloop);
|
||||||
|
|
||||||
|
if (gst_pulsesrc_is_dead (src, TRUE)) {
|
||||||
|
goto unlock_and_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pa_stream_get_time (src->stream, &time) < 0) {
|
||||||
|
GST_DEBUG_OBJECT (src, "could not get time");
|
||||||
|
time = GST_CLOCK_TIME_NONE;
|
||||||
|
} else {
|
||||||
|
time *= 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unlock_and_out:
|
||||||
|
pa_threaded_mainloop_unlock (src->mainloop);
|
||||||
|
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue