Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ concurrency:

env:
PROFILE: lgpl
IPHONEOS_DEPLOYMENT_TARGET: "13.0"
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: "true"

Expand Down Expand Up @@ -115,6 +114,8 @@ jobs:
name: iOS device staticlib
runs-on: macos-14
timeout-minutes: 150
env:
IPHONEOS_DEPLOYMENT_TARGET: "13.0"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -138,6 +139,39 @@ jobs:
--target aarch64-apple-ios \
--no-default-features --features libass --crate-type staticlib

tvos:
name: tvOS simulator staticlib
runs-on: macos-14
timeout-minutes: 150
env:
TVOS_DEPLOYMENT_TARGET: "13.0"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- name: Install native build tools
run: brew install nasm meson ninja pkg-config
- name: Cache native dependencies
uses: actions/cache@v4
with:
path: third_party
key: native-v2-tvos-simulator-aarch64-min${{ env.TVOS_DEPLOYMENT_TARGET }}-${{ hashFiles('xtask/src/main.rs', 'third_party/patches/**') }}
- name: Build tvOS native dependencies
run: >-
cargo run --locked -p xtask -- deps build --all
--profile "$PROFILE" --target aarch64-apple-tvos-sim
- name: Compile tvOS static library
run: |
TVOS_SDKROOT="$(xcrun --sdk appletvsimulator --show-sdk-path)"
export SDKROOT="$TVOS_SDKROOT"
export BINDGEN_EXTRA_CLANG_ARGS_aarch64_apple_tvos_sim="--target=arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator -isysroot $TVOS_SDKROOT"
ERIKA_NATIVE_PROFILE="$PROFILE" ERIKA_NATIVE_TARGET="aarch64-apple-tvos-sim" \
cargo +nightly rustc -Z build-std=std,panic_abort --locked \
-p erika_capi --lib --release \
--target aarch64-apple-tvos-sim \
--no-default-features --features libass --crate-type staticlib

