From 8758151dcdb0f89e362dd297405a384d3a034380 Mon Sep 17 00:00:00 2001
From: chenlh <2008get@163.com>
Date: 星期三, 28 一月 2026 20:21:37 +0800
Subject: [PATCH] 天宫输入源模块设置时爆音及参数拷贝更新

---
 src/tob.cpp |   93 +++++++++++++++++++++++-----------------------
 1 files changed, 47 insertions(+), 46 deletions(-)

diff --git a/src/tob.cpp b/src/tob.cpp
index 8d34e61..1c90427 100644
--- a/src/tob.cpp
+++ b/src/tob.cpp
@@ -13,16 +13,12 @@
 #include "protocol_internal.h"
 #include "IModule.h"
 #include "f2f.h"
+#include "var_state.h"
 #include "../drv/memory.h"
 
 
 
-//#define DEBUG
-#ifdef DEBUG
-#define dbg_printf printf
-#else
-#define dbg_printf
-#endif
+
 
 //static ToB* tob = NULL;
 
@@ -130,14 +126,14 @@
 
 		if (pmod->mDsp != dsp_index)  continue;
 
-#ifdef DEBUG
+#if DEBUG
 		dbg_printf("Module ID %d type %d rxnum %d txnum %d. \n",pmod->mID ,pmod->mType, pmod->mRxNum,pmod->mTxNum);
 #endif
 //		if(pmod->mID == 394) {
 //			int ddr = sram_free_space(SRAM_DDR);
 //			int ccm = sram_free_space(SRAM_CCM);
 //			int l1 = sram_free_space(SRAM_L1);
-//			printf("ddr %d ccm %d l1 %d.\n",ddr, ccm ,l1);
+//			dbg_printf("ddr %d ccm %d l1 %d.\n",ddr, ccm ,l1);
 //		}
 		IModule* m = CreateBaseModule(pmod->mType,pmod->mTag, pmod->mRxNum,pmod->mTxNum);
 		if(!m) {
@@ -199,8 +195,8 @@
 
 	return 	ErrStatus::SUCCESS;
 }
-#define DEBUG 0
-#if 1//DEBUG
+
+#ifdef DEBUG
 	const s8* type_string[ModuleType::PROC_COUNT] = {
 			"none"
 			,"input"
@@ -270,9 +266,10 @@
 
 		if (pmod->mDsp != dsp_index)  continue;
 
-#if DEBUG
-		//if (PROC_FIR == pmod->mType)
-			printf("Module ID %d type %d %s rxnum %d txnum %d tag %d. \n",pmod->mID ,pmod->mType, type_string[pmod->mType], pmod->mRxNum,pmod->mTxNum,pmod->mTag);
+#ifdef DEBUG
+//		if (300 == pmod->mID)
+		if (PROC_FEEDBACK == pmod->mType)
+			dbg_printf("Module ID %d type %d %s rxnum %d txnum %d tag %d. \n",pmod->mID ,pmod->mType, type_string[pmod->mType], pmod->mRxNum,pmod->mTxNum,pmod->mTag);
 #endif
 
 		IModule* m = CreateBaseModule(pmod->mType, pmod->mTag, mRxNum, mTxNum);
@@ -289,9 +286,9 @@
 		}
 		mModuleIndex[pmod->mID] = ++mModuleNum;
 
-//		printf("Module id:%d, Tx buffer id:", pmod->mID);
+//		dbg_printf("Module id:%d, Tx buffer id:", pmod->mID);
 		for (size_t i = 0; i < mTxNum && !bOutput; i++){
-//			printf("bid %d, ", mTxbufID[i]);
+//			dbg_printf("bid %d, ", mTxbufID[i]);
 			if (mTxbufID[i] > 0) {
 				Frame* pcm = frames->GetFrame(mTxbufID[i]-1);
 				m->SetOutputChannelDataPtr(i, pcm);
@@ -301,14 +298,14 @@
 						nPhyInput[mPhyID[i].mIntType] = mPhyID[i].mPhyID;
 					m->SetInputChannelDataPtr(i, pcm);
 					SetRxChannelPtr(static_cast<IntDataType>(mPhyID[i].mIntType), mPhyID[i].mPhyID-1, pcm->Data());
-//					printf("phy_id %d\n", mPhyID[i].mPhyID);
+//					dbg_printf("phy_id %d\n", mPhyID[i].mPhyID);
 				}
 			}
 			else {
 				m->SetOutputChannelDataPtr(i, 0);
 			}
 		}
