title: PyAudio stream read is blocking (no data) on device with ALSA and pulseaudio
body: <p>I'm trying to get audio data in Python on a Linux device that runs PulseAudio.</p>
  
  <p>The previous environment in which pyaudio worked was just ALSA. 
  Now the environment runs PulseAudio. I've hooked ALSA into PulseAudio by setting the default ALSA device to be a pulse. </p>
  
  <p><code>arecord -f dat test.wav</code> and then <code>aplay test.wav</code> work fine for me right now.</p>
  
  <p>However, it seems like pyaudio does not work under these settings. </p>
  
  <pre><code>import pyaudio
  import wave
  
  CHUNK = 1024
  FORMAT = pyaudio.paInt16
  CHANNELS = 2
  RATE = 44100
  
  p = pyaudio.PyAudio()
  
  stream = p.open(format=FORMAT,
                  channels=CHANNELS,
                  rate=RATE,
                  input=True,
                  frames_per_buffer=CHUNK)
  
  stream.read(CHUNK)
  </code></pre>
  
  <p><code>stream.read()</code> hangs. <code>strace</code> shows it stuck in a loop of:</p>
  
  <pre><code>poll([{fd=3, events=POLLIN|POLLERR|POLLNVAL}], 1, 3) = 1 ([{fd=3, revents=POLLIN}])
  </code></pre>
  
  <p>I guess the meta question here is, does a stack of pyaudio -> port audio -> alsa -> PulseAudio work? If not, is there a canonical way of getting audio in Python from PulseAudio? A lot of the top of the python/PulseAudio libraries out there have not had any activity in the past couple years. </p>
  
  <p>My asound.conf looks something like this</p>
  
  <pre><code>pcm.!default{
  type plug
  route_policy "average"
  slave.pcm "asymed"
  }
  
  pcm.asymed{
  type asym
  playback.pcm "pulse_playback"
  capture.pcm "pulse_capture"
  }
  
  pcm.pulse_playback {
  type pulse
  device "alsa_output.platform-sound_0.analog-stereo"
  }
  
  pcm.pulse_capture {
  type pulse
  device "alsa_input.platform-sound_1.analog-stereo"
  }
  </code></pre>