Skip to content

Commit

Permalink
解决语音监听对话框不更新状态的问题
Browse files Browse the repository at this point in the history
修复语音监听对话框显示已收到数据不更新状态的问题。
发现"发送本地语音"会导致主控端容易崩溃的问题,现象类似于操作远程桌面时的随机崩溃。
  • Loading branch information
yuanyuanxiang committed Jan 26, 2019
1 parent be45b5b commit af63166
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 9 deletions.
4 changes: 4 additions & 0 deletions ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,7 @@
1、修复被控端消息提示对话框在消息换行时显示不完整的问题。

2、添加/完善录制远程被控端视频的功能。

3、修复语音监听对话框显示已收到数据不更新状态的问题。

4、发现"发送本地语音"会导致主控端容易崩溃的问题,现象类似于操作远程桌面时的随机崩溃。
8 changes: 5 additions & 3 deletions client/AudioManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ VOID CAudioManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
{
case COMMAND_NEXT:
{
NotifyDialogIsOpen();
if (1 == ulLength)
NotifyDialogIsOpen();
break;
}
default:
{
m_AudioObject->PlayBuffer(szBuffer, ulLength);
{
m_AudioObject->PlayBuffer(szBuffer, ulLength);
break;
}
}
Expand Down Expand Up @@ -83,6 +84,7 @@ BOOL CAudioManager::SendRecordBuffer()
szPacket[0] = TOKEN_AUDIO_DATA; //向主控端发送该消息
//复制缓冲区
memcpy(szPacket + 1, szBuffer, dwBufferSize);
szPacket[dwBufferSize] = 0;
//发送出去
if (dwBufferSize > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion client/TestRun.vcxproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<DeploymentDirectory>C:\VM\Remoter</DeploymentDirectory>
<AdditionalFiles>$(TargetDir)\TestRun.pdb;$(TargetDir)\ServerDll.dll;$(TargetDir)\ServerDll.pdb</AdditionalFiles>
<RemoteDebuggerDeployDebugCppRuntime>false</RemoteDebuggerDeployDebugCppRuntime>
<DebuggerFlavor>WindowsRemoteDebugger</DebuggerFlavor>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
Binary file modified server/2015Remote/2015Remote.rc
Binary file not shown.
20 changes: 17 additions & 3 deletions server/2015Remote/AudioDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void CAudioDlg::DoDataExchange(CDataExchange* pDX)

BEGIN_MESSAGE_MAP(CAudioDlg, CDialog)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_CHECK, &CAudioDlg::OnBnClickedCheck)
END_MESSAGE_MAP()


Expand All @@ -70,6 +71,9 @@ BOOL CAudioDlg::OnInitDialog()

m_bThreadRun = m_hWorkThread ? TRUE : FALSE;

// "发送本地语音"会导致崩溃,详见"OnBnClickedCheck"
GetDlgItem(IDC_CHECK)->EnableWindow(FALSE);

return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
Expand All @@ -82,7 +86,7 @@ DWORD CAudioDlg::WorkThread(LPVOID lParam)
{
if (!This->m_bSend)
{
Sleep(50);
WAIT(This->m_bIsWorking, 1, 50);
continue;
}
DWORD dwBufferSize = 0;
Expand All @@ -101,12 +105,11 @@ void CAudioDlg::OnReceiveComplete(void)
m_nTotalRecvBytes += m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1; //1000+ =1000 1
CString strString;
strString.Format("Receive %d KBytes", m_nTotalRecvBytes / 1024);
SetDlgItemText(IDC_TIP, strString);
SetDlgItemText(IDC_TIPS, strString);
switch (m_ContextObject->InDeCompressedBuffer.GetBuffer(0)[0])
{
case TOKEN_AUDIO_DATA:
{

m_AudioObject.PlayBuffer(m_ContextObject->InDeCompressedBuffer.GetBuffer(1),
m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1); //播放波形数据
break;
Expand Down Expand Up @@ -134,3 +137,14 @@ void CAudioDlg::OnClose()
delete this;
#endif
}

// 处理是否发送本地语音到远程
void CAudioDlg::OnBnClickedCheck()
{
// @notice 2019.1.26
// 如果启用"发送本地语音",则被控端崩溃在zlib inffas32.asm
// 需将主控端zlib拷贝到被控端重新编译
// 但是即使这样,主控端在开启"发送本地语音"时容易崩溃
// 此现象类似于操作远程桌面时的随机崩溃。原因不明
UpdateData(true);
}
3 changes: 2 additions & 1 deletion server/2015Remote/AudioDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class CAudioDlg : public CDialog

DECLARE_MESSAGE_MAP()
public:
BOOL m_bSend;
BOOL m_bSend; // 是否发送本地语音到远程
virtual BOOL OnInitDialog();
afx_msg void OnClose();
afx_msg void OnBnClickedCheck();
};
9 changes: 8 additions & 1 deletion server/2015Remote/IOCPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
if (ContextObject && This->m_bTimeToKill == FALSE &&dwTrans==0)
{
ContextObject->olps = NULL;
OutputDebugStringA("!!! RemoveStaleContext \n");
This->RemoveStaleContext(ContextObject);
}
SAFE_DELETE(OverlappedPlus);
Expand Down Expand Up @@ -539,7 +540,9 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
OVERLAPPEDPLUS* OverlappedPlus = new OVERLAPPEDPLUS(IOWrite);
BOOL bOk = PostQueuedCompletionStatus(m_hCompletionPort, 0, (DWORD)ContextObject, &OverlappedPlus->m_ol);
if ( (!bOk && GetLastError() != ERROR_IO_PENDING) ) //如果投递失败
{
{
int a = GetLastError();
OutputDebugStringA("!!! OnClientPreSending 投递消息失败\n");
RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus);
}
Expand Down Expand Up @@ -569,6 +572,7 @@ BOOL IOCPServer::OnClientPostSending(CONTEXT_OBJECT* ContextObject,ULONG ulCompl
if ( iOk == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING )
{
int a = GetLastError();
OutputDebugStringA("!!! OnClientPostSending 投递消息失败\n");
RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus);
}
Expand Down Expand Up @@ -686,6 +690,8 @@ void IOCPServer::OnAccept()
//因为我们接受到了一个用户上线的请求那么我们就将该请求发送给我们的完成端口 让我们的工作线程处理它
if ( (!bOk && GetLastError() != ERROR_IO_PENDING)) //如果投递失败
{
int a = GetLastError();
OutputDebugStringA("!!! OnAccept 投递消息失败\n");
RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus);
return;
Expand All @@ -710,6 +716,7 @@ VOID IOCPServer::PostRecv(CONTEXT_OBJECT* ContextObject)
if (iOk == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING)
{
int a = GetLastError();
OutputDebugStringA("!!! PostRecv 投递消息失败\n");
RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus);
}
Expand Down
Binary file modified server/2015Remote/resource.h
Binary file not shown.

0 comments on commit af63166

Please sign in to comment.