Commit Graph
470 Commits
Author SHA1 Message Date
zarzet a4a476e44e feat(playback): spatial audio switch for the platform spatializer
A Spatial audio switch in Playback settings, on by default, in the Audio
output group of both styles: after Skip silence on Android, after
exclusive output on macOS, and in its own Audio output group on iOS.
Windows and Linux have no row and no search entry. The app renders
nothing; the switch only tells the platform whether it may spatialize.

- media3: a new `setSpatialAudio` call maps to the audio attributes'
  spatialization behavior (auto or never). It applies live: the sink
  reopens its AudioTrack and drops its buffer, so native seeks to the
  current position to decode that audio again instead of skipping it.
- Old Android engine: the fork takes `setSpatialAudio` on its player
  channel (no platform interface change) and sets the behavior on API
  32+ as each source loads, so a change applies from the next song. The
  subtitle says so while the new engine is off.
- iOS and macOS: the Darwin fork sets allowedAudioSpatializationFormats
  (iOS 14, macOS 11) to mono, stereo and multichannel or to none, on the
  current item and every new one.

The subtitle ends with a live status line. Android reads the
Spatializer (available, enabled, head tracker, and canBeSpatialized for
stereo and 5.1) over a new event channel that re-reads on spatializer,
head tracker and device changes and on resume. iOS reports whether the
output port has spatial audio enabled, on route and spatial capability
changes. The line names the direct USB and AAudio paths and macOS
exclusive output, which never reach the system's spatial audio.
2026-11-09 02:41:48 +07:00
zarzet 46db8c84b8 Merge branch 'feat/batch-sw' into feat/batch-int 2026-11-08 16:50:00 +07:00
zarzet ddf8741534 fix(haptics): let swipe ticks follow the touch feedback setting
The native pulse channel takes an optional usage. Touch pulses play
with VibrationAttributes.USAGE_TOUCH on Android 13 and later, and as
assistance sonification below that, so the system's touch feedback
switch controls them. A pulse without a usage stays media vibration,
so Music Haptics is unchanged. iOS ignores the usage. The queue swipe's
haptics now send touch pulses.
2026-11-08 16:49:40 +07:00
zarzet 0b390d60c6 feat(playback): skip silence on the new Android engine
A Skip silence switch in Playback settings, off by default, shown on
Android phones and tablets under the new playback engine. It works only
through media3: while that engine is off the switch is disabled and its
subtitle says why. Changes apply live through a new `setSkipSilence`
call on the media3 channel, sent after `create` and on every change.

media3 skips silence in its audio processor chain, which it bypasses
for float PCM, and it asks every decoder for float once the sink takes
float output. While the setting is on, the renderer therefore asks
decoders for 16-bit PCM and refuses to reuse a decoder set up for the
other mode, so hi-res sources lose their low bits while it is on (the
subtitle says so). A decoder already running keeps its mode: turning
it on mid-song starts skipping from the next song, turning it off
stops at once.

Interplay:
- AutoMix: suspended while AutoMix is on. AutoMix times its fade start
  and beat matching on the clock from analysed file positions, which
  skipping would outrun. The subtitle says so.
- Gapless: `queueNext` stays on the same player, so the trailing and
  leading silence around the handoff is skipped too; the 30 s lead
  leaves the queue call far ahead of the end.
- Position, duration, synced lyrics: media3 reports media time, which
  jumps forward over a skipped passage, so lyrics stay in sync and the
  duration is unchanged.
- Scrobbling and listening statistics count listened wall time, so a
  song with long silences counts slightly less time; the thresholds are
  far from that.
2026-11-08 16:23:27 +07:00
zarzet a2c01d72bf feat(library): use folder images as covers for songs without one
Large libraries often keep album art as cover.jpg or folder.jpg beside
the songs instead of embedding it, so those songs showed no cover.

When a song has no embedded artwork, local scans now fall back to an
image in its folder: cover, folder, front, album, albumart (jpg, jpeg,
png, webp), case-insensitive, ignoring hidden and AppleDouble files. A
disc folder (CD1, Disc 2, ...) without one uses its parent's image.
Embedded artwork always wins.

