none
wince MDD/PDD 音频驱动录音问题 RRS feed

  • 常规讨论

  • wince5.0 ARM是at91sam9260,音频芯片是wm8731。驱动结构式MDD/PDD结构

    下面是PDD层录音的continue消息的处理

    VOID private_WaveInContinue( PWAVEHDR pwh )

    {

     T_BUFFER * pBuffer;
     T_BUFFER * pBuffer2;

    OutputDebugString(L"+PDD_WaveInContinue\r\n");

    pBuffer = PopBuffer(&BufferToUpFifo);//弹出准备好数据 //将已录好音数据传至系统

    if (pBuffer) {

    OutputDebugString(L"+PDD_WaveInContinue---pBuffer\r\n");

    private_AudioGetBuffer (pwh, (PDWORD) pBuffer->pData, g_capture_buffer_size / sizeof(DWORD));

    PushBuffer(&FreeInBufferFifo,pBuffer);

     pBuffer2 = PopBuffer(&BufferToUpFifo);//弹出第2个已录音好数据

    if (pBuffer2)

     {

    OutputDebugString(L"+PDD_WaveInContinue---pBuffer2\r\n");

    private_AudioGetBuffer (pwh, (PDWORD) pBuffer2->pData, g_capture_buffer_size / sizeof(DWORD));

    PushBuffer(&FreeInBufferFifo,pBuffer2);//

     }

     }

    //使能接收中断,接收买中断

    g_pSSC0->SSC_IER = (AT91C_SSC_ENDRX | AT91C_SSC_RXBUFF /*| AT91C_SSC_TXEMPTY*/);

    OutputDebugString(L"-PDD_WaveInContinue\r\n");

    }

     

    VOID
    private_AudioGetBuffer (
                           PWAVEHDR pwh,
                           PDWORD pSrcBuffer,
                           DWORD dwSrcSamples
                           )
    {
       OutputDebugString(L"+Private_AudioGetBuffer\r\n");
    //将录音数据全部填充入pwh中
        while ((pwh != NULL) && (dwSrcSamples > 0))
        {
        //如果录音数量大于缓冲区长度
            if (pwh->dwBytesRecorded >= pwh->dwBufferLength)
            {
                pwh = pwh->lpNext;
            }
            else
            {
                DWORD dwDstSamples = (pwh->dwBufferLength - pwh->dwBytesRecorded) / g_sample_size[WAPI_IN];
       //计算可接受的采样数
                DWORD dwSamples = min(dwSrcSamples, dwDstSamples);

                g_pfnGetBuffer(pwh->lpData + pwh->dwBytesRecorded, (PINT16) pSrcBuffer, dwSamples);
                pwh->dwBytesRecorded += dwSamples * g_sample_size[WAPI_IN];
                pSrcBuffer += dwSamples;
                dwSrcSamples -= dwSamples;
            }
        }
     OutputDebugString(L"+Private_AudioGetBuffer end \r\n");
    }

     

    在驱动中设立了3个FIFO结构体,4个接收buffer[4],3个FIFO公用这4个缓冲区,里面按照要求存放着开辟的缓冲区的个数以及对当前FIFO可用的缓冲区个数以及对应缓冲区序号,这些与原来放音的结构模式相同。
    T_BUFFER_FIFO FreeInBufferFifo;//可以用于录音的FIFO
    T_BUFFER_FIFO   BufferToUpFifo;//音已录好转被上传的FIFO
    T_BUFFER_FIFO   BufferBeingRecordFifo;//正在录音存储的序列FIFO

    现在现象是驱动可以打开录音,且录音不断进入接收中断,并且不断进入VOID private_WaveInContinue( PWAVEHDR pwh ) 填充数据,但这时如果再发送stop消息,驱动收不到,且停止不了录音。不知什么问题?

    2010年7月20日 5:28