-//		printf(";Rx buffer id:");
+//		dbg_printf(";Rx buffer id:");
 		for (size_t i = 0; i < mRxNum && !bInput; i++) {
 //			printf("mID %d,bid %d\n", pmod->mID, mRxbufID[i]);
 			if (mRxbufID[i] > 0) {
@@ -319,25 +316,25 @@
 					if(nPhyOutput[mPhyID[i].mIntType] < mPhyID[i].mPhyID)
 						nPhyOutput[mPhyID[i].mIntType] = mPhyID[i].mPhyID;
 
-					//pcm = frames->AllocFrame(); // It is not necessary to be compatible with the AXE1208 series here, because the TOP architecture is different.
+					pcm = frames->AllocFrame(); // It is not necessary to be compatible with the AXE1208 series here, because the TOP architecture is different.
 					m->SetOutputChannelDataPtr(i, pcm);
 					SetTxChannelPtr(static_cast<IntDataType>(mPhyID[i].mIntType), mPhyID[i].mPhyID-1, pcm->Data());
-//					printf("mID %d,bid %d\n", pmod->mID, mPhyID[i].mPhyID-1);
-//					printf("phy_type %d, _id %d\n", mPhyID[i].mIntType, mPhyID[i].mPhyID);
+//					dbg_printf("mID %d,bid %d\n", pmod->mID, mPhyID[i].mPhyID-1);
+//					dbg_printf("phy_type %d, _id %d\n", mPhyID[i].mIntType, mPhyID[i].mPhyID);
 				}
 			}
 			else {
 				m->SetInputChannelDataPtr(i, 0);
 			}
 		}
-//		printf("\n");
+//		dbg_printf("\n");
 
 		m->Init();
 
 		// 从 paramset 中获取对应的参数控制函数指针
 		ParamCtrl_fn paramEntry = paramset->GetParamEntry( m->GetModuleType());
 		if(paramEntry == NULL) {
-			printf("paramEntry is NULL!\n");
+			dbg_printf("paramEntry is NULL!\n");
 		}
 		// 调用参数控制函数
 		u32 result = paramEntry(m, (uvoid*)pmod->mParamaddr, len);
@@ -347,12 +344,12 @@
 //	int ddr = sram_free_space(SRAM_DDR,mem_any);
 //	int ccm = sram_free_space(SRAM_L2,mem_any);
 //	int l1 = sram_free_space(SRAM_L1,mem_heap);
-//	printf("mListAdd:0x%x, ddr %d ccm %d l1 %d.\n", &mList, ddr, ccm ,l1);
+//	dbg_printf("mListAdd:0x%x, ddr %d ccm %d l1 %d.\n", &mList, ddr, ccm ,l1);
 
 //for (auto pl : mList) {
 //	delete pl;
 //	int l2mem = sram_free_space(SRAM_L2, mem_any);
