Files
2026-08-24 10:03:24 +08:00

61 lines
2.1 KiB
C

/*
* Copyright (C) 2023 Amlogic Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _AUDIO_BUFFER_
#define _AUDIO_BUFFER_
#include <stdbool.h>
#include <stdint.h>
#include "aml_audio_log.h"
struct audio_buffer {
bool b_pts_valid;
int original_format; //out_write buffer's format
int original_sample_rate; //original_format's sample rate
int format; //current buffer's format
int sub_format; //for IEC data
int dd_ddp_frame_size;
int sample_rate; //current format's sample rate
int channel; //current format's channel
int channel_mask;
int32_t size;
int duration; //only used for raw data
uint64_t pts; //unit 90k;
const void* buffer;
const void* iec_data_buf;// Used for HDMI source DD/DDP/MAT bypass or mpegh bypass
int32_t iec_data_size;// Used for HDMI source DD/DDP/MAT bypass or mpegh bypass
int32_t iec_data_ch;// mpegh iec data channel number
int32_t iec_data_sr;// mpegh iec data sample rate
int32_t iec_data_format;// mpegh
};
static inline bool check_audio_buffer_valid(struct audio_buffer *abuffer) {
if (NULL == abuffer) {
AM_LOGE("abuffer is null, need check it!!");
return false;
}
if (abuffer->sample_rate <= 0 || abuffer->channel <= 0 || abuffer->size <= 0 || NULL == abuffer->buffer) {
AM_LOGE("abuffer checked invalid!! abuffer->sample_rate:%d, abuffer->channel:%d, abuffer->size:%d, abuffer->buffer:%p",
abuffer->sample_rate, abuffer->channel, abuffer->size, abuffer->buffer);
return false;
}
return true;
}
#endif