Commit Graph
461 Commits
Author SHA1 Message Date
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
zarzet 9019e853fd fix(android): check cover names per folder and serve the opened file
The cover folders also hold files that are not covers: `.source`
sidecars with the user's audio file paths and `.current` pointers next
to the covers, the regenerate marker, and staging files. Only the image
signature check kept them out. Each folder now also names its covers by
their endings (cover store `.image`; Library thumbnails `.jpg`, `.png`
and `.image`; embedded artwork `.jpg`), so those files are refused by
name before anything is opened.

The provider checked one open of the file and served another. It now
opens the resolved file once with O_NOFOLLOW (and O_CLOEXEC from API
27), checks that descriptor with fstat for a regular file and pread for
an image signature, and serves a dup of that same descriptor; getType
reads its type the same way. The signatures are written as byte values,
so the source stays ASCII.
2026-10-30 18:53:55 +07:00
zarzet 8b36e856ef feat(android): serve cover files to media browsers read-only
Android Auto loads browse item artwork from the item's icon URI in its
own process, so it cannot open the app's private cover files and local
covers were left out of every browse list.

CoverContentProvider serves them as content://<applicationId>.covers/
<folder>/<file>. A car cannot hold a permission, so the provider is
exported, and in exchange it only reads: openFile accepts mode "r" only,
insert/update/delete throw, query lists nothing. CoverProviderFiles
resolves a URI to a file only when its path is an allowed folder name
and a plain file name, the canonical file sits directly in the
canonical folder (no "..", encoded "/" or symbolic link out), and it is
a regular file starting with a known image signature.

The allowed folders are the ones browse lists name: the cover store
(files/covers), Library thumbnails (files/library_covers) and embedded
artwork extracted from downloads (cache/embedded_cover_previews). The
covers channel hands Dart the authority and folder paths, registered on
the shared engine so a car-started engine has it too.
2026-10-30 18:53:55 +07:00
zarzet 338e9ba83c fix(covers): key library thumbnails by 128-bit SHA-256
Scan thumbnails were named by a 32-bit djb2 hash of "path|size|mtime" (or
the document key) and an existing file was reused without checking its
source, so two songs whose keys collided showed one cover. The Android
document scan had its own copy of the same hash.

Thumbnails are now named cover_<first 128 bits of SHA-256 of the key>, in
Rust for every scan and through library_cover_slot for the Kotlin document
scan, so reuse by name is safe. Rows that name older files keep working;
those files are not looked up again and are pruned once unreferenced.

A forced rescan can touch a .regenerate marker in the cover folder:
thumbnails older than it are extracted again under the same name instead
of being reused, and the newer of a .jpg and .png sibling wins.
2026-10-30 14:15:10 +07:00
zarzet a73f63772d chore(deps): update Flutter, native and Rust dependencies 2026-10-30 01:29:33 +07:00
zarzet 2000cabd62 fix(android): resolve audio service lint warnings 2026-10-30 00:00:09 +07:00
zarzet 22e3536dd5 fix(android): guard media artwork against recycled bitmaps 2026-10-29 23:46:29 +07:00
zarzet d58565d287 feat(library): suggest songs under albums, singles and playlists
Albums, singles and playlists, online and in the Library, end with
"Suggested songs": up to ten songs like the ones above that the collection
does not hold yet, each with a preview, an add button and a click or tap
that downloads it. On a user playlist the add button adds the song there
and it leaves the suggestions; elsewhere it opens the playlist picker.
Phones list the songs as rows, desktop in the page's song table.

Suggestions come from a new optional extension method, getRelatedTracks,
which extensions declare with the relatedTracks capability: it takes up to
three of the collection's songs and returns songs in the shape of search
results. The extension most seeds came from is preferred so it can use
their IDs. Without such an extension, the first metadata provider is
searched by the collection's artists. A refresh button starts from other
songs, and loaded suggestions stay for ten minutes.
2026-10-29 02:23:07 +07:00
zarzet 500f884018 fix(downloads): hide temporary SAF audio from media scanners 2026-10-29 01:23:43 +07:00
zarzet 23d6bb44a0 fix(metadata): export cover and lyrics for local library files
Offer cover and LRC export for accessible imported songs. Publish Android SAF sidecars beside the audio document without requiring download history, reuse cached artwork when needed, and clean temporary outputs on every exit path.

Validation: 36 Flutter tests, one Android SAF instrumentation test, scoped analysis, formatting checks, and git diff --check passed.
2026-10-28 22:02:24 +07:00
zarzet aa788591a3 fix(library): hide CUE sources after a complete split
Publish all split tracks and their visibility rule atomically while preserving the original files and playlist rows. Keep the rule across rescans, restore originals when outputs leave the visible Library, and stabilize Android SAF identities and artwork caching.

Validation: 84 Flutter tests, 19 native Library tests, scoped analyzer, formatting checks, and Android Kotlin compilation passed.
2026-10-28 20:43:10 +07:00
zarzet 2fe3bf7ab8 fix(link): recover remote covers and retire cancelled playback errors 2026-10-27 17:55:36 +07:00
zarzet 1f12076765 feat(search): recognize songs playing nearby
A microphone button in the empty search field listens to the room and
names the song, on phones and desktop.

