I am encountering the following warning (from [Audio Toolbox][1]?) very often 
when opening an external microphone audio stream with libavformat on macOS (M2, 
Sonoma 14.5):

`CMIO_Unit_Converter_Audio.cpp:590:RebuildAudioConverter 
AudioConverterSetProperty(dbca) failed (1886547824)`

This warning results on the codec id of the stream not being properly detected 
and it defaulting to the dummy AV_CODEC_ID_FIRST_AUDIO, which defaults to 
AV_CODEC_ID_PCM_S16LE, and results on distorted audio decoding the packet when 
this is not the correct codec.

You can observe the error with the following code (change the value of 
inputDevice to your device of choice), where I open and close and input audio 
stream 10 times in a row. Except for the internal macbook microphone, all the 
other ones I tried error more times than succeed, some only succeeding on the 
first call. From what I can tell, all these microphones correct detected codec 
with this code is AV_CODEC_ID_PCM_F32LE.

=================
#include "libavdevice/avdevice.h"
#include "libavformat/avformat.h"
#include <stdio.h>

const char inputDevice[] = ":0";

int main(int argc, char *argv[]) {
  const AVInputFormat *inputFormat;
  AVStream *inputStream = NULL;
  AVFormatContext *inputFormatContext = NULL;
  int ret;
  int i, j;

  // Initialize the input
  avdevice_register_all();

  inputFormat = av_find_input_format("avfoundation");

  for (i = 0; i < 10; i++) {
    ret = avformat_open_input(&inputFormatContext, inputDevice, inputFormat,
                              NULL);
    if (ret != 0) {
      fprintf(stderr, "Couldn't open input audio device");
      break;
    }

    ret = avformat_find_stream_info(inputFormatContext, NULL);
    if (ret < 0) {
      fprintf(stderr, "Couldn't find stream information.");
      break;
    }

    for (j = 0; j < inputFormatContext->nb_streams; j++) {
      if (inputFormatContext->streams[j]->codecpar->codec_type ==
          AVMEDIA_TYPE_AUDIO) {
        inputStream = inputFormatContext->streams[j];
        break;
      }
    }
    if (!inputStream) {
      fprintf(stderr, "Couldn't find a audio stream.");
      break;
    }
    printf("codecID: %s\n",
           inputStream->codecpar->codec_id == AV_CODEC_ID_FIRST_AUDIO
               ? "Incorrect"
               : "Correct");
    avformat_close_input(&inputFormatContext);
  }
  return 0;
}
=================

Example output:

codecID: Correct
codecID: Incorrect
codecID: Incorrect
codecID: Incorrect
codecID: Incorrect
codecID: Correct
codecID: Incorrect
codecID: Incorrect
codecID: Incorrect
codecID: Correct


How can avoid the warning? What am I doing wrong?


  [1]: 
https://developer.apple.com/documentation/audiotoolbox/audio_converter_services?language=objc
_______________________________________________
Libav-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to