Skip to content

Commit

Permalink
Iterate through all formats, if any, the codec advertises that it can…
Browse files Browse the repository at this point in the history
… process, stopping if the AV_SAMPLE_FMT_FLTP is found.
  • Loading branch information
mikebrady committed Jun 9, 2022
1 parent 3d9d975 commit 4705be9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions shairport.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,13 @@ int has_fltp_capable_aac_decoder(void) {
int has_capability = 0;
const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_AAC);
if (codec != NULL) {
AVCodecContext *codec_context = avcodec_alloc_context3(codec);
if (codec_context != NULL) {
if (avcodec_open2(codec_context, codec, NULL) >= 0) {
if (codec_context->sample_fmt == AV_SAMPLE_FMT_FLTP)
const enum AVSampleFormat *p = codec->sample_fmts;
if (p != NULL) {
while ((has_capability == 0) && (*p != AV_SAMPLE_FMT_NONE)) {
if (*p == AV_SAMPLE_FMT_FLTP)
has_capability = 1;
avcodec_close(codec_context);
p++;
}
av_free(codec_context);
}
}
return has_capability;
Expand Down

0 comments on commit 4705be9

Please sign in to comment.