- The audio fingerprint and the Shazam request run in Rust behind a new
  recognize_song data job, so every platform shares one path.
- Listening sends the audio so far at 4, 8 and 12 seconds and stops at
  the first match; quiet or short clips are reported instead of sent.
- A match can be played from the library (by ISRC, then title and
  artist), searched in Mornye, or opened in Shazam. Recent matches are
  kept in a local history.
- Android asks for the microphone only when listening starts; iOS and
  macOS gain the microphone usage description and entitlement. The Linux
  package recommends pulseaudio-utils for capture.
2026-10-26 01:33:56 +07:00
zarzet eb6e4bb1a8 feat(autoplay): analyze how songs sound
Analyze each Library song once in the background, on the device, and
let Autoplay pick songs that sound like the session and flow into each
other.

- Decode two 24 s mono windows at about 30% and 60% of a song with one
  FFmpeg thread, describe them natively, and delete the PCM at once.
  Documents are opened through FFmpegKit's SAF parameter, not copied.
- Keep features in a small database of their own, keyed by path with
  the file's size, modification time and the analysis version. Failed
  songs are recorded and tried again only once the file or the version
  changes; rows of songs the Library no longer has are removed.
- Sweep one song at a time with rests four times the work, never in
  the first 20 s of a song or while AutoMix mixes. Android sweeps only
  while charging unless the listener allows battery, desktop sweeps
  at that pace, iOS analyzes only the song playing. The song playing
  is analyzed 20 s after it starts, on battery too.
- Add a sound signal: up to +5 for sounding like the latest songs,
  with timbre weighing most over features standardized across the
  songs at hand; each pick loses up to 1.5 for a tempo jump (octaves
  folded) and 1.5 for an energy jump, and gains 0.5 for a neighboring
  key. Unanalyzed songs score and follow as an average analyzed one.
2026-10-25 23:36:14 +07:00
zarzet 74f01b6f93 feat(android): add Android TV remote navigation 2026-10-25 16:36:32 +07:00
zarzet 40ec34b793 Merge branch 'main' into link/integration 2026-10-25 04:33:00 +07:00
zarzet 4682990e6d feat(player): browse and play the Library from Android Auto
Android Auto showed only the current queue, had no search, and could not
love songs or browse until the app was opened on the phone: Dart startup
waited for an Activity, so AudioService never configured and the star
had no handler.

- audio_service: add setFlutterEngineConfigurator so the app registers
  its playback plugins and a playback subset of the backend channel on
  the shared engine whichever component creates it. MainActivity replaces
  that handler with the full backend when it attaches. SAF playback
  leases now belong to the process.
- Start the player, restore the session and set up the media controls
  without an Activity. The star loves songs straight in the collections
  database until the app shell takes the controls over.
- Add MediaLibraryBrowser: Songs (with Shuffle library), Albums, Artists
  and Playlists (Loved first) tabs, grouped search results, paging, and
  voice requests that play songs or the album, artist or playlist asked
  for. Choosing a song plays the folder it came from.
- Return the playing song for media resumption after a cold start.
- Move playable media factories, track file resolution, media identity
  and locale lookup out of the providers so the headless path shares
  them.

Local covers stay out of browse lists because a car cannot open the
app's own files; songs that play keep their artwork.
2026-10-25 04:32:46 +07:00
zarzet 32fc942a04 feat(link): add the phone client for desktop discovery and pairing
Phones find Mornye on a computer over mDNS (bonsoir, _mornye._tcp),
pair with its 6-digit PIN and keep a live session with the chosen
desktop.

- Pinned HTTPS: first contact records the presented certificate and
  checks it against info and the mDNS fingerprint; later requests and
  the WebSocket accept only that SHA-256.
- Pairing posts the PIN proof, maps bad_proof, pairing_closed and 429
  to clear errors, saves a Subsonic API-key network connection, adds it
  to Library and scans it. Re-pairing replaces the key in place.
- LinkClientSession: Bearer JSON get/post with timeouts and
  LinkException mapping, WebSocket hello/welcome, backoff from 1 s
  doubling to 30 s, pause in the background, reconnect when discovery
  sees the desktop again, address updates when it moves.
- LinkClientController publishes the active session through
  linkActiveClientProvider and rescans on catalog.changed.
- Settings entry "Mornye on your computer" on Android and iOS with
  nearby and paired computers, PIN and manual address dialogs, forget,
  and local network permission, Wi-Fi and certificate warnings.
- iOS NSBonjourServices and the Android multicast permission.
2026-10-25 02:37:07 +07:00
zarzet fdc94673e1 chore(android): update Gradle to 9.8.2 and android-junit5 to 2.0.2 2026-10-24 12:12:27 +07:00
zarzet 4bdd22d2e8 fix(android): preserve audio routing during player initialization
Preserve the system audio mode and speakerphone route when only player settings change. Apply explicit global routing changes using the incoming context instead of the previous defaults.

Verified with three native routing regression tests and 34 Dart player tests. The Android build and audioplayers lint checks pass. Related to #721.
2026-10-24 10:30:12 +07:00