[FFmpeg-devel] [PATCH 3/3] lavd/alsa_audio_enc: implementation of query_codec

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Nov 2 10:53:49 CET 2013


On Fri, Nov 01, 2013 at 03:40:50PM +0100, Lukasz Marek wrote:
> Implementation of query_codec callback that allow to
> check if specific codec is supported by device.
> 
> Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
> ---
>  libavdevice/alsa-audio-enc.c |   25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/libavdevice/alsa-audio-enc.c b/libavdevice/alsa-audio-enc.c
> index 0f4e4a2..d3447a3 100644
> --- a/libavdevice/alsa-audio-enc.c
> +++ b/libavdevice/alsa-audio-enc.c
> @@ -115,6 +115,30 @@ audio_get_output_timestamp(AVFormatContext *s1, int stream,
>      *dts = s1->streams[0]->cur_dts - delay;
>  }
>  
> +static int audio_query_codec(enum AVCodecID id, int std_compliance)
> +{
> +    return id == AV_CODEC_ID_PCM_F64LE ||
> +           id == AV_CODEC_ID_PCM_F64BE ||
> +           id == AV_CODEC_ID_PCM_F32LE ||
> +           id == AV_CODEC_ID_PCM_F32BE ||
> +           id == AV_CODEC_ID_PCM_S32LE ||
> +           id == AV_CODEC_ID_PCM_S32BE ||
> +           id == AV_CODEC_ID_PCM_U32LE ||
> +           id == AV_CODEC_ID_PCM_U32BE ||
> +           id == AV_CODEC_ID_PCM_S24LE ||
> +           id == AV_CODEC_ID_PCM_S24BE ||
> +           id == AV_CODEC_ID_PCM_U24LE ||
> +           id == AV_CODEC_ID_PCM_U24BE ||
> +           id == AV_CODEC_ID_PCM_S16LE ||
> +           id == AV_CODEC_ID_PCM_S16BE ||
> +           id == AV_CODEC_ID_PCM_U16LE ||
> +           id == AV_CODEC_ID_PCM_U16BE ||
> +           id == AV_CODEC_ID_PCM_S8    ||
> +           id == AV_CODEC_ID_PCM_U8    ||
> +           id == AV_CODEC_ID_PCM_MULAW ||
> +           id == AV_CODEC_ID_PCM_ALAW ? 1: 0;

I'm not sure what the point of it is.
It doesn't cover all possibilities (e.g. AC3, DTS etc. in SPDIF is often
supported), while it also contains formats that are
almost never supported (especially the reverse endianness
formats, but most of the time only AV_CODEC_ID_PCM_S16LE
actually works).
I don't understand what the point of a query function is anyway
when it doesn't even have enough information to open the device
and check what actually works...


More information about the ffmpeg-devel mailing list