I haven't worked with audio, but I think I may see the problem. You're hanging in dequeueOutputBuffer()
because the codec is waiting for more input.
Some of the video codecs want ~4 buffers of input before they'll even finish initialization (for example). I expect some audio codecs may behave the same way. Codec implementations vary from device to device, so it's not surprising that what runs on the emulator behaves much differently.
Change the timeouts from -1 (wait forever) to something modest (say, 1000 microseconds).