cmus/cmus — pull request #50 by stonekyx (2013-07-31 02:37:52+00:00)
Title: fix ffmpeg input plugin

I'm sorry but this is the same pull request as the one I closed just now. I'm new to Github and didn't know that one should create a feature branch for pull requests.

So the following is copied from my last pull request.

---------------------------------------

I don't actually know if the plugin is already working in other branches, but when I used the latest version in the master branch, cmus just made noises when playing .ape or .wma files, which obviously uses ffmpeg plugin.

First I fixed the use of deprecated APIs, by adding more #if branches. When I changed to use avcodec_decode_audio4, the noise partly disappeared, but some audio played too fast this time. It was about sample formats. There were different problems here, but only one solution.

It seemed that the previous version of ffmpeg plugin just gives up when sample_fmt is AV_SAMPLE_FMT_FLT or AV_SAMPLE_FMT_DBL, but I do have some files with these sample formats. The solution I adopted is to use swresample, as this is the simplest one. In ffmpeg_open, the parameters of SwrContext is set, and in ffmpeg_fill_buffer, only a call to swr_convert solves everything. Now my file with AV_SAMPLE_FMT_FLTP plays perfect.

The exact version of ffmpeg I have tested with is 1.2.1. The output plugin was alsa.

My system is ArchLinux. `uname -a` prints:
Linux stone-arch 3.9.3-1-ARCH #1 SMP PREEMPT Mon May 20 08:00:01 CEST 2013 i686 GNU/Linux