Commit Graph
9 Commits
Author SHA1 Message Date
TheM14 587ff24e86 Fix native PCM startup stall at the queue gate
The PCM queue cap was applied before the first output sample.  For any
input longer than about two seconds the gate could trigger while
samples_out was still zero, emit() had nothing to return, and process_pcm
returned without marking filter progress.  The decoder thread then stopped
and audio never became ready; short clips and E-AC-3 JOC were unaffected.

Only apply the cap after the first output sample, and mark progress when
the gate cannot emit.  This keeps the EOF flush bounded without blocking
startup.
2026-11-14 02:53:36 +08:00
TheM14 11b353e9b1 Bound native PCM lookahead and clear EOF state on seek
The PCM path decoded and pushed samples into joc_core without any
backpressure.  The kernel's rendered-output queue is bounded, but its
input queue is not, so a large part of the track could pile up and
joc_stream_flush() at EOF rendered all of it in one call, causing the
stall near the end of playback.

Keep at most 96000 samples (2 seconds at 48 kHz) between the samples
pushed into the renderer and the samples already handed to mpv.  When
that limit is reached, drain output and wait instead of decoding another
packet.  The flush at EOF then only has a short queue to process.

Also clear eof_pending/eof_frame and the PCM decoder's in-flight
frame/packet in ad_joc_reset().  Near the end of a track the demuxer may
already have delivered EOF; seeking back left the stale EOF state in
place, and the next process call wrote EOF immediately, closing the
track.

E-AC-3 JOC and the ad-joc-pcm=no path are unchanged.
2026-11-13 17:49:38 +08:00
TheM14 66359ff089 Add native ad-joc-pcm takeover with libswresample
- Add ad-joc-pcm (default no). With it disabled, non-E-AC-3 audio is handed
  directly to ad_lavc and the native component does not take PCM over.
- With ad-joc-pcm=yes, decode registered PCM/compressed codecs with
  libavcodec, convert to 48 kHz interleaved float32 through libswresample,
  and feed joc_core's JOC_STREAM_IN_PCM_LAYOUT path.
- Register common codecs (FLAC, MP3, AAC, AC3, TrueHD, DTS, ALAC, Vorbis,
  Opus, WavPack, APE, TTA, MPC and PCM variants) so ad=joc can select the
  native path for them.
- Keep the existing E-AC-3 JOC path unchanged; ad-joc-pcm only affects
  non-E-AC-3 inputs.
- Document the option in fork/mpv.conf.example and fork/README.md.
2026-11-13 14:23:35 +08:00
TheM14 f555235f2b Remove the cache lines the decoder was left with
The previous change dropped the SOFA input but left two lines of the old disk
cache block inside create(): the stream config was still assigned
hrtf_cache_policy, which the kernel no longer has, and the brace that closed the
block ended the binaural branch early. Both compilers stopped there, so the
Windows and the Android build agreed on the error.

The frame-length message in feed() is a size_t and uses %zu now, which the same
build reported as a warning.
2026-11-01 20:04:34 +08:00
TheM14 a2471ce502 Compile the fork decoder against the kernel that takes one HRTF input
ad_joc.c still asked the stream config for hrtf_sofa_path, hrtf_cache_dir and
hrtf_cache_policy, which the kernel no longer has; the same file is compiled by
the Windows and the Android build, so both stopped there.

The decoder now recognises only the Rosella model -- a JSON file containing a
personalized_hrtf object -- and passes its path to personalized_headphone_path.
The SOFA magic sniffing, the .jochrtf extension branch, the default cache
directory and the disk-cache retry path are gone, the default lookup is
HRTF/binaural.personalized_headphone, and the format warning for the frame length
uses %zu. The README, the fork docs and the example configs name the model file
instead of binaural.sofa.
2026-11-01 19:59:08 +08:00
TheM14 ecf14d8c32 Sync the Rosella filterbank choice into the plugin and the fork
The kernel can now render the Rosella path through either bank; expose
that choice in both front ends with the same values and the same
default.

- plugin: joc-rosella-filterbank = 1|2 (public|captured); unset means
  the kernel default (the public bank), and it applies only to
  joc-hrtf-source=rosella, logging a warning otherwise
- fork: --ad-joc-rosella-filterbank, the same values and default; it
  sits in the ad_joc option group, so it is read only when ad_joc
  decodes a Rosella model
- log the bank actually selected (public|captured) on both paths
- add a bank-2 case to tools/verify_parity.ps1
- document the key in both READMEs and the example config

Checked: the plugin builds, the option parser covers the numeric and
named spellings plus invalid values, and for both banks the plugin's
PCM is bit-identical to joc_cli with --rosella-filterbank 1|2.
2026-10-31 02:29:23 +08:00
TheM14 78f2c4b4bd Serve the renderer's channel order without touching the player's layout 2026-10-29 01:09:55 +08:00
TheM14 7d013fef46 Support the two 4.0 layouts in the plugin and the fork 2026-10-27 23:52:43 +08:00
TheM14 126e2cd233 Init mpv-joc 2026-10-18 21:31:38 +08:00