yep, will move that down, after:
```
  if (!m_CodecCtx || frames < m_NeededFrames)
    return 0;
```
Actually, thinking about this:
```
    /* The following data should not be initialized. */
    /**
     * Number of samples per channel in an audio frame.
     *
     * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
     *   except the last must contain exactly frame_size samples per channel.
     *   May be 0 when the codec has CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
     *   frame size is not restricted.
     * - decoding: may be set by some decoders to indicate constant frame size
     */
    int frame_size;
```
and m_NeededFrames ==  m_CodecCtx->frame_size

fortunately, only libavcodec/pcm.c defines this so we haven't hit possible problems.

So, IMHO, moving it down should fix the possible problem you're pointing out but we should adapt the code a bit when m_NeededFrames is 0.