Updated on 2023-06-15 GMT+08:00

Reading Audio Data

This section describes how to read one or more frames of audio. Only 1.0.8 and later firmware versions are supported.

  • API calling

    virtual int hilens::AudioCapture::Read(AudioFrame &frames, int n=1)

  • Parameter description

    The AudioFrame structure is defined as follows. For details about the parameters, see Table 1.

    typedef struct AudioFrame_s{
      std::shared_ptr<void> data;
      unsigned int size;
    }AudioFrame;
    Table 1 Parameters

    Parameter

    Description

    data

    Output parameter, indicating the smart pointer for storing the audio data that is read.

    size

    Output parameter, indicating the size of the audio data that is read.

    n

    Input parameter, indicating the number of audio frames read at a time. The maximum value is 512.

  • Return Value

    If the operation is successful, 0 is returned. If the operation fails, -1 is returned. You can view the log to locate the fault.