ALSA Device Filtering (45 → ~12 devices):
- Aggressively filter to show only useful devices for audiophiles
- Keep: default, sysdefault:CARD=, front:CARD=, hdmi:CARD=, iec958:CARD=
- Blacklist: surround* variants, usbstream:, pipewire, pulse, bare sysdefault
- Reduces 45 listed devices to ~12 actually useful ones
Add hw:CARD=XXX,DEV=0 Devices for Bit-Perfect Playback:
- Auto-generate hw: devices for each detected card
- hw: = direct hardware access without ALSA plugins (true bit-perfect)
- sysdefault:CARD= has dmix/resampling plugins (NOT bit-perfect)
- Description shows "(Direct Hardware - Bit-perfect)" to distinguish
- This fixes user's issue: DAC was stuck at 44.1kHz with sysdefault:CARD=C20
Loading Indicator:
- Show "Loading devices..." while parsing aplay -L output
- Fixes 4-5 second frozen UI on ALSA Direct backend selection
- isLoadingDevices state added to SettingsView
Stop Playback on Device Change:
- Call stop_playback() in handleBackendDeviceChange
- Prevents stuck/dead audio streams when changing output device
- Fixes: "After any config change, song in player stops working"
User can now:
1. Select hw:CARD=C20,DEV=0 for true bit-perfect to DAC
2. See loading indicator instead of frozen UI
3. Change device without breaking playback
4. Only see relevant devices (not 7 surround variants per card)
ALSA Backend Fallback:
- enumerate_via_aplay() - Preferred method with real hardware descriptions
- enumerate_via_cpal() - Fallback without descriptions (frontend will translate)
- enumerate_alsa_devices() tries aplay first, falls back to CPAL on failure
- Warning log suggests installing alsa-utils if aplay fails
Edge Case Handled:
- System has ALSA installed but not alsa-utils package
- CPAL detects ALSA host → AlsaBackend available
- aplay -L command fails → fallback to CPAL enumeration
- User sees translated names instead of real hardware descriptions
- App still works, just with less friendly device names
Package Dependencies:
- Added alsa-utils as "Recommends" for .deb packages (Debian/Ubuntu)
- Added alsa-utils as "Recommends" for .rpm packages (Fedora/RHEL)
- "Recommends" = installs by default but not required (apt/dnf behavior)
- If user explicitly removes alsa-utils, app falls back gracefully
In practice alsa-utils is almost always installed with ALSA, but this
ensures we handle the edge case properly.
ALSA Backend Changes:
- Parse aplay -L output to get real hardware descriptions
- Description from hardware: "Cambridge Audio Cambridge Audio USB Audio 2.0, USB Audio"
- No more hardcoded CARD_NAMES for specific hardware
- Still uses CPAL to verify device exists and get max sample rate
- Blacklist filtering preserved (null, lavrate, samplerate, etc.)
Frontend Changes:
- Prefer device.description (from aplay -L) when available
- Falls back to getDevicePrettyName() translation only if no description
- ALSA Direct shows: "Cambridge Audio ... USB Audio, Front output / input"
- Not: "Cambridge Audio USB Front Output" (hardcoded translation)
Removed Hardcoding:
- Removed CS201 → "Cambridge Audio USB" (was specific to user's DAC)
- Removed C20 → "Cambridge Audio"
- Generic CARD_NAMES remain (NVidia, Intel HD Audio, etc.)
This makes device names work for ANY hardware, not just known cards.
Each backend should use native tools:
- ALSA: aplay -L
- PipeWire: pw-cli/pactl (future)
- PulseAudio: pactl (future)
Problem 1: ALSA Direct showed NO devices because aplay -L output doesn't
match CPAL device names, causing create_output_stream to fail.
Solution: Revert to CPAL enumeration but with blacklist filtering to skip
non-playback devices (null, lavrate, samplerate, speexrate, jack, oss,
speex, upmix, vdownmix).
Problem 2: Auto backend didn't apply fancy names because needsTranslation()
was too restrictive and didn't cover all ALSA device name patterns.
Solution: Simplify to: if device name starts with 'alsa_output.' it's from
PipeWire (already has friendly name), otherwise it's ALSA (needs translation).
This covers ALL ALSA naming patterns including front:CARD=, sysdefault:CARD=,
hw:, hdmi:, iec958:, etc.
Changes:
- alsa_backend.rs: Back to CPAL with blacklist filter
- SettingsView.svelte: Simplified needsTranslation() logic
Problem 1: ALSA backend showed only 1 device or listed plugins/virtual devices
that don't work for playback (null, lavrate, samplerate, etc.).
Solution: Filter aplay -L output to only include actual playback devices:
- Hardware devices (hw:, plughw:, sysdefault:CARD=, front:CARD=)
- System defaults (default, pipewire, pulse)
- Digital outputs (hdmi:, iec958:, surround)
Problem 2: Quality badge showed file sample rate (e.g., 44.1kHz) instead of
actual hardware sample rate (e.g., 192kHz) when DAC Passthrough was active.
Solution: ExpandedPlayer now polls hardware_sample_rate every second when
DAC Passthrough is enabled and displays the real hardware rate instead of
the file metadata rate.
Changes:
- alsa_backend.rs: Add is_valid_device() filter for playback devices
- ExpandedPlayer.svelte: Poll get_hardware_audio_status every 1s
- ExpandedPlayer.svelte: Use displaySamplingRate (hardware rate when DAC on)
This ensures the quality badge accurately reflects bit-perfect playback status.
Problem 1: ALSA backend only showed CPAL hardware devices, missing virtual
devices like 'default', 'plughw', USB DACs, etc.
Solution: Use 'aplay -L' to enumerate ALL ALSA devices including:
- Hardware devices (hw:X,Y)
- Virtual devices (default, plughw, dmix)
- USB audio devices
- Network audio devices
Problem 2: UI was applying getDevicePrettyName() to all backends, causing
PipeWire's already-friendly names to be translated incorrectly.
Solution: Only apply translator for ALSA/Auto backends. PipeWire names
pass through unchanged since pactl already provides friendly descriptions.
Changes:
- ALSA backend: Use aplay -L instead of CPAL enumeration
- Frontend: Conditional translation based on selected backend
- Map deviceByDisplayName for correct reverse lookup
- Load settings with correct translation logic
This fixes both issues: ALSA now shows all devices including DACs,
and PipeWire names are no longer mangled.
Remove unused ProviderCredentials parameters from playlist import functions.
The proxy now handles all provider credentials, making these parameters
obsolete.
Changes:
- preview_public_playlist: Remove spotify_creds and tidal_creds params
- import_public_playlist: Remove spotify_creds and tidal_creds params
- Update all callers to remove None, None arguments
- Remove unused ProviderCredentials import
This fixes compilation error:
error[E0061]: this function takes 1 argument but 3 arguments were supplied
ALSA Direct Backend Implementation:
- Fully functional ALSA backend using CPAL's ALSA host
- Enumerates ALSA devices with hardware names
- Supports custom sample rates for bit-perfect playback
- Supports exclusive mode (device blocking)
- Smaller buffer size (512 samples) for lower latency in exclusive mode
- Clear error messages when device is in use
Smart Toggles in UI:
- Exclusive Mode auto-disabled with PipeWire/Auto backends
(PipeWire is multiplexed and cannot provide true exclusive access)
- Gapless Playback auto-disabled with DAC Passthrough
(bit-perfect requires recreating streams for sample rate changes)
- Toggle component now supports 'disabled' prop with visual feedback
- Tooltips updated to explain why features are disabled
- Auto-disable exclusive mode when switching to PipeWire backend
User Benefits:
- ALSA Direct now appears in backend dropdown
- True exclusive mode available with ALSA Direct
- Prevents confusing feature combinations
- Clear explanations via tooltips
- No more wondering why exclusive mode doesn't work with PipeWire
Technical Notes:
- ALSA backend uses CPAL host selection (not alsa-rs directly)
- Disabled toggles shown as grayed out with cursor: not-allowed
- Backend switching auto-adjusts incompatible settings
Problem: PipeWire was resampling 192kHz streams to 48kHz because the sink
was running at 48kHz. Creating a stream at 192kHz wasn't enough - PipeWire
would resample it down to match the sink's current rate.
Solution: Use pw-metadata to force PipeWire's global sample rate before
creating the stream:
pw-metadata -n settings 0 clock.force-rate 192000
This tells PipeWire to switch the sink to 192kHz, preventing resampling.
Technical details:
- Executes AFTER setting default sink
- Waits 300ms for PipeWire to apply the change
- Creates stream AFTER sample rate is forced
- Each new stream updates the forced rate (supports rate switching)
This ensures:
- 192kHz track -> 192kHz hardware (no resampling)
- 44.1kHz track -> 44.1kHz hardware (no resampling)
- True bit-perfect playback
Evidence: pw-top now shows ALSA sink running at requested sample rate
All API requests now go through Cloudflare Workers proxy.
User-provided credentials were collected but never used.
Removed:
- src-tauri/src/api_keys.rs (entire module)
- API Keys section from Settings UI
- ApiKeysState and related commands
- User credential parameters from providers
- Simplified DiscogsClient (removed with_user_credentials)
- Cleaned up imports and translations
Moved documentation:
- CHANGELOG-api-keys-refactor.md
- HANDOFF-MERGE.md
- MERGE-PREP.md
- POST-MERGE-CLEANUP.md
Moved to: qbz-nix-docs/feature-api-keys-refactor/
This cleanup reduces codebase by ~715 lines and removes
confusing UI that promised functionality that didn't work.
This major refactor achieves Flathub compliance by removing all embedded
API credentials from the binary. All API requests now go through a
Cloudflare Workers proxy for secure credential management.
New Features:
- Discogs artwork selection UI with multi-release support
- Catalog number support for audiophile libraries
- Carousel navigation for artwork options
- Release metadata display (title, year)
Technical Changes:
- Cloudflare Workers proxy for Last.fm, Spotify, Tidal, Discogs
- Database migration adds catalog_number column
- URI scheme registration (qbz://) for OAuth flows
- Rate limiting and User-Agent validation server-side
See CHANGELOG-api-keys-refactor.md for complete details.
See POST-MERGE-CLEANUP.md for removing legacy API Keys UI.
PipeWire backend was using generic OutputStream::try_from_device() which
lets PipeWire decide the sample rate, causing resampling even when
DAC Passthrough is enabled.
Now uses OutputStream::try_from_device_config() with custom StreamConfig
that forces the exact sample rate requested (e.g. 192kHz), just like
the legacy CPAL path.
Changes:
- Import CPAL config types (StreamConfig, SampleRate, etc.)
- Create StreamConfig with requested sample_rate and channels
- Use try_from_device_config() instead of try_from_device()
- Verify device supports the configuration
- Support exclusive mode with lower buffer size (512 samples)
This ensures bit-perfect playback:
- 192kHz track -> 192kHz hardware output
- 44.1kHz track -> 44.1kHz hardware output
- No resampling by PipeWire
Previously, init_device() used hardcoded 48000Hz when reinitializing
streams with backend system. This broke bit-perfect playback after
pause/resume or device changes.
Now init_device() accepts sample_rate and channels parameters and uses
the last known values from current_sample_rate/current_channels to
maintain the correct format across reinitializations.
This ensures DAC Passthrough works correctly:
- 192kHz track stays at 192kHz through pause/resume
- No unwanted resampling to 48kHz
- Bit-perfect playback maintained
Fixes apply to:
- Auto-reinitialization after sink failures
- Resume command when stream needs recreation
- ReinitDevice command (settings changes)
Root cause: We were restoring the default sink immediately after
creating the OutputStream, but the actual sink-input is only created
when playback starts (500ms+ later). By that time, we had already
restored the default to Speaker.
Solution: Don't restore the default sink at all. When user selects
a device in QBZ, it becomes the system default (expected behavior,
matches Strawberry Music Player).
Added 200ms delay after changing default sink to give PipeWire
time to process the change before creating the CPAL host.
PULSE_SINK environment variable approach was not working because
CPAL/rodio does not properly propagate it when creating streams.
New approach:
1. Save current default sink with pactl get-default-sink
2. Temporarily set default sink to target device
3. Create CPAL stream (will use current default)
4. Restore original default sink
This ensures audio routes to the selected device without permanently
changing the system default sink.
Tested approach is more reliable than PULSE_SINK env var.
Critical fix: Create fresh CPAL host AFTER setting PULSE_SINK environment variable.
Problem:
- PULSE_SINK was set in create_output_stream()
- But host was already created and connected in new()
- Host reads PULSE_SINK when it connects, not when stream is created
- Result: audio routing failed despite PULSE_SINK being set
Solution:
- Create new CPAL host in create_output_stream() AFTER setting PULSE_SINK
- This ensures host reads the environment variable when connecting
- Added verification logging to confirm PULSE_SINK is set
This should fix device selection routing to Cambridge DAC.
COMPILATION ERROR FIXED:
- audio_settings field was private
- Can't access from commands module
SOLUTION:
- Added public method: Player::reload_settings(settings)
- Encapsulation preserved
- Commands use public API
VERIFIED: cargo check passes
PROBLEMA ENCONTRADO:
1. Frontend guardaba backend_type correctamente ✅
2. Player leía settings al inicio (backend_type = None) ✅
3. Usuario cambiaba backend en UI → se guardaba en BD ✅
4. Pero Player en memoria tenía settings VIEJOS ❌
5. reinit_audio_device usaba legacy CPAL sin backend ❌
SÍNTOMAS:
- "Backend system not configured, using legacy CPAL path"
- "Device '...' not found, using default"
- Audio salía por laptop speakers, no por DAC
SOLUCIÓN IMPLEMENTADA:
1. init_device() ahora intenta backend system primero:
- Lee thread_settings.backend_type
- Si configurado, llama try_init_stream_with_backend()
- Fallback a legacy CPAL si falla
2. reinit_audio_device() recarga settings desde BD:
- Lee AudioSettings desde database
- Actualiza Player.audio_settings en memoria
- Luego llama reinit_device()
- Garantiza que Player siempre tiene config fresca
AHORA FUNCIONARÁ:
- Cambiar backend → se guarda → se recarga → se usa
- Cambiar device → se guarda → se recarga → se usa
- PULSE_SINK se setea correctamente
- Audio debe salir por Cambridge DAC
TESTING REQUERIDO:
Ir a Settings → Audio → Backend: PipeWire → Device: DacMagic Plus
Reproducir música → debería salir por DAC
PLAYER INTEGRATION:
- Added try_init_stream_with_backend() helper function
- Modified AudioCommand::Play to use backend system when configured
- Falls back to legacy CPAL path if backend_type is None
- Preserves existing behavior for users without backend config
BACKEND PRIORITY:
1. Try backend system (if backend_type is set in audio_settings)
2. Fall back to legacy CPAL direct access (backward compatible)
VERIFIED:
- cargo check passes
- Backward compatible with existing installations
- Ready for Phase 5 (UI components)
ARCHITECTURE:
- Created trait AudioBackend for unified interface
- Backends: PipeWire, ALSA (stub), PulseAudio
PIPEWIRE BACKEND (complete):
- Enumerates devices via pactl (pretty names)
- Sets PULSE_SINK env var for device routing
- Uses CPAL 'pulse'/'pipewire' device
- Does NOT change system default
- Only affects QBZ process
ALSA BACKEND (stub):
- To be implemented by Copilot
- Will provide direct hw access
- True exclusive mode
PULSE BACKEND (complete):
- Reuses PipeWire implementation
- Legacy fallback
BENEFITS:
- User can choose audio stack
- Pretty names from pactl
- Device selection only affects QBZ
- Preparation for Strawberry-style UI
Next: Tauri commands for enumeration
Logs now show:
- Device index
- Device name
- Is default
- Supported configs (channels/sample rates)
This helps identify devices when pretty names aren't clear.
PREVIOUS WRONG APPROACH (commit 212aae5):
- Used pactl to enumerate devices (PipeWire sink names)
- Tried to open those sink names with CPAL
- CPAL couldn't find PipeWire sink names → fell back to default
- Attempted workaround: change system default with set_pipewire_default_sink
- UNACCEPTABLE: Changed system-wide default, affecting all apps
ROOT CAUSE (identified by ChatGPT research):
- CPAL can open specific devices by name (research was correct)
- BUT: Name mismatch between pactl sinks and CPAL device names
- pactl returns: "alsa_output.usb-Cambridge_Audio..." (PipeWire sink)
- CPAL sees: "DacMagic Plus Analog Stereo" (user-friendly name)
CORRECT SOLUTION:
- Use CPAL for BOTH enumeration AND opening devices
- CPAL device names are consistent: enumerate → save → find → open
- No need to change system default
- Device selection only affects QBZ
CHANGES:
1. Rewrote get_pipewire_sinks() on Linux to use CPAL instead of pactl
2. Removed all calls to set_pipewire_default_sink()
3. Pass CPAL device names directly to reinit_audio_device()
4. CPAL can now find and open devices because names match
BENEFITS:
- ✅ Device selection only affects QBZ (not system-wide)
- ✅ No regresions
- ✅ No features lost
- ✅ Works exactly like librespot (Spotify client in Rust)
- ✅ Consistent with rodio/CPAL architecture
TESTING REQUIRED:
1. Select Cambridge DAC in QBZ → audio plays through Cambridge
2. Open Firefox/other app → uses its own device (unaffected)
3. Toggle devices in QBZ → changes correctly
4. Restart QBZ → restores saved device
5. DAC passthrough bit-perfect → works
- Added /release/{id} endpoint to Cloudflare proxy for detailed release info
- Modified search_artwork_options to fetch full image sets from top 2 releases
- Interleave images: up to 4 from release #1, 4 from #2, 2 from others
- Added release_title and release_year metadata to each image option
- UI now displays release title and year for each artwork option
- Better image diversity and context for users
Users now see which release variant each artwork comes from,
making it easier to choose the correct edition.
- Added catalog_number field to LocalTrack and LocalAlbum models
- Extract catalog_number tag from audio files using lofty
- Database migration to add catalog_number column to local_tracks table
- Modified Discogs search to prefer catalog number over artist/album
- Updated UI to display catalog number in album details
- Pass catalog_number to discogs_search_artwork command
For audiophile users with well-tagged libraries, catalog numbers
provide more precise Discogs search results than artist + album.
- Modified search_artwork_options to return unique images from different releases
- Only take one image per release (prefer cover_image, fallback to thumb)
- Use HashSet to track and filter duplicate URLs
- Process up to 20 results to get more diverse options
- Adjusted grid layout from minmax(100px, 1fr) to minmax(80px, 1fr) to fit at least 4 items per row
Backend:
- Add DiscogsImageOption struct for artwork options
- Add discogs_search_artwork command to search multiple images
- Add discogs_download_artwork command to download selected image
- Extend DiscogsClient with search_artwork_options() method
- Extend DiscogsClient with download_artwork_from_url() method
- Register new commands in lib.rs
Frontend:
- Add Discogs image selection to album edit modal
- Add 'Fetch from Discogs' button with Discogs logo
- Display grid of artwork options from Discogs search results
- Allow user to select preferred artwork option
- Download and save selected artwork on Save
- Add comprehensive CSS styling for Discogs UI elements
- Adjust Discogs logo color filter for proper contrast
User can now click 'Fetch from Discogs', browse multiple artwork
options, select one, and save it as the album's cover art.
- Update DISCOGS_API_URL to point to proxy endpoint
- Remove embedded CONSUMER_KEY and CONSUMER_SECRET constants
- Simplify DiscogsClient to only handle HTTP requests
- Update search_release() to use proxy /search endpoint
- Update search_artist() to use proxy /search endpoint
- Update download_image() to use proxy /image endpoint
- Add User-Agent 'QBZ/1.0.0' for proxy validation
- Maintain backward compatibility with with_user_credentials (no-op)
Backend changes:
- Add audio_diagnostics module to read actual hardware sample rate from /proc/asound
- New command get_hardware_audio_status() parses hw_params for real-time monitoring
- Add glob dependency for file pattern matching
Frontend (AudioOutputBadges):
- Implement 3-state DAC badge system:
- Green: DAC passthrough working correctly (rates match)
- Yellow: DAC passthrough ON but resampling detected (warning)
- Gray: DAC passthrough OFF (intentionally disabled)
- Dynamic tooltips showing actual hardware sample rate
- Compare file sample rate vs hardware sample rate
- Increase tooltip z-index to 9999 to prevent occlusion issues
- Add pointer-events: none to tooltip to prevent interaction issues
Frontend (SettingsView):
- Replace hardcoded "192 kHz" with dynamic hardware sample rate
- Load and display actual hardware audio status
- Show format details (e.g., S32_LE) when available
- Display "No active playback" when no audio is playing
- Add muted styling for inactive state
Frontend (QualityBadge):
- Add native tooltip showing tier and format
- Add cursor: help to indicate interactivity
i18n:
- Add "noActivePlayback" translations (EN/ES)
This allows users to verify bit-perfect playback is working and detect
resampling issues that would compromise audio quality.
- Update LASTFM_API_URL to point to proxy endpoint
- Remove MD5 signature generation (proxy handles it)
- Remove api_key and api_secret from LastFmClient (proxy manages credentials)
- Simplify client to only handle session_key
- Update get_token() to return (token, authUrl) tuple from proxy
- Update all methods (get_session, scrobble, update_now_playing) to use proxy
- Add User-Agent header 'QBZ/1.0.0' for proxy validation
- Update bootstrap.ts to skip credential restoration (proxy handles it)
- Maintain backward compatibility with set_credentials as no-op
- Remove DEFAULT_API_SECRET constant and get_api_secret() function
- Update Default impl to require user-provided secret
- Update has_embedded_credentials() to only check API key
- API secret will be handled by Cloudflare Workers proxy
Add auto-disable logic to prevent incompatible settings from being enabled simultaneously:
Frontend (SettingsView.svelte):
- DAC Passthrough ON → auto-disables Gapless Playback and Crossfade
- Gapless Playback ON → auto-disables DAC Passthrough
- Crossfade > 0 → auto-disables DAC Passthrough
- Added handleGaplessPlaybackChange() and handleCrossfadeChange() handlers
- Modified handleDacPassthroughChange() to disable incompatible settings
Backend (player/mod.rs):
- Only recreate OutputStream on format change when DAC passthrough is enabled
- When DAC passthrough is OFF: reuse existing stream for gapless transitions
- When DAC passthrough is ON: recreate stream for bit-perfect playback
- Added detailed logging for stream recreation decisions
This fixes the issue where Gapless Playback was enabled but gaps still occurred
due to DAC passthrough forcing stream recreation on sample rate changes.
The previous implementation tried to map ALSA device names (from cpal)
to PipeWire descriptions, but the naming schemes are completely different:
- cpal returns names like "plughw:1,0"
- pactl returns sink names like "alsa_output.usb-Cambridge_Audio_..."
This fix changes the approach:
1. Use PipeWire sinks directly for the device dropdown (already filtered
to real outputs and have friendly descriptions like "DacMagic Plus")
2. Store the PipeWire sink name when user selects a device
3. Set the PipeWire default sink using pactl when device is selected
4. Use rodio's default device (which follows PipeWire's default)
This ensures users see 4-5 meaningful devices with friendly names
instead of 30+ raw ALSA device names.
Backend changes:
- Add set_pipewire_default_sink command (pactl set-default-sink)
- Register new command in lib.rs
Frontend changes:
- Use pipewireSinks directly for device dropdown
- Display sink description (friendly name)
- Store sink name (for pactl)
- Call set_pipewire_default_sink when device changes
- Remove unused AudioDevice interface and getDevicePrettyName import
The play_data function was calling decode_with_symphonia which decoded
the entire audio file (271MB+) just to extract sample_rate and channels.
This caused 30-35 second delays between download complete and playback.
New extract_audio_metadata function:
- For FLAC: uses rodio decoder (reads headers only)
- For isomp4: uses symphonia probe to read codec_params without decoding
This restores the fast playback we had before.
Improvements to the Wayland compatibility fix:
Detection:
- Add NVIDIA GPU detection via /proc and kernel modules
- Apply DMA-BUF workaround only on NVIDIA systems
- Preserve full acceleration on Intel/AMD GPUs
User Overrides:
- QBZ_FORCE_DMABUF=1: Force-enable DMA-BUF (bypass workaround)
- QBZ_DISABLE_DMABUF=1: Force-disable DMA-BUF
- QBZ_FORCE_X11=1: Force X11 backend on Wayland
Diagnostics:
- Clear logging of display server type
- NVIDIA detection status
- Applied workarounds and reasons
- User override notifications
This makes the fix selective and transparent while protecting
NVIDIA + Wayland users from fatal protocol errors.
Related: #6
cc
This commit implements proper sample rate passthrough for high-quality
audio playback, addressing issue #10 where DAC sample rates were locked
at 44.1kHz regardless of file quality.
Core Changes:
- Modified Player to accept and store AudioSettings (exclusive mode, DAC passthrough)
- Updated AudioCommand::Play to include sample_rate and channels metadata
- Created create_output_stream_with_config() to build custom StreamConfig
- Added sample rate tracking to detect changes between tracks
- Modified Play handler to recreate OutputStream when sample rate changes
- Updated play_data() to extract audio metadata before playback
- Modified lib.rs to read AudioSettings on startup and pass to Player
Device Detection Improvements (Issue #4):
- Added display_name and device_type fields to AudioDevice struct
- Implemented get_pipewire_device_descriptions() to extract friendly names
- Updated get_audio_devices() to map technical names to user-friendly names
- Added device type detection (USB, HDMI, PCI, Bluetooth)
Technical Details:
- Audio files are decoded twice: once for metadata, once for playback
- Stream is recreated only when sample rate or channel count changes
- Falls back to default device config if custom config fails
- Supports both PipeWire and PulseAudio device naming via pactl
- Logs sample rate transitions and OutputStream configuration
Files Modified:
- src-tauri/src/player/mod.rs: Core playback engine changes
- src-tauri/src/lib.rs: Initialize Player with AudioSettings
- src-tauri/src/commands/playback.rs: Device enumeration improvements
Tested: Compiles successfully on Linux with Rust 1.92
L1 (Memory): 300MB for ~3-4 Hi-Res tracks, instant access
L2 (Disk): 500MB playback cache at ~/.cache/qbz/playback/
Flow:
- When track evicted from memory, saved to disk cache
- When loading: check memory → disk → download cache → network
- Tracks promoted back to memory when accessed from disk
This reduces re-downloads when navigating back to recently played
tracks in mixed playlists.
- Stop playback immediately when starting a Qobuz track to prevent
previous track from continuing during download
- Show buffering toast while downloading Qobuz audio
- Skip buffering UI for local tracks since they load instantly
- Add is_local field to QueueTrack for prefetch optimization
- Update prefetch to skip local tracks (no network needed)
- Update all queue track builders to include is_local flag
Wire onPlaylistCountUpdate from PlaylistDetailView to Sidebar's
updatePlaylistCounts method in +page.svelte. This ensures the
sidebar displays accurate track counts from the database instead
of calculated values that could drift out of sync.
- Add PlaylistLocalTrack struct with playlist_position field
- Add playlist_get_local_tracks_with_position command
- Update PlaylistDetailView to merge tracks by position instead of
appending local tracks at the end
- Update PlaylistModal to calculate correct position when adding local
tracks (total count = qobuz + existing local)
- Local tracks now appear in the order they were added, interleaved
with Qobuz tracks