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
56 changes: 56 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build environment
description: >
System build tools, the pinned Rust toolchain and Bun, and the static media
engine (FFmpeg/mpv & co., scripts/build-media.sh) restored from cache or
built — everything the check and bundle jobs share. Runs on the Ubuntu
24.04 and macOS 26 runners.

runs:
using: composite
steps:
- name: System packages
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
mapfile -t pkgs < <(sed -e 's/#.*//' packaging/ubuntu/packages.txt)
sudo apt-get install -y --no-install-recommends "${pkgs[@]}"

# build-media.sh needs bash 4+ (assoc arrays); macOS ships 3.2 as
# /bin/bash. meson, nasm and pkg-config are not on the runner image.
- name: Build tools (Homebrew bash 5, meson, nasm, pkg-config)
if: runner.os == 'macOS'
shell: bash
run: brew install bash meson nasm pkg-config

- name: Rust (rust-toolchain.toml)
shell: bash
run: rustup toolchain install

- uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json

# FFmpeg/mpv & co. sources and static build, redone only when
# build-media.sh (tags, options) or the system packages change
- name: Media engine cache
uses: actions/cache@v6
with:
path: |
third_party/src
third_party/prefix
key: ${{ runner.os == 'Linux' && format('media-ubuntu24.04-{0}', hashFiles('.github/workflows/ci.yml.bump', 'scripts/build-media.sh', 'packaging/ubuntu/packages.txt')) || format('media-macos-{0}-{1}', runner.arch, hashFiles('.github/workflows/ci.yml.bump', 'scripts/build-media.sh')) }}

- name: Media engine
if: runner.os == 'Linux'
shell: bash
run: scripts/build-media.sh

- name: Media engine (incl. the macOS static tail)
if: runner.os == 'macOS'
shell: bash
run: '"$(brew --prefix)/bin/bash" scripts/build-media.sh'

- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
119 changes: 8 additions & 111 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,7 @@ jobs:
steps:
- uses: actions/checkout@v7

- name: System packages
run: |
sudo apt-get update
mapfile -t pkgs < <(sed -e 's/#.*//' packaging/ubuntu/packages.txt)
sudo apt-get install -y --no-install-recommends "${pkgs[@]}"

- name: Rust (rust-toolchain.toml)
run: rustup toolchain install

- uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json

# FFmpeg/mpv & co. sources and static build, redone only when
# build-media.sh (tags, options) or the system packages change
- name: Media engine cache
uses: actions/cache@v6
with:
path: |
third_party/src
third_party/prefix
key: media-ubuntu24.04-${{ hashFiles('.github/workflows/ci.yml.bump', 'scripts/build-media.sh', 'packaging/ubuntu/packages.txt') }}

- name: Media engine
run: scripts/build-media.sh

- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- uses: ./.github/actions/setup

- name: Frontend
run: |
Expand All @@ -85,32 +57,7 @@ jobs:
steps:
- uses: actions/checkout@v7

# build-media.sh needs bash 4+ (assoc arrays); macOS ships 3.2 as
# /bin/bash. meson, nasm and pkg-config are not on the runner image.
- name: Build tools (Homebrew bash 5, meson, nasm, pkg-config)
run: brew install bash meson nasm pkg-config

- name: Rust (rust-toolchain.toml)
run: rustup toolchain install

- uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json

- name: Media engine cache
uses: actions/cache@v6
with:
path: |
third_party/src
third_party/prefix
key: media-macos-${{ runner.arch }}-${{ hashFiles('.github/workflows/ci.yml.bump', 'scripts/build-media.sh') }}

- name: Media engine (incl. the macOS static tail)
run: '"$(brew --prefix)/bin/bash" scripts/build-media.sh'

- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- uses: ./.github/actions/setup

- name: Frontend
run: |
Expand Down Expand Up @@ -148,40 +95,15 @@ jobs:
wait "$testpid"

bundle:
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
# version tags, pushes to main and manual runs
if: &bundle-trigger startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
needs: check
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v7

- name: System packages
run: |
sudo apt-get update
mapfile -t pkgs < <(sed -e 's/#.*//' packaging/ubuntu/packages.txt)
sudo apt-get install -y --no-install-recommends "${pkgs[@]}"

- name: Rust (rust-toolchain.toml)
run: rustup toolchain install

- uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json

- name: Media engine cache
uses: actions/cache@v6
with:
path: |
third_party/src
third_party/prefix
key: media-ubuntu24.04-${{ hashFiles('.github/workflows/ci.yml.bump', 'scripts/build-media.sh', 'packaging/ubuntu/packages.txt') }}

- name: Media engine
run: scripts/build-media.sh

- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- uses: ./.github/actions/setup

# one binary (glibc 2.39) as .deb, AppImage and .rpm — like
# scripts/ubuntu-build.sh; the AppImage tools run without FUSE
Expand All @@ -206,39 +128,14 @@ jobs:
if-no-files-found: error

bundle-macos:
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
if: *bundle-trigger
needs: check-macos
runs-on: macos-26
timeout-minutes: 90
steps:
- uses: actions/checkout@v7

