ihwplayer use tplayer instead of tinaplayer

This commit is contained in:
lupeng 2018-08-15 09:56:22 +08:00
parent 7dd505f556
commit 4935f977a0
34 changed files with 383 additions and 93 deletions

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

@ -1529,7 +1529,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 +2552,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 +2821,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
#