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 702972 - audioringbuffer: gst_audio_ring_buffer_prepare_read() might read partially written segment
audioringbuffer: gst_audio_ring_buffer_prepare_read() might read partially wr...
Status: RESOLVED INCOMPLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
1.0.7
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-06-24 12:55 UTC by Paul HENRYS
Modified: 2018-05-06 10:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (4.11 KB, patch)
2013-06-24 12:55 UTC, Paul HENRYS
none Details | Review
Patch (8.19 KB, patch)
2013-07-01 12:03 UTC, Paul HENRYS
none Details | Review
Patch (8.43 KB, patch)
2013-07-01 15:18 UTC, Paul HENRYS
none Details | Review

Description Paul HENRYS 2013-06-24 12:55:25 UTC
Created attachment 247632 [details] [review]
Patch

gst_audio_ring_buffer_prepare_read() reads per segment whereas default_commit() might not filled totally the segment depending on the sample offset for instance. This means that gst_audio_ring_buffer_prepare_read() might read a partially written segment.
In the patch in attachment, I added a "writepointer" which makes it possible to calculate the difference between the last written segment and the last read segment in gst_audio_ring_buffer_prepare_read(). If the difference is lower than 1 the function sets the readpointer (readptr) to the previous segment read and decrement segdone as it should be incremented later on by the function calling gst_audio_ring_buffer_prepare_read().

This adds an extra latency as there will be always at least one full segment in the audioringbuffer and there might be a more optimize way to handle such a case.

Please comments if I am saying something wrong :)
Comment 1 Sebastian Dröge (slomo) 2013-07-01 10:31:45 UTC
That would mean that a segment is read twice in the worst case if the writer thread is too slow with filling the segments?

(Also this breaks ABI, you should decrement the size of the gst_reserved pointer in the GstAudioRingBuffer struct and move the segwritten field right above it)
Comment 2 Paul HENRYS 2013-07-01 12:03:23 UTC
Created attachment 248127 [details] [review]
Patch
Comment 3 Paul HENRYS 2013-07-01 15:11:27 UTC
Apparently I did not post my last comment :s just provided a patch with a mistake...

Actually, it could be more than twice for instance when retrieving audio from the network with jitter. In any case, when reading more than once, it should read a cleared segment thus a silence (as done in gstaudiosink).
The third patch provided, add the forgotten modification in gstaudiosrc and correct the ABI (thx Sebastian). Thx to let me know if I am missing something there.
Comment 4 Paul HENRYS 2013-07-01 15:18:51 UTC
Created attachment 248155 [details] [review]
Patch
Comment 5 Sebastian Dröge (slomo) 2013-07-02 07:29:34 UTC
But wouldn't that mean that the source is too slow to fill the ringbuffer anyway, and realtime playback will never work properly? Also I think your patch causes A/V sync to get lost.

The idea is that the ringbuffer is always filled faster than it is read, and if that doesn't happen for a short moment the reader of the ringbuffer will shortly read old values from the ringbuffer, but later the writer will catch up again.
Comment 6 Sebastian Dröge (slomo) 2014-12-22 09:53:41 UTC
Paul?
Comment 7 Vivia Nikolaidou 2018-05-06 10:31:20 UTC
Closing this bug report as no further information has been provided. Please feel free to reopen this bug report if you can provide the information that was asked for in a previous comment.
Thanks!