// 负责发送本地语音 DWORD WINAPI CAudioDlg::WorkThread(LPVOID lparam) { CAudioDlg *pThis = (CAudioDlg *)lparam; while (pThis->m_bIsWorking) { if (!pThis->m_bIsSendLocalAudio) { Sleep(1000); continue; } DWORD dwBytes = 0; WaitForSingleObject(m_hEventWaveIn, INFINITE); //等待音频数据到来 if(ReaiLen == NULL) return 0; dwBytes = ReaiLen; ReaiLen = 0; // ::MessageBox(NULL,"001", "通知!!", MB_OK); //音频编码函数 int lin; char m_cBufln[1024]; lin=sizeof(m_cBufln); g_ACode.EncodeAudioData (Readata,dwBytes,m_cBufln,&lin); pThis->m_iocpServer->Send(pThis->m_pContext, (unsigned char *)m_cBufln, lin); // SetEvent(m_HoMiEven);// 通知波形数据到来 } return 0; }
void CMyWaveIn::GetData(char *pBuffer,int iLen) { m_soLock.Lock (); if (m_bSend) { int iOut = sizeof(m_cBufOut); g_ACode.EncodeAudioData (pBuffer,iLen,m_cBufOut,&iOut); m_pUdp->Send (m_cBufOut,iOut); } m_soLock.Unlock (); CWaveIn::GetData (pBuffer,iLen); }