Skip to content

WSL No playback. #446

@Pycnomerus

Description

@Pycnomerus

I had a problem running on wsl2 Debian where even with ffmpeg or pulseAudio no sound would come out of the peon preview.
But the sound would work from peon update test.

turn our the two approach are inconsistant, claude proposal ended up working for me, here's the patch I used.

--- a/libexec/peon.sh
 +++ b/libexec/peon.sh
 @@ -499,17 +499,15 @@ play_sound() {
      wsl)
 -      local tmpdir tmpfile
 -      tmpdir=$(powershell.exe -NoProfile -NonInteractive -Command '[System.IO.Path]::GetTempPath()' 2>/dev/null | tr -d '\r')
 -      tmpfile="$(wslpath -u "${tmpdir}peon-ping-sound.wav")"
 -      if command -v ffmpeg &>/dev/null; then
 -        ffmpeg -y -i "$file" -filter:a "volume=$vol" "$tmpfile" 2>/dev/null
 -      elif [[ "$file" == *.wav ]]; then
 -        cp "$file" "$tmpfile"
 -      else
 -        return 0
 -      fi
 -      local safe_tmpdir="${tmpdir//\'/\'\'}"
 -      setsid powershell.exe -NoProfile -NonInteractive -Command "
 -        (New-Object Media.SoundPlayer '${safe_tmpdir}peon-ping-sound.wav').PlaySync()
 -      " &>/dev/null &
 -      save_sound_pid $!
 +      local wpath
 +      wpath=$(wslpath -w "$file")
 +      wpath="${wpath//\\//}"
 +      powershell.exe -NoProfile -NonInteractive -Command "
 +        Add-Type -AssemblyName PresentationCore
 +        \$p = New-Object System.Windows.Media.MediaPlayer
 +        \$p.Open([Uri]::new('file:///$wpath'))
 +        \$p.Volume = $vol
 +        Start-Sleep -Milliseconds 500
 +        \$p.Play()
 +        Start-Sleep -Seconds 4
 +        \$p.Close()
 +      " &>/dev/null
        ;;

Summary for the issue:

Problem (Debian WSL): peon preview and hook sounds are silent.

Two bugs compound:

  1. setsid powershell.exe ... & exits immediately on Debian WSL — the background process dies before playing anything. (nohup has the same problem.)
  2. Media.SoundPlayer requires PCM WAV — if ffmpeg isn't installed and the file isn't .wav, it silently return 0s. Even when ffmpeg is present, the backgrounding issue kills playback.

Fix: Use System.Windows.Media.MediaPlayer (PresentationCore) directly on the original file — same approach install.sh already uses for the test sound. This works for WAV, MP3, and other
formats natively via Windows Media Foundation, with no ffmpeg dependency. Runs synchronously (the hook process is already async from Claude Code's perspective, so the ~1-2s block is
harmless).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions