After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 673977 - Use pulseaudio stream time for the pulsesrc clock
Use pulseaudio stream time for the pulsesrc clock
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
0.10.x
Other Linux
: Normal normal
: 0.10.32
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-04-12 10:32 UTC by Mohammed Sameer
Modified: 2012-06-07 13:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch. (2.02 KB, patch)
2012-04-12 10:32 UTC, Mohammed Sameer
none Details | Review
Test case (1.64 KB, text/plain)
2012-04-16 15:22 UTC, Mohammed Sameer
  Details

Description Mohammed Sameer 2012-04-12 10:32:17 UTC
Created attachment 211913 [details] [review]
proposed patch.

This patch makes pulsesrc provide a clock that uses the pulseaudio stream time.

This allows getting more accurate timestamps which helps to synchronize AV while recording.

The main issue is that we need to use the audio source clock as the clock for the recording pipeline and the pulse source clock is a bit course because it depends on the samples read.
Comment 1 Wim Taymans 2012-04-16 14:27:45 UTC
Did you measure any difference? The pulse clock does not only depend on the number of samples read but also on the amount of samples ready for reading from pulsesrc (with pa_stream_get_latency()). The combination of number of samples read and available is exactly what pa_stream_get_time() also uses.
Comment 2 Mohammed Sameer 2012-04-16 15:22:25 UTC
Created attachment 212149 [details]
Test case

I can only measure it if I use an arm board but not on the desktop.

I'm attaching a simple test case (Build via: gcc -o pulsesrctest pulsesrctest.c  `pkg-config --cflags --libs gstreamer-0.10`)

The test case tries 30 times per second to get the time from the pipeline clock and the time from the system monotonic clock and calculates the difference to the previous value and prints it.

Here are the values of the original element:
0	0	0
35	0	-35
33	0	-33
33	22	-11
33	79	46
33	0	-33
33	73	40
33	34	1
33	59	26
33	0	-33
33	0	-33
33	67	34
33	33	0
33	0	-33
33	70	37
34	0	-34
33	89	56
33	11	-22
38	60	22
35	0	-35
34	0	-34
33	75	42
33	15	-18
33	0	-33
33	69	36
36	0	-36
33	85	52
33	0	-33
33	85	52
33	0	-33
36	0	-36
33	85	52
33	10	-23
33	0	-33
33	75	42
36	0	-36
33	85	52
33	3	-30
34	81	47
33	0	-33
34	0	-34
33	85	52
33	17	-16
33	0	-33
33	73	40
36	79	43
33	0	-33
33	11	-22
33	0	-33
33	74	41
36	0	-36
33	85	52
33	23	-10
33	0	-33
33	73	40
36	73	37
33	0	-33
36	18	-18


And here are the values after patching pulsesrc:
0	0	0
33	33	0
33	33	0
33	33	0
33	34	1
34	35	1
37	40	3
33	36	3
33	36	3
33	37	4
33	38	5
36	40	4
33	36	3
33	34	1
33	34	1
33	33	0
35	34	-1
33	31	-2
33	31	-2
35	32	-3
33	30	-3
33	30	-3
33	30	-3
33	30	-3
33	31	-2
34	32	-2
33	31	-2
33	31	-2
33	31	-2
33	31	-2
33	32	-1
33	31	-2
36	34	-2
33	32	-1
33	32	-1
37	36	-1
35	34	-1
33	32	-1
36	35	-1
33	32	-1
36	35	-1
33	32	-1
36	36	0
33	32	-1
33	32	-1
33	33	0
33	33	0
33	33	0
33	33	0
33	33	0
36	36	0
33	33	0
33	33	0
33	33	0
33	33	0
36	37	1
33	33	0
33	33	0

As you can see, the difference between both clocks after patching pulsesrc is more uniform.
Comment 3 Wim Taymans 2012-06-07 13:07:15 UTC
commit e62d5bdace82f263385d005dcc2f57560cdfcdb9
Author: Mohammed Sameer <msameer@foolab.org>
Date:   Thu Apr 12 13:21:17 2012 +0300

    Better GstClock for pulsesrc
    
    This clock uses the actual stream time (pa_stream_get_time) to get a more accurate timestamp.


commit f14a69fe260a21a9e3df0f34c46223a445f30ac9
Author: Wim Taymans <wim.taymans@collabora.co.uk>
Date:   Thu Jun 7 15:03:02 2012 +0200

    pulsesrc: improve clock handling
    
    Post the notify outside of the pa_lock to avoid a deadlock caused by basesrc
    calling get_time with the object lock.
    Reset the clock on connect.
    Post clock-lost and clock-provide messages.
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=673977