Files
ai-passport/main/xiaozhi_buffer.h
T
hex2077 6a7f4e010b chore: 新增大量静态资源、测试桩文件与配置文件,清理旧无用资源
本次提交新增了多种字体、UI图片、音频剪辑等静态资源,添加了测试桩文件与项目配置文件,同时清理了部分已废弃的旧图片与测试桩代码文件。
2026-09-22 00:42:26 +08:00

27 lines
949 B
C

#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define XZ_AUDIO_CAPACITY 4096u
#define XZ_AUDIO_PACKET_MAX 1500u
/* One owner: the network/audio worker. Lives after the decoder in its arena;
* encoder and decoder/playback queue are never active at the same time. */
typedef struct {
uint8_t data[XZ_AUDIO_CAPACITY];
unsigned head,tail,used,count,samples,peak;
int64_t first_us;
bool playing;
} xz_audio_buffer_t;
bool xz_audio_arena_layout(size_t encoder,size_t decoder,size_t *queue_offset,size_t *bytes);
unsigned xz_opus_samples(const uint8_t *data,size_t size);
bool xz_audio_push(xz_audio_buffer_t *q,const uint8_t *data,size_t size,int64_t now);
bool xz_audio_ready(xz_audio_buffer_t *q,int64_t now,bool ended);
size_t xz_audio_pop(xz_audio_buffer_t *q,uint8_t *out,size_t capacity);
bool xz_audio_room(const xz_audio_buffer_t *q);
#ifdef __cplusplus
}
#endif