Restructure step 5: one media pipeline on a player host
- PlayerHost port (MediaKitHost): players by role, pins, hwdec policy, render probe, log routing, disposal order; the only media_kit user. - MediaPipeline: plan (one pure switch over state, origin, caps, presence) -> resolve -> open (prepared player promoted, else fresh) -> ready; commands queued during a switch apply once (P15); viewers play the buffer and wait for a dropped source without seek loops (D6). - Every web page resolved by our yt-dlp into an EDL with headers and cookies (danmaku excluded); mpv's ytdl_hook no longer used (ytdl=no). - D11: sign-in errors say which cookies were used and whether they hold any for the site. - Relay: 256 KiB slices read as they fill, superseded pulls released (seek-to-play ~4.2 s -> ~2.8 s, P29); own Jellyfin relay channel only when someone needs it (P28). - STARSYNC_SMOKE run and a Windows CI smoke step after the build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8970f2694b
commit
25b19f2d6a
47 files changed
+4083
-1728
No files matched your search
@@ -4,9 +4,11 @@ import 'dart:io';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:media_kit/media_kit.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import '../platform/desktop/media_kit_host.dart' show MediaKitHost;
|
||||
import '../platform/ports/player_host.dart';
|
||||
|
||||
// Poster frames for the Files source, made by mpv itself (no ffmpeg on
|
||||
// users' machines; Windows ships only libmpv). A hidden player per file
|
||||
// with `vo=null`: mpv still keeps the last decoded frame, so
|
||||
@@ -23,6 +25,9 @@ class Thumbnail {
|
||||
|
||||
const thumbnailWidth = 480;
|
||||
|
||||
/// The players thumbnails are made with (the app's host, set in `main`).
|
||||
PlayerHost thumbnailPlayers = MediaKitHost()..init();
|
||||
|
||||
/// Where thumbnails are cached; swapped in tests.
|
||||
Future<Directory> Function() thumbnailCacheRoot = getApplicationCacheDirectory;
|
||||
|
||||
@@ -33,7 +38,7 @@ const _timeout = Duration(seconds: 20);
|
||||
int _running = 0;
|
||||
final _waiting = <Completer<void>>[];
|
||||
final _inFlight = <String, Future<Thumbnail?>>{};
|
||||
final _players = <Player>{};
|
||||
final _players = <HostedPlayer>{};
|
||||
bool _closed = false;
|
||||
|
||||
/// App close: no new thumbnails, running ones stop at their next check
|
||||
@@ -49,7 +54,7 @@ Future<void> cancelAllThumbnails({
|
||||
for (final p in _players.toList()) {
|
||||
_players.remove(p);
|
||||
try {
|
||||
await p.dispose().timeout(deadline);
|
||||
await thumbnailPlayers.dispose(p).timeout(deadline);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
@@ -147,19 +152,10 @@ Future<Thumbnail?> _generate(
|
||||
String out,
|
||||
bool Function() cancelled,
|
||||
) async {
|
||||
final player = Player(
|
||||
configuration: const PlayerConfiguration(
|
||||
vo: 'null',
|
||||
muted: true,
|
||||
osc: false,
|
||||
libass: false,
|
||||
title: 'thumbnail',
|
||||
bufferSize: 4 << 20,
|
||||
),
|
||||
);
|
||||
final player = await thumbnailPlayers.create(PlayerRole.thumbnail);
|
||||
_players.add(player);
|
||||
try {
|
||||
final mpv = player.platform as NativePlayer;
|
||||
final mpv = player;
|
||||
for (final (k, v) in [
|
||||
('ao', 'null'),
|
||||
('aid', 'no'),
|
||||
@@ -176,7 +172,7 @@ Future<Thumbnail?> _generate(
|
||||
]) {
|
||||
await mpv.setProperty(k, v);
|
||||
}
|
||||
await player.open(Media(path), play: false);
|
||||
await player.open(path);
|
||||
final target = File(out);
|
||||
final deadline = DateTime.now().add(_timeout);
|
||||
while (DateTime.now().isBefore(deadline)) {
|
||||
@@ -199,6 +195,6 @@ Future<Thumbnail?> _generate(
|
||||
return null;
|
||||
} finally {
|
||||
// [cancelAllThumbnails] may have taken it already.
|
||||
if (_players.remove(player)) await player.dispose();
|
||||
if (_players.remove(player)) await thumbnailPlayers.dispose(player);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user