The Rust path scan (desktop, iOS, Android file paths) picks the image
from the directory listing it already makes and hands it to the
workers; the thumbnail key includes the image path, size and mtime, so
a replaced image gets a new thumbnail. CUE tracks get the same
fallback. The Android SAF scan picks the image from its own listing
through new FFI helpers and makes each image into a content-named
thumbnail once per scan.
2026-11-08 15:54:58 +07:00
zarzet e0653009b2 build(android): update Media3 to 1.11.1
Pins every androidx.media3 module to 1.11.1 from the root build, so
video_player_android's exoplayer, HLS, DASH, RTSP and SmoothStreaming
modules (which still ask for 1.9.2) resolve to the same version as the
playback engine.

1.11.1 keeps the float output and Sonic rules the engine relies on for
high resolution PCM and platform speed changes. The PCM AudioTrack
buffer is now a fixed 500 ms instead of four times the platform minimum,
so with the 2x cap the engine buffers 1 s at 1x; the comments now say so.
2026-11-08 03:45:07 +07:00
zarzet 3c20cac699 feat(files): remove the folders a deleted song leaves empty
Deleting songs from the app left their album and artist folders behind,
so people had to clean them up with a file manager. The song's own .lrc
and .mlrc files stayed too, which kept those folders from being empty.

Deleting a song now also deletes its .lrc and .mlrc files, unless
another song in the folder has the same name. Settings > Files >
Existing Files gains Remove Empty Folders, on by default: once a song is
gone, the folders it leaves empty are removed, up to but never including
the download folder or a Local Library folder, and never a storage,
volume or home folder or a folder right inside one, such as Music or
Download. A folder still counts as empty when it only holds system index
files, Mornye's cover.mp4 or lyrics files of songs that are gone.
Folders are removed while the download queue is idle, so a download
never loses the folder it writes into.

Every place that deletes a song from the library goes through this:
the library and album screens, song details, Duplicate Review and
Mornye Link. Android storage access folders work through two new
platform calls that find a song's folders before it is deleted and list
a folder. Network songs and CUE tracks are only deleted, as before.
2026-11-08 02:43:14 +07:00
zarzet 5c513133f7 fix(android): size the media3 audio buffer for 2x speed
With AudioTrack playback parameters media3 sizes the PCM buffer for 8x
speed, about 3 s at normal speed. Once a song's end is in that buffer the
track is told to play out, so a song queued later (for example after a
seek near the end) made the handoff open a new AudioTrack with a short
gap. Size the buffer for 2x instead, a quarter of the size and still at
least the normal buffer's time up to 2x, above the app's 1.2x maximum.
Volume, speed and the session equalizer act after the buffer.

Add an instrumentation test that measures queued handoffs with an
analytics listener: audio tracks opened, underruns and total play time.
2026-11-08 00:17:44 +07:00
zarzet 884864745d feat(android): add a media3 ExoPlayer playback engine channel
Add com.zarz.mornye/media3_player with per-player event channels for
ordinary mixer playback through media3 1.9.2, the version
video_player_android already bundles. Players live on one owned
HandlerThread looper; create replies after its event channel is
registered. Offload, audio focus and becoming-noisy handling are off,
the session id is set before the first source, and the wake mode follows
the source type.

