summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-01-23 17:58:17 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-01-23 17:58:17 -0300
commit784a3eeb90e392ca769a6be62a1a92e80a44188e (patch)
tree723e21f7c6ccfcf6719c9b22a75c7cba381ce67c
parenta04cd80a23bf636400ccd928484781a84655102c (diff)
-Fixed video stream theora not finishing when stream finishes, closes #3066
-rw-r--r--drivers/theora/video_stream_theora.cpp29
-rw-r--r--drivers/theora/video_stream_theora.h2
2 files changed, 26 insertions, 5 deletions
diff --git a/drivers/theora/video_stream_theora.cpp b/drivers/theora/video_stream_theora.cpp
index 0659f007e5..1d2e6b9dda 100644
--- a/drivers/theora/video_stream_theora.cpp
+++ b/drivers/theora/video_stream_theora.cpp
@@ -38,8 +38,16 @@ int VideoStreamPlaybackTheora:: buffer_data() {
}
int VideoStreamPlaybackTheora::queue_page(ogg_page *page){
- if(theora_p)ogg_stream_pagein(&to,page);
- if(vorbis_p)ogg_stream_pagein(&vo,page);
+ if(theora_p) {
+ ogg_stream_pagein(&to,page);
+ if (to.e_o_s)
+ theora_eos=true;
+ }
+ if(vorbis_p) {
+ ogg_stream_pagein(&vo,page);
+ if (vo.e_o_s)
+ vorbis_eos=true;
+ }
return 0;
}
@@ -238,6 +246,8 @@ void VideoStreamPlaybackTheora::clear() {
videobuf_ready = 0;
frames_pending = 0;
videobuf_time = 0;
+ theora_eos=false;
+ vorbis_eos=false;
if (file) {
memdelete(file);
@@ -281,6 +291,9 @@ void VideoStreamPlaybackTheora::set_file(const String& p_file) {
th_comment_init(&tc);
th_info_init(&ti);
+ theora_eos=false;
+ vorbis_eos=false;
+
/* Ogg file open; parse the headers */
/* Only interested in Vorbis/Theora streams */
int stateflag = 0;
@@ -499,7 +512,9 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
bool frame_done=false;
bool audio_done=false;
- while (!frame_done || !audio_done) {
+ bool theora_done=false;
+
+ while (!frame_done || (!audio_done && !vorbis_eos)) {
//a frame needs to be produced
ogg_packet op;
@@ -641,10 +656,14 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
break;
}
}
+
+
+ //print_line("no theora: "+itos(no_theora)+" theora eos: "+itos(theora_eos)+" frame done "+itos(frame_done));
+
#ifdef THEORA_USE_THREAD_STREAMING
- if (file && thread_eof && (no_vorbis || no_theora) && ring_buffer.data_left()==0) {
+ if (file && thread_eof && no_theora && theora_eos && ring_buffer.data_left()==0) {
#else
- if (file && /*!videobuf_ready && */ (no_vorbis || no_theora) && file->eof_reached()) {
+ if (file && /*!videobuf_ready && */ no_theora && theora_eos) {
#endif
printf("video done, stopping\n");
stop();
diff --git a/drivers/theora/video_stream_theora.h b/drivers/theora/video_stream_theora.h
index 3e144c0125..f07acb2935 100644
--- a/drivers/theora/video_stream_theora.h
+++ b/drivers/theora/video_stream_theora.h
@@ -36,6 +36,8 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback {
void video_write(void);
float get_time() const;
+ bool theora_eos;
+ bool vorbis_eos;
ogg_sync_state oy;
ogg_page og;