diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:41:43 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 21:57:34 +0200 |
commit | 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (patch) | |
tree | 198d4ff7665d89307f6ca2469fa38620a9eb1672 /modules/webm | |
parent | 07bc4e2f96f8f47991339654ff4ab16acc19d44f (diff) |
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
Diffstat (limited to 'modules/webm')
-rw-r--r-- | modules/webm/video_stream_webm.cpp | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 47c54b61e9..832e14d91a 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -55,16 +55,19 @@ public: ERR_FAIL_COND_MSG(!file, "Failed loading resource: '" + p_file + "'."); } ~MkvReader() { - if (file) + if (file) { memdelete(file); + } } virtual int Read(long long pos, long len, unsigned char *buf) { if (file) { - if (file->get_position() != (size_t)pos) + if (file->get_position() != (size_t)pos) { file->seek(pos); - if (file->get_buffer(buf, len) == len) + } + if (file->get_buffer(buf, len) == len) { return 0; + } } return -1; } @@ -72,10 +75,12 @@ public: virtual int Length(long long *total, long long *available) { if (file) { const size_t len = file->get_len(); - if (total) + if (total) { *total = len; - if (available) + } + if (available) { *available = len; + } return 0; } return -1; @@ -178,8 +183,9 @@ bool VideoStreamPlaybackWebm::has_loop() const { } float VideoStreamPlaybackWebm::get_length() const { - if (webm) + if (webm) { return webm->getLength(); + } return 0.0f; } @@ -200,8 +206,9 @@ Ref<Texture2D> VideoStreamPlaybackWebm::get_texture() const { } void VideoStreamPlaybackWebm::update(float p_delta) { - if ((!playing || paused) || !video) + if ((!playing || paused) || !video) { return; + } time += p_delta; @@ -244,11 +251,13 @@ void VideoStreamPlaybackWebm::update(float p_delta) { } video_frame = video_frames[video_frames_pos]; - if (!webm->readFrame(video_frame, audio_frame)) //This will invalidate frames + if (!webm->readFrame(video_frame, audio_frame)) { //This will invalidate frames break; //Can't demux, EOS? + } - if (video_frame->isValid()) + if (video_frame->isValid()) { ++video_frames_pos; + } }; bool video_frame_done = false; @@ -315,8 +324,9 @@ void VideoStreamPlaybackWebm::update(float p_delta) { video_frames[video_frames_pos] = video_frame; } - if (video_frames_pos == 0 && webm->isEOS()) + if (video_frames_pos == 0 && webm->isEOS()) { stop(); + } } void VideoStreamPlaybackWebm::set_mix_callback(VideoStreamPlayback::AudioMixCallback p_callback, void *p_userdata) { @@ -325,14 +335,16 @@ void VideoStreamPlaybackWebm::set_mix_callback(VideoStreamPlayback::AudioMixCall } int VideoStreamPlaybackWebm::get_channels() const { - if (audio) + if (audio) { return webm->getChannels(); + } return 0; } int VideoStreamPlaybackWebm::get_mix_rate() const { - if (audio) + if (audio) { return webm->getSampleRate(); + } return 0; } @@ -357,24 +369,30 @@ bool VideoStreamPlaybackWebm::should_process(WebMFrame &video_frame) { } void VideoStreamPlaybackWebm::delete_pointers() { - if (pcm) + if (pcm) { memfree(pcm); + } - if (audio_frame) + if (audio_frame) { memdelete(audio_frame); + } if (video_frames) { - for (int i = 0; i < video_frames_capacity; ++i) + for (int i = 0; i < video_frames_capacity; ++i) { memdelete(video_frames[i]); + } memfree(video_frames); } - if (video) + if (video) { memdelete(video); - if (audio) + } + if (audio) { memdelete(audio); + } - if (webm) + if (webm) { memdelete(webm); + } } /**/ @@ -384,8 +402,9 @@ VideoStreamWebm::VideoStreamWebm() {} Ref<VideoStreamPlayback> VideoStreamWebm::instance_playback() { Ref<VideoStreamPlaybackWebm> pb = memnew(VideoStreamPlaybackWebm); pb->set_audio_track(audio_track); - if (pb->open_file(file)) + if (pb->open_file(file)) { return pb; + } return nullptr; } @@ -443,7 +462,8 @@ bool ResourceFormatLoaderWebm::handles_type(const String &p_type) const { String ResourceFormatLoaderWebm::get_resource_type(const String &p_path) const { String el = p_path.get_extension().to_lower(); - if (el == "webm") + if (el == "webm") { return "VideoStreamWebm"; + } return ""; } |