mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-10-21 05:01:26 -07:00
Merge remote-tracking branch 'origin/main' into add-hachidori-backend
This commit is contained in:
3 files changed
+28
-1
No files matched your search
@@ -39,6 +39,22 @@ describe('buildMediaTimingPreviewArgs', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps macOS previews on coreaudio with packed float output', () => {
|
||||
const options = { mediaPath: '/tmp/window.mkv' };
|
||||
|
||||
assert.ok(
|
||||
buildMediaTimingPreviewArgs('/tmp/review.sock', options, 'darwin').includes(
|
||||
'--audio-format=float',
|
||||
),
|
||||
);
|
||||
assert.equal(
|
||||
buildMediaTimingPreviewArgs('/tmp/review.sock', options, 'linux').some((arg) =>
|
||||
arg.startsWith('--audio-format='),
|
||||
),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('separates an option-like media path without adding optional audio arguments', () => {
|
||||
const args = buildMediaTimingPreviewArgs('/tmp/review.sock', {
|
||||
mediaPath: '--fullscreen',
|
||||
|
||||
@@ -44,6 +44,7 @@ interface MediaTimingPreviewDeps {
|
||||
export function buildMediaTimingPreviewArgs(
|
||||
socketPath: string,
|
||||
options: MediaTimingPreviewStartOptions,
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
): string[] {
|
||||
const args = [
|
||||
'--no-config',
|
||||
@@ -66,6 +67,12 @@ export function buildMediaTimingPreviewArgs(
|
||||
if (options.absoluteTimestamps) {
|
||||
args.push('--rebase-start-time=no');
|
||||
}
|
||||
if (platform === 'darwin') {
|
||||
// coreaudio can reject planar float (what Opus decodes to) on Bluetooth outputs such as
|
||||
// AirPods, and mpv then falls back to avfoundation. Its 2 s device buffer makes time-pos
|
||||
// updates sparse and ends the clip well before the audio does, so the preview cursor jumps.
|
||||
args.push('--audio-format=float');
|
||||
}
|
||||
args.push('--', options.mediaPath);
|
||||
return args;
|
||||
}
|
||||
@@ -170,7 +177,7 @@ export class MediaTimingPreviewSession {
|
||||
this.startupError = null;
|
||||
const child = this.deps.spawnProcess(
|
||||
command,
|
||||
buildMediaTimingPreviewArgs(socketPath, { ...options, mediaPath }),
|
||||
buildMediaTimingPreviewArgs(socketPath, { ...options, mediaPath }, this.deps.platform),
|
||||
);
|
||||
this.process = child;
|
||||
child.once('error', (error) => {
|
||||
|
||||
Reference in new issue
Block a user