diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/theora/video_stream_theora.cpp | 15 | ||||
-rw-r--r-- | drivers/theora/video_stream_theora.h | 9 |
2 files changed, 21 insertions, 3 deletions
diff --git a/drivers/theora/video_stream_theora.cpp b/drivers/theora/video_stream_theora.cpp index 48529d563b..bea49e34b7 100644 --- a/drivers/theora/video_stream_theora.cpp +++ b/drivers/theora/video_stream_theora.cpp @@ -238,6 +238,8 @@ void VideoStreamPlaybackTheora::set_file(const String& p_file) { /* Ogg file open; parse the headers */ /* Only interested in Vorbis/Theora streams */ int stateflag = 0; + + int audio_track_skip=audio_track; while(!stateflag){ int ret=buffer_data(); if(ret==0)break; @@ -264,8 +266,14 @@ void VideoStreamPlaybackTheora::set_file(const String& p_file) { theora_p=1; }else if(!vorbis_p && vorbis_synthesis_headerin(&vi,&vc,&op)>=0){ /* it is vorbis */ - copymem(&vo,&test,sizeof(test)); - vorbis_p=1; + if (audio_track_skip) { + vorbis_info_clear(&vi); + vorbis_comment_clear(&vc); + audio_track_skip--; + } else { + copymem(&vo,&test,sizeof(test)); + vorbis_p=1; + } }else{ /* whatever it is, we don't care about it */ ogg_stream_clear(&test); @@ -677,7 +685,7 @@ int VideoStreamPlaybackTheora::get_channels() const{ void VideoStreamPlaybackTheora::set_audio_track(int p_idx) { - + audio_track=p_idx; } int VideoStreamPlaybackTheora::get_mix_rate() const{ @@ -701,6 +709,7 @@ VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() { texture = Ref<ImageTexture>( memnew(ImageTexture )); mix_callback=NULL; mix_udata=NULL; + audio_track=0; delay_compensation=0; }; diff --git a/drivers/theora/video_stream_theora.h b/drivers/theora/video_stream_theora.h index 77a9ae8667..95c7fe88f6 100644 --- a/drivers/theora/video_stream_theora.h +++ b/drivers/theora/video_stream_theora.h @@ -65,6 +65,8 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback { AudioMixCallback mix_callback; void* mix_udata; + int audio_track; + protected: void clear(); @@ -113,15 +115,22 @@ class VideoStreamTheora : public VideoStream { OBJ_TYPE(VideoStreamTheora,VideoStream); String file; + int audio_track; + + public: Ref<VideoStreamPlayback> instance_playback() { Ref<VideoStreamPlaybackTheora> pb = memnew( VideoStreamPlaybackTheora ); + pb->set_audio_track(audio_track); pb->set_file(file); return pb; } void set_file(const String& p_file) { file=p_file; } + void set_audio_track(int p_track) { audio_track=p_track; } + + VideoStreamTheora() { audio_track=0; } }; |