Merge branch 'master' of ssh://g.hz.netease.com:22222/IoT/PV2/SmartAudioPV2

update
This commit is contained in:
wangzijiao 2018-08-23 15:05:38 +08:00
commit ec4dc47be6
43 changed files with 876 additions and 106 deletions

View File

@ -49,6 +49,8 @@ ifdef CONFIG_SUNXI_MULITCORE_BOOT
obj-y += secondary_main.o
endif
obj-$(CONFIG_NETEASE_OTA) += netease_ota.o
obj-y += board_common.o
subdir-ccflags-$(CONFIG_SUNXI_FINS_FUNC_BOARD_DIR) += -finstrument-functions

View File

@ -0,0 +1,445 @@
#include <common.h>
#include <sunxi_mbr.h>
#include <boot_type.h>
#include <sys_partition.h>
#include <sys_config.h>
#include <mmc.h>
#include <power/sunxi/axp.h>
#include <asm/io.h>
#include <power/sunxi/pmu.h>
#include <asm/arch/ccmu.h>
#include <fs.h>
#include <u-boot/md5.h>
#define MBR_PAGE_SIZE (512)
#define MD5_CHKSUM_LEN (16)
#define OTA_PARAMS_TAG ("OTAPARAM")
#define MD5_STR_LEN (32 + 4)
#define OTA_PARTITION_DEV ("sunxi_flash")
#define OTA_PARTITION_NAME ("0:0")
#define READ_OTA_PARAMS_ADDR (0x40007800)
#define READ_BOOT_ADDR (READ_OTA_PARAMS_ADDR + (1024 * 1024))
#define READ_ROOTFS_ADDR (READ_BOOT_ADDR + (1024 * 1024 * 4))
typedef struct
{
char tags[8];
int otaStatus;
char otaVer[MD5_STR_LEN];
char bootChksum[MD5_STR_LEN];
unsigned int bootfileSize;
char rootfsChksum[MD5_STR_LEN];
unsigned int rootfsfileSize;
char paramsChksum[MD5_STR_LEN];
} OTA_PARAMS, *POTA_PARAMS;
static const char hex_asc[] = "0123456789abcdef";
static char* __bin2hex(char *p, unsigned char *cp, int count)
{
while (count) {
unsigned char c = *cp++;
/* put lowercase hex digits */
*p++ = 0x20 | hex_asc[c >> 4];
*p++ = 0x20 | hex_asc[c & 0xf];
count--;
}
return p;
}
static void ota_print_params(POTA_PARAMS pInfo)
{
printf("tags: %s\n", pInfo->tags);
printf("status: 0x%08X\n", pInfo->otaStatus);
printf("version: %s\n", pInfo->otaVer);
printf("boot_ver: %s\n", pInfo->bootChksum);
printf("boot_size: %u\n", pInfo->bootfileSize);
printf("rootfs_ver: %s\n", pInfo->rootfsChksum);
printf("rootfs_size: %u\n", pInfo->rootfsfileSize);
}
static int ota_load_boot_partition(POTA_PARAMS pInfo)
{
unsigned char md5sum[MD5_CHKSUM_LEN];
char cmdBuf[128];
int iSize = sunxi_partition_get_size_byname("boot");
//u32 start_block = sunxi_partition_get_offset_byname("boot");
memset(cmdBuf, 0, 128);
sprintf(cmdBuf, "sunxi_flash read 0x%x boot", READ_BOOT_ADDR);
run_command(cmdBuf, 0);
if(pInfo->bootfileSize == 0)
pInfo->bootfileSize = iSize * MBR_PAGE_SIZE;
md5((unsigned char*)READ_BOOT_ADDR, (int)pInfo->bootfileSize, md5sum);
__bin2hex(pInfo->bootChksum, md5sum, MD5_CHKSUM_LEN);
return 0;
}
static int ota_load_rootfs_partition(POTA_PARAMS pInfo)
{
unsigned char md5sum[MD5_CHKSUM_LEN];
char cmdBuf[128];
int iSize = sunxi_partition_get_size_byname("rootfs");
//u32 start_block = sunxi_partition_get_offset_byname("boot");
memset(cmdBuf, 0, 128);
sprintf(cmdBuf, "sunxi_flash read 0x%x rootfs", READ_ROOTFS_ADDR);
run_command(cmdBuf, 0);
if(pInfo->rootfsfileSize == 0)
pInfo->rootfsfileSize = iSize * MBR_PAGE_SIZE;
md5((unsigned char*)READ_ROOTFS_ADDR, (int)pInfo->rootfsfileSize, md5sum);
__bin2hex(pInfo->rootfsChksum, md5sum, MD5_CHKSUM_LEN);
return 0;
}
static int ota_calc_params_checksum(POTA_PARAMS pInfo)
{
unsigned char md5sum[MD5_CHKSUM_LEN];
md5((unsigned char*)pInfo, sizeof(OTA_PARAMS) - MD5_STR_LEN, md5sum);
__bin2hex(pInfo->paramsChksum, md5sum, MD5_CHKSUM_LEN);
return 0;
}
static int ota_verify_params_checksum(POTA_PARAMS pInfo)
{
unsigned char md5sum[MD5_CHKSUM_LEN];
char md5str[MD5_STR_LEN];
memset(md5str, 0, MD5_STR_LEN);
md5((unsigned char*)pInfo, sizeof(OTA_PARAMS) - MD5_STR_LEN, md5sum);
__bin2hex(md5str, md5sum, MD5_CHKSUM_LEN);
return strcmp(md5str, pInfo->paramsChksum);
}
static int ota_save_params(POTA_PARAMS pInfo)
{
int iSize = (sizeof(OTA_PARAMS) + MBR_PAGE_SIZE - 1) / MBR_PAGE_SIZE;
u32 start_block = sunxi_partition_get_offset_byname("ota_info");
sunxi_flash_write(start_block, iSize, pInfo);
sunxi_flash_flush();
return 0;
}
static int ota_erase_partition(const char* pPart)
{
char cmdBuf[128];
printf("erase partition %s ......\n", pPart);
memset(cmdBuf, 0, 128);
sprintf(cmdBuf, "sunxi_flash write 0x%x %s", READ_OTA_PARAMS_ADDR, pPart);
run_command(cmdBuf, 0);
return 0;
}
static int ota_read_params(POTA_PARAMS pInfo)
{
char cmdBuf[128];
int init_params = 0;
memset(cmdBuf, 0, 128);
sprintf(cmdBuf, "sunxi_flash read 0x%x ota_info", READ_OTA_PARAMS_ADDR);
run_command(cmdBuf, 0);
memcpy(pInfo, (unsigned char*)READ_OTA_PARAMS_ADDR, sizeof(OTA_PARAMS));
if(strncmp(pInfo->tags, OTA_PARAMS_TAG, 7) == 0)
{
ota_print_params(pInfo);
if(ota_verify_params_checksum(pInfo) != 0)
{
init_params = 1;
printf("verify ota information error\n");
}
printf("found ota information\n");
}
else
{
init_params = 1;
}
if(init_params)
{
printf("ota system init.....\n");
memset(pInfo, 0, sizeof(OTA_PARAMS));
strcpy(pInfo->tags, OTA_PARAMS_TAG);
pInfo->otaStatus = 0;
ota_load_boot_partition(pInfo);
ota_load_rootfs_partition(pInfo);
ota_calc_params_checksum(pInfo);
ota_print_params(pInfo);
ota_save_params(pInfo);
}
return 0;
}
static int ota_read_boot_image(void)
{
int read_bytes = 0;
if (fs_set_blk_dev("sunxi_flash", "0", FS_TYPE_EXT))
{
return -1;
}
read_bytes = fs_read("ota/boot.img", READ_BOOT_ADDR, 0, 0);
printf("Read boot image to 0x%08X total %d(0x%X) bytes\n", READ_BOOT_ADDR, read_bytes, read_bytes);
return read_bytes;
}
static int ota_read_rootfs_image(void)
{
int read_bytes = 0;
if (fs_set_blk_dev("sunxi_flash", "0", FS_TYPE_EXT))
{
return -1;
}
read_bytes = fs_read("ota/rootfs.img", READ_ROOTFS_ADDR, 0, 0);
printf("Read rootfs image to 0x%08X total %d(0x%X) bytes\n", READ_ROOTFS_ADDR, read_bytes, read_bytes);
return read_bytes;
}
static int ota_calc_image_chksum(unsigned char* addr, int iSize, char* pChksm)
{
unsigned char md5sum[MD5_CHKSUM_LEN];
md5(addr, iSize, md5sum);
__bin2hex(pChksm, md5sum, MD5_CHKSUM_LEN);
return 0;
}
static int ota_upgrade_boot_image(void)
{
char cmdBuf[128];
memset(cmdBuf, 0, 128);
sprintf(cmdBuf, "sunxi_flash write 0x%x boot", READ_BOOT_ADDR);
run_command(cmdBuf, 0);
return 0;
}
static int ota_upgrade_rootfs_image(void)
{
char cmdBuf[128];
memset(cmdBuf, 0, 128);
sprintf(cmdBuf, "sunxi_flash write 0x%x rootfs", READ_ROOTFS_ADDR);
run_command(cmdBuf, 0);
return 0;
}
#if 0
static int ota_read_file(const char* pDev, const char* pPart, const char* pFile)
{
OTA_PARAMS otaInfo;
int read_bytes = 0;
if (fs_set_blk_dev(pDev, pPart, FS_TYPE_EXT))
{
return -1;
}
read_bytes = fs_read(pFile, READ_BOOT_ADDR, 0, 0);
printf("Read %s to 0x%08X total 0x%X bytes\n", pFile, READ_BOOT_ADDR, read_bytes);
ota_read_params(&otaInfo);
return read_bytes;
}
#endif
int do_ota(cmd_tbl_t *cmdtp, int flag, int argc,
char *const argv[])
{
static int read_boot_size = 0, read_rootfs_size = 0;
printf("ota cmd: argc = %d\n", argc);
if (argc < 2)
return CMD_RET_USAGE;
if(strncmp(argv[1], "erase", strlen("erase")) == 0)
{
if(argc != 3)
{
return CMD_RET_USAGE;
}
if(strncmp(argv[2], "boot", strlen("boot")) == 0
|| strncmp(argv[2], "rootfs", strlen("rootfs")) == 0
|| strncmp(argv[2], "ota_info", strlen("ota_info")) == 0
|| strncmp(argv[2], "rootfs_data", strlen("rootfs_data")) == 0
|| strncmp(argv[2], "UDISK", strlen("UDISK")) == 0)
{
ota_erase_partition(argv[2]);
}
else
{
return CMD_RET_USAGE;
}
}
else if(strncmp(argv[1], "readimg", strlen("readimg")) == 0)
{
if(argc != 3)
{
return CMD_RET_USAGE;
}
if(strncmp(argv[2], "boot", strlen("boot")) == 0)
{
read_boot_size = ota_read_boot_image();
printf("Read %d\n", read_boot_size);
}
else if(strncmp(argv[2], "rootfs", strlen("rootfs")) == 0)
{
read_rootfs_size = ota_read_rootfs_image();
printf("Read %d\n", read_rootfs_size);
}
else
{
return CMD_RET_USAGE;
}
}
else if(strncmp(argv[1], "show_params", strlen("readimg")) == 0)
{
OTA_PARAMS otaInfo;
ota_read_params(&otaInfo);
}
else if(strncmp(argv[1], "upgrade", strlen("upgrade")) == 0)
{
int force = 0, flag = 0;
OTA_PARAMS otaInfo, upgInfo;
if(argc == 2)
{
flag = (1 << 0) | (1 << 1);
}
else
{
if(argc == 4)
{
force = simple_strtoul(argv[3], NULL, 16);
}
if(strncmp(argv[2], "boot", strlen("boot")) == 0)
{
flag |= 1;
}
if(strncmp(argv[2], "rootfs", strlen("rootfs")) == 0)
{
flag |= (1 << 1);
}
if(strncmp(argv[2], "all", strlen("all")) == 0)
{
flag = (1 << 0) | (1 << 1);
}
}
if(flag == 0)
{
return CMD_RET_USAGE;
}
ota_read_params(&otaInfo);
memset(&upgInfo, 0, sizeof(OTA_PARAMS));
if(flag & (1 << 0))
{
printf("%s(%d)\n", __FUNCTION__, __LINE__);
upgInfo.bootfileSize = ota_read_boot_image();
printf("%s(%d)\n", __FUNCTION__, __LINE__);
ota_calc_image_chksum((unsigned char*)READ_BOOT_ADDR,
upgInfo.bootfileSize, upgInfo.bootChksum);
printf("%s(%d)\n", __FUNCTION__, __LINE__);
if(strcmp(upgInfo.bootChksum, otaInfo.bootChksum) != 0
|| upgInfo.bootfileSize != otaInfo.bootfileSize)
{
printf("Upgrade boot image maybe error:\n\t%s --> %s\n\t%u-%u\n",
upgInfo.bootChksum, otaInfo.bootChksum,
upgInfo.bootfileSize, otaInfo.bootfileSize);
if(force == 0)
{
return CMD_RET_FAILURE;
}
}
printf("%s(%d)\n", __FUNCTION__, __LINE__);
ota_upgrade_boot_image();
printf("%s(%d)\n", __FUNCTION__, __LINE__);
}
if(flag & (1 << 1))
{
printf("%s(%d)\n", __FUNCTION__, __LINE__);
upgInfo.rootfsfileSize = ota_read_rootfs_image();
printf("%s(%d)\n", __FUNCTION__, __LINE__);
ota_calc_image_chksum((unsigned char*)READ_ROOTFS_ADDR,
upgInfo.rootfsfileSize, upgInfo.rootfsChksum);
printf("%s(%d)\n", __FUNCTION__, __LINE__);
if(strcmp(upgInfo.rootfsChksum, otaInfo.rootfsChksum) != 0
|| upgInfo.rootfsfileSize != otaInfo.rootfsfileSize)
{
printf("Upgrade rootfs image maybe error:\n\t%s --> %s\n\t%u-%u\n",
upgInfo.rootfsChksum, otaInfo.rootfsChksum,
upgInfo.rootfsfileSize, otaInfo.rootfsfileSize);
if(force == 0)
{
return CMD_RET_FAILURE;
}
}
ota_upgrade_rootfs_image();
}
}
else
{
return CMD_RET_USAGE;
}
//return do_load(cmdtp, flag, argc, argv, FS_TYPE_EXT);
return 0;
}
U_BOOT_CMD(ota, 5, 0, do_ota,
"netease OTA command:",
"<command> <parmeters>\n"
" erase <partiton name>\n"
" - erase mtd partiton\n"
" read <boot/rootfs>\n"
" - read ota image form UDISK file system\n"
" upgrade <boot/rootfs/all> [0/1(skip verify chksum)]\n"
" - read ota image form UDISK file system and upgrade nand partiton\n"
" show_params\n"
" - show ota params information\n"
" - *********************************************");

