You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.3 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd. Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: audio hal direct output header file.
* Author: yinyingcai
* Create: 2020-05-11
* Notes: NA
* History: 2020-05-11 yinyingcai for CodingStyle
*/
#ifndef HDO_H
#define HDO_H
#include <system/audio.h>
#include <hardware/audio.h>
#include <tinyalsa/asoundlib.h>
#include "audio_hw.h"
#define DIRECTOUT_BUFFER_MS 50
#define AUDIO_DRC_RFMODE 0
#define AUDIO_DRC_LINEMODE 1
#define AUDIO_DRC_RANGE_DEFAULT 100
#define PTS_TMP_BUFFERSIZE (DIRECTOUT_BUFFER_MS * 192 * 2 * 2 * 2) // 192K 20ms 2ch 16bit 2cnt
enum {
CMD_DRAIN, /* full drain */
CMD_PARTIAL_DRAIN, /* partial drain */
};
struct hdo_data {
uint32_t usecase;
uint32_t play_state;
struct stream_out *out;
uint32_t hTrack;
uint32_t hAvplay;
// file dbg
FILE *fd_es;
FILE *fd_pts;
// tunnel pb pts
uint32_t u32FrameSize;
uint64_t u64FramePts;
uint32_t u32RawDataLeftSize;
uint32_t u32TmpBufSize;
bool bEosFlag;
bool bBasePtsAdd;
uint8_t cTmpBuf[PTS_TMP_BUFFERSIZE];
// volume cfg
int bSetVolumeSuccess;
int bTrackMuted;
float userSetVolume;
int s32IntegerGain;
int s32DecimalGain;
};
int hdo_init(struct audio_device* adev);
void hdo_deinit(void);
int hdo_create(struct hdo_data** pphdo);
void hdo_destroy(struct hdo_data* hdo);
int hdo_open(struct hdo_data *hdo);
int hdo_close(struct hdo_data *hdo);
size_t hdo_get_buffer_size(const struct hdo_data *hdo);
int hdo_pause(struct hdo_data *hdo);
int hdo_resume(struct hdo_data *hdo);
int hdo_flush(struct hdo_data *hdo);
int hdo_drain(const struct hdo_data *hdo, int type);
uint32_t hdo_get_latency(const struct hdo_data *hdo);
int hdo_get_render_position(const struct hdo_data *hdo, uint32_t *dsp_frames);
int hdo_get_tstamp(const struct hdo_data *hdo, uint64_t *dsp_frames);
ssize_t hdo_write(struct hdo_data *hdo, const uint8_t* buffer, size_t bytes);
int hdo_create_hwsync_source(const int *sync_source);
int hdo_destroy_hwsync_source(int sync_source);
int hdo_obtain_hwsync_streaminfo(struct audio_device* adev);
#endif