Files
subcast/scripts/dev-app.sh
向阳乔木 74f0429439 Playback, subtitle and video reliability: streaming ASR, local video sound, playback log
Audio
- Stall watchdog, wake recovery only when really stuck, and a clear failure notice
- Web Audio graph is closed per episode (trim-silence no longer locks the next
  episode at 1.45x or holds its volume) and attaches only to CORS-safe addresses
- Play intent survives the switch to the loopback proxy (was an endless spinner)
- Proxy route memory and pinned redirects for podcast audio

Subtitles
- Qwen3-ASR and cloud ASR stream lines chunk by chunk (VAD-split); live lines
  kept in time order
- Decoding runs in a child process (`--asr-worker --decode`)
- Every source passes `decodable_audio`: ffmpeg fallback, HE-AAC included
- Word timings from whisper, VAD sentence alignment, subtitle polish

Video
- Cached/downloaded video plays over the loopback `/f/<id>` route: through
  asset:// WKWebView exposed no audio track (pictures, no sound)
- Silent-picture check falls back to the stream; mid-play stall watchdog;
  stream address prewarmed when the embed is slow; refresh before expiry
- Video cache commands

Diagnostics and tests
- Local playback health log (paths, fallbacks, time to first sound/line,
  errors), copied from Settings > Advanced > Network check
- `offline::playable_roots` + test that the asset scope covers it
- Tests for HE-AAC detection, WAV round trip, isolated decode, local Range route

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 12:57:38 -08:00

90 lines
3.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# A local SubCast.app for trying changes, signed with the Developer ID like a release.
#
# Why sign: an ad-hoc build is known to the Keychain only by its hash, which changes on every build, so each
# new build asks for the login password again to read the saved API keys. Signed with the same identity and
# bundle id as the release, the Keychain recognises it as the same app: "Always Allow" once and it stays.
#
# scripts/dev-app.sh debug build, sign, open
# scripts/dev-app.sh --fast-release fast optimized build (no LTO, incremental), sign, open
# scripts/dev-app.sh --install also replace /Applications/SubCast.app before opening
# scripts/dev-app.sh --with-cli force rebuilding subcast-cli (reused from cache when omitted)
# scripts/dev-app.sh --no-open build, sign (and install if requested) without opening
set -euo pipefail
cd "$(dirname "$0")/.."
export PATH="$HOME/.cargo/bin:$PATH"
FAST_RELEASE=0
INSTALL=0
WITH_CLI=0
OPEN=1
while [ $# -gt 0 ]; do
case "$1" in
--fast-release) FAST_RELEASE=1 ;;
--install) INSTALL=1 ;;
--with-cli) WITH_CLI=1 ;;
--no-open) OPEN=0 ;;
*) echo "unknown option: $1" >&2; exit 2 ;;
esac
shift
done
START_TS=$(date +%s)
IDENTITY="${APPLE_SIGNING_IDENTITY:-Developer ID Application: xiangyang qiao (BRCU3DPFH4)}"
if ! security find-identity -v -p codesigning | grep -qF "$IDENTITY"; then
echo "Signing identity not found: $IDENTITY (set APPLE_SIGNING_IDENTITY)" >&2
exit 1
fi
TAURI_CFG='{"bundle":{"createUpdaterArtifacts":false}}'
if [ "$FAST_RELEASE" = 1 ]; then
PROFILE_DIR="fast-release"
TAURI_FLAGS=(--bundles app --no-sign --config "$TAURI_CFG" -- --profile fast-release)
CLI_CARGO_FLAGS=(--profile fast-release)
else
PROFILE_DIR="debug"
TAURI_FLAGS=(--debug --bundles app --no-sign --config "$TAURI_CFG")
CLI_CARGO_FLAGS=()
fi
APP="src-tauri/target/$PROFILE_DIR/bundle/macos/SubCast.app"
# The running copy holds the bundle open; quit it first.
osascript -e 'quit app id "ai.qiaomu.subcast"' >/dev/null 2>&1 || true
APPLE_SIGNING_IDENTITY="$IDENTITY" npx tauri build "${TAURI_FLAGS[@]}"
CLI_BIN=""
if [ "$WITH_CLI" = 0 ]; then
for cand in \
"src-tauri/target/$PROFILE_DIR/subcast-cli" \
"src-tauri/target/release/subcast-cli" \
"src-tauri/target/debug/subcast-cli" \
"/Applications/SubCast.app/Contents/MacOS/subcast-cli"; do
if [ -x "$cand" ]; then
CLI_BIN="$cand"
break
fi
done
fi
if [ -z "$CLI_BIN" ]; then
cargo build "${CLI_CARGO_FLAGS[@]}" -p subcast-cli
CLI_BIN="src-tauri/target/$PROFILE_DIR/subcast-cli"
fi
cp "$CLI_BIN" "$APP/Contents/MacOS/subcast-cli"
# Tauri signs when APPLE_SIGNING_IDENTITY is set; sign again explicitly so the result never depends on that.
codesign --force --deep --options runtime --entitlements src-tauri/Entitlements.plist --sign "$IDENTITY" "$APP"
codesign --verify --deep --strict "$APP"
codesign -d -r- "$APP" 2>&1 | grep designated
TARGET_APP="$APP"
if [ "$INSTALL" = 1 ]; then
rm -rf /Applications/SubCast.app
ditto "$APP" /Applications/SubCast.app
codesign --verify --deep --strict /Applications/SubCast.app
TARGET_APP="/Applications/SubCast.app"
fi
echo "==> Done in $(( $(date +%s) - START_TS ))s ($TARGET_APP)"
[[ "$OPEN" = 1 ]] && open "$TARGET_APP" || true