📄 hwctxt.h
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#pragma once
//
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Module Name: HWCTXT.H
Abstract: Platform dependent code for the mixing audio driver.
Environment: Samsung SC2410 CPU and Windows 3.0 (or later)
-*/
#include <s3c2410x.h>
#define OUTCHANNELS (2)
#define BITSPERSAMPLE (16)
#define SAMPLERATE (44100)
// Inverse sample rate, in .32 fixed format, with 1 added at bottom to ensure round up.
#define INVSAMPLERATE ((UINT32)(((1i64<<32)/SAMPLERATE)+1))
typedef INT16 HWSAMPLE;
typedef HWSAMPLE *PHWSAMPLE;
// Set USE_MIX_SATURATE to 1 if you want the mixing code to guard against saturation
// This costs a couple of instructions in the inner loop
#define USE_MIX_SATURATE (1)
// The code will use the follwing values as saturation points
#define AUDIO_SAMPLE_MAX (32767)
#define AUDIO_SAMPLE_MIN (-32768)
#define AUDIO_DMA_PAGE_SIZE 2048 // Size in bytes
// The following define the maximum attenuations for the SW volume controls in devctxt.cpp
// e.g. 100 => range is from 0dB to -100dB
#define STREAM_ATTEN_MAX 100
#define DEVICE_ATTEN_MAX 35
#define CLASS_ATTEN_MAX 35
//----- Used for scheduling DMA transfers -----
#define OUT_BUFFER_A 0
#define OUT_BUFFER_B 1
#define IN_BUFFER_A 0
#define IN_BUFFER_B 1
class HardwareContext
{
public:
static BOOL CreateHWContext(DWORD Index);
HardwareContext();
~HardwareContext();
void Lock() {EnterCriticalSection(&m_Lock);}
void Unlock() {LeaveCriticalSection(&m_Lock);}
DWORD GetNumInputDevices() {return 1;}
DWORD GetNumOutputDevices() {return 1;}
DWORD GetNumMixerDevices() {return 1;}
DeviceContext *GetInputDeviceContext(UINT DeviceId)
{
return &m_InputDeviceContext;
}
DeviceContext *GetOutputDeviceContext(UINT DeviceId)
{
return &m_OutputDeviceContext;
}
BOOL Init(DWORD Index);
BOOL Deinit();
void PowerUp();
void PowerDown();
BOOL StartInputDMA();
BOOL StartOutputDMA();
void StopInputDMA();
void StopOutputDMA();
void InterruptThread();
DWORD GetOutputGain (void);
MMRESULT SetOutputGain (DWORD dwVolume);
DWORD GetInputGain (void);
MMRESULT SetInputGain (DWORD dwVolume);
BOOL GetOutputMute (void);
MMRESULT SetOutputMute (BOOL fMute);
BOOL GetInputMute (void);
MMRESULT SetInputMute (BOOL fMute);
BOOL PmControlMessage (
DWORD dwCode,
PBYTE pBufIn,
DWORD dwLenIn,
PBYTE pBufOut,
DWORD dwLenOut,
PDWORD pdwActualOut);
protected:
DWORD m_dwOutputGain;
DWORD m_dwInputGain;
BOOL m_fInputMute;
BOOL m_fOutputMute;
DWORD m_MicrophoneRouting;
DWORD m_SpeakerRouting;
DWORD m_InternalRouting;
DWORD m_MasterOutputGain;
BOOL InitInterruptThread();
BOOL InitInputDMA();
BOOL InitOutputDMA();
BOOL Codec_channel();
BOOL InitCodec();
BOOL MapRegisters();
BOOL UnmapRegisters();
BOOL MapDMABuffers();
BOOL UnmapDMABuffers();
ULONG TransferInputBuffer(ULONG NumBuf);
ULONG TransferOutputBuffer(ULONG NumBuf);
DWORD GetInterruptThreadPriority();
DWORD m_DriverIndex;
CRITICAL_SECTION m_Lock;
BOOL m_Initialized;
BOOL m_InPowerHandler;
DWORD m_dwSysintrOutput;
DWORD m_dwSysintrInput;
InputDeviceContext m_InputDeviceContext;
OutputDeviceContext m_OutputDeviceContext;
PBYTE m_Input_pbDMA_PAGES[2];
PBYTE m_Output_pbDMA_PAGES[2];
BOOL m_InputDMARunning;
BOOL m_OutputDMARunning;
ULONG m_OutBytes[2]; // Track how many data bytes in each output buffer
HANDLE m_hAudioInterrupt; // Handle to Audio Interrupt event.
HANDLE m_hAudioInterruptThread; // Handle to thread which waits on an audio interrupt event.
//----------------------- Platform specific members ----------------------------------
DWORD m_OutputDMABuffer; // Output DMA channel's current buffer
DWORD m_InputDMABuffer; // Input DMA channel's current buffer
BOOL AudioMute(DWORD channel, BOOL bMute);
//------------------------------------------------------------------------------------
CEDEVICE_POWER_STATE m_DxState;
};
void CallInterruptThread(HardwareContext *pHWContext);
//------------------------------------------ Externs ----------------------------------------------
extern HardwareContext *g_pHWContext;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -