From 1ac2340f684bf8c0b05fb571f5994b0755050671 Mon Sep 17 00:00:00 2001
From: chenlh <2008get@163.com>
Date: 星期四, 29 一月 2026 15:22:04 +0800
Subject: [PATCH] 更新删除输出第一通道后有电平无声音的情况

---
 src/messageproc.cpp |  177 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 131 insertions(+), 46 deletions(-)

diff --git a/src/messageproc.cpp b/src/messageproc.cpp
index f007cb3..b1704aa 100644
--- a/src/messageproc.cpp
+++ b/src/messageproc.cpp
@@ -47,11 +47,7 @@
 	int data_len;
 
 	ToB* tob = ToB::GetInstance();
-<<<<<<< HEAD
-	u16 LevelCnt = tob->GetLevels(Levels);	//918 levels
-=======
-	u16 LevelCnt = tob->GetLevels(Levels);	//864 levels
->>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
+	u16 LevelCnt = tob->GetLevels(Levels, levels_max_len);	//1688 levels
 	u32 msgLen = LevelCnt * sizeof(*Levels);
 	int Packegs = (msgLen+MSG_DATA_LEN-1)/MSG_DATA_LEN;
 
@@ -100,13 +96,9 @@
 
 		s16* data = (s16*)(ptr + 1);
 
-		data_num = (data_num - sizeof(struct ParamCtrl))/sizeof(s16);
+		data_num = (data_num - sizeof(struct ParamCtrl)) / sizeof(s16);
 //		ptr->mid = var.pscene->get_module_id(ptr->mid, type, ptr->cmd) ;
-<<<<<<< HEAD
-//		printf("mID:%d pID:%d val[0]:%d val[1]:%d\n",ptr->mid, ptr->cmd, data[0], data[1]);
-=======
-
->>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
+//		dbg_printf("mID:%d pID:%d val[0]:%d val[1]:%d\n",ptr->mid, ptr->cmd, data[0], data[1]);
 		tob->toCtrl(ptr->mid, ptr->cmd, data, data_num);
 	}
 
@@ -128,7 +120,7 @@
 		bin = (u8*)sram_malloc(SRAM_DDR, mem_any, pmsg->totalPkts*MSG_DATA_LEN);
 	}
 	if(bin == NULL) return -1;
-//	printf("No:%d len %d\n", pmsg->pktNo,pmsg->dataLen);
+//	dbg_printf("No:%d len %d\n", pmsg->pktNo,pmsg->dataLen);
 	var.TopoLoading = utrue;
 	memcpy(bin+pmsg->pktNo*MSG_DATA_LEN, pmsg->data , pmsg->dataLen);
 
@@ -147,23 +139,14 @@
 				var.TopoStatus = PRESET_STA::PRESET_ERR;
 			}
 			else if(tob){
-<<<<<<< HEAD
 				int preset_size = sizeof(tag_parameters); // 45128 + sizeof(tag_fir) * MAX_OUTPUT_NUM;	 // size + FIR
 				u8* content = (u8*)sram_malloc(SRAM_DDR, mem_any, preset_size);
-=======
-				u8* content = (u8*)sram_malloc(SRAM_DDR, mem_any, 45128);//45*1024);
->>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 				s32 size ;
 
 				tob->toClear();
 
 				var.pscene->update_module();
 				size = var.pscene->convert_to_bin(content);
-<<<<<<< HEAD
-=======
-
-				tob->toClear();
->>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 				tob->toAnalysis(content, size);
 
 				sram_free(SRAM_DDR, content);
@@ -176,22 +159,6 @@
 
 	return 0;
 }
-
-/*void Message::param_init(ptag_device_config pDevCfg)
-{
-	pDevCfg->dual_dsp = 0;
-	pDevCfg->dsp_index = 0;
-	pDevCfg->local_rx_num = 16;
-	pDevCfg->local_tx_num = 16;
-	pDevCfg->dante_rx_num = 16;
-	pDevCfg->dante_tx_num = 16;
-	pDevCfg->external_clock = 1;
-	pDevCfg->scene_size = 1000;
-	pDevCfg->level_num = 10;
-	pDevCfg->modulelist = 9;
-	pDevCfg->hardware_type = 1;
-
-}*/
 
 s32 Message::HandshakeMessageProcess(MSG* pmsg)
 {
@@ -209,15 +176,9 @@
 		}
 
 //		param_init(device_config);
-<<<<<<< HEAD
 		hw_adapter_t* _adapter = new tg_hw_adapter_t(device_config->dual_dsp, device_config->dsp_index
 							,device_config->local_rx_num, device_config->local_tx_num
 							,device_config->dante_rx_num, device_config->dante_tx_num);
-=======
-		hw_adapter_t* _adapter = new tg_hw_adapter_t(device_config->dual_dsp,device_config->dsp_index
-							,device_config->local_rx_num,device_config->local_tx_num
-							,device_config->dante_rx_num,device_config->dante_tx_num);
->>>>>>> 0d5b7df96a2ee186b7b085dca9cf9a33f791c430
 		var.pscene = new(SRAM_DDR) tgScene(_adapter);
 
 		_adapter->config_board(&dspconfig);
@@ -228,7 +189,6 @@
 		var.g_level_report_interval = LEVEL_REPORT_TIME(dspconfig.mLevelReportInt);
 
 		ModuleLeveldBUSetting(dspconfig.mConvertUnit);
-		//Config(conf);
 		RouteConfig(dspconfig.routes, dspconfig.mRouteNum);
 		SRCsConfig(0 , &dspconfig.srcs[0]);
 		SRCsConfig(1 , &dspconfig.srcs[1]);
@@ -240,7 +200,129 @@
 	}
 
 	Send(MsgType::MSG_ACK_REQ, 0 , 0);
