Skip to content

Commit

Permalink
More winblows fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EIREXE committed Jul 27, 2023
1 parent cee77df commit aa3bd44
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ runs:
cd gdextension_build
echo "Building with flags:" platform=${{ inputs.platform }} target=${{ inputs.target }} ${{ env.SCONSFLAGS }}
scons platform=${{ inputs.platform }} target=${{ inputs.target }} ${{ env.SCONSFLAGS }}
ls -l bin/
ls -l build/addons/ffmpeg/
47 changes: 43 additions & 4 deletions .github/workflows/runner.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,55 @@
name: 🔗 GHA
on: [push, pull_request]
on:
push:
pull_request:
workflow_dispatch:
inputs:
doRelease:
description: 'Publish new release'
type: boolean
default: false
required: false

concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-runner
cancel-in-progress: true

jobs:
windows-build:
windows-build-debug:
name: 🏁 Windows
needs: static-checks
uses: ./.github/workflows/windows_builds.yml

with:
target: template_debug
windows-build-release:
name: 🏁 Windows Release
uses: ./.github/workflows/windows_builds.yml
with:
target: template_release
static-checks:
name: 📊 Static checks
uses: ./.github/workflows/static_checks.yml
publish_release:
name: Publish release
needs: [windows-build-debug, windows-build-release]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: windows
path: artifacts
- name: Create release
id: create_release
run: |
set -xe
shopt -s nullglob
RELDATE="$(date +'%Y-%m-%d %H:%M')"
NAME="Auto-Build $RELDATE"
TAGNAME="autobuild-$(date +'%Y-%m-%d-%H-%M')"
hub release create $(for a in artifacts/*.{zip,tar.xz}; do echo -a $a; done) -m "$NAME" -t "master" "$TAGNAME"
echo "tag_name=${TAGNAME}" >> $GITHUB_OUTPUT
echo "rel_date=${RELDATE}" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ github.token }}
52 changes: 25 additions & 27 deletions .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,68 @@
name: 🏁 Windows Builds
on:
workflow_call:
inputs:
target:
required: true
type: string

# Global Settings
# SCONS_CACHE for windows must be set in the build environment
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes
SCONS_CACHE_MSVC_CONFIG: true

concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-windows
cancel-in-progress: true
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-windows-${{ inputs.target }}

jobs:
build-windows:
# Windows 10 with latest image
runs-on: "windows-latest"
runs-on: "ubuntu-20.04"
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Editor (target=editor)
cache-name: windows-editor
target: editor
- name: Windows build - ${{ inputs.target }}
cache-name: windows
target: ${{ inputs.target }}
# Skip debug symbols, they're way too big with MSVC.
sconsflags: debug_symbols=no vsproj=yes windows_subsystem=console
bin: "./bin/godot.windows.editor.x86_64.exe"

- name: Template (target=template_release)
cache-name: windows-template
target: template_release
sconsflags: debug_symbols=no

sconsflags: debug_symbols=no use_mingw=yes
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Godot build cache
uses: ./.github/actions/cache
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Install mingw64
shell: sh
run: |
sudo apt-get install mingw-w64
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
- name: Setup python and scons
uses: ./.github/actions/deps

- name: Setup MSVC problem matcher
uses: ammaraskar/msvc-problem-matcher@master

- name: Compilation
uses: ./.github/actions/build
with:
sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }}
platform: windows
target: ${{ matrix.target }}
tests: ${{ matrix.tests }}

- name: Prepare artifact
- name: Calculate short sha
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Pack build
shell: sh
run: |
Remove-Item bin/* -Include *.exp,*.lib,*.pdb -Force
cd ./gdextension_build/build
zip -9 -r eirteam-ffmpeg-${{ steps.vars.outputs.sha_short }}-${{ inputs.target }}.zip *
- name: Upload artifact
uses: ./.github/actions/upload-artifact
with:
name: ${{ matrix.cache-name }}
name: windows
path: ./gdextension_build/build/*.zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ misc/hooks/pre-commit-custom-*

# Buildsystem
bin
gdextension_build/build
*.gen.*
compile_commands.json
platform/windows/godot_res.res
Expand Down
35 changes: 12 additions & 23 deletions SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,12 @@ import SCons

Import("env")

if not "RPATH" in env:
env.Append(RPATH=env.Literal("\\$$ORIGIN"))
if env["platform"] == "linuxbsd":
if not "RPATH" in env:
env.Append(RPATH=env.Literal("\\$$ORIGIN"))

env_ffmpeg = env.Clone()


def _jal_emitter(target, source, env):
print("EMITTER!!!")
target += ["" + x for x in ffmpeg_download.get_ffmpeg_install_sources(os.path.dirname(target[0].get_path()))]
print(target)
return target, source


def Command2(env, target, source, action, **kw):
"""Builds the supplied target files from the supplied
source files using the supplied action. Action may
be any type that the Builder constructor will accept
for an action."""
bkw = {"action": action, "target_factory": env.fs.Entry, "source_factory": env.fs.Entry, "emitter": _jal_emitter}

bld = SCons.Builder.Builder(**bkw)
return bld(env, target, source, **kw)


FFMPEG_DUMMY = "thirdparty/ffmpeg/LICENSE.txt"

ffmpeg_download_action = ffmpeg_download.ffmpeg_download_builder(
Expand All @@ -45,9 +27,16 @@ excluded = []
sources = [x for x in Glob("*.cpp") if str(x) not in excluded]

env_ffmpeg.Prepend(CPPPATH="thirdparty/ffmpeg/include")
env.Append(LIBPATH="thirdparty/ffmpeg/lib")
env.Append(LIBPATH=["#modules/ffmpeg/thirdparty/ffmpeg/lib"])

ffmpeg_libs = ["avcodec", "avfilter", "avformat", "avutil", "swresample", "swscale"]
env.Append(LIBS=ffmpeg_libs)

if env.msvc:
# MSVC: Think Different(tm)
env.Append(LINKFLAGS=[x + ".lib" for x in ffmpeg_libs])
else:
# mingw
env.Append(LIBS=ffmpeg_libs)

ffmpeg_install_action = ffmpeg_download.ffmpeg_install(env_ffmpeg, "#bin", "thirdparty/ffmpeg")
env_ffmpeg.Depends(ffmpeg_install_action, ffmpeg_download_action)
Expand Down
47 changes: 37 additions & 10 deletions et_video_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "gdextension_build/gdex_print.h"
#endif

#include "tracy_import.h"

void ETVideoStreamPlayback::seek_into_sync() {
decoder->seek(playback_position);
Vector<Ref<DecodedFrame>> decoded_frames;
Expand All @@ -42,6 +44,7 @@ void ETVideoStreamPlayback::seek_into_sync() {
}
decoder->return_frames(decoded_frames);
available_frames.clear();
available_audio_frames.clear();
}

double ETVideoStreamPlayback::get_current_frame_time() {
Expand All @@ -59,7 +62,18 @@ bool ETVideoStreamPlayback::check_next_frame_valid(Ref<DecodedFrame> p_decoded_f
return p_decoded_frame->get_time() <= playback_position && Math::abs(p_decoded_frame->get_time() - playback_position) < LENIENCE_BEFORE_SEEK;
}

bool ETVideoStreamPlayback::check_next_audio_frame_valid(Ref<DecodedAudioFrame> p_decoded_frame) {
// in the case of looping, we may start a seek back to the beginning but still receive some lingering frames from the end of the last loop. these should be allowed to continue playing.
if (looping && Math::abs((p_decoded_frame->get_time() - decoder->get_duration()) - playback_position) < LENIENCE_BEFORE_SEEK)
return true;

return p_decoded_frame->get_time() <= playback_position && Math::abs(p_decoded_frame->get_time() - playback_position) < LENIENCE_BEFORE_SEEK;
}

const char *const upd_str = "update_internal";

void ETVideoStreamPlayback::update_internal(double p_delta) {
ZoneScopedN("update_internal");
if (paused || !playing) {
return;
}
Expand Down Expand Up @@ -94,6 +108,8 @@ void ETVideoStreamPlayback::update_internal(double p_delta) {
bool got_new_frame = false;

while (available_frames.size() > 0 && check_next_frame_valid(available_frames[0])) {
ZoneScopedN("frame_receive");

if (last_frame.is_valid()) {
decoder->return_frame(last_frame);
}
Expand All @@ -109,8 +125,10 @@ void ETVideoStreamPlayback::update_internal(double p_delta) {
if (got_new_frame) {
if (texture.is_valid()) {
if (texture->get_size() != last_frame_image->get_size() || texture->get_format() != last_frame_image->get_format()) {
ZoneScopedN("Image update slow");
texture->set_image(last_frame_image); // should never happen, but life has many doors ed-boy...
} else {
ZoneScopedN("Image update fast");
texture->update(last_frame_image);
}
}
Expand All @@ -123,17 +141,22 @@ void ETVideoStreamPlayback::update_internal(double p_delta) {
}
}

PackedFloat32Array audio_frames = decoder->get_decoded_audio_frames();

while (available_audio_frames.size() > 0 && check_next_audio_frame_valid(available_audio_frames[0])) {
ZoneScopedN("Audio mix");
Ref<DecodedAudioFrame> audio_frame = available_audio_frames[0];
int sample_count = audio_frame->get_sample_data().size() / decoder->get_audio_channel_count();
#ifdef GDEXTENSION
if (audio_frames.size() > 0) {
mix_audio(audio_frames.size() / decoder->get_audio_channel_count(), audio_frames, 0);
}
mix_audio(sample_count, audio_frame->get_sample_data(), 0);
#else
if (mix_callback && audio_frames.size() > 0) {
mix_callback(mix_udata, audio_frames.ptr(), audio_frames.size() / decoder->get_audio_channel_count());
}
mix_callback(mix_udata, audio_frame->get_sample_data().ptr(), sample_count);
#endif
available_audio_frames.pop_front();
}
if (available_audio_frames.size() == 0) {
for (Ref<DecodedAudioFrame> frame : decoder->get_decoded_audio_frames()) {
available_audio_frames.push_back(frame);
}
}

buffering = decoder->is_running() && available_frames.size() == 0;

Expand Down Expand Up @@ -186,7 +209,10 @@ void ETVideoStreamPlayback::stop_internal() {
}

void ETVideoStreamPlayback::seek_internal(double p_time) {
decoder->seek(p_time);
decoder->seek(p_time * 1000.0f);
available_frames.clear();
available_audio_frames.clear();
playback_position = p_time * 1000.0f;
}

double ETVideoStreamPlayback::get_length_internal() const {
Expand All @@ -202,7 +228,7 @@ Ref<Texture2D> ETVideoStreamPlayback::get_texture_internal() const {
}

double ETVideoStreamPlayback::get_playback_position_internal() const {
return playback_position;
return playback_position / 1000.0;
}

int ETVideoStreamPlayback::get_mix_rate_internal() const {
Expand All @@ -220,6 +246,7 @@ void ETVideoStreamPlayback::clear() {
last_frame.unref();
last_frame_texture.unref();
available_frames.clear();
available_audio_frames.clear();
frames_processed = 0;
playing = false;
}
2 changes: 2 additions & 0 deletions et_video_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class ETVideoStreamPlayback : public VideoStreamPlayback {

Ref<VideoDecoder> decoder;
List<Ref<DecodedFrame>> available_frames;
List<Ref<DecodedAudioFrame>> available_audio_frames;
Ref<DecodedFrame> last_frame;
#ifndef FFMPEG_MT_GPU_UPLOAD
Ref<ImageTexture> last_frame_texture;
Expand All @@ -91,6 +92,7 @@ class ETVideoStreamPlayback : public VideoStreamPlayback {
void seek_into_sync();
double get_current_frame_time();
bool check_next_frame_valid(Ref<DecodedFrame> p_decoded_frame);
bool check_next_audio_frame_valid(Ref<DecodedAudioFrame> p_decoded_frame);
bool paused = false;
bool playing = false;

Expand Down
Loading

0 comments on commit aa3bd44

Please sign in to comment.