传输中有很有节奏的都督声,似乎是每次发送或接收时产生的。如何解决好?

解决方案 »

  1.   

    接收和发送是两个socket,都是双缓冲,但问题依然存在。
    socket有数据到时,发送MM_WOM_OPEN消息给窗体:
    void CVoiceSocket::OnReceive(int nErrorCode)
    {
    // TODO: 在此添加专用代码和/或调用基类
        SendMessage(hwnd,MM_WOM_OPEN,0,0);
    CAsyncSocket::OnReceive(nErrorCode);
    }LRESULT Voice::ON_MM_WOM_OPEN(WPARAM wParam, LPARAM lParam)
    {

    if(!IsVoiceOn)
    return 0;
        int recvcount;
    if(outfirst)
    {
    recvcount=m_voicerecv.Receive(Out1,5120);
    waveOutUnprepareHeader(hWaveOut,&hout1,sizeof(WAVEHDR));
            hout1.dwBufferLength=recvcount;
            waveOutPrepareHeader(hWaveOut,&hout1,sizeof(WAVEHDR));
    waveOutWrite(hWaveOut,&hout1,sizeof(WAVEHDR));
    }
    else
    {
            recvcount=m_voicerecv.Receive(Out2,5120);
    waveOutUnprepareHeader(hWaveOut,&hout2,sizeof(WAVEHDR));
            hout2.dwBufferLength=recvcount;
            waveOutPrepareHeader(hWaveOut,&hout2,sizeof(WAVEHDR));
    waveOutWrite(hWaveOut,&hout2,sizeof(WAVEHDR));
    }
    outfirst=!outfirst;

    return 0;
    }以下是发送:
    LRESULT Voice::ON_MM_WIM_DATA(WPARAM wParam, LPARAM lParam)
    {
    WAVEHDR* hdr=(WAVEHDR*)lParam;
    char sendbuf[5120];
    int sendlen=(int)hdr->dwBytesRecorded;
    memcpy(sendbuf,hdr->lpData,sendlen);    if(IsVoiceOn)
    {
    infirst=!infirst;
        if(infirst)
    waveInAddBuffer(hWaveIn,&hin1,sizeof(WAVEHDR)); 
    else
        waveInAddBuffer(hWaveIn,&hin2,sizeof(WAVEHDR));
    char sendbuf2[5120];
    DWORD deslen=sendlen;
        if(!Coded(sendbuf,sendlen,sendbuf2,&deslen))
    return 0;
     
    for(int i=0;i<voicelist.GetCount();i++)
    {
            m_voicesend.SendTo(sendbuf2,(int)deslen,voicelist.GetAt(i).Port,voicelist.GetAt(i).IP);
    }
    }

    return 0;
    }究竟哪里有问题呢?
      

  2.   

    有一个实例参考一下http://www.vckbase.com/document/viewdoc/?id=1080