[xiph-commits] r3176 - liboggplay/trunk/plugin
tahn at svn.annodex.net
tahn at svn.annodex.net
Mon Jul 30 04:46:15 PDT 2007
Author: tahn
Date: 2007-07-30 04:46:15 -0700 (Mon, 30 Jul 2007)
New Revision: 3176
Modified:
liboggplay/trunk/plugin/plugin_gui_mac.c
Log:
Pause the audio playback if we get frames with no data after starting presentation (otherwise the video and audio gets out of sync).
Modified: liboggplay/trunk/plugin/plugin_gui_mac.c
===================================================================
--- liboggplay/trunk/plugin/plugin_gui_mac.c 2007-07-30 11:22:04 UTC (rev 3175)
+++ liboggplay/trunk/plugin/plugin_gui_mac.c 2007-07-30 11:46:15 UTC (rev 3176)
@@ -345,11 +345,13 @@
PluginWindowInfo * info = (PluginWindowInfo *)_info;
ThreadData td;
- bool paused = FALSE;
- bool drop_video_frame = FALSE;
- bool audio_ok = TRUE;
- int64_t playback_target = 0;
- int64_t time_ref = 0;
+ bool started_presenting = FALSE;
+ bool paused = FALSE;
+ bool drop_video_frame = FALSE;
+ bool audio_ok = TRUE;
+ bool audio_paused = FALSE;
+ int64_t playback_target = 0;
+ int64_t time_ref = 0;
int64_t cur_time;
int64_t offset;
int64_t bytes;
@@ -443,20 +445,44 @@
}
/*
- * Spin until we have some video or audio data (but wait for a bit first
- * so we don't chew too many cycles).
+ * Do we have any data to play with?
*/
bool have_video = (td.frame_data.video_data != NULL);
bool have_audio = (td.frame_data.samples != NULL && td.frame_data.size > 0);
if (!have_video && !have_audio) {
+
+ /*
+ * If we've started playing the video then suddenly don't have any
+ * data (which can happen with a low bandwidth connection), pause the
+ * audio to keep everything in sync.
+ */
+ if (started_presenting && td.audio_handle != NULL) {
+ sa_stream_pause(td.audio_handle);
+ audio_paused = TRUE;
+ }
+
+ /*
+ * Spin until we have some video or audio data (but wait for a bit first
+ * so we don't chew too many cycles).
+ */
if (!paused) {
free_oggplay_frame(info->oggplay_handle, &td.frame_data);
}
oggplay_millisleep(5);
continue;
}
+ started_presenting = TRUE;
/*
+ * And we're back!
+ */
+ if (audio_paused && td.audio_handle != NULL) {
+ audio_paused = FALSE;
+ sa_stream_resume(td.audio_handle);
+ playback_target = 0;
+ }
+
+ /*
* Pause mode handling. We can't implement pausing just by waiting on a
* semaphore because we need to keep updating the GL display so we handle
* resizing, scrolling and changing tabs. So we have to keep the loop
More information about the commits
mailing list