全部回复

  • 刚刚看了你发给我的code,发现你在处理WPDM_ENDOFDATA时,没有对WAPI_IN的情况作出反应。

    case WPDM_ENDOFDATA:
            RETAILMSG( WAVEDEV_DEBUG, (TEXT( "....endofdata\r\n" )) );
      if (apidir == WAPI_OUT)
       private_WaveOutEndOfData();
      else
       mmRet = MMSYSERR_NOTSUPPORTED;
      break;

    应该要有一个相应的private_WaveInEndOfData()函数来终止传输。

     

    2010年7月20日 14:09
    版主
  •  这个我觉得问题不大,根据MSDN,WPDM_ENDOFDATA针对WAPI_IN时未用,即其对应不用处理。不过我到时试一下。因为我参考的驱动是

    F:\WINCE500\PUBLIC\COMMON\OAK\CSP\ARM\INTEL\PXA25X\WAVEDEV\wavepdd.c下的,他的代码

      case WPDM_ENDOFDATA:
            DEBUGMSG( ZONE_VERBOSE, (TEXT( "....endofdata\r\n" )) );
            if (apidir == WAPI_OUT)
                private_WaveOutEndOfData();
            else
                mmRet = MMSYSERR_NOTSUPPORTED;
            break;

     case WPDM_STOP:
            DEBUGMSG( ZONE_VERBOSE, (TEXT( "....stop  %s\r\n" ),(apidir == WAPI_IN)?"i n ":"o u t ") );
            if (apidir == WAPI_IN)
                private_WaveInStop((PWAVEHDR) dwParam1);
            else
                private_WaveOutStop();
            break;

    同样对WPDM_ENDOFDATA是输入的情况未作处理,而是对WPDM_STOP做了处理。

    我写的代码类似的,仅对WPDM_STOP做了处理:

     case WPDM_STOP:
            RETAILMSG( WAVEDEV_DEBUG, (TEXT( "....stop  %s\r\n" ),(apidir == WAPI_IN)?L"in":L"out") );
    /////////////////////////////////////////
      if (apidir == WAPI_IN)
      private_WaveInStop((PWAVEHDR) dwParam1);
      else
      private_WaveOutStop();
      break;

     case WPDM_ENDOFDATA:
            RETAILMSG( WAVEDEV_DEBUG, (TEXT( "....endofdata\r\n" )) );
      if (apidir == WAPI_OUT)
       private_WaveOutEndOfData();
      else
       mmRet = MMSYSERR_NOTSUPPORTED;
      break;

     

    不过我会测试过,然后将这里是否是影响驱动反馈回来。

    现在开始录音后不断的进中断和continue函数,但是好像上位机应用程序没收到数据,这时再向驱动发stop指令,MDD层的WAVE_PROC就没收到这个消息。所以驱动也相应不了,telnet也没反应了,好像系统只忙着录音,其他的都没法执行了,不知是不是private_AudioGetBuffer ( )函数的问题

    • 已编辑 xinjie1023 2010年7月21日 11:16 内容不完整
    2010年7月21日 11:12
  • 嗯,我想你说得对,WPDM_ENDOFDATA对于IN来说不需要处理。那现在最有可能的就是,你的recording造成的interrupt过多,使得,其他process没有机会执行。

    要证明这个,只需要在你得wavedev driver里面disable PDC interrupt(你是应该用PDC来传数据的八),然后看看你的waveInStop函数是否会被执行。

    2010年7月22日 1:42
    版主
  • 好的,我现在用的是pdc传输的,虽然看到打印的消息不断地进入中断和continue函数,但是不见应用程序接收到数据的消息,不知为什么。

    我会尝试你的方法,进入一次continue关闭中断看看是否能收到stop以及接到什么数据。

    别人给了我个ac97的程序,与我写的类似。我给你下看看。

    顺便问2问题,

    (1)  我在初始化里创建2个DMA对象并如下做了初始化和缓冲区会不会有问题?还是必须创建一个DMA对象一次创建8个缓冲区?

    DMA_ADAPTER_OBJECT Adapter;

    DMA_ADAPTER_OBJECT Adapter1;

     //DMA映射  
        Adapter.ObjectSize    = sizeof(DMA_ADAPTER_OBJECT);  //对象大小
        Adapter.InterfaceType = Internal;          //接口为内部
        Adapter.BusNumber     = 0;       //总线个数

       //DMA映射   
        AdapterRec.ObjectSize    = sizeof(DMA_ADAPTER_OBJECT);  //对象大小
       AdapterRec.InterfaceType = Internal;          //接口为内部
       AdapterRec.BusNumber     = 0;       //总线个数
        
     分配DMA空间   创建4个缓冲区 ,
        dma_page[0] = (BYTE *) HalAllocateCommonBuffer(&Adapter, (AUDIO_BUFFER_SIZE * (NUM_DMA_AUDIO_BUFFERS)), &PA, FALSE);
      

     dmarec_page[0] = (BYTE *) HalAllocateCommonBuffer(&AdapterRec, (AUDIO_INBUFFER_SIZE * NUM_DMA_AUDIO_BUFFERS), &PA, FALSE);
     

    (2)如果录音以16位采样,IIS一次传输16个bit,那么g_pSSC0->SSC_RCR 的计数是以字节为计数单位?

     

    • 已编辑 xinjie1023 2010年7月22日 11:58 增加提问
    2010年7月22日 11:02
  • 在atmel的驱动程序里是用一个DMA object创建给Transmit和receive的DMA buffer,不过我觉得一个还是两个DMA object应该没有关系,只要可以access每个buffer的physical address和virtual address就可以了。

    PDC的RCR和TCR取决于你设置在SSC_RFMR里的DATLEN,你可以看看9260 datasheet里面关于DATLEN的description.

    2010年7月23日 1:45
    版主
  • 那我就是16位的了。
    2010年7月23日 2:29
  • 经过测试,我在private_waveincontinue()里填充一次  pwh后停止录音接收中断,然后发送waveinstop是可以收到消息的。但是在waveinstop之前并没有WIM_DATA返回,不知为什么?
    2010年7月24日 5:27
  • 你查看一下private_AudioGetBuffer函数里,pwh->dwBytesRecorded有没有跟pwh->dwBufferLength相等过。一般只有这样才会有WIM_DATA message

    2010年7月26日 5:33
    版主
  • 好的,还有个问题,原来驱动在PDD中断中未对溢出做处理,但是加上溢出中断标志的判断,发现PDD中断进入后不断地进入溢出中断判断,不知为什么,原来未处理溢出中断时也未开启溢出中断检测理论上不应该出现这种情况吧?
    2010年7月26日 6:37
  • 你确定触发中断的肯定是overflow吗? 还是同时status register 里面有别的bit也被设了?
    2010年7月26日 7:51
    版主
  • 因为在判断时都是进行的位与操作,其他对应位即使为1,位与后也没有了吧?我想问下,中断状态寄存器置位何时消除的呢?如果我在中断中用状态寄存器g_pSSC0->SSC_SR多次与接收和发送等中断对应位相位与,会不会对其他位也清空,还是退出中断时统一自动清空的?我再针对你的问题测试一下。
    2010年7月26日 9:17
  • 我又找到了微软提供的MDD层的代码\WINCE500\PUBLIC\COMMON\OAK\DRIVERS\WAVEDEV\MDD,现在代码我还没完全看懂,但是到目前我看他传到PDD层的gsi[WAPI_IN].pwh为什么是空呢?在MDD层没看到其赋值有效地PWAVEHDR类型的数据?
    2010年7月26日 14:09
  • 第一个问题,状态寄存器一般你读了之后就被reset了,所以你只要读了其中一位,所以位都reset to 0了。

    第二个问题,你是用我上次给你的test code做的测试吗? pwh不应该为空,否则就没有receive buffer了。Pdd也找不到地方可以copy capture到的数据。

    2010年7月27日 13:41
    版主
  •     你好,现在有个新问题,我把SSC的接收RK0设置为输出模式,理论上应该输出接收时钟才对,但是没有信号,一直为高,莫非我驱动哪个地方配置的有问题?TK0配置后有时钟输出。
    2010年8月3日 10:23
  • 有没有试过把CKS设成0, CKO为1,CKG为0

    另外给SSC_CMR里面的DIV设一个合适的值。

    2010年8月4日 1:54
    版主
  • 原来提供核心板的公司把RK0作为网络监测的引脚用了,现在暂时把她的那部分应用屏蔽,好了。

     驱动中用v_fMoreData=TRUE表示放音连续标志(原来的bsp也是这样表示),v_RecfMoreData=TRUE表示录音数据连续(修改驱动增加的)。 现在测试发现一个问题,当录音时每次进PDD_AudioGetInterruptType()函数,强制将放音连续的标志v_fMoreData=FALSE即强制不让其进入放音中断,录音基本能循环起来,虽然有丢数据和失真。但是如果不强制将v_fMoreData=FALSE,刚开始几次循环根据打印消息v_fMoreData是FALSE,但是执行大约10次左右后突然在中断中打出放音消息,即v_fMoreData=TRUE了,但是驱动中只有private_waveout()函数将v_fMoreData置TRUE了,在private_waveout()其中增加打印消息看是否进入,在只录音时并没执行此函数,但是为什么v_fMoreData变成TRUE了呢?不会是v_fMoreData内存分配被人占用了或者内存溢出了?

     

    PDD_WaveProc

    WPDM_OPEN

    private_WaveOpen Format Query

    PDD_WaveProc

     WPDM_OPEN

    private_WaveOpen wave out open ok

    MDD layer WIDM_OPEN in WAV_IOControl()

    PDD_WaveProc

    WPDM_OPEN

    private_WaveOpen Format Query MDD layer

    WIDM_OPEN in WAV_IOControl()

    PDD_WaveProc

    WPDM_OPEN

    private_WaveOpen gChannelSrc.dwDMASize==4096

    wave in open ok

    MDD layer WIDM_START in WAV_IOControl()

    PDD_WaveProc

     private_WaveInStart popbuffer ok

    PDD_AudioGetInterruptType //进入中段未执行任何动作 PDD_WaveProc MDD layer

    AUDIO_STATE_IGNORE

    -PDD_WaveInStart PDD_AudioGetInterruptType //再次录音进入中断 PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 //1个缓冲区录满 PDD_AudioGetInterruptType----8 //1个缓冲区录满进入上传区,同时将1个空闲缓冲区压站,录音缓冲区2个,空闲缓冲区1个 PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer //MDD层读取数据continue,上传1个缓冲区,空闲缓冲区变为2个 +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 //1个缓冲区录满进入上传区,同时将1个空闲缓冲区压站,录音缓冲区2个,空闲缓冲区1个 PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer //MDD层读取数据continue,上传1个缓冲区,空闲缓冲区变为2个 +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8//1个缓冲区录满进入上传区,同时将1个空闲缓冲区压站,录音缓冲区2个,空闲缓冲区1个 PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer //MDD层读取数据continue,上传1个缓冲区,空闲缓冲区变为2个 +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8//1个缓冲区录满进入上传区,同时将1个空闲缓冲区压站,录音缓冲区2个,空闲缓冲区1个 PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer//MDD层读取数据continue,上传1个缓冲区,空闲缓冲区变为2个 +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8//1个缓冲区录满进入上传区,同时将1个空闲缓冲区压站,录音缓冲区2个,空闲缓冲区1个 PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback //返回应用程序数据 MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer //MDD层读取数据continue,上传1个缓冲区,空闲缓冲区变为2个 +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_WaveProc PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 //1个缓冲区录满进入上传区,同时将1个空闲缓冲区压站,录音缓冲区2个,空闲缓冲区1个 PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer //MDD层读取数据continue,上传1个缓冲区,空闲缓冲区变为2个 +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_WaveProc PDD_AudioGetInterruptType play //为何进入放音??????????????? PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IGNORE PDD_AudioGetInterruptType play PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8//1个缓冲区录满进入上传区,同时将1个空闲缓冲区压站,录音缓冲区2个,空闲缓冲区1个 MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer AUDIO_STATE_IN_RECORDING PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IGNORE PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_RECORDING PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_RECORDING PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_RECORDING PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IGNORE PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----4 PDD_AudioGetInterruptType----5 PDD_AudioGetInterruptType----6 PDD interrupt AUDIO_STATE_IN_OVERFLOW PDD_WaveProc MDD layer AUDIO_STATE_IN_STOPPED PDD_WaveProc PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----5 PDD_AudioGetInterruptType----6 PDD interrupt AUDIO_STATE_IN_OVERFLOW MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_STOPPED MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IGNORE PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 PDD_WaveProc MDD layer AUDIO_STATE_IN_RECORDING PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IGNORE PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_RECORDING MDD layer gsi[apidir].pwh != NULL PDD_WaveProc +PDD_WaveInContinue +PDD_WaveInContinue---pBuffer +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInContinue PDD_WaveProc continue ok PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----8 PDD interrupt AUDIO_STATE_IN_OVERFLOW MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback PDD_WaveProc MDD layer AUDIO_STATE_IN_STOPPED MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback PDD_WaveProc PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----4 PDD_AudioGetInterruptType----5 PDD interrupt AUDIO_STATE_IN_OVERFLOW MDD layer AUDIO_STATE_IN_STOPPED MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IGNORE PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IGNORE PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----3 PDD_AudioGetInterruptType----7 int handler. No buffer to record in the Fifo PDD interrupt AUDIO_STATE_IN_OVERFLOW MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_STOPPED MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----7 int handler. No buffer to record in the Fifo PDD interrupt AUDIO_STATE_IN_OVERFLOW MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_STOPPED MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----7 int handler. No buffer to record in the Fifo PDD interrupt AUDIO_STATE_IN_OVERFLOW MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_STOPPED MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----7 int handler. No buffer to record in the Fifo PDD interrupt AUDIO_STATE_IN_OVERFLOW MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback PDD_WaveProc MDD layer AUDIO_STATE_IN_STOPPED MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----7 int handler. No buffer to record in the Fifo PDD interrupt AUDIO_STATE_IN_OVERFLOW MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_STOPPED MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----7 int handler. No buffer to record in the Fifo PDD interrupt AUDIO_STATE_IN_OVERFLOW MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_STOPPED MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----7 int handler. No buffer to record in the Fifo PDD interrupt AUDIO_STATE_IN_OVERFLOW MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_WaveProc continue ok MDD layer AUDIO_STATE_IN_STOPPED MDD layer gsi[apidir].pwh != NULL PDD_WaveProc PDD_AudioGetInterruptType play PDD_AudioGetInterruptType play1 PDD_AudioGetInterruptType PDD_AudioGetInterruptType----2 PDD_AudioGetInterruptType----7 int handler. No buffer to record in the Fifo PDD interrupt AUDIO_STATE_IN_OVERFLOW MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback PDD_WaveProc MDD layer AUDIO_STATE_IN_STOPPED MDD layer gsi[apidir].pwh != NULL PDD_WaveProc MDD layer WIDM_RESET in WAV_IOControl() MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer gsi[apidir].pwh != NULL MDD layer RemoveCompleteBlocks LOOP1 MDD layer Block Complete... Sending callback MDD layer WIDM_CLOSE in WAV_IOControl() PDD_WaveProc +PDD_WaveInStop +Private_AudioGetBuffer +Private_AudioGetBuffer end +Private_AudioGetBuffer +Private_AudioGetBuffer end +Private_AudioGetBuffer +Private_AudioGetBuffer end +Private_AudioGetBuffer +Private_AudioGetBuffer end -PDD_WaveInStop PDD_WaveProc close ok PDD_WaveProc PDD_WaveProc PDD_WaveProc close ok

    2010年8月4日 14:09
  • 我想问下现在驱动设置的ssc的接受长度为16bit为一次传输长度,那么如果

     dma_page[0] = (BYTE *) HalAllocateCommonBuffer(&Adapter, (AUDIO_BUFFER_SIZE * (NUM_DMA_AUDIO_BUFFERS+NUM_DMA_AUDIO_BUFFERS1)), &PA, FALSE);

     

    其中NUM_DMA_AUDIO_BUFFERS=NUM_DMA_AUDIO_BUFFERS1=4

    AUDIO_BUFFER_SIZE =4096

    开辟8个缓冲区,前四个放音,后4个录音。那么在给ssc的g_pSSC0->SSC_RCR赋初值时是给 = pBuffer->dwSize(4096)还是 pBuffer->dwSize/2  (2048)呢?

    现在出现这种情况,赋值4096,在能连续录音时不断进中断,不知怎么v_fMoreData由原来为FALSE变为TRUE了。

    如果赋值2048,上传2次录音消息就不再进中断了直到录音结束。但是看打印消息这种情况ssc溢出很多,而为4096时基本没有溢出。但是好像内存溢出将v_fMoreData由原来为FALSE变为TRUE了,有什么比较好的方法测试一下这个v_fMoreData在何时变化的呢?

     

    还有刚开始以为接收缓冲区太小,我就把放音创建了4个4096的缓冲区,录音创建了4个8192的缓冲区,但是录音刚开始系统就崩溃了,莫非缓冲区开的太多太大了?

    2010年8月5日 2:48
  • 现在设置的是ssc的g_pSSC0->SSC_RCR赋初值时是给 pBuffer->dwSize/2 。

    现在在中断中查询放音对应的pdc是否使能,放音标志V_fMoreData是否为True以及中断是否有效.现在发现中断循环时pdc发送原来不使能会变为使能,V_fMoreData会由原来FALSE变为True不知为什么?莫非内存溢出并且把发送对应的寄存器也使能了?

    但是如果放音,他不会在中断中进入录音的程序。那么还是录音什么地方把寄存器搞乱了?

    2010年8月6日 6:45
  • pBuffer->dwSize/2应该没错。

    至于V_fMoreData的溢出问题,我没有碰到过,不过你可以做一个试验,把V_fMoreData地declare放在gIntrAudio之前,看看会不会再出现这种情况,或者出现别的情况。

    BTW,如果真的溢出的话,那什么都有可能发生。比如g_dwXmitComplete可能被设成一个奇怪的值,那就会影响private_AudioComplete里的copy 操作。

    2010年8月6日 7:43
    版主
  • 好的我测试一下,现在是放音时(录音不开)对放音没影响,放音开(录音不开)对录音有影响,刚开始我以为是分配8个缓冲区溢出,原来放音前4个,录音后4个,现在他俩换过来,还是录音时进中断会处理放音的中断,好像放音的pdc和ssc状态寄存器都不对了,本来不使能的,但是看程序执行使能了。有没有方法检测是不是寄存器溢出了呢?我改这个驱动参考的9263的一个有录放音ac97的程序。

     

    把V_fMoreData地declare放在gIntrAudio之前这样是什么意思呢?

    还有在变量声明时录音的标志V_RecfMoreData声明在了V_fMoreData之后,只放音也不会在中断中进入录音。
    2010年8月6日 7:49
  • 上面的问题解决了,驱动没问题,主要是应用程序中间有调用放音的地方(应用别人写,并且虽然驱动里加了对放音开始相关的打印信息,但不知为什么试过几次都没注意到打出信息来,偶尔一次打出来了),因为录放音都是44.1khz采样,所以可能数据更新太快,导致系统放音和录音同时工作时丢数据或处理不过来了,导致没录音数据上传或没有获得录音数据。

    还有个问题wm8731现在都是44.1khz测试,。现在想改成8k的,但是wince设备能力里没有8k的这种能力,如何修改驱动让wm8731工作在8k呢?对wm8731的配置是8k了,但是好像传到应用程序的数据还是44.1khz的数据。是不是改这样几个地方:

    (1)供给wm8731的mclk时钟还是11.2mhz

    (2)ssc的通信时钟改为8k

    (3)对wm8731的配置是8k

    (4)实际应用程序对应8k就可以。

    相当于虽然wince没定义8k,但是这样让系统以为是以他法定的某种频率采样,而实际以8k工作就达到效果了?

    2010年8月6日 10:39
  • 按照上面的配置实现了8k的录音,8k采样的放音,但是问题来了。8KHZ放音时发现播放文件刚开始的语音丢失了,反而最后的一部分语音被重复播放了,中间播放部分都是正常的,在waveoutstart里把前2次送去放音的缓冲区打印出来,发现与语音文件开始部分的内容吻合,说明填充缓冲区时数据正确,刚开始的数据填充到缓冲区了,那问题出在了哪里呢?换44.1khz时这个问题也应该存在,但是可能听不出来。如果你手头有9260的板子且有放音部分,你可以改成8khz测试一下。我仔细看了下驱动也没有地方有问题。
    2010年8月7日 9:36
  • 原因找到了,原来的驱动有点小问题

    在waveoutstart 中原来的驱动为
    FreeOutBufferFifo   2
    BufferToPlayFifo   0
    BufferBeingPlayedFifo  2

    应该修改为

    FreeOutBufferFifo  0

    BufferToPlayFifo   2

    BufferBeingPlayedFifo  2

    就好了,即初始状态应该空余的为0,而准备好数据和正播放数据都填充好。驱动基本没问题了。

    谢谢gyren对我长时间的帮助和分析,希望以后多交流。谢谢。

    2010年8月9日 4:28
  • 说实话,我不太清楚为什么初始化的时候要

    FreeOutBufferFifo  0

    BufferToPlayFifo   2

    BufferBeingPlayedFifo  2

    一般来说初始化之后,应该是

    FreeOutBufferFifo  4

    BufferToPlayFifo   0

    BufferBeingPlayedFifo  0

    然后,当waveoutstart被叫的时候,就会从FreeOutBufferFifo中拿出buffer来,填入数据,存入BufferBeingPlayedFifo并开始play。这期间如果waveoutcontinue被叫,就会继续从FreeOutBufferFifo 里拿出buffer,填入数据存入BufferToPlayFifo。

    如果一个buffer放完,BufferToPlayFifo中的buffer就会进入BufferBeingPlayedFifo,BufferBeingPlayedFifo中的buffer又会重新回到FreeOutBufferFifo。

    如此往复。

    不过anyway,你的问题解决就好。

    2010年8月10日 13:48
    版主
  • 谢谢,我说的可能不明白。

    (1)一般来说初始化之后,应该是

    FreeOutBufferFifo  4

    BufferToPlayFifo   0

    BufferBeingPlayedFifo  0(这是对的)

    (2)然后,当waveoutstart被叫的时候,就会从FreeOutBufferFifo中的buffer都拿出,填入数据,存入BufferBeingPlayedFifo并开始play。

    然后

    FreeOutBufferFifo  0个buffer

    BufferToPlayFifo   2个填充好准备播放数据

    BufferBeingPlayedFifo  2个填充好正要播放数据。

    而不是原来驱动的

    FreeOutBufferFifo   2
    BufferToPlayFifo   0
    BufferBeingPlayedFifo  2

    ,关于这个你可以仔细分析当waveoutstart第1次播放完第1个缓冲区后进入中段的条件判断以及后续的waveoutcontinue,大约分析3-4个循环你就看出来了,其中第1个buffer后有个buffer被丢弃了,而播放了其他buffer。

    2010年8月10日 13:57
  • 呵呵,我想这个depend on timing,如果最初的BufferBeingPlayedFifo 播放完的时候,BufferToPlayFifo为空,就可能造成数据丢失或者数据不被处理。因为之后waveoutcontinue填进来的数据在BufferToPlayFifo中,可能就由于没有新的中断而不被play。

    2010年8月10日 15:08
    版主