[FFmpeg-devel] [PATCH] lavd/oss: support for more than 2 channels

Paul B Mahol onemda at gmail.com
Fri Jul 20 18:16:21 CEST 2012


On 7/20/12, Nicolas George <nicolas.george at normalesup.org> wrote:
> Le tridi 3 thermidor, an CCXX, Paul B Mahol a ecrit :
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>>  libavdevice/oss_audio.c |   19 ++++++++++++++-----
>>  1 files changed, 14 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavdevice/oss_audio.c b/libavdevice/oss_audio.c
>> index 53acba3..feb3bb2 100644
>> --- a/libavdevice/oss_audio.c
>> +++ b/libavdevice/oss_audio.c
>> @@ -119,11 +119,20 @@ static int audio_open(AVFormatContext *s1, int
>> is_output, const char *audio_devi
>>          goto fail;
>>      }
>>
>> -    tmp = (s->channels == 2);
>> -    err = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
>> -    if (err < 0) {
>> -        av_log(s1, AV_LOG_ERROR, "SNDCTL_DSP_STEREO: %s\n",
>> strerror(errno));
>> -        goto fail;
>> +    if (s->channels > 2) {
>> +        tmp = s->channels;
>> +        err = ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &tmp);
>> +        if (err < 0) {
>> +            av_log(s1, AV_LOG_ERROR, "SNDCTL_DSP_CHANNELS: %s\n",
>> strerror(errno));
>> +            goto fail;
>> +        }
>
> What is OSS's channel order? My guess is it is the same as ALSA, and if
> soit
> needs reordering.

Really? Channel ordering have nothing to do with this patch, without this
patch more than 2 channels data is not played correctly at all.
(So better something than nothing). This is what mplayer(2) use.

>
> Note: I have been considering writing a set of common reordering functions
> for some time. Now would probably be the time.

Why reordering? Isn't reordering meant to be done with libswr?

Isn't that libavdevice audio outdevs should play only channel order they
actually support, and any reordering should be done in libswr and not in
lavd itself.

>
>> +    } else {
>> +        tmp = (s->channels == 2);
>> +        err = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
>> +        if (err < 0) {
>> +            av_log(s1, AV_LOG_ERROR, "SNDCTL_DSP_STEREO: %s\n",
>> strerror(errno));
>> +            goto fail;
>> +        }
>
> What happens if you call "SNDCTL_DSP_CHANNELS, 2" instead of
> "SNDCTL_DSP_STEREO, 1"?

I do not care.


More information about the ffmpeg-devel mailing list