SAF leases are duplicated and read through media3's
FileDescriptorDataSource, closed once the item has left the playlist and
its last reader closed. queueNext appends to the same playlist for
gapless playback and reports the transition; a queued item whose load
fails is dropped so the current one plays out, then reported as the
failed current item. High-resolution PCM uses float output with platform
playback parameters for speed. The DynamicsProcessing equalizer is
copied from the audioplayers fork.
2026-11-08 00:17:44 +07:00
zarzet 9379513549 fix(player): keep the lyric line opt-in and in sync
Follow-up to the lyric line under the track title (PR #847).

- The setting is off by default; Lyrics settings and settings search turn
  it on, with localized English and Indonesian strings.
- Opening the player no longer probes unresolved SAF documents for the
  line. It shows once playback publishes the resolved source, as before.
- The line follows audio_service's extrapolated position, the playback
  speed and the lyrics timing offset, like the desktop mini player. The
  timer targets the next line's start with the 80 ms lead applied, so it
  no longer fires zero-delay timers before each line, and it stops while
  paused, buffering, seeking or offstage.
- With the setting off nothing subscribes to playback.
- A translated line shows as plain text; word timing applies only to the
  original line.
- Text uses the theme's body style, the chevron mirrors in right-to-left
  layouts, alignment is directional and reduced motion skips the fade.
- The line reads as one Lyrics button to screen readers.
- Drops the unrelated Android lint opt-out and .gitignore entry, and uses
  generic test data. New tests cover the default, the offset, timing,
  seeking, and the player waiting for a resolved source.
2026-11-07 21:02:30 +07:00
PrathxmOp 0b51c40620 feat(player): add real-time synchronized lyrics preview under track header
- Render interactive single-line synced lyric preview under title and artist
- Support word-by-word real-time karaoke sweep with WordTimedLyricLine
- Interpolate playback clock with microsecond precision and schedule line boundary timers to eliminate line switch delays
- Auto-inspect embedded lyrics on Now Playing screen without requiring opening lyrics page
- Add playerShowLyricSnippet setting toggle
- Add comprehensive widget tests and disable release lint checks in android
2026-11-07 20:49:26 +07:00
zarzet 6c5e727450 feat(lyrics): show the sung line on the lock screen
An opt-in setting replaces the song title in the system media
controls with the current synced lyric line. Only the OS sees it:
the wrapper sits under the media session filter, so Last.fm,
Discord, widgets and Link keep the real title.

Lyrics come from the file and its .mlrc sidecar, never online.
Breaks of 3 s or more show the title, and the title changes at
most twice a second. Android shows lines only while the keyguard
is up and the screen is on; iOS cannot tell, so it shows them
while Mornye is in the background and restates the position first
so Now Playing does not jump back.
2026-11-07 20:12:07 +07:00
zarzet 8fe787a002 feat(convert): let Smart Dither use TPDF HP
Smart Dither only adds dither when lowering bit depth, but it always used
plain TPDF. A new Use TPDF HP switch makes it use high-pass TPDF instead,
in the convert sheet (shown while Smart is selected) and for automatic
FLAC conversion of downloads (under Smart Dither, saved as
autoConvertSmartDitherHighPass). The native Android finalizer, the
Dart FFmpeg path and Mornye Link conversions all honor it; Link sends it
as ditherHighPass, which older desktops ignore. The switch is off by
default, so existing conversions do not change.

The explicit Triangular HP option is now labelled TPDF HP, next to TPDF.
2026-11-07 19:48:04 +07:00
zarzet efe4df0e1f feat(motion): save animated covers as cover.mp4 in album folders
An opt-in Files setting copies a download's animated cover into its
album folder as cover.mp4, so file managers and other players find it.
Only folders that hold one album get it: the folder is planned again
with a marked album name, and flat, artist, playlist and shared Singles
folders are skipped, as is a song kept in a folder other than the
planned one. An existing cover.mp4 is never replaced, for local files,
Android folder access and network storage alike; songs of one album
that finish together write it once.

The player, mini player and album headers now show a cover.mp4 found
beside a local song before the artwork saved for the album. Android
documents are found through a new findSafSibling call and copied into
app storage once per version, since the video player only opens files.
2026-11-07 16:04:21 +07:00
zarzet 305037a907 feat(lyrics): save translations to .mlrc files
Saving a lyrics translation now covers every kind of lyrics:

- Plain lyrics can be translated on request. Each line's pronunciation
  and translation show under it. Automatic translation stays synced-only.
- AI pronunciation is saved too, with its word timing, as x-romaji and
  x-romaji-words tags next to the translation.
- A new .mlrc file next to the song keeps its lyrics with their
  translation and pronunciation and leaves the audio file as it is. It is
  UTF-8 LRC that starts with [x-mlrc:1]. Supplement tags are keyed by
  line time, or by line index for lyrics without timing. TTML is written
  as enhanced LRC with voices and backing vocals. The player reads it next
  to local and Android document songs and lays it over the song's lyrics
  by line text.
- AI Translation settings gain a Files section: Save To picks the song
  file or a .mlrc file, and Save Automatically saves each shown
  translation without a snackbar. TTML and plain lyrics always go to
  .mlrc. Saving into the song file also refreshes an existing .mlrc.
- Android reads and writes the sidecar through new SAF calls, and the
  .lrc sidecar write shares the same code.
2026-11-07 15:19:06 +07:00
zarzet fe33d6c7c9 feat(audio): add smart dither for file conversion 2026-11-07 01:23:32 +07:00
zarzet d290a4cee3 fix(cast): stop treating every TV media error as fatal
Android failed the song on any media error message from the receiver,
even if the TV kept playing. The app then showed "TV could not play this
audio file", stopped following the position and stopped sending Pause.

Fail only when the receiver stops with an error, as the iOS and desktop
sender already does. Media errors now reach the app log with their reason
and code on every platform, so a failed seek can be traced.
2026-11-07 01:22:35 +07:00
zarzet bf2d72a395 fix(android): register player events before create replies
Since player operations moved off the UI thread, create replied before
the event channel's main-thread registration ran. Dart listened to a
stream with no handler, lost the prepared event, and playback loaded
forever. Reply after the registration instead.
2026-11-05 17:05:36 +07:00
zarzet c065e4ebeb fix(android): move player operations off the UI thread 2026-11-05 15:52:38 +07:00
zarzet 20e5b550d9 chore: neutralize UI terminology and clarify code comments 2026-11-04 22:53:56 +07:00
zarzet 38172a4b12 fix(orientation): let tablets rotate outside the full player (#807)
Tablets (shortest side at least 600dp) may use every orientation outside
the full player, and the activity starts with the user's rotation setting
on them. Phones and TV keep their existing rules.

Contributed by Keven Chantre in #807. Fixes #805.
2026-11-04 16:10:21 +07:00
zarzet 335ae95ff3 fix(android): keep media controls responsive during artwork reads 2026-11-04 02:25:16 +07:00
zarzet 8bca89936f feat(cast): Google Cast on iOS and desktop
- iOS: a Swift plugin drives the Rust sender on the existing cast
  channels. A silent mixable loop keeps the app serving audio while a
  session is connected. Audio output now opens the same sheet as
  Android, with AirPlay and Bluetooth opening the system route picker.
- Desktop: CastOutput talks to the Rust sender through the backend
  channel. Material shows a Cast button in the player bar that gives
  way after the volume slider in narrow windows; the Mornye capsule
  puts Cast in its volume popover.
- iOS and desktop pick receivers in a new app sheet that looks for
  devices while open and connects on tap.
- Android keeps Google's sender and dialog, and now serves media from
  the Rust server. The Dart CastMediaServer is removed.
2026-11-04 02:01:11 +07:00
zarzet 6e964bb2d3 feat(player): open audio files and folders directly 2026-11-04 01:35:52 +07:00
zarzet 5f369d77be fix(android): restore keyboard viewport after backgrounding 2026-11-04 01:17:58 +07:00
zarzet 6e07941b35 feat(library): save network songs offline with independent copies 2026-11-03 03:18:14 +07:00
zarzet 39d3ba6c53 merge: sync reviewed pull requests from origin main 2026-11-03 00:44:44 +07:00
zarzet db878105ab fix(download): resolve SAF conversion filenames from document metadata (#768) 2026-11-03 00:12:23 +07:00
zarzet 66ffc89987 fix(android): size notification mark for the status bar 2026-11-02 19:25:54 +07:00
zarzet e1c497aafe fix(android): promote download service before queue preparation
Enter foreground before reading queue payloads or recovering ReplayGain, and handle missing covers during download completion prewarming.
2026-11-02 19:21:04 +07:00
zarzet bdebceec5d perf(library): share Android thumbnail files by content
Use SHA-256 names for Android library artwork and migrate stored Library paths in resumable pages. Preserve legacy files until saved references release them. Host fixtures reduce twelve repeated thumbnails to two files and keep shared bytes unchanged when one song changes artwork.
2026-11-01 21:24:57 +07:00
zarzet f53154c159 feat(android): add Google Cast audio output 2026-11-01 21:22:09 +07:00
zarzet 0895e9aec0 perf(android): stream unchanged CUE scans and retain metadata objects
Keep descriptor metadata as a JSONObject through SAF enrichment and final scan publication. Preserve the string API for existing callers and use the typed result for CUE artwork too.

Read unchanged CUE FILE directives directly with an 8 KiB buffered reader instead of copying the entire sheet to temporary storage. Preserve BOM, quoted names, basename fallback, late directives and MediaStore retry behavior.

Evidence: 46 focused SAF JVM tests and 46 Dart scan tests pass. A 1.8 MB CUE fixture consumes at most 8 KiB when FILE appears first, and metadata remains the same object until one final serialization. Restoring either previous implementation fails its regression test. JVM module compilation uses unchanged-ABI generated bindings; no device build.
2026-11-01 21:08:42 +07:00
zarzet 3f84aeb5bc fix(audio): reconcile USB output status with native playback 2026-11-01 20:45:07 +07:00
zarzet 453f84090a perf(android): defer crash session preference I/O
Install the crash handler immediately and read and commit session preferences on the existing recovery executor before inspecting the previous exit. Report readers retain their recovery wait and synchronous crash persistence is unchanged.

The JVM startup test calls the real initializer and rejects all preference I/O on its caller thread. It fails with the former synchronous initialization, then passes with the worker implementation.
2026-11-01 20:39:57 +07:00
zarzet e28fa2aeaa perf(bridge): avoid redundant download and small job codecs
Keep download snapshots as JSON across the Android channel and decode large progress payloads off the UI isolate while retaining event order and permissive empty-result behavior. Encode bounded small native data requests inline, with the existing pre-dispatch cancellation yield and background fallback for larger graphs.

Host tests verify zero encoder isolates for small requests, background decoding of large snapshots, cursor resets, stream cancellation, exact JSON and separate binary arguments. Restoring the old codec paths fails the corresponding isolate and event-loop probes.
2026-11-01 20:39:57 +07:00
zarzet 8dccb0582d fix(library): unify Windows extended path identities 2026-11-01 20:21:44 +07:00
zarzet 030d44bbd0 fix(android): avoid Sony snapshot crash when locking screen 2026-11-01 20:16:44 +07:00
zarzet 22c4f92a82 perf(library): reduce schema writes and repeated path migration
Bump Library to v21 and History to v16, add album artist indexes, and remove six Library and three History indexes whose seeks are served by existing queue indexes. Keep the named file-path index for released readers and synchronize native schema checks.

Persist the iOS container migration marker in the database transaction, exclude current paths, and bound Library and CUE reads to 256 rows. Repeat opens read one marker row. Test rollback, path keys, bookmarked sources and downgrade/reupgrade compatibility.

Four alternating 15,000-row host write pairs reduced median batch time from 3364.773 ms to 2782.200 ms (17.3 percent). Native staging now takes the shared History schema version.
2026-11-01 19:41:07 +07:00
zarzet 0bfbf21f64 fix(android): cancel blocked SAF worker waits
Poll cancellation while waiting for a SAF worker and cancel outstanding tasks. Preserve thread interruption and reject results returned after cancellation. Three focused JVM tests pass.
2026-11-01 19:11:45 +07:00
zarzet afee4332a2 fix(setup): accept existing all-files access on Android
Setup only checked the audio permission from Android 13, so a phone that
already granted all-files access (or granted it in settings and came
back) stayed stuck on the storage step, and Grant Permission asked again.
Setup now treats all-files access as enough on Android 11 and later, and
rechecks it before requesting anything.

It also reads the Android API level from the app's own channel, falling
back to device_info, so the Android 17 steps still appear when full
device information is unavailable.
2026-11-01 15:16:27 +07:00
zarzet 8e24b08fec feat(download): add FLAC quality caps and Opus 160 kbps
Add FLAC auto-conversion with maximum bit depth and sample rate in foreground and Android background downloads. Preserve lower source rates, artwork, metadata and output quality.

Keep 48 kHz available for mixed-source batch conversion and add 160 kbps to manual, batch and automatic conversion.

Validation: 122 Flutter tests and 26 Android JVM tests passed. Analysis of lib and test passed.
2026-11-01 00:06:41 +07:00
zarzet a5e8077419 fix(link): keep Android phones available in the background 2026-10-31 23:56:12 +07:00
zarzet 22a2abaca0 fix(about): restore Git commit in direct mobile builds
Supply GIT_COMMIT from Android Gradle and the iOS Flutter build phase so the existing About footer displays the revision without manual build flags. Preserve explicit defines and source archive builds.

Validation: 19 targeted tests passed, Android compiler define forwarding checked with automatic and explicit revisions, ShellCheck and Xcode project syntax checks passed, git diff --check clean.
2026-10-31 23:50:21 +07:00
zarzet 072cbc3f48 fix(downloads): recover moved files after changing folders 2026-10-31 23:28:11 +07:00
zarzet ad2820cca5 fix(player): keep Android PCM defaults apart from the Bluetooth format
On Android, the audio info sheet showed the default low-latency PCM rate,
bit depth and buffer as the output of a Bluetooth route, and computed
resampling from them. Android does not report the negotiated A2DP or LE
Audio codec format, so for Bluetooth, LE and hearing aid routes the sheet
now says so, labels the PCM values as system defaults, and shows no
resampling. The sheet also reads the route again when the app returns to
the foreground, so a route changed in Settings shows at once.
2026-10-31 22:38:11 +07:00
zarzet 71c7de52b2 fix(ffmpeg): register the plugin callbacks before Kotlin wraps them
With FFmpegKit now loaded on the first Dart call, a download that
finalizes before any Dart FFmpeg use is the usual order. The finalizer's
complete-callback filter then read a null callback and forwarded to
nothing, and the plugin's later registration replaced the filter. If the
read and the write straddled the registration, the filter forwarded to
null until the process restarted.

The plugin now exposes ensureGlobalCallbacksRegistered(), which registers
the global callbacks on the calling thread (loading FFmpegKit if needed),
waits for a registration already in progress and throws a load failure
to its first caller. The background load uses it too, and the finalizer
calls it before wrapping, so the filter always wraps the plugin callback
and is never replaced. The finalizer runs on worker threads, so the main
thread still never waits for the load.

The host-JVM main looper stand-in is now a thread named main that the
tests post calls through, and replies are checked against it: draining
the waiting calls on the loader thread instead of posting them, removing
the registration lock, or making the new method a no-op each fail a
test. No startup cost change; the ST1 gain is unchanged.
2026-10-31 22:25:05 +07:00
zarzet f2cf97a3de perf(player): bound the Android notification art cache
audio_service kept every decoded cover in an LruCache sized one eighth
of the Java heap (16 to 64 MB) that only onDestroy emptied, so a long
shuffle session filled it after 8 to 15 covers and held it through
background playback. Its decode used a power-of-two sample size toward
512 px, so an 800 px Library thumbnail stayed 2.4 MiB and a 1000 px
cover 3.8 MiB, although the session only takes 512 px copies.

The service now keeps the current cover and the two before it
(RecentArtCache), and onTrimMemory at TRIM_MEMORY_RUNNING_LOW or above
(UI_HIDDEN and BACKGROUND on Android 14 and later) drops all but the
current one. Eviction never recycles, so the notification and session
keep what they show. Each decoded cover is scaled to 512 px with the
same createScaledBitmap call the session copy made, so the session's
512 px copies keep their pixels; the 256 px notification icon is now
scaled from 512 px (owner-approved).

Retained art goes from up to 16 to 64 MB to at most three 1 MiB
bitmaps, one after a trim. Recorded in MORNYE_PATCHES.md; JUnit
RecentArtCacheTest, and the instrumented MediaControlMetadataTest
covers the 512 px bound.
2026-10-31 22:17:26 +07:00
zarzet 7db4842096 fix(android): close a cover descriptor on any failed check
An unexpected runtime error between the open and the image check left
the descriptor open, so a binder thread of the cover provider could leak
it. The descriptor is now closed in a finally block whenever no image
type was found.
2026-10-30 18:53:55 +07:00
zarzet a7f84b6df0 fix(android): show local covers in Android Auto's queue view
The car's queue view loads each queue item's icon URI in its own process,
so a local song's app-private file:// cover showed nothing there, while
its browse entry already shows the cover through the cover provider.

audio_service gains AudioServicePlugin.setQueueArtResolver (recorded in
MORNYE_PATCHES.md). raw2queue applies it to each QueueItem description
only; the item's MediaMetadataCompat, the metadata cache, the playing
item, the notification and the lock screen keep the original artwork.
A null answer, a resolver that throws, or no resolver keeps the
description as it was.

The app's resolver maps a file:// or plain absolute path that names a
cover directly in the provider's folders, read from the path alone with
the same per-folder name rules, to the provider URI its browse entry
gets, so the car's cache sees one URI per cover.
2026-10-30 18:53:55 +07:00