luckfox-pico-sdk/sysdrv/source/mcu/rt-thread/components/aupipe/basics/audiotee.c
luckfox-eng29 8f34c2760d project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between
the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door
for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more
usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp:
Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for
compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem.
sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device
tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately.
sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick
boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades.
sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for
fastboot.

Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
2024-10-14 09:47:04 +08:00

141 lines
3.1 KiB
C

/**
* Copyright (c) 2023 Rockchip Electronics Co., Ltd
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************
* @file audiotee.c
* @author Jun Zeng
* @version V0.1
* @date 10-03-2023
* @brief audiotee for rksoc
*
******************************************************************************
*/
#include "aupipe.h"
#ifdef RT_USING_AUPIPE_AUDIOTEE
#include "drv_heap.h"
#undef DBG_SECTION_NAME
#define DBG_SECTION_NAME "AUDIOTEE"
#define AUDIOTEE(obj) ((ApAudioTee *)(obj))
typedef struct audiotee_object
{
ApObject base;
ApPad *src_pad;
ApPad *sink_pad;
int channels;
} ApAudioTee;
static int audiotee_process(ApPad *pad, ApBuffer *buffer);
static int audiotee_init(ApObject *obj, void *arg)
{
ApAudioTee *object = AUDIOTEE(obj);
int status = RT_EOK;
char *parameters = (char *)arg;
status |= aupipe_find_property(parameters, "channels",
VALUE_TYPE_INT, &object->channels);
if (status != RT_EOK)
{
LOG_E("%s plug-in parameter initialization failed", object->base.name);
return -RT_ERROR;
}
object->src_pad = aupipe_pad_new(obj, object->channels * 2);
RT_ASSERT(object->src_pad != NULL);
object->sink_pad = aupipe_pad_new(obj, object->channels);
RT_ASSERT(object->sink_pad != NULL);
for (int i = 0; i < object->channels; i++)
{
object->sink_pad[i].process = audiotee_process;
}
return RT_EOK;
}
static int audiotee_deinit(ApObject *obj)
{
ApAudioTee *object = AUDIOTEE(obj);
rt_free(object->src_pad);
rt_free(object->sink_pad);
return RT_EOK;
}
static int audiotee_process(ApPad *pad, ApBuffer *buffer)
{
ApAudioTee *obj = AUDIOTEE(pad->parent);
Aupipe *aupipe = obj->base.parent;
ApBuffer *new_buffer = aupipe_buffer_new(DATA_TYPE_AUDIO, buffer->len);
if (!new_buffer)
{
LOG_E("%s malloc %d failed", obj->base.name, buffer->len);
return -RT_ERROR;
}
rt_memcpy(new_buffer->data, buffer->data, buffer->len);
new_buffer = aupipe_buffer_ref(new_buffer);
aupipe_pad_push(&obj->src_pad[pad->id], new_buffer);
aupipe_pad_push(&obj->src_pad[pad->id + obj->channels], buffer);
return RT_EOK;
}
static int audiotee_set_state(ApObject *obj, int state)
{
ApAudioTee *object = AUDIOTEE(obj);
switch (state)
{
case STATE_NULL_TO_READY:
LOG_I("STATE_NULL_TO_READY");
break;
case STATE_READY_TO_NULL:
LOG_I("STATE_READY_TO_NULL");
break;
default:
break;
}
return RT_EOK;
}
static int audiotee_set_property(ApObject *obj, char *name, void *arg)
{
return RT_EOK;
}
static int audiotee_get_property(ApObject *obj, char *name, void *arg)
{
return RT_EOK;
}
static ApPad *audiotee_get_pad(ApObject *obj, int type, int id)
{
ApAudioTee *object = AUDIOTEE(obj);
if (type == PAD_TYPE_SINK)
return &object->sink_pad[id];
return &object->src_pad[id];
}
OBJECT_BASE_DEFINE(audiotee, ApAudioTee);
#endif