-//	printf("L2mem %d\n", l2mem);
+//	dbg_printf("L2mem %d\n", l2mem);
 //}
 
 	if (size != nbytes) {
@@ -366,7 +363,7 @@
 	/*for (auto pt = mList.begin(); pt < mList.end(); pt++) {
 		IModule *p =  *pt._Myptr;
 		static int i = 0;
-		printf("%d, id %d, type %d\n",i++, p->GetModuleID(), p->GetModuleType());
+		dbg_printf("%d, id %d, type %d\n",i++, p->GetModuleID(), p->GetModuleType());
 	}*/
 
 	return 	ErrStatus::SUCCESS;
@@ -381,7 +378,7 @@
 	head->crc = 0;
 	tmp_crc = CRC::crc32(bin, nbytes);
 	if (tmp_crc != crc) {
-		printf("flowchar crc check fail.\n");
+		dbg_printf("flowchar crc check fail.\n");
 		return ErrStatus::ERR_PARAM;
 	}
 	processed = ufalse;
@@ -398,13 +395,14 @@
 ErrStatus ToB::toProc()
 {
 	if(processed) {
-		for (auto iter = mList.begin(); iter < mList.end(); iter++) {
-//			if(((*iter)->GetModuleType() >= 6) && ((*iter)->GetModuleType() <= 6)) {
+		for (auto iter : mList) {// = mList.begin(); iter < mList.end(); iter++) {
+//			if(((*iter)->GetModuleType() >= PROC_COMPRESS) && ((*iter)->GetModuleType() <= PROC_COMPRESS)) {
 //				printf("%d ", (*iter)->GetModuleID());
-				(*iter)->Proc();
+//				int ii = 2;
 //			}
+			iter->Proc();
 		}
-//		printf("\n");
+//		dbg_printf("\n");
 	}
 	else {
 		MuteOutput();
@@ -412,34 +410,34 @@
 	return ErrStatus::SUCCESS;
 }
 
-u32 ToB::GetModuleType(u32 mID)
+IModule* ToB::GetModule(u32 mID)
 {
 	if(mID >= mModuleIndex.size() || mModuleIndex[mID] == 0) {
-		return ErrStatus::ERR_PARAM;
+		return NULL;
 	}
 	IModule* m = mList[mModuleIndex[mID]-1];
 	if( m != NULL) {
-		return m->GetModuleType();
+		return m;
 	}
-	return 0;
+	return NULL;
 }
 
 /*ErrStatus ToB::toCtrl(u32 mID, u32 pID, const s16* val, u32 num)
 {
     if(mID >= mModuleIndex.size() || mModuleIndex[mID] == 0) {
-    	printf("ToB::toCtrl mID Error!\n");
+    	dbg_printf("ToB::toCtrl mID Error!\n");
         return ErrStatus::ERR_PARAM;
     }
 
     IModule* m = mList[mModuleIndex[mID]-1];
     if(!m) {
-    	printf("ToB::toCtrl m Error!\n");
+    	dbg_printf("ToB::toCtrl m Error!\n");
         return ErrStatus::ERR_PARAM;
     }
 
     auto entries  = paramset->GetEntries(m->GetModuleType());
     if(!entries.second) {
-    	printf("ToB::toCtrl entries Error!\n");
+    	dbg_printf("ToB::toCtrl entries Error!\n");
         return ErrStatus::ERR_METHOD;
     }
 
@@ -451,13 +449,16 @@
 	if(mID >= mModuleIndex.size() || mModuleIndex[mID] == 0) {
 		return ErrStatus::ERR_PARAM;
 	}
+//	VarState& var = VarState::GetInstance();
+//	printf("mID:%d\n", mID);
+	void *paramPtr = VarState::GetInstance().pscene->get_param(mID);
 
 	IModule* m = mList[mModuleIndex[mID]-1];
 	if( m != NULL) {
 //		m->Ctrl(pID, val, num);
-		paramset->GetCtrlEntry(m->GetModuleType())(m, pID, (s16*)val, num);
+		paramset->GetCtrlEntry(m->GetModuleType())(m, pID, (s16*)val, num, paramPtr);
 	}
-//	printf("mID:%d pID:%d val[0]:%d val[1]:%d\n",mID, pID, val[0], val[1]);
+//	dbg_printf("mID:%d pID:%d val[0]:%d val[1]:%d\n",mID, pID, val[0], val[1]);
 	return ErrStatus::SUCCESS;
 }
 
@@ -494,17 +495,17 @@
 }
 
 
-u32 ToB::GetLevels(s16* buffer)
+u32 ToB::GetLevels(s16* buffer, u32 level_max_len)
 {
-	u32 n =0,size =0;
-
+	u32 n=0, size =0;
+	u32 remain_len;
 	if( !processed ) {
 		return 0;
 	}
-	for (std::vector<IModule*>::iterator iter = mList.begin();
-		iter != mList.end() ; iter++) {
-		size = (*iter)->GetLevel(buffer + n );
-//		printf("proc %s level num:%d\n",type_string[(*iter)->GetModuleType()],size);
+	for (std::vector<IModule*>::iterator iter = mList.begin(); iter != mList.end(); iter++) {
+		remain_len = level_max_len - n;
+		size = (*iter)->GetLevel(buffer + n, remain_len);
+//		dbg_printf("proc:%s level num:%d remain:%d\n", type_string[(*iter)->GetModuleType()], size, remain_len);
 		n += size;
 	}
 

--
Gitblit v1.9.3