# build-media.sh needs bash 4+ (assoc arrays); macOS ships 3.2 as
# /bin/bash. meson, nasm and pkg-config are not on the runner image.
- name: Build tools (Homebrew bash 5, meson, nasm, pkg-config)
run: brew install bash meson nasm pkg-config

- name: Rust (rust-toolchain.toml)
run: rustup toolchain install

- uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json

- name: Media engine cache
uses: actions/cache@v6
with:
path: |
third_party/src
third_party/prefix
key: media-macos-${{ runner.arch }}-${{ hashFiles('.github/workflows/ci.yml.bump', 'scripts/build-media.sh') }}

- name: Media engine (incl. the macOS static tail)
run: '"$(brew --prefix)/bin/bash" scripts/build-media.sh'

- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- uses: ./.github/actions/setup

# Apple signing: import the certificate when the secrets are set;
# otherwise fall back to ad-hoc signing so the app runs at all on
Expand Down Expand Up @@ -407,7 +304,7 @@ jobs:
# the same triggers as the other bundles; the action uploads
# testpattern.flatpak as an artifact, which the release job picks up.
flatpak:
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
if: *bundle-trigger
needs: check
runs-on: ubuntu-24.04
timeout-minutes: 90
Expand Down
31 changes: 24 additions & 7 deletions src-tauri/src/cast/commands.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
//! The `cast_*` commands the UI drives casting with.

use super::*;
use std::sync::Arc;

use parking_lot::Mutex;
use tauri::{AppHandle, Emitter, Manager, Runtime, State};
use tokio::sync::mpsc;

use crate::error::{Error, Result};
use crate::playback::PlayRequest;
use crate::player::Player;
use crate::state::{AppState, read_blocking};
use crate::{playback, settings};

use super::discovery::{search, start_browsing};
use super::session::run;
use super::{
Cast, CastState, Cmd, Device, Devices, Item, Meta, STATUS_EVENT, Session, Status, emit_devices,
probe, relay, remember,
};

/// The cast devices found so far; the first call starts looking
/// (updates follow as `cast://devices`).
#[tauri::command]
pub fn cast_devices<R: Runtime>(app: AppHandle<R>, cast: State<'_, Cast>) -> Result<Devices> {
if cast.relay.is_none() {
return Err(Error::msg(
"Casting is unavailable: no network port could be opened",
"Casting is unavailable: no network port could be opened".into(),
));
}
// mDNS is optional: the search by address finds TVs without it
Expand All @@ -28,7 +45,7 @@ pub async fn cast_add_device<R: Runtime>(
address: String,
) -> Result<Device> {
let ip = probe::parse_address(&address)
.ok_or_else(|| Error::msg("Enter the TV's IP address, like 192.168.1.20"))?;
.ok_or_else(|| Error::msg("Enter the TV's IP address, like 192.168.1.20".into()))?;
let device = probe::probe(&state.http, ip).await.ok_or_else(|| {
Error::msg(format!(
"No Chromecast answered at {ip}. Check the address in the Google Home app."
Expand Down Expand Up @@ -84,7 +101,7 @@ pub async fn cast_play<R: Runtime>(
let reuse = match (&device_id, running) {
(None, Some(_)) => true,
(Some(id), Some(s)) => &s.device.id == id,
(None, None) => return Err(Error::msg("Not casting")),
(None, None) => return Err(Error::msg("Not casting".into())),
(Some(_), None) => false,
};
if reuse {
Expand All @@ -99,7 +116,7 @@ pub async fn cast_play<R: Runtime>(
return s
.tx
.send(Cmd::Load(item))
.map_err(|_| Error::msg("The cast session has ended"));
.map_err(|_| Error::msg("The cast session has ended".into()));
}

let id = device_id.unwrap_or_default();
Expand All @@ -108,15 +125,15 @@ pub async fn cast_play<R: Runtime>(
.lock()
.get(&id)
.cloned()
.ok_or_else(|| Error::msg("That TV is no longer on the network"))?;
.ok_or_else(|| Error::msg("That TV is no longer on the network".into()))?;
if let Some(old) = session.take() {
let _ = old.tx.send(Cmd::Stop);
}
let (tx, rx) = mpsc::unbounded_channel();
let status = Arc::new(Mutex::new(Status {
device_id: device.id.clone(),
device_name: device.name.clone(),
state: "connecting",
state: CastState::Connecting,
live: item.source.live,
volume: 1.0,
..Default::default()
Expand Down
11 changes: 10 additions & 1 deletion src-tauri/src/cast/discovery.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
//! Finding TVs: mDNS browsing, the remembered ones, and a sweep of the
//! local networks by address.

use super::*;
use std::net::{IpAddr, SocketAddr};
use std::sync::atomic::Ordering;
use std::time::Instant;

use tauri::{AppHandle, Manager, Runtime};

use crate::error::{Error, Result};
use crate::state::{AppState, read_blocking};

use super::{Cast, Device, SERVICE, SWEEP_EVERY, emit_devices, probe, remembered};

fn device_from(s: &mdns_sd::ResolvedService) -> Option<Device> {
// capabilities bit 0: video out (speakers and speaker groups lack it)
Expand Down
Loading
Loading