View File

@ -17,6 +17,7 @@
#define __KERNEL__
#endif
#define CONFIG_NETEASE_OTA
/* #define DEBUG */
/*#define FPGA_PLATFORM*/
@ -169,6 +170,11 @@
#define CONFIG_CMD_SUNXI_PMU
#define CONFIG_CMD_SUNXI_SYSCFG
#define CONFIG_CMD_EXT4
#define CONFIG_CMD_MD5SUM
#define CONFIG_MD5
#ifdef CONFIG_SUNXI_DMA
#define CONFIG_SUNXI_CMD_DMA
#endif

View File

@ -84,6 +84,8 @@ extern void early_paging_init(const struct machine_desc *);
extern void adjust_lowmem_bounds(void);
extern enum reboot_mode reboot_mode;
extern void setup_dma_zone(const struct machine_desc *desc);
extern int sunxi_get_serial(u8 *serial);
extern int sunxi_get_soc_chipid(u8 *chipid);
unsigned int processor_id;
EXPORT_SYMBOL(processor_id);
@ -1216,6 +1218,14 @@ static int c_show(struct seq_file *m, void *v)
int i, j;
u32 cpuid;
#if defined(CONFIG_ARCH_SUNXI)
u32 serial[4];
u32 chip_id[4] = {0};
int ret;
memset(serial, 0, sizeof(serial));
ret = sunxi_get_serial((u8 *)serial);
ret = sunxi_get_soc_chipid((u8 *)chip_id);
#endif
for_each_online_cpu(i) {
/*
* glibc reads /proc/cpuinfo to determine the number of
@ -1272,8 +1282,14 @@ static int c_show(struct seq_file *m, void *v)
seq_printf(m, "Hardware\t: %s\n", machine_name);
seq_printf(m, "Revision\t: %04x\n", system_rev);
#if defined(CONFIG_ARCH_SUNXI)
seq_printf(m, "Serial\t\t: %04x%08x%08x\n",
serial[2], serial[1], serial[0]);
seq_printf(m, "Chipid\t\t: %08x%08x%08x%08x\n",
chip_id[3],chip_id[2], chip_id[1], chip_id[0]);
#else
seq_printf(m, "Serial\t\t: %s\n", system_serial);
#endif
return 0;
}

View File

@ -90,6 +90,7 @@ static ssize_t sys_info_show(struct class *class,
{
int i;
int databuf[4] = {0};
int serial[4];
char tmpbuf[129] = {0};
size_t size = 0;
@ -105,12 +106,18 @@ static ssize_t sys_info_show(struct class *class,
size += sprintf(buf + size, "%s\n", "normal");
/* chipid */
sunxi_get_serial((u8 *)databuf);
sunxi_get_soc_chipid((u8 *)databuf);
for (i = 0; i < 4; i++)
sprintf(tmpbuf + i*8, "%08x", databuf[i]);
tmpbuf[128] = 0;
size += sprintf(buf + size, "sunxi_chipid : %s\n", tmpbuf);
/* serial */
memset(serial, 0, sizeof(serial));
sunxi_get_serial((u8 *)serial);
sprintf(tmpbuf, "%04x%08x%08x", serial[2], serial[1], serial[0]);
size += sprintf(buf+size, "sunxi_serial : %s\n", tmpbuf);
/* chiptype */
sunxi_get_soc_chipid_str(tmpbuf);
size += sprintf(buf + size, "sunxi_chiptype : %s\n", tmpbuf);

View File

@ -11,4 +11,9 @@
#ifndef CDX_CONFIG_H
#define CDX_CONFIG_H
/* wk */
#define DEFAULT_GAIN_IHW 1.0
#define ERR_THRESHOLD 0.000001
#endif

View File

@ -55,6 +55,8 @@ struct AudioRenderComp {
CdxPlaybkCfg cfg;
RenderThreadCtx *threadCtx;
float gain;
};
static void handleStart(AwMessage *msg, void *arg);
@ -136,9 +138,19 @@ int AudioRenderCompDestroy(AudioRenderComp* p)
return 0;
}
AudioRenderComp* AudioRenderCompSetGain(AudioRenderComp* a, float gain){
AudioRenderComp* p = (AudioRenderComp*)a;
p->gain = gain;
return p;
}
int AudioRenderCompStart(AudioRenderComp* p)
{
return BaseCompStart(&p->base, NULL, NULL);
//return BaseCompStart(&p->base, NULL, NULL);
return BaseCompStart(&p->base, NULL, &p->gain);
}
int AudioRenderCompStop(AudioRenderComp* p)
@ -276,6 +288,7 @@ static void* AudioRenderThread(void* arg)
};
p->threadCtx = &threadCtx;
p->gain = DEFAULT_GAIN_IHW;
while (AwMessageQueueGetMessage(p->mq, &msg) == 0)
{
@ -294,6 +307,11 @@ static void handleStart(AwMessage *msg, void *arg)
logi("audio render process start message.");
float gainTmp = msg->gain;
//WK_PRINT("begin to process MESSAGE_ID_START, gainIn:%f", *gainTmp);
p->gain = gainTmp;
//WK_PRINT("gain:%f",p->gain);
if (p->eStatus == PLAYER_STATUS_STARTED)
{
logw("already in started status.");
@ -719,6 +737,37 @@ static inline int notifyAudioPts(AudioRenderComp *p)
return 0;
}
static void pcmDataTransByGain(unsigned char* data, unsigned int len, float gain, unsigned int nBitsPerSample)
{
if(fabs(gain-DEFAULT_GAIN_IHW) < ERR_THRESHOLD){
//WK_PRINT("gain :%f..............", gain);
return ;
}
if(16 != nBitsPerSample){
//WK_PRINT("nBitsPerSample err :%d..............", nBitsPerSample);
return ;
}
if((len % 4) != 0){
//WK_PRINT("len info of pcm data:%d..............\n", len);
}
int dataByGain;
short* pcm16Bit;
unsigned char * tmp;
unsigned char * dataMax = &data[len];
for (tmp = data; tmp < dataMax; ++tmp){
pcm16Bit = (short*)tmp;
dataByGain = (*pcm16Bit) * gain;
if(dataByGain > 32767 || dataByGain < -32768){
//WK_PRINT("%d out of range to %d by gain of %f..............", *pcm16Bit, dataByGain, gain);
}
*tmp = dataByGain & 0xff;
*++tmp = (dataByGain & 0xff00) >> 8;
}
}
static inline int writeToSoundDevice(AudioRenderComp *p)
{
RenderThreadCtx *threadCtx = p->threadCtx;
@ -745,6 +794,8 @@ static inline int writeToSoundDevice(AudioRenderComp *p)
if(p->bForceWriteToDeviceFlag == 1)
memset(pPcmData, 0, nPcmDataLen);
pcmDataTransByGain(pPcmData, nPcmDataLen, p->gain, p->threadCtx->nSampleRate);
while(nPcmDataLen > 0)
{
nWritten = SoundDeviceWrite(p->pSoundCtrl,

View File

@ -21,6 +21,8 @@ AudioRenderComp* AudioRenderCompCreate(void);
int AudioRenderCompDestroy(AudioRenderComp* a);
AudioRenderComp* AudioRenderCompSetGain(AudioRenderComp* a, float gain);
int AudioRenderCompStart(AudioRenderComp* a);
int AudioRenderCompStop(AudioRenderComp* a);

View File

@ -86,6 +86,7 @@ int BaseCompStart(BaseCompCtx *p, task_t afterPostBeforeWait, void *arg)
.execute = p->handler.start,
.replySem = &p->replySem[MESSAGE_ID_START],
.result = &reply,
.gain = *((float*)arg),
};
BaseCompPostAndWait(p, &msg, afterPostBeforeWait, arg);

View File

@ -25,6 +25,7 @@ struct AwMessage {
int64_t seekTime;
void *opaque;
int64_t int64Value;
float gain;
};
};

View File

@ -131,6 +131,8 @@ int PlayerSetCallback(Player* pl, PlayerCallback callback, void* pUserData);
//** Play Control APIs.
//**
Player* PlayerGainSet(Player* pl, float gain);
int PlayerStart(Player* pl);
int PlayerStop(Player* pl); //* media stream information is still kept by the player.

View File

@ -131,7 +131,7 @@ typedef struct PlayerContext
int nUnSurpportVideoBufferSize;
int bDiscardAudio;
float mGain;
}PlayerContext;
static int CallbackProcess(void* pSelf, int eMessageId, void* param);
@ -721,6 +721,13 @@ int PlayerHasAudio(Player* pl)
return 0;
}
Player* PlayerGainSet(Player* pl, float gain){
PlayerContext* p;
p = (PlayerContext*)pl;
p->mGain = gain;
return (Player*)p;
}
int PlayerStart(Player* pl)
{
PlayerContext* p;
@ -760,8 +767,10 @@ int PlayerStart(Player* pl)
SubtitleDecCompStart(p->pSubtitleDecComp);
if(p->pVideoRender != NULL)
VideoRenderCompStart(p->pVideoRender);
if(p->pAudioRender != NULL)
if(p->pAudioRender != NULL){
p->pAudioRender = AudioRenderCompSetGain(p->pAudioRender, p->mGain);
AudioRenderCompStart(p->pAudioRender);
}
if(p->pSubtitleRender != NULL)
SubtitleRenderCompStart(p->pSubtitleRender);
}
@ -824,8 +833,10 @@ int PlayerStart(Player* pl)
SubtitleDecCompStart(p->pSubtitleDecComp);
if(p->pVideoRender != NULL)
VideoRenderCompStart(p->pVideoRender);
if(p->pAudioRender != NULL)
if(p->pAudioRender != NULL){
p->pAudioRender = AudioRenderCompSetGain(p->pAudioRender, p->mGain);
AudioRenderCompStart(p->pAudioRender);
}
if(p->pSubtitleRender != NULL)
SubtitleRenderCompStart(p->pSubtitleRender);
}