-	printf("HandShake OK\n");
+//	dbg_printf("HandShake OK\n");
+	return 0;
+}
+
+// section equal - ret:1
+// section not equal - ret:0
+bool decide_modu_type_equal(ptag_module pmodu, s16 dst_ch, s16 src_ch)
+{
+	bool ret = 0;
+	if (pmodu[dst_ch].proc_type == pmodu[src_ch].proc_type) {
+		if (PROC_EQ == pmodu[dst_ch].proc_type) {
+			ptag_eq proc_eq = (ptag_eq)&pmodu[dst_ch].proc_ins;
+			u16 section_dst = proc_eq->nsection;
+			proc_eq = (ptag_eq)&pmodu[src_ch].proc_ins;
+			u16 section_src = proc_eq->nsection;
+			if (section_src == section_dst)
+				ret = 1;
+		}
+		else if (PROC_GEQ == pmodu[dst_ch].proc_type) {
+			ptag_geq proc_geq = (ptag_geq)&pmodu[dst_ch].proc_ins;
+			u16 section_dst = proc_geq->nsections;
+			proc_geq = (ptag_geq)&pmodu[src_ch].proc_ins;
+			u16 section_src = proc_geq->nsections;
+			if (section_src == section_dst)
+				ret = 1;
+		}
+		else
+			ret = 1;
+	}
+	return ret;
+}
+
+s32 Message::ChannelParamCopy(MSG* pmag)
+{
+	s32 len = 0;
+	ptag_ch_param_copy ch_copy = (ptag_ch_param_copy)pmag->data;
+	VarState& var = VarState::GetInstance();
+	void* params_ptr = var.pscene->get_parameters();
+	if (params_ptr == nullptr) {
+		return -1;
+	}
+	ptag_parameters params = static_cast<ptag_parameters>(params_ptr);
+	ToB* tob = ToB::GetInstance();
+	param_ctrl_t* paramset = tob->GetParamCtrl();
+	s32** chin_mid = var.pscene->get_chin_mid();
+	s32** chout_mid = var.pscene->get_chout_mid();
+	tg_param_ctrl_t paramctrl;
+
+	s32 max_ch = ch_copy->bOutput ? var.pscene->get_output_num() : var.pscene->get_input_num();
+	if (ch_copy->src_ch_index >= max_ch || ch_copy->dst_ch_index >= max_ch || ch_copy->src_ch_index < 0 || ch_copy->dst_ch_index < 0) {
+		dbg_printf("ch %s copy channel index error\n",  ch_copy->bOutput ? "out" : "in");
+		return false;
+	}
+
+	if (!ch_copy->bOutput) {
+		memcpy(&params->input.input[ch_copy->dst_ch_index], &params->input.input[ch_copy->src_ch_index], sizeof(params->input.input[0]));
+		IModule* m = tob->GetModule(chin_mid[ch_copy->dst_ch_index][0]);	// [ch_idx][0] is the input type
+		ParamCtrl_fn paramEntry = paramset->GetParamEntry(PROC_INPUT);
+		paramEntry(m, (uvoid*)&params->input, len);
+
+		ptag_module inmod_params[5] = {params->in1, params->in2, params->in3, params->in4, params->in5};
+		for (s32 i = 0; i < 5; i++) {
+			if (paramctrl.decide_modu_type_equal(static_cast<ptag_module>(inmod_params[i]), ch_copy->dst_ch_index, ch_copy->src_ch_index)) {	// 1
+				memcpy(&inmod_params[i][ch_copy->dst_ch_index], &inmod_params[i][ch_copy->src_ch_index], sizeof(tag_module));
+			}
+			else {
+				dbg_printf("ch dst module in%d type != src.\n", i+1);
+				continue;
+			}
+
+			paramEntry = paramset->GetParamEntry(inmod_params[i][ch_copy->dst_ch_index].proc_type);
+			if(paramEntry == NULL) {
+				dbg_printf("paramEntry is NULL!\n");
+				return -1;
+			}
+			m = tob->GetModule(chin_mid[ch_copy->dst_ch_index][i + 1]);
+			u32 result = paramEntry(m, (uvoid*)&inmod_params[i][ch_copy->dst_ch_index].proc_ins, len);
+		}
+	}
+	else {
+		memcpy(&params->output.output[ch_copy->dst_ch_index], &params->output.output[ch_copy->src_ch_index], sizeof(params->output.output[0]));
+		IModule* m = tob->GetModule(chout_mid[ch_copy->dst_ch_index][0]);	// [ch_idx][0] is the output type
+		ParamCtrl_fn paramEntry = paramset->GetParamEntry(PROC_OUTPUT);
+		paramEntry(m, (uvoid*)&params->output, len);
+
+		ptag_module outmod_params[3] = {params->out1, params->out3, params->out4};
+		for (s32 i = 0; i < 3; i++) {
+			if (paramctrl.decide_modu_type_equal(static_cast<ptag_module>(outmod_params[i]), ch_copy->dst_ch_index, ch_copy->src_ch_index)) {	// 2
+				memcpy(&outmod_params[i][ch_copy->dst_ch_index], &outmod_params[i][ch_copy->src_ch_index], sizeof(tag_module));
+			}
+			else {
+				dbg_printf("ch dst module out%d type != src.\n", i+1);
+				continue;
+			}
+
+			paramEntry = paramset->GetParamEntry(outmod_params[i][ch_copy->dst_ch_index].proc_type);
+			if(paramEntry == NULL) {
+				dbg_printf("paramEntry is NULL!\n");
+				return -1;
+			}
+			m = tob->GetModule(chout_mid[ch_copy->dst_ch_index][(0==i) ? (i+1) : (i+2)]);
+			u32 result = paramEntry(m, (uvoid*)&outmod_params[i][ch_copy->dst_ch_index].proc_ins, len);
+//			printf("dst p adr:0x%x\n", (uvoid*)&outmod_params[i][ch_copy->dst_ch_index]);
+		}
+
+		ptag_module_fir outmod2_param = params->out2;
+		if (paramctrl.decide_modu_type_equal(static_cast<ptag_module_fir>(outmod2_param), ch_copy->dst_ch_index, ch_copy->src_ch_index)) {	// 3
+			memcpy(&outmod2_param[ch_copy->dst_ch_index], &outmod2_param[ch_copy->src_ch_index], sizeof(tag_module_fir));
+		}
+		else {
+			dbg_printf("ch dst module out2 type != src.\n");
+			return -1;
+		}
+
+		paramEntry = paramset->GetParamEntry(outmod2_param[ch_copy->dst_ch_index].proc_type);
+		if(paramEntry == NULL) {
+			dbg_printf("paramEntry is NULL!\n");
+			return -1;
+		}
+		m = tob->GetModule(chout_mid[ch_copy->dst_ch_index][2]);
+		u32 result = paramEntry(m, (uvoid*)&outmod2_param[ch_copy->dst_ch_index].proc_ins, len);
+	}
+
 	return 0;
 }
 
@@ -248,7 +330,7 @@
 {
 	extern ubool  systemMute;
 	if(pmsg->magic != 0x5aa5) {
-		//printf("magic error.\n");
+//		dbg_printf("magic error.\n");
 		return -1;
 	}
 
@@ -266,6 +348,9 @@
 	case MsgType::MSG_ACK_REQ:
 		HandshakeMessageProcess(pmsg);
 		break;
+	case MsgType::MSG_CHANNEL_COPY_REQ:
+		ChannelParamCopy(pmsg);
+		break;
 	default:
 		break;
 	}

--
Gitblit v1.9.3