apiVersion: v1
kind: ConfigMap
metadata:
  name: mpd-config
  namespace: media
  labels:
    app.kubernetes.io/instance: mpd
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: mpd
    app.kubernetes.io/version: latest
    helm.sh/chart: mpd-0.1.0
  annotations:
    meta.helm.sh/release-name: mpd
    meta.helm.sh/release-namespace: media
data:
  mpd.conf: |
    music_directory "/var/lib/mpd/music"
    playlist_directory "/var/lib/mpd/playlists"
    db_file "/var/lib/mpd/data/database"
    log_file "/var/log/mpd/mpd.log"
    pid_file "/run/mpd/pid"
    state_file "/var/lib/mpd/data/state"
    sticker_file "/var/lib/mpd/data/sticker.sql"
    bind_to_address "0.0.0.0"
    port "6600"
    zeroconf_enabled "no"

    # Performance tuning - SIGNIFICANTLY INCREASED buffer settings for network streaming
    # These larger buffers help prevent glitches especially with NFS storage
    audio_buffer_size "32768"         # Increased from 8192 to 32MB (4x larger)
    max_output_buffer_size "131072"   # Increased from 16384 to 128MB (8x larger)

    # Additional performance settings
    connection_timeout "60"           # Give more time for slow network operations
    max_connections "20"              # Allow more concurrent connections
    max_playlist_length "32768"       # Support larger playlists

    # Filesystem charset for better compatibility
    filesystem_charset "UTF-8"

    # Auto-update database when files change
    auto_update "yes"
    auto_update_depth "4"

    # HTTP streaming output - High quality MP3
    audio_output {
        type "httpd"
        name "HTTP Stream"
        encoder "lame"
        port "8000"
        bitrate "320"
        format "44100:16:2"
        max_clients "10"
        always_on "yes"
        tags "yes"
        mixer_type "software"
    }

    # Optional: FIFO output for visualizers
    audio_output {
        type "fifo"
        name "FIFO"
        path "/tmp/mpd.fifo"
        format "44100:16:2"
    }
