diff options
Diffstat (limited to 'modules/theora/video_stream_theora.cpp')
-rw-r--r-- | modules/theora/video_stream_theora.cpp | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index c75bec31df..bc8ca23d60 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -406,20 +406,19 @@ void VideoStreamPlaybackTheora::update(float p_delta) { ogg_packet op; bool no_theora = false; + bool buffer_full = false; - while (vorbis_p) { + while (vorbis_p && !audio_done && !buffer_full) { int ret; float **pcm; - bool buffer_full = false; - /* if there's pending, decoded audio, grab it */ ret = vorbis_synthesis_pcmout(&vd, &pcm); if (ret > 0) { const int AUXBUF_LEN = 4096; int to_read = ret; - int16_t aux_buffer[AUXBUF_LEN]; + float aux_buffer[AUXBUF_LEN]; while (to_read) { @@ -429,11 +428,7 @@ void VideoStreamPlaybackTheora::update(float p_delta) { for (int j = 0; j < m; j++) { for (int i = 0; i < vi.channels; i++) { - - int val = Math::fast_ftoi(pcm[i][j] * 32767.f); - if (val > 32767) val = 32767; - if (val < -32768) val = -32768; - aux_buffer[count++] = val; + aux_buffer[count++] = pcm[i][j]; } } @@ -602,10 +597,9 @@ bool VideoStreamPlaybackTheora::is_playing() const { void VideoStreamPlaybackTheora::set_paused(bool p_paused) { paused = p_paused; - //pau = !p_paused; }; -bool VideoStreamPlaybackTheora::is_paused(bool p_paused) const { +bool VideoStreamPlaybackTheora::is_paused() const { return paused; }; @@ -733,32 +727,10 @@ VideoStreamPlaybackTheora::~VideoStreamPlaybackTheora() { memdelete(file); }; -RES ResourceFormatLoaderVideoStreamTheora::load(const String &p_path, const String &p_original_path, Error *r_error) { - if (r_error) - *r_error = ERR_FILE_CANT_OPEN; - - VideoStreamTheora *stream = memnew(VideoStreamTheora); - stream->set_file(p_path); - - if (r_error) - *r_error = OK; - - return Ref<VideoStreamTheora>(stream); -} +void VideoStreamTheora::_bind_methods() { -void ResourceFormatLoaderVideoStreamTheora::get_recognized_extensions(List<String> *p_extensions) const { + ClassDB::bind_method(D_METHOD("set_file", "file"), &VideoStreamTheora::set_file); + ClassDB::bind_method(D_METHOD("get_file"), &VideoStreamTheora::get_file); - p_extensions->push_back("ogm"); - p_extensions->push_back("ogv"); -} -bool ResourceFormatLoaderVideoStreamTheora::handles_type(const String &p_type) const { - return (p_type == "VideoStream" || p_type == "VideoStreamTheora"); -} - -String ResourceFormatLoaderVideoStreamTheora::get_resource_type(const String &p_path) const { - - String exl = p_path.get_extension().to_lower(); - if (exl == "ogm" || exl == "ogv") - return "VideoStreamTheora"; - return ""; + ADD_PROPERTY(PropertyInfo(Variant::STRING, "file", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_file", "get_file"); } |