[vlc-commits] OSS: synchronize start of playback (fixes: #7213)
Rémi Denis-Courmont
git at videolan.org
Thu Aug 30 23:04:31 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Aug 31 00:00:56 2012 +0300| [c36ef28adb260c01da6e8ee9f51ed272df080624] | committer: Rémi Denis-Courmont
OSS: synchronize start of playback (fixes: #7213)
This is untested as the bug could not be reproduced locally.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c36ef28adb260c01da6e8ee9f51ed272df080624
---
modules/audio_output/oss.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/modules/audio_output/oss.c b/modules/audio_output/oss.c
index f1189bf..8f9c88d 100644
--- a/modules/audio_output/oss.c
+++ b/modules/audio_output/oss.c
@@ -55,6 +55,7 @@ struct aout_sys_t
int fd;
uint8_t level;
bool mute;
+ bool starting;
};
static int Open (vlc_object_t *);
@@ -250,6 +251,7 @@ static int Open (vlc_object_t *obj)
aout->mute_set = MuteSet;
}
}
+ sys->starting = true;
/* Build the devices list */
var_Create (aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE);
@@ -329,12 +331,24 @@ static void Play (audio_output_t *aout, block_t *block,
{
mtime_t latency = (delay * CLOCK_FREQ * aout->format.i_frame_length)
/ (aout->format.i_rate * aout->format.i_bytes_per_frame);
- /* TODO: insert zeroes when starting playback */
*drift = mdate () + latency - block->i_pts;
}
else
msg_Warn (aout, "cannot get delay: %m");
+ if (sys->starting)
+ { /* Start on time */
+ /* TODO: resync on pause resumption and underflow recovery */
+ mtime_t delta = -*drift;
+ if (delta > 0) {
+ msg_Dbg(aout, "deferring start (%"PRId64" us)", delta);
+ msleep(delta);
+ *drift = 0;
+ } else
+ msg_Warn(aout, "starting late (%"PRId64" us)", delta);
+ sys->starting = false;
+ }
+
while (block->i_buffer > 0)
{
ssize_t bytes = write (fd, block->p_buffer, block->i_buffer);
More information about the vlc-commits
mailing list