-Fixed video stream theora not finishing when stream finishes, closes #3066

This commit is contained in:
Juan Linietsky 2016-01-23 17:58:17 -03:00
parent a04cd80a23
commit 784a3eeb90
2 changed files with 26 additions and 5 deletions

View file

@ -38,8 +38,16 @@ int VideoStreamPlaybackTheora:: buffer_data() {
} }
int VideoStreamPlaybackTheora::queue_page(ogg_page *page){ int VideoStreamPlaybackTheora::queue_page(ogg_page *page){
if(theora_p)ogg_stream_pagein(&to,page); if(theora_p) {
if(vorbis_p)ogg_stream_pagein(&vo,page); 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; return 0;
} }
@ -238,6 +246,8 @@ void VideoStreamPlaybackTheora::clear() {
videobuf_ready = 0; videobuf_ready = 0;
frames_pending = 0; frames_pending = 0;
videobuf_time = 0; videobuf_time = 0;
theora_eos=false;
vorbis_eos=false;
if (file) { if (file) {
memdelete(file); memdelete(file);
@ -281,6 +291,9 @@ void VideoStreamPlaybackTheora::set_file(const String& p_file) {
th_comment_init(&tc); th_comment_init(&tc);
th_info_init(&ti); th_info_init(&ti);
theora_eos=false;
vorbis_eos=false;
/* Ogg file open; parse the headers */ /* Ogg file open; parse the headers */
/* Only interested in Vorbis/Theora streams */ /* Only interested in Vorbis/Theora streams */
int stateflag = 0; int stateflag = 0;
@ -499,7 +512,9 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
bool frame_done=false; bool frame_done=false;
bool audio_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 //a frame needs to be produced
ogg_packet op; ogg_packet op;
@ -641,10 +656,14 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
break; break;
} }
} }
//print_line("no theora: "+itos(no_theora)+" theora eos: "+itos(theora_eos)+" frame done "+itos(frame_done));
#ifdef THEORA_USE_THREAD_STREAMING #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 #else
if (file && /*!videobuf_ready && */ (no_vorbis || no_theora) && file->eof_reached()) { if (file && /*!videobuf_ready && */ no_theora && theora_eos) {
#endif #endif
printf("video done, stopping\n"); printf("video done, stopping\n");
stop(); stop();

View file

@ -36,6 +36,8 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback {
void video_write(void); void video_write(void);
float get_time() const; float get_time() const;
bool theora_eos;
bool vorbis_eos;
ogg_sync_state oy; ogg_sync_state oy;
ogg_page og; ogg_page og;