I had the same problems. It seems libav mp2 decoding by default outputs in S16P format (planar) which is not so common in various audio editing applications that support raw input (audacity for example). I solved my problem by specifiying request_sample_fmt in AVCodecContext being AV_SAMPLE_FMT_S16. Thus there's no additional need for software resampling.
In function audio_decode_example:
...
c = avcodec_alloc_context3(codec);
if (!c) {
fprintf(stderr, "Could not allocate audio codec context\n");
exit(1);
}
c->request_sample_fmt = AV_SAMPLE_FMT_S16;
...