hwctxt.cpp
字号:
( TEXT( "StartHiFiOutputDMA - preparing output paths failed\r\n") ) );
goto exit;
}
#if WM_OUTPUT_MUTE_DELAY
//
// The outputs are now unmuted.
//
m_pWMAudioDeviceData->HiFiOutputMuted = FALSE;
#endif
}
#if WM_OUTPUT_MUTE_DELAY
//
// Check to see if the output mute timer has already started.
// If it has reset it.
//
if ( m_pWMAudioDeviceData->OutputMuteTimerStarted )
{
SetEvent( m_hOutputMuteTimeoutEvent );
}
#endif
// Prime the output buffer and turn on DMA if anything got transferred
OutputTransferred = TransferHiFiOutputBuffers();
// If we did transfer any data to the DMA buffers, go ahead and enable DMA
if ( OutputTransferred )
{
DEBUGMSG( ZONE_DMA, (TEXT("Started HiFi output DMA\r\n")));
}
else
{
retval = MMSYSERR_ERROR;
}
}
exit:
if ( MMSYSERR_NOERROR != retval )
{
m_pWMAudioDeviceData->HiFiOutputDMARunning = FALSE;
}
//
// Unlock access to the global data.
//
UnlockGlobalData( m_hGlobalDataDeviceMutex );
return;
}
//-----------------------------------------------------------------------------
// Member function: StopHiFiOutputDMA
//
// Stops the HiFi output DMA. Note any data still in the buffers will be lost.
//
// Parameters:
// pWMAudioData pointer to the global audio data
//
// Returns: void
//-----------------------------------------------------------------------------
void HardwareContext::StopHiFiOutputDMA( volatile WM_SHARED_AUDIO_DATA *pWMAudioData )
{
DWORD retval = MMSYSERR_NOERROR;
WMSTATUS status = WMS_SUCCESS;
WM_POWERFLAG powerSections = WM_POWER_NONE;
//
// Lock our global data access
//
retval = LockGlobalData( m_hGlobalDataDeviceMutex );
if ( MMSYSERR_ERROR == retval )
{
goto exit;
}
if ( pWMAudioData->HiFiOutputDMARunning )
{
WMAudioStop( m_hAudioDevice, m_hHiFiOutputStream );
pWMAudioData->HiFiOutputDMARunning = FALSE;
#if !WM_OUTPUT_MUTE_DELAY
//
// Disable the output paths.
//
retval = private_PrepareOutputPaths( WM_STREAM_HIFI_OUT, pWMAudioData, FALSE );
if ( MMSYSERR_NOERROR != retval )
{
DEBUGMSG( ZONE_ERROR,
( TEXT( "StopHiFiOutputDMA - disabling output paths failed\r\n") ) );
goto exit;
}
#endif
DEBUGMSG( ZONE_DMA, (TEXT("Stopped HiFi output DMA\r\n")));
}
exit:
#if WM_OUTPUT_MUTE_DELAY
//
// Check to see if the output mute timer has already
// started. If it hasn't signal timer to disable the
// output paths after a defined amount of time.
// If the timer has already started, reset the timer
// and signal the output mute thread to run again.
//
if ( !m_pWMAudioDeviceData->OutputMuteTimerStarted )
{
SetEvent( m_hOutputMuteIntEvent );
}
else
{
Lock();
SetEvent( m_hOutputMuteTimeoutEvent );
SetEvent( m_hOutputMuteIntEvent );
Unlock();
}
#endif
//
// Unlock access to the global data.
//
UnlockGlobalData( m_hGlobalDataDeviceMutex );
return;
}
//-----------------------------------------------------------------------------
// Member function: StartHiFiInputDMA
//
// Makes sure DMA is running for the HiFi input stream.
//
// Parameters:
// none
//
// Returns: void
//-----------------------------------------------------------------------------
void HardwareContext::StartHiFiInputDMA()
{
DWORD retval = MMSYSERR_NOERROR;
WMSTATUS status = WMS_SUCCESS;
//
// Check that we have a valid pointer to the global audio data.
//
if ( !m_pWMAudioDeviceData )
{
ASSERT( 0 );
retval = MMSYSERR_ERROR;
goto exit;
}
//
// Lock our global data access
//
retval = LockGlobalData( m_hGlobalDataDeviceMutex );
if ( MMSYSERR_ERROR == retval )
{
goto exit;
}
if ( !m_pWMAudioDeviceData->HiFiInputDMARunning )
{
// For now, pretend input dma is running in case we accidentally get reentered
m_pWMAudioDeviceData->HiFiInputDMARunning = TRUE;
m_HiFiInBytes[0] = m_HiFiInBytes[1]=0;
m_nextHiFiInputBuf = 0;
m_HiFiInputStarted = FALSE;
//
// Enable the input paths.
//
retval = private_PrepareInputPaths( WM_STREAM_HIFI_IN, m_pWMAudioDeviceData, TRUE );
if ( MMSYSERR_NOERROR != retval )
{
DEBUGMSG( ZONE_ERROR,
( TEXT( "StartHiFiInputDMA - preparing input paths failed\r\n") ) );
goto exit;
}
WMAudioStartRecording( m_hAudioDevice, m_hHiFiInputStream );
DEBUGMSG( ZONE_DMA, (TEXT("Started HiFi input DMA\r\n")));
}
exit:
if ( MMSYSERR_NOERROR != retval )
{
m_pWMAudioDeviceData->HiFiInputDMARunning = FALSE;
}
//
// Unlock access to the global data.
//
UnlockGlobalData( m_hGlobalDataDeviceMutex );
return;
}
//-----------------------------------------------------------------------------
// Member function: StopHiFiInputDMA
//
// Stops the DMA for the HiFi input stream.
//
// Parameters:
// pWMAudioData pointer to the global audio data
//
// Returns: void
//-----------------------------------------------------------------------------
void HardwareContext::StopHiFiInputDMA( volatile WM_SHARED_AUDIO_DATA *pWMAudioData )
{
DWORD retval = MMSYSERR_NOERROR;
WMSTATUS status = WMS_SUCCESS;
WM_POWERFLAG powerSections = WM_POWER_NONE;
//
// Check that we have a valid pointer to the global audio data.
//
if ( !pWMAudioData )
{
ASSERT( 0 );
retval = MMSYSERR_ERROR;
goto exit;
}
// Lock our global data access
//
retval = LockGlobalData( m_hGlobalDataDeviceMutex );
if ( MMSYSERR_ERROR == retval )
{
goto exit;
}
if ( pWMAudioData->HiFiInputDMARunning )
{
WMAudioStop( m_hAudioDevice, m_hHiFiInputStream );
pWMAudioData->HiFiInputDMARunning = FALSE;
//
// Disable the input paths.
//
retval = private_PrepareInputPaths( WM_STREAM_HIFI_IN, pWMAudioData, FALSE );
if ( MMSYSERR_NOERROR != retval )
{
DEBUGMSG( ZONE_ERROR,
( TEXT( "StopHiFiInputDMA - preparing input paths failed\r\n") ) );
goto exit;
}
DEBUGMSG( ZONE_DMA, (TEXT("Stopped HiFi input DMA\r\n")));
}
exit:
//
// Unlock access to the global data.
//
UnlockGlobalData( m_hGlobalDataDeviceMutex );
return;
}
#if WM_VOICE
//-----------------------------------------------------------------------------
// Member function: StartVoiceOutputDMA
//
// Makes sure DMA is running for the Voice output stream, and transmits the first
// buffer-fulls of data.
//
// Parameters:
// none
//
// Returns: void
//-----------------------------------------------------------------------------
void HardwareContext::StartVoiceOutputDMA()
{
DWORD retval = MMSYSERR_NOERROR;
WMSTATUS status = WMS_SUCCESS;
//
// Check that we have a valid pointer to the global audio data.
//
if ( !m_pWMAudioDeviceData )
{
ASSERT( 0 );
retval = MMSYSERR_ERROR;
goto exit;
}
//
// Lock our global data access
//
retval = LockGlobalData( m_hGlobalDataDeviceMutex );
if ( MMSYSERR_ERROR == retval )
{
goto exit;
}
if ( !m_pWMAudioDeviceData->VoiceOutputDMARunning )
{
ULONG OutputTransferred = 0;
// For now, pretend output dma is running in case we accidentally get reentered
m_pWMAudioDeviceData->VoiceOutputDMARunning = TRUE;
m_VoiceOutBytes[0] = m_VoiceOutBytes[1]=0;
m_nextVoiceOutputBuf = 0;
m_VoiceOutputStarted = FALSE;
#if WM_OUTPUT_MUTE_DELAY
if ( m_pWMAudioDeviceData->VoiceOutputMuted )
#endif
{
//
// Enable the output paths.
//
retval = private_PrepareOutputPaths( WM_STREAM_VOICE_OUT, m_pWMAudioDeviceData, TRUE );
if ( MMSYSERR_NOERROR != retval )
{
DEBUGMSG( ZONE_ERROR,
( TEXT( "StartVoiceOutputDMA - preparing output paths failed\r\n") ) );
goto exit;
}
#if WM_OUTPUT_MUTE_DELAY
/*
* The outputs are now unmuted.
*/
m_pWMAudioDeviceData->VoiceOutputMuted = FALSE;
#endif
}
#if WM_OUTPUT_MUTE_DELAY
/*
* Check to see if the output mute timer has already started.
* If it has reset it.
*/
if ( m_pWMAudioDeviceData->OutputMuteTimerStarted )
{
SetEvent( m_hOutputMuteTimeoutEvent );
}
#endif
// Prime the output buffer and turn on DMA if anything got transferred
OutputTransferred = TransferVoiceOutputBuffers();
// If we did transfer any data to the DMA buffers, go ahead and enable DMA
if ( OutputTransferred )
{
DEBUGMSG( ZONE_DMA, (TEXT("Started Voice output DMA\r\n")));
}
else
{
retval = MMSYSERR_ERROR;
}
}
exit:
if ( MMSYSERR_NOERROR != retval )
{
m_pWMAudioDeviceData->VoiceOutputDMARunning = FALSE;
}
//
// Unlock access to the global data.
//
UnlockGlobalData( m_hGlobalDataDeviceMutex );
return;
}
//-----------------------------------------------------------------------------
// Member function: StopVoiceOutputDMA
//
// Stops the Voice output DMA. Note any data still in the buffers will be lost.
//
// Parameters:
// pWMAudioData pointer to the global audio data
//
// Returns: void
//-----------------------------------------------------------------------------
void HardwareContext::StopVoiceOutputDMA( volatile WM_SHARED_AUDIO_DATA *pWMAudioData )
{
DWORD retval = MMSYSERR_NOERROR;
WMSTATUS status = WMS_SUCCESS;
WM_POWERFLAG powerSections = WM_POWER_NONE;
//
// Check that we have a valid pointer to the global audio data.
//
if ( !pWMAudioData )
{
ASSERT( 0 );
retval = MMSYSERR_ERROR;
goto exit;
}
//
// Lock our global data access
//
retval = LockGlobalData( m_hGlobalDataDeviceMutex );
if ( MMSYSERR_ERROR == retval )
{
goto exit;
}
if ( pWMAudioData->VoiceOutputDMARunning )
{
WMAudioStop( m_hAudioDevice, m_hVoiceOutputStream );
pWMAudioData->VoiceOutputDMARunning = FALSE;
#if !WM_OUTPUT_MUTE_DELAY
//
// Disable the output paths.
//
retval = private_PrepareOutputPaths( WM_STREAM_VOICE_OUT, pWMAudioData, FALSE );
if ( MMSYSERR_NOERROR != retval )
{
DEBUGMSG( ZONE_ERROR,
( TEXT( "StopVoiceOutputDMA - disabling output paths failed\r\n") ) );
goto exit;
}
#endif
DEBUGMSG( ZONE_DMA, (TEXT("Stopped Voice output DMA\r\n")));
}
exit:
#if WM_OUTPUT_MUTE_DELAY
//
// Check to see if the output mute timer has already
// started. If it hasn't signal timer to disable the
// output paths after a defined amount of time.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -