title: Capture playback on play-only sound card with ALSA
body: <p>My hw:1,0 is a playback-only external USB card. The recording application cannot capture the samples being sent to hw:1,0 if it tries opening hw:1,0 for capture. The alsamixer doesn't give any "[Capture]" options for hw:1,0 - just one volume control on "[Playback]" tab.</p>
  
  <p>Is it possible to create some virtual "xxx" device that would accept a stream from playing application and send it out via 2 streams (copies) - first one to real "hw:1,0" (to my headphones) and the second one to another virtual device "zzz" that would provide capture ability, feeding the stream to applications that could open "zzz" for capturing?</p>
  
  <p><strong>update</strong></p>
  
  <p>I added ALSA Loopback device in kernel, now i have loopback device. Then i found working .asoundrc (see below), but when i capture screen + sound using ffmpeg, the sound goes WAY before than video, some great sync problem. So with this .asoundrc (below) i can use hw:0,0 (loopback device, hw:0,0 - play, hw:0,1 - capture) to capture what i send to "default". Also i can hear these samples via my external USB hw:2,0.</p>
  
  <p>ffmpeg command:</p>
  
  <pre><code>ffmpeg  -f alsa -i hw:0,1  -f x11grab -s 854x480 -r 30 -i :0.0 -vcodec libx264 -vb 4000k /tmp/screen_854x480.avi
  </code></pre>
  
  <p>.asoundrc:</p>
  
  <pre><code>pcm.!default {
      type plug
      slave.pcm "mdev"
      route_policy "duplicate"
  
  }
  
  pcm.mdev {
      type multi
  
      slaves.a.pcm "hw:Loopback,0,0"
      slaves.a.channels 2
      slaves.b.pcm "dmixer"
      slaves.b.channels 2
  
      bindings.0.slave a
      bindings.0.channel 0
      bindings.1.slave a
      bindings.1.channel 1
      bindings.2.slave b
      bindings.2.channel 0
      bindings.3.slave b
      bindings.3.channel 1
  }
  
  pcm.dmixer {
      type dmix
      ipc_key 1024
      slave {
              pcm "hw:2,0"
              period_time 0
              period_size 1024
              buffer_size 4096
              rate 44100
              channels 2
              format S16_LE
      }
  }
  </code></pre>