View File

@ -161,6 +161,8 @@ int XPlayerPrepareAsync(XPlayer* p);
int XPlayerStart(XPlayer* p);
int XPlayerStartWithGain(XPlayer* p, float gain);
int XPlayerStop(XPlayer* p);
int XPlayerPause(XPlayer* p);

View File

@ -187,6 +187,7 @@ typedef struct PlayerContext
XPlayerNotifyCallback mCallback;
void* pUser;
float gain;
}PlayerContext;
static void* XPlayerThread(void* arg);
@ -233,6 +234,8 @@ XPlayer* XPlayerCreate()
mPriData->mSeekTobug = 0;
#endif
mPriData->gain = DEFAULT_GAIN_IHW;
pthread_mutex_init(&mPriData->mMutexMediaInfo, NULL);
pthread_mutex_init(&mPriData->mMutexStatus, NULL);
sem_init(&mPriData->mSemSetDataSource, 0, 0);
@ -744,11 +747,18 @@ int XPlayerStart(XPlayer* p)
msg.messageId = XPLAYER_COMMAND_START;
msg.params[0] = (uintptr_t)&mPriData->mSemStart;
msg.params[1] = (uintptr_t)&mPriData->mStartReply;
msg.params[2] = (uintptr_t)&mPriData->gain;
AwMessageQueuePostMessage(mPriData->mMessageQueue, &msg);
SemTimedWait(&mPriData->mSemStart, -1);
return mPriData->mStartReply;
}
int XPlayerStartWithGain(XPlayer * p, float gain)
{
PlayerContext* mPriData = (PlayerContext*)p;
mPriData->gain = gain;
XPlayerStart(p);
}
int XPlayerStop(XPlayer* p)
{
@ -1972,6 +1982,15 @@ static void* XPlayerThread(void* arg)
else if(msg.messageId == XPLAYER_COMMAND_START)
{
logd("process message XPLAYER_COMMAND_START.");
mPriData->gain = *(float*)msg.params[2];
//WK_PRINT("gain_ihw orginal:%f",gain_ihw);
if(mPriData->gain > 0){
} else {
mPriData->gain = DEFAULT_GAIN_IHW;
}
if(mPriData->mStatus != XPLAYER_STATUS_PREPARED &&
mPriData->mStatus != XPLAYER_STATUS_STARTED &&
mPriData->mStatus != XPLAYER_STATUS_PAUSED &&
@ -2070,6 +2089,9 @@ static void* XPlayerThread(void* arg)
//* post a start message.
memset(&newMsg, 0, sizeof(AwMessage));
newMsg.messageId = XPLAYER_COMMAND_START;
newMsg.params[0] = 0;
newMsg.params[1] = 0;
newMsg.params[2] = (unsigned int)&mPriData->gain;
AwMessageQueuePostMessage(mPriData->mMessageQueue, &newMsg);
//* should I reply 0 to the user at this moment?
@ -2086,6 +2108,8 @@ static void* XPlayerThread(void* arg)
pthread_mutex_unlock(&mPriData->mMutexStatus);
mPriData->mPlayer = PlayerGainSet(mPriData->mPlayer, mPriData->gain);
if(mPriData->mApplicationType == APP_STREAMING)
{
PlayerFast(mPriData->mPlayer, 0);

View File

@ -291,6 +291,13 @@ int TPlayerStart(TPlayer* p){
return XPlayerStart(p->mXPlayer);
}
int TPlayerStartWithGain(TPlayer * p, float gain)
{
TP_CHECK(p);
TP_CHECK(p->mXPlayer);
return XPlayerStartWithGain(p->mXPlayer, gain);
}
int TPlayerPause(TPlayer* p){
TP_CHECK(p);
TP_CHECK(p->mXPlayer);

View File

@ -1,5 +1,5 @@
#ifndef TPLAYER_H
#define TAPLAYER_H
#define TPLAYER_H
#include <stdbool.h>
#include <xplayer.h>
@ -145,6 +145,8 @@ int TPlayerPrepareAsync(TPlayer* p);
int TPlayerStart(TPlayer* p);
int TPlayerStartWithGain(TPlayer* p, float gain);
int TPlayerPause(TPlayer* p);
int TPlayerStop(TPlayer* p);

Binary file not shown.

4
package/netease/ihw_player/Makefile Normal file → Executable file
View File

@ -16,12 +16,14 @@ define Package/$(PKG_NAME)
SECTION:=utils
CATEGORY:=Netease
TITLE:=$(PKG_NAME) app
DEPENDS:=+netease_voice +liballwinner +libmad +libjson-c +cppunit +libuws +libspeech $(MAKE_COMMON_DEPEND)
DEPENDS:=+netease_voice +libmad +libjson-c +cppunit +libuws +libspeech +libcedarx2.7 +alsa-utils +libuapi $(MAKE_COMMON_DEPEND)
ifeq ('$(CONFIG_XUNFEI_TTS_SDK)_$(CONFIG_TTS_TEXT_XUNFEI)', 'y_y')
DEPENDS+=+libmsc
endif
endef
#+liballwinner
ifeq ('$(CONFIG_XUNFEI_TTS_SDK)_$(CONFIG_TTS_TEXT_XUNFEI)', 'y_y')
TARGET_LDFLAGS += -lmsc
endif

17
package/netease/ihw_player/src/Makefile Normal file → Executable file
View File

@ -11,10 +11,13 @@ CppFiles = $(shell find $(MK_PWD) -name "*.cpp" ! -name "cppunit.cpp")
CFiles = $(shell find $(MK_PWD) -name "*.c")
CFilesForUint = $(shell find $(MK_PWD) -name "*.c" ! -name "ihwplayer.c")
SourceIncludePath := -I$(STAGING_DIR)/usr/include/allwinner/include -I$(STAGING_DIR)/usr/include/allwinner
# 依赖的第3方库
LoadLibs += -ltinaplayer -lxplayer -lcdc_vdecoder -lcdc_adecoder -lcdc_sdecoder -lcdc_base -lcdc_ve -lcdc_memory \
-lcdx_parser -lplayer -lcdx_stream -lcdx_base -lpostprocess \
-law_plugin -ldl -lstdc++ -lrt -lm -lc -lasound -lmad -ljson-c -lspeech -luWS -lcrypto -lssl $(BUILD_COMMON_LIB)
LoadLibs += -ltplayer -lxplayer -lcdc_vdecoder -ladecoder -lcdc_sdecoder -lcdc_base -lcdc_ve -lcdc_memory \
-lcdx_parser -lcdx_playback -lcdx_stream -lcdx_base -luapi \
-lpthread -ldl -lstdc++ -lrt -lm -lc -lz -lasound -lmad -ljson-c -lspeech -luWS -lcrypto -lssl $(BUILD_COMMON_LIB)
# 依赖文件
CppObject = $(CppFiles:%.cpp=%.o)
CObject = $(CFiles:%.c=%.o)
@ -25,19 +28,19 @@ StlNeed = -std=c++11
# 链接
$(Target): $(CppObject) $(CObject)
@echo "Begin link.............."
$(CC) -Wall -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LoadLibs)
$(CC) -Wall -o $@ $^ $(CFLAGS) $(SourceIncludePath) $(LDFLAGS) $(LoadLibs)
# 编译
$(CppObject): %.o : %.cpp
@echo "Begin bulid cpp.............."
$(CXX) -c $< $(CXXFLAGS) $(Include) -o $@ $(StlNeed)
$(CXX) -c $< $(CXXFLAGS) $(SourceIncludePath) $(Include) -o $@ $(StlNeed)
$(CObject): %.o : %.c
@echo "Begin bulid c.............."
$(CXX) -c $< $(CFLAGS) $(Include) -o $@ $(StlNeed)
$(CXX) -c $< $(CFLAGS) $(SourceIncludePath) $(Include) -o $@ $(StlNeed)
# 编译单元测试
@echo "Begin bulid unittest.............."
$(CXX) $(CXXFLAGS) $(Include) -lcppunit -ldl $(LoadLibs) $(LDFLAGS) \
$(CXX) $(CXXFLAGS) $(SourceIncludePath) $(Include) -lcppunit -ldl $(LoadLibs) $(LDFLAGS) \
./unit/cppunit.cpp $(CppFiles) $(CFilesForUint) $(StlNeed) -o unitIhwplayer
# 伪目标

2
package/netease/ihw_player/src/ihwplayer.c Normal file → Executable file
View File

@ -11,7 +11,7 @@
2017/07/13 wk Initially created
*****************************************************************************/
#include "player.h"
#include "playerapi.h"
#include <pthread.h>
#include "readCmd.h"
#include "updatelist.h"

2
package/netease/ihw_player/src/include/jsonc.h Normal file → Executable file
View File

@ -14,7 +14,7 @@
#ifndef _JSON_C_H_
#define _JSON_C_H_
#include "player.h"
#include "playerapi.h"
#include <json-c/json.h>
#include <stdlib.h>
#include <string.h>

View File

@ -0,0 +1,131 @@
#ifndef _LU_PLAYER_H_
#define _LU_PLAYER_H_
#include <semaphore.h>
#include <pthread.h>
#include <string>
#include <map>
#include <asm/types.h>
#include <allwinner/tplayer.h>
#include <uvdbus/log.h>
using namespace std;
namespace aw{
#define POINT_CHECK_NULL(a, ret) {do{if(a == NULL){ \
LOG_EX(LOG_Error ,"point is null!\n"); \
return ret; \
}}while(0); \
}
class LuPlayer{
public:
LuPlayer()
{
tplayer = TPlayerCreate(CEDARX_PLAYER);
}
~LuPlayer()
{
TPlayerDestroy(tplayer);
tplayer = NULL;
}
int setDebugFlag(bool debugFlag)
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerSetDebugFlag(tplayer, debugFlag);
}
int setNotifyCallback(TPlayerNotifyCallback notifier, void* pUserData)
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerSetNotifyCallback(tplayer, notifier, pUserData);
}
int setDataSource(const char* pUrl, const CdxKeyedVectorT* pHeaders)
{
POINT_CHECK_NULL(tplayer, -1);
POINT_CHECK_NULL(pUrl, -1);
return TPlayerSetDataSource(tplayer, pUrl, pHeaders);
}
int prepare()
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerPrepare(tplayer);
}
int prepareAsync()
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerPrepareAsync(tplayer);
}
int start()
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerStart(tplayer);
}
int start(float gain)
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerStartWithGain(tplayer, gain);
}
int stop()
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerStop(tplayer);
}
int pause()
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerPause(tplayer);
}
int reset()
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerReset(tplayer);
}
int isPlaying()
{
POINT_CHECK_NULL(tplayer, -2);
return TPlayerIsPlaying(tplayer);
}
int seekTo(int msec)
{
POINT_CHECK_NULL(tplayer, -1);
if(msec < 0) msec = 0;
return TPlayerSeekTo(tplayer, msec);
}
int getCurrentPosition(int* msec)
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerGetCurrentPosition(tplayer, msec);
}
int getDuration(int* msec)
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerGetDuration(tplayer, msec);
}
MediaInfo* getMediaInfo()
{
POINT_CHECK_NULL(tplayer, NULL);
return TPlayerGetMediaInfo(tplayer);
}
int setLooping(int bLoop)
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerSetLooping(tplayer, bLoop);
}
int setVolume(int volume)
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerSetVolume(tplayer, volume);
}
int getVolume()
{
POINT_CHECK_NULL(tplayer, -1);
return TPlayerGetVolume(tplayer);
}
private:
TPlayer *tplayer;
};
}
#endif