windows:
name: Windows ${{ matrix.arch }} build
runs-on: ${{ matrix.runner }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
/packages/erika_flutter/android/build/
/packages/erika_flutter/android/local.properties
/packages/erika_flutter/ios/native/
/packages/erika_flutter/tvos/native/
.DS_Store
4 changes: 2 additions & 2 deletions crates/erika/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ash = "0.38.0"
ash = "0.38.0"
glow = "0.17.0"

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos"))'.dependencies]
objc2.workspace = true
objc2-core-foundation.workspace = true
objc2-core-graphics = { workspace = true, features = ["CGColorSpace"] }
Expand All @@ -69,6 +69,6 @@ objc2-foundation.workspace = true
objc2-metal.workspace = true
objc2-quartz-core.workspace = true

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dev-dependencies]
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos"))'.dev-dependencies]
objc2.workspace = true
objc2-metal.workspace = true
10 changes: 8 additions & 2 deletions crates/erika/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fn main() {
println!("cargo:rerun-if-env-changed=ANDROID_API_LEVEL");
println!("cargo:rerun-if-env-changed=ANDROID_NDK_HOME");
println!("cargo:rerun-if-env-changed=ANDROID_NDK_ROOT");
println!("cargo:rerun-if-env-changed=TVOS_DEPLOYMENT_TARGET");
println!("cargo:rerun-if-changed=src/renderer/ohos_native_buffer.vert");
println!("cargo:rerun-if-changed=src/renderer/ohos_native_buffer.frag");
println!("cargo:rerun-if-changed=src/renderer/ohos_native_buffer.vert.spv");
Expand All @@ -25,7 +26,7 @@ fn main() {
enforce_bundled_ffmpeg_version(ffmpeg_version_major);

let target_os = env::var("CARGO_CFG_TARGET_OS").ok();
if target_os.as_deref() == Some("ios") {
if matches!(target_os.as_deref(), Some("ios" | "tvos")) {
println!("cargo:rustc-link-lib=framework=AudioToolbox");
} else if target_os.as_deref() == Some("android") {
for lib in [
Expand Down Expand Up @@ -113,7 +114,7 @@ fn main() {

if target_os.as_deref() == Some("windows") {
println!("cargo:rustc-link-lib=dwrite");
} else if matches!(target_os.as_deref(), Some("ios" | "macos")) {
} else if matches!(target_os.as_deref(), Some("ios" | "tvos" | "macos")) {
if target_os.as_deref() == Some("macos") {
println!("cargo:rustc-link-lib=framework=ApplicationServices");
}
Expand Down Expand Up @@ -286,6 +287,11 @@ fn inferred_native_target() -> Option<String> {
("android", "x86_64") => Some("x86_64-linux-android".to_string()),
("android", "x86") => Some("i686-linux-android".to_string()),
("ios", _) => Some("ios".to_string()),
("tvos", "aarch64") if env::var("CARGO_CFG_TARGET_ABI").as_deref() == Ok("sim") => {
Some("aarch64-apple-tvos-sim".to_string())
}
("tvos", "aarch64") => Some("aarch64-apple-tvos".to_string()),
("tvos", "x86_64") => Some("x86_64-apple-tvos".to_string()),
_ => None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/erika/src/apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum AppleDecodeBackend {
Software,
}

#[cfg(target_os = "ios")]
#[cfg(any(target_os = "ios", target_os = "tvos"))]
pub mod iosaudio {
use std::ffi::c_void;
use std::ptr::{self, NonNull};
Expand Down
12 changes: 8 additions & 4 deletions crates/erika/src/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ impl VideoDecodePreference {
}
}

#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos"))]
impl Default for VideoDecodePreference {
fn default() -> Self {
Self::VideoToolbox
Expand Down Expand Up @@ -567,7 +567,7 @@ impl Default for VideoDecodePreference {

#[cfg(not(any(
target_os = "macos",
target_os = "ios",
any(target_os = "ios", target_os = "tvos"),
target_os = "windows",
target_os = "android",
target_env = "ohos"
Expand Down Expand Up @@ -1603,8 +1603,12 @@ impl PlaybackSession {
let decoder_alive = self.video_decoder.is_some();
let discarded = self.discard_queued_frames_and_packets();
trace_discarded_playback_queues("seek_before_decoder_transition", discarded, decoder_alive);
let bypass_seek_keyframe_gate = cfg!(any(target_os = "macos", target_os = "ios"))
&& self.active_video_decoder_backend() == Some(DecoderBackend::VideoToolbox)
let bypass_seek_keyframe_gate = cfg!(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos"
)) && self.active_video_decoder_backend()
== Some(DecoderBackend::VideoToolbox)
&& self.active_video_codec_is_av1();
self.video_fallback_waiting_for_keyframe =
self.video_decoder.is_some() && !bypass_seek_keyframe_gate;
Expand Down
23 changes: 14 additions & 9 deletions crates/erika/src/presenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ use crossbeam_channel::{Receiver, Sender};
use crate::android::aaudio::{AAudioOutput, AAudioOutputConfig};
#[cfg(target_os = "macos")]
use crate::apple::coreaudio::{CoreAudioOutput, CoreAudioOutputConfig};
#[cfg(target_os = "ios")]
#[cfg(any(target_os = "ios", target_os = "tvos"))]
use crate::apple::iosaudio::{IosAudioQueueOutput, IosAudioQueueOutputConfig};
#[cfg(not(any(
target_os = "android",
target_os = "macos",
target_os = "ios",
any(target_os = "ios", target_os = "tvos"),
target_os = "windows",
target_env = "ohos"
)))]
Expand All @@ -47,7 +47,7 @@ use crate::ohos::ohaudio::{OHAudioOutput, OHAudioOutputConfig};
use crate::overlay::{OverlayFrame, OverlayTimeline, OverlayViewport};
#[cfg(any(target_os = "windows", target_os = "android"))]
use crate::playback::VideoDecodePreference;
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos"))]
use crate::renderer::metal::MetalRenderer;
use crate::renderer::metal::MetalRendererConfig;
#[cfg(feature = "libass")]
Expand Down Expand Up @@ -113,7 +113,7 @@ impl Default for PresenterAudioConfig {
ring_buffer: config.ring_buffer,
}
}
#[cfg(target_os = "ios")]
#[cfg(any(target_os = "ios", target_os = "tvos"))]
{
let config = IosAudioQueueOutputConfig::default();
Self {
Expand Down Expand Up @@ -144,7 +144,7 @@ impl Default for PresenterAudioConfig {
#[cfg(not(any(
target_os = "android",
target_os = "macos",
target_os = "ios",
any(target_os = "ios", target_os = "tvos"),
target_os = "windows",
target_env = "ohos"
)))]
Expand Down Expand Up @@ -2893,7 +2893,7 @@ fn build_renderer(
_metal_config: MetalRendererConfig,
) -> Result<Box<dyn RendererBackend>> {
match preference {
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos"))]
RendererBackendPreference::PlatformNative | RendererBackendPreference::Auto => {
Ok(Box::new(MetalRenderer::with_config(_metal_config)?))
}
Expand All @@ -2903,7 +2903,12 @@ fn build_renderer(
crate::renderer::d3d11::D3d11Renderer::with_config(_metal_config)?,
))
}
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "windows")))]
#[cfg(not(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "windows"
)))]
RendererBackendPreference::PlatformNative | RendererBackendPreference::Auto => {
build_wgpu_renderer(_metal_config)
}
Expand Down Expand Up @@ -2968,7 +2973,7 @@ fn build_audio_output(config: PresenterAudioConfig) -> Box<dyn AudioOutputBacken
ring_buffer: config.ring_buffer,
}))
}
#[cfg(target_os = "ios")]
#[cfg(any(target_os = "ios", target_os = "tvos"))]
{
Box::new(IosAudioQueueOutput::new(IosAudioQueueOutputConfig {
ring_buffer: config.ring_buffer,
Expand Down Expand Up @@ -2996,7 +3001,7 @@ fn build_audio_output(config: PresenterAudioConfig) -> Box<dyn AudioOutputBacken
#[cfg(not(any(
target_os = "android",
target_os = "macos",
target_os = "ios",
any(target_os = "ios", target_os = "tvos"),
target_os = "windows",
target_env = "ohos"
)))]
Expand Down
4 changes: 2 additions & 2 deletions crates/erika/src/renderer/metal/apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@ impl MetalRendererImpl {
layer: &CAMetalLayer,
source: crate::renderer::pipeline::SourceColorState,
) {
#[cfg(target_os = "ios")]
#[cfg(any(target_os = "ios", target_os = "tvos"))]
{
let _ = layer;
let _ = source;
return;
}

#[cfg(not(target_os = "ios"))]
#[cfg(not(any(target_os = "ios", target_os = "tvos")))]
{
if !self.output_mode.is_edr() {
return;
Expand Down
Loading
Loading