本文介绍了使用IOCTL将音频数据从用户模式发送到Sysvad(虚拟音频驱动程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序(用户模式)中,我接收音频数据并使用以下功能将其保存:

In my application(usermode), i receive audio data and save it use function:

VOID CSoundRecDlg::ProcessHeader(WAVEHDR * pHdr)
{
    MMRESULT mRes=0;
    TRACE("%d",pHdr->dwUser);
    if(WHDR_DONE==(WHDR_DONE &pHdr->dwFlags))
    {
        mmioWrite(m_hOPFile,pHdr->lpData,pHdr->dwBytesRecorded);
        mRes=waveInAddBuffer(m_hWaveIn,pHdr,sizeof(WAVEHDR));
        if(mRes!=0)
            StoreError(mRes,TRUE,"File: %s ,Line Number:%d",__FILE__,__LINE__);
    }
}

pHdr指针指向音频数据(字节[11025])如何使用IOCTL在sysvad中获取此数据.感谢您的帮助.

pHdr Pointer points to the audio data(byte[11025])How to I can get this data in sysvad using IOCTL. Thanks for help.

推荐答案

如果我正确理解,您的音频缓冲区比您要发送的音频缓冲区要多得多,因此需要在sysvad中进行输出.对于这种情况,您将不得不使用"writebytes"写黄油.请查看此示例以获取更多详细信息.

If I understand correctly you have an audio buffer than you want to send for output in sysvad. For this case scenario you would have to write the butter in using "writebytes"please look at this example for more in depth details.

https://github.com/microsoft/Windows-driver-samples/blob/master/audio/sysvad/EndpointsCommon/minwavertstream.cpp

更新

回答您的评论:

循环缓冲区并不是必须的,它实际上取决于您要执行的实现,重点是要在内存中获取缓冲区,编写它就像这样

Circular buffer is not a must it really depends from the implementation you want to do, the main point is to get the buffer in memory, writing it is simply like this

 adapterObject->WriteEtwEvent(eMINIPORT_LAST_BUFFER_RENDERED,
                                    m_ullLinearPosition + ByteDisplacement, // Current linear buffer position
                                    m_ulCurrentWritePosition, // The very last WaveRtBufferWritePosition that the driver received
                                    0,
                                    0);

理想情况下,您应该将关注点与彼此独立的读写逻辑使用,而缓冲对象只是在它们之间传递

ideally you would use separation of concerns with the logic for reading and writing independent from each other, with the buffer object just passed between them

这篇关于使用IOCTL将音频数据从用户模式发送到Sysvad(虚拟音频驱动程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 01:39