2
package/netease/ihw_player/src/include/readCmd.h Normal file → Executable file
View File

@ -10,7 +10,7 @@
#include <errno.h>
#include <sys/select.h>
#include "player.h"
#include "playerapi.h"
#ifdef __cplusplus
extern "C" {

2
package/netease/ihw_player/src/include/updatelist.h Normal file → Executable file
View File

@ -9,7 +9,7 @@
#include <stdlib.h>
#include <ctype.h>
#include "player.h"
#include "playerapi.h"
#ifdef __cplusplus
extern "C" {

View File

@ -98,7 +98,8 @@ typedef enum{
// 非tts的audio播放
#define STOP_ERR_TYR_TIMES 3
typedef struct {
TinaPlayer *nTinaplayer;
//TinaPlayer *nTinaplayer;
LuPlayer *nTinaplayer;
volatile PlayerStatus nStatus;
u8 nError;
#if LOCK_ENABLE
@ -791,20 +792,23 @@ static void audioPlayerPlayThreadFun(void){
RETURNED VALUES: void
*****************************************************************************/
static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* param1)
//static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* param1)
static int callbackForTinaPlayer(void* pUserData, int msg, int param0, void* param1)
{
AudioPlayer* mAudioPlayer = (AudioPlayer*)pUserData;
//LOG_EX(LOG_Debug, "callbackForTinaPlayer:%d\n", msg);
switch(msg)
{
case TINA_NOTIFY_NOT_SEEKABLE:
//case TINA_NOTIFY_NOT_SEEKABLE:
case TPLAYER_NOTIFY_NOT_SEEKABLE:
{
LOG_EX(LOG_Debug, "TINA_NOTIFY_NOT_SEEKABLE\n");
break;
}
case TINA_NOTIFY_ERROR:
//case TINA_NOTIFY_ERROR:
case TPLAYER_NOTIFY_MEDIA_ERROR:
{
PlayerStatus audioSt;
if(param0 == NOTIFY_ERROR_TYPE_IO)
@ -832,7 +836,8 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
break;
}
case TINA_NOTIFY_PREPARED:
//case TINA_NOTIFY_PREPARED:
case TPLAYER_NOTIFY_PREPARED:
{
#if LOCK_ENABLE
pthread_mutex_lock(&mAudioPlayer->nMutex);
@ -850,7 +855,7 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
pthread_mutex_unlock(&mutexPlay);
break;
}
/*
case TINA_NOTIFY_BUFFERRING_UPDATE:
{
int nBufferedFilePos;
@ -861,9 +866,10 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
LOG_EX(LOG_Debug, "TINA_NOTIFY_BUFFERRING_UPDATE: buffer %d percent of the media file, buffer fullness = %d percent.\n",
nBufferedFilePos, nBufferFullness);
break;
}
}*/
case TINA_NOTIFY_PLAYBACK_COMPLETE:
//case TINA_NOTIFY_PLAYBACK_COMPLETE:
case TPLAYER_NOTIFY_PLAYBACK_COMPLETE:
{
LOG_EX(LOG_Debug, "TINA_NOTIFY_PLAYBACK_COMPLETE\n");
#if LOCK_ENABLE
@ -877,7 +883,8 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
break;
}
case TINA_NOTIFY_SEEK_COMPLETE:
//case TINA_NOTIFY_SEEK_COMPLETE:
case TPLAYER_NOTIFY_SEEK_COMPLETE:
{
LOG_EX(LOG_Debug, "TINA_NOTIFY_SEEK_COMPLETE\n");
break;
@ -892,7 +899,7 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
}
}
return;
return 0;
}
/*****************************************************************************
@ -920,7 +927,8 @@ bool audioPlayerInit(AudioPlayerCallback callback){
#if LOCK_ENABLE
pthread_mutex_init(&mAudioPlayer.nMutex, NULL);
#endif
mAudioPlayer.nTinaplayer = new TinaPlayer();
//mAudioPlayer.nTinaplayer = new TinaPlayer();
mAudioPlayer.nTinaplayer = new LuPlayer();
if(NULL == mAudioPlayer.nTinaplayer){
LOG_EX(LOG_Error, "can not create tinaplayer, quit.\n");
@ -935,12 +943,12 @@ bool audioPlayerInit(AudioPlayerCallback callback){
goto ErrRet;
}
/*
if(mAudioPlayer.nTinaplayer->initCheck() != 0){
LOG_EX(LOG_Error, "initCheck of tinaplayer fail, quit.\n");
notifyCallback(0, AUDIO_ST_ERR);
goto ErrRet;
}
}*/
mAudioPlayer.nStatus = AUDIO_ST_IDLE;
LOG_EX(LOG_Debug, "mAudioPlayer Create successfully.\n");

34
package/netease/ihw_player/src/libplayer/background.cpp Normal file → Executable file
View File

@ -19,7 +19,8 @@ typedef enum
} BackGrondIndex;
typedef struct {
TinaPlayer *nTinaplayer[BG_TINA_PLAYER_NUM];
//TinaPlayer *nTinaplayer[BG_TINA_PLAYER_NUM];
LuPlayer *nTinaplayer[BG_TINA_PLAYER_NUM];
BackGrondIndex Index;
PlayerStatus nStatus[BG_TINA_PLAYER_NUM];
u8 nError;
@ -46,7 +47,8 @@ static uint32 nonMusicPlayerId;
RETURNED VALUES: void
*****************************************************************************/
static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* param1)
//static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* param1)
static int callbackForTinaPlayer(void* pUserData, int msg, int param0, void* param1)
{
BackGroundPlayer* mBackGroundPlayer = (BackGroundPlayer*)pUserData;
@ -55,13 +57,15 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
//LOG_EX(LOG_Debug, "callbackForTinaPlayer:%d\n", msg);
switch(msg)
{
case TINA_NOTIFY_NOT_SEEKABLE:
//case TINA_NOTIFY_NOT_SEEKABLE:
case TPLAYER_NOTIFY_NOT_SEEKABLE:
{
LOG_EX(LOG_Debug, "TINA_NOTIFY_NOT_SEEKABLE\n");
break;
}
case TINA_NOTIFY_ERROR:
//case TINA_NOTIFY_ERROR:
case TPLAYER_NOTIFY_MEDIA_ERROR:
{
for(int i = 0; i < BG_TINA_PLAYER_NUM ; i++){
pthread_mutex_lock(&mBackGroundPlayer->nMutex[i]);
@ -74,7 +78,8 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
break;
}
case TINA_NOTIFY_PREPARED:
//case TINA_NOTIFY_PREPARED:
case TPLAYER_NOTIFY_PREPARED:
{
pthread_mutex_lock(&mBackGroundPlayer->nMutex[mBackGroundPlayer->Index]);
mBackGroundPlayer->nStatus[mBackGroundPlayer->Index] = BG_ST_PREPARED;
@ -88,7 +93,7 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
}
break;
}
/*
case TINA_NOTIFY_BUFFERRING_UPDATE:
{
int nBufferedFilePos;
@ -100,9 +105,10 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
nBufferedFilePos, nBufferFullness);
break;
}
}*/
case TINA_NOTIFY_PLAYBACK_COMPLETE:
//case TINA_NOTIFY_PLAYBACK_COMPLETE:
case TPLAYER_NOTIFY_PLAYBACK_COMPLETE:
{
//* stop the player.
//* TODO
@ -110,7 +116,8 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
break;
}
case TINA_NOTIFY_SEEK_COMPLETE:
//case TINA_NOTIFY_SEEK_COMPLETE:
case TPLAYER_NOTIFY_SEEK_COMPLETE:
{
LOG_EX(LOG_Debug, "TINA_NOTIFY_SEEK_COMPLETE\n");
@ -124,7 +131,7 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
}
}
return;
return 0;
}
/*****************************************************************************
FUNCTION NAME: soundEffectInit
@ -143,7 +150,8 @@ bool backGroundPlayerInit(bgPlayerCallback callback){
memset(&mBackGroundPlayer, 0, sizeof(BackGroundPlayer));
pthread_mutex_init(&mBackGroundPlayer.nMutex[0], NULL);
mBackGroundPlayer.nTinaplayer[0] = new TinaPlayer();
//mBackGroundPlayer.nTinaplayer[0] = new TinaPlayer();
mBackGroundPlayer.nTinaplayer[0] = new LuPlayer();
mBackGroundPlayer.Index = BG_TINA_PLAYER_1;
bgPlayerInited = true;
mBackGroundPlayer.needResetTinaplay[mBackGroundPlayer.Index] = FALSE;
@ -161,12 +169,12 @@ bool backGroundPlayerInit(bgPlayerCallback callback){
goto ErrRet;
}
/*
if(mBackGroundPlayer.nTinaplayer[0]->initCheck() != 0){
LOG_EX(LOG_Error, "initCheck of tinaplayer fail, quit.\n");
notifyCallback(0, PLAYER_ERR_TINA_INIT);
goto ErrRet;
}
}*/
mBackGroundPlayer.nStatus[0] = BG_ST_IDLE;
LOG_EX(LOG_Debug, "backGroundPlayerInit successfully.\n");

View File

@ -1,6 +1,6 @@
#pragma once
#include "player.h"
#include "playerapi.h"
#include <stdio.h>
#include <unistd.h>
#include <memory.h>

View File

@ -15,9 +15,10 @@
#ifndef __AUDIO_PLAYER_H__
#define __AUDIO_PLAYER_H__
#include "player.h"
#include "playerapi.h"
#include <allwinner/tinaplayer.h>
//#include <allwinner/tinaplayer.h>
#include <luplayer.h>
#include "alsa_interface.h"
/*
typedef enum

View File

@ -22,12 +22,13 @@
#include <errno.h>
#include <sys/select.h>
#include <allwinner/tinaplayer.h>
//#include <allwinner/tinaplayer.h>
#include <luplayer.h>
#include <fcntl.h>
#include <linux/input.h>
#include <tina_log.h>
#include "player.h"
#include "playerapi.h"
using namespace aw;

View File

@ -18,7 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include "player.h"
#include "playerapi.h"
#ifdef __cplusplus
extern "C" {

View File

@ -24,12 +24,14 @@
#include <sys/select.h>
#include <math.h>
#include <allwinner/tinaplayer.h>
//#include <allwinner/tinaplayer.h>
#include <fcntl.h>
#include <linux/input.h>
#include <tina_log.h>
#include "player.h"
#include "playerapi.h"
#include "luplayer.h"
using namespace aw;

View File

@ -15,7 +15,7 @@
#ifndef __PCM_PLAYER_H__
#define __PCM_PLAYER_H__
#include "player.h"
#include "playerapi.h"
#include "alsa_interface.h"
#include "ringbuffer.h"

View File

@ -293,8 +293,8 @@ typedef struct{
#define DBUS_UV_MSG
#ifdef CALLBACK_MSG
typedef void (* PlayerCallback)(uint32, PlayerStatus, char *, int);
bool playerInit(PlayerCallback);
typedef void (* IhwPlayerCallback)(uint32, PlayerStatus, char *, int);
bool playerInit(IhwPlayerCallback);
#else
bool playerInit(void);
#endif

View File

@ -23,12 +23,13 @@
#include <errno.h>
#include <sys/select.h>
#include <allwinner/tinaplayer.h>
//#include <allwinner/tinaplayer.h>
#include <luplayer.h>
#include <fcntl.h>
#include <linux/input.h>
#include <tina_log.h>
#include "player.h"
#include "playerapi.h"
using namespace aw;

View File

@ -12,7 +12,7 @@
*****************************************************************************/
#include "musicplayer.h"
#include "player.h"
#include "playerapi.h"
#define NET_PLAYER_DEBUG
@ -37,7 +37,8 @@ TinaPlayerPrepareSt tinaPlayerPrepareSt = MUSIC_TINA_NOTIFY_NULL;
#endif
typedef struct {
TinaPlayer *nTinaplayer[MUSIC_TINA_PALYER_NUM];
//TinaPlayer *nTinaplayer[MUSIC_TINA_PALYER_NUM];
LuPlayer *nTinaplayer[MUSIC_TINA_PALYER_NUM];
MusicPlayerIndex nPlayerIndex;
u8 nPreStatus[MUSIC_TINA_PALYER_NUM];
PlayerStatus nStatus[MUSIC_TINA_PALYER_NUM];
@ -560,7 +561,8 @@ static void threadMainFun(void){
RETURNED VALUES: void
*****************************************************************************/
static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* param1)
//static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* param1)
static int callbackForTinaPlayer(void* pUserData, int msg, int param0, void* param1)
{
MusicPlayer* pMusicPlayer = (MusicPlayer*)pUserData;
@ -570,14 +572,16 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
switch(msg)
{
case TINA_NOTIFY_NOT_SEEKABLE:
//case TINA_NOTIFY_NOT_SEEKABLE:
case TPLAYER_NOTIFY_NOT_SEEKABLE:
{
pMusicPlayer->nSeekable = 0;
LOG_EX(LOG_Debug, "TINA_NOTIFY_NOT_SEEKABLE\n");
break;
}
case TINA_NOTIFY_ERROR:
//case TINA_NOTIFY_ERROR:
case TPLAYER_NOTIFY_MEDIA_ERROR:
{
for(int i = 0; i < MUSIC_TINA_PALYER_NUM ; i++){
pthread_mutex_lock(&pMusicPlayer->nMutex[i]);
@ -592,7 +596,8 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
break;
}
case TINA_NOTIFY_PREPARED:
//case TINA_NOTIFY_PREPARED:
case TPLAYER_NOTIFY_PREPARED:
{
MusicPlayerIndex musicPlayerindex;
bool isPrepareNext = false;
@ -635,7 +640,7 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
}
break;
}
/*
case TINA_NOTIFY_BUFFERRING_UPDATE:
{
int nBufferedFilePos;
@ -647,9 +652,10 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
nBufferedFilePos, nBufferFullness);
break;
}
}*/
case TINA_NOTIFY_PLAYBACK_COMPLETE:
//case TINA_NOTIFY_PLAYBACK_COMPLETE:
case TPLAYER_NOTIFY_PLAYBACK_COMPLETE:
{
//* stop the player.
//* TODO
@ -677,17 +683,20 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
break;
}
case TINA_NOTIFY_SEEK_COMPLETE:
//case TINA_NOTIFY_SEEK_COMPLETE:
case TPLAYER_NOTIFY_SEEK_COMPLETE:
{
LOG_EX(LOG_Debug, "TINA_NOTIFY_SEEK_COMPLETE\n");
break;
}
case TINA_NOTIFY_BUFFER_START:
//case TINA_NOTIFY_BUFFER_START:
case TPLAYER_NOTIFY_BUFFER_START:
{
LOG_EX(LOG_Debug, "TINA_NOTIFY_BUFFER_START\n");
break;
}
case TINA_NOTIFY_BUFFER_END:
//case TINA_NOTIFY_BUFFER_END:
case TPLAYER_NOTIFY_BUFFER_END:
{
LOG_EX(LOG_Debug, "TINA_NOTIFY_BUFFER_END\n");
break;
@ -700,7 +709,7 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
}
}
return;
return 0;
}
/*****************************************************************************
@ -754,8 +763,10 @@ bool musicPlayerInit(MusicPlayerCallback callback){
memset(&musicplayer, 0, sizeof(MusicPlayer));
pthread_mutex_init(&musicplayer.nMutex[0], NULL);
pthread_mutex_init(&musicplayer.nMutex[1], NULL);
musicplayer.nTinaplayer[0] = new TinaPlayer();
musicplayer.nTinaplayer[1] = new TinaPlayer();
//musicplayer.nTinaplayer[0] = new TinaPlayer();
//musicplayer.nTinaplayer[1] = new TinaPlayer();
musicplayer.nTinaplayer[0] = new LuPlayer();
musicplayer.nTinaplayer[1] = new LuPlayer();
musicplayer.needResetTinaplay[0] = false;
musicplayer.needResetTinaplay[1] = false;
@ -776,11 +787,11 @@ bool musicPlayerInit(MusicPlayerCallback callback){
}
if(musicplayer.nTinaplayer[0]->initCheck() != 0 || musicplayer.nTinaplayer[1]->initCheck() != 0){
/*if(musicplayer.nTinaplayer[0]->initCheck() != 0 || musicplayer.nTinaplayer[1]->initCheck() != 0){
LOG_EX(LOG_Error, "initCheck of tinaplayer fail, quit.\n");
notifyCallback(0, PLAYER_ERR_TINA_INIT);
goto ErrRet;
}
}*/
musicplayer.nStatus[0] = MUSIC_ST_IDLE;
musicplayer.nStatus[1] = MUSIC_ST_IDLE;

View File

@ -14,7 +14,7 @@
#include <pthread.h>
#include <array>
#include "player.h"
#include "playerapi.h"
#include "musicplayer.h"
#include "dlist.h"
#include "audioplayer.h"
@ -27,7 +27,7 @@
#define TIMER_UINT 1
#ifdef CALLBACK_MSG
PlayerCallback playerCallback;
IhwPlayerCallback playerCallback;
#endif
static SEPlayerStateCallback seplayerStateCb;
@ -861,7 +861,7 @@ bool uvTimerInit(uv_loop_t *loop){
RETURNED VALUES: bool of init status
*****************************************************************************/
bool playerInit(PlayerCallback callback){
bool playerInit(IhwPlayerCallback callback){
playerCallback = callback;
return playerInitInter();
}

View File

@ -19,7 +19,8 @@ typedef enum
} SoundEffectIndex;
typedef struct {
TinaPlayer *nTinaplayer[SE_TINA_PALYER_NUM];
//TinaPlayer *nTinaplayer[SE_TINA_PALYER_NUM];
LuPlayer *nTinaplayer[SE_TINA_PALYER_NUM];
SoundEffectIndex Index;
volatile PlayerStatus nStatus[SE_TINA_PALYER_NUM];
u8 nError;
@ -53,7 +54,7 @@ static char *sourceRec = NULL;
RETURNED VALUES: void
*****************************************************************************/
static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* param1)
static int callbackForTinaPlayer(void* pUserData, int msg, int param0, void* param1)
{
SoundEffect* mSEplayer = (SoundEffect*)pUserData;
@ -63,13 +64,15 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
switch(msg)
{
case TINA_NOTIFY_NOT_SEEKABLE:
//case TINA_NOTIFY_NOT_SEEKABLE:
case TPLAYER_NOTIFY_NOT_SEEKABLE:
{
LOG_EX(LOG_Debug, "TINA_NOTIFY_NOT_SEEKABLE\n");
break;
}
case TINA_NOTIFY_ERROR:
//case TINA_NOTIFY_ERROR:
case TPLAYER_NOTIFY_MEDIA_ERROR:
{
for(int i = 0; i < SE_TINA_PALYER_NUM ; i++){
#if LOCK_ENABLE
@ -91,7 +94,8 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
break;
}
case TINA_NOTIFY_PREPARED:
//case TINA_NOTIFY_PREPARED:
case TPLAYER_NOTIFY_PREPARED:
{
#if LOCK_ENABLE
pthread_mutex_lock(&mSEplayer->nMutex[mSEplayer->Index]);
@ -111,7 +115,7 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
pthread_mutex_unlock(&mutexWaitPrepared);
break;
}
/*
case TINA_NOTIFY_BUFFERRING_UPDATE:
{
int nBufferedFilePos;
@ -123,9 +127,10 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
nBufferedFilePos, nBufferFullness);
break;
}
}*/
case TINA_NOTIFY_PLAYBACK_COMPLETE:
//case TINA_NOTIFY_PLAYBACK_COMPLETE:
case TPLAYER_NOTIFY_PLAYBACK_COMPLETE:
{
//* stop the player.
//* TODO
@ -141,7 +146,8 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
break;
}
case TINA_NOTIFY_SEEK_COMPLETE:
//case TINA_NOTIFY_SEEK_COMPLETE:
case TPLAYER_NOTIFY_SEEK_COMPLETE:
{
LOG_EX(LOG_Debug, "TINA_NOTIFY_SEEK_COMPLETE\n");
break;
@ -154,7 +160,7 @@ static void callbackForTinaPlayer(void* pUserData, int msg, int param0, void* pa
}
}
return;
return 0;
}
/*****************************************************************************
FUNCTION NAME: soundEffectInit
@ -175,7 +181,8 @@ bool soundEffectInit(SEPlayerCallback callback){
pthread_mutex_init(&mSEplayer.nMutex[0], NULL);
#endif
mSEplayer.nTinaplayer[0] = new TinaPlayer();
//mSEplayer.nTinaplayer[0] = new TinaPlayer();
mSEplayer.nTinaplayer[0] = new LuPlayer();
mSEplayer.Index = SE_TINA_PLAYER_1;
sePlayerInited = true;
mSEplayer.needResetTinaplay[mSEplayer.Index] = FALSE;
@ -193,12 +200,12 @@ bool soundEffectInit(SEPlayerCallback callback){
goto ErrRet;
}
/*
if(mSEplayer.nTinaplayer[0]->initCheck() != 0){
LOG_EX(LOG_Error, "initCheck of tinaplayer fail, quit.\n");
notifyCallback(0, PLAYER_ERR_TINA_INIT);
goto ErrRet;
}
}*/
mSEplayer.nStatus[0] = SE_ST_IDLE;
LOG_EX(LOG_Debug, "mSEplayerCreate successfully.\n");

2
package/netease/ihw_player/src/unit/cppunit.cpp Normal file → Executable file
View File

@ -8,7 +8,7 @@
#include <stdio.h>
#include <musicplayer.h>
#include <player.h>
#include <playerapi.h>
#include <audioplayer.h>
#define AUDIO_MP3_URL "/mnt/SDCARD/netplay/audio/audio.mp3"

View File

@ -27,7 +27,7 @@ extern "C" {
//__FUNCTION__, __LINE__))
#define USED_NETEASE_AI (1) // netease MSC library
#define USED_NETEASE_DC (1) // netease data collection library
#define USED_NETEASE_DC (0) // netease data collection library
#define USED_NETEASE_FMAE (0) // netease CAE library
#define USED_NETEASE_DUILITE (1)
#define USED_NETEASE_DUILITE_VAD (1)

View File

@ -1,4 +1,4 @@
bootdelay=0
bootdelay=3
#default bootcmd, will change at runtime according to key press
bootcmd=run setargs_nand boot_normal#default nand boot
#kernel command arguments
@ -8,7 +8,7 @@ nand_root=/dev/nandd
mmc_root=/dev/mmcblk0p7
root_partition=rootfs
init=/sbin/init
loglevel=8
loglevel=0
boot_partition=boot
cma=64M
@ -32,3 +32,9 @@ recovery_key_value_min=0x10
#fastboot key
fastboot_key_value_max=0x8
fastboot_key_value_min=0x2
#ota cmd
boot_cache=0x40007800
rootfs_cache=0x40407800
loadkernel=ext4load sunxi_flash 0:0 ${boot_cache} ota/boot.img
loadrootfs=ext4load sunxi_flash 0:0 ${rootfs_cache} ota/rootfs.img

View File

@ -59,13 +59,12 @@ size = 512
[partition]
name = rootfs_data
;size = 61440
size = 8192
user_type = 0x8000
[partition]
name = private
size = 1024
name = ota_info
size = 512
user_type = 0x8000
; recovery分区说明

View File

@ -137,8 +137,7 @@ CONFIG_KERNEL_KALLSYMS=y
# CONFIG_KERNEL_FANOTIFY is not set
# CONFIG_KERNEL_BLK_DEV_BSG is not set
CONFIG_KERNEL_MAGIC_SYSRQ=y
CONFIG_KERNEL_COREDUMP=y
CONFIG_KERNEL_ELF_CORE=y
# CONFIG_KERNEL_ELF_CORE is not set
# CONFIG_KERNEL_PROVE_LOCKING is not set
CONFIG_KERNEL_PRINTK_TIME=y
# CONFIG_KERNEL_SLABINFO is not set
@ -1529,7 +1528,7 @@ CONFIG_PACKAGE_wifimanager-smartaudio=y
# CONFIG_PACKAGE_zlib-dev is not set
# CONFIG_PACKAGE_ar is not set
# CONFIG_PACKAGE_binutils is not set
# CONFIG_PACKAGE_cppunit is not set
CONFIG_PACKAGE_cppunit=y
# CONFIG_PACKAGE_gdb is not set
# CONFIG_PACKAGE_gdbserver is not set
# CONFIG_PACKAGE_objdump is not set
@ -2552,7 +2551,7 @@ CONFIG_PACKAGE_libs2json=y
# CONFIG_PACKAGE_libsocks is not set
# CONFIG_PACKAGE_libsodium is not set
# CONFIG_PACKAGE_libsoxr is not set
# CONFIG_PACKAGE_libspeech is not set
CONFIG_PACKAGE_libspeech=y
CONFIG_PACKAGE_libspeex=y
# CONFIG_PACKAGE_libspeexdsp is not set
# CONFIG_PACKAGE_libtalloc is not set
@ -2821,7 +2820,14 @@ CONFIG_PACKAGE_SPlayer-demo=y
# CONFIG_PACKAGE_config_server is not set
# CONFIG_PACKAGE_factoryTest is not set
# CONFIG_PACKAGE_golangtest is not set
# CONFIG_PACKAGE_ihwplayer is not set
CONFIG_PACKAGE_ihwplayer=y
#
# ttsText Mode Select
#
# CONFIG_TTS_TEXT_XUNFEI is not set
# CONFIG_TTS_TEXT_ROKID is not set
CONFIG_TTS_TEXT_NIL=y
CONFIG_PACKAGE_libuvdbus=y
#
@ -2845,8 +2851,8 @@ CONFIG_XUNFEI_CAE_SDK=y
CONFIG_NETEASE_DUILITE_SDK=y
# CONFIG_NETEASE_TTS_SDK is not set
CONFIG_XUNFEI_TTS_SDK=y
# CONFIG_USED_NONE is not set
CONFIG_USED_DC_SDK=y
CONFIG_USED_NONE=y
# CONFIG_USED_DC_SDK is not set
CONFIG_PACKAGE_ntes_record=y
# CONFIG_PACKAGE_ota is not set
# CONFIG_PACKAGE_pv1res is not set