|
_SCALE_SOFTWARE 0xA000
//硬件音量,有些声卡无法使用,不推荐
#define VOLUME_SCALE_HARDWARE 0xEE00
本系统各API(功能)之间依赖:
以下四个函数无任何依赖,可直接调用
void GetDriverVersionString(char *szBuffer, int bufferLen);
int GetDriverVersionWord();
void ShowAboutDlg(HWND MyParents);
int LoadAudBus_Service(HWND MyParents);
以下函数需要先加载音频服务(LoadAudBus_Service)后才可调用
int GetOutDeviceCount();
void GetOutDeviceName(int nIndex, LPWSTR szBuffer, int bufferLen);
int SelectOutDevice(int nIndex);
int SelectDefaultOutDevice();
void GetSelectedOutDevice(LPWSTR szBuffer, int bufferLen);
int SetInputAudioFormat(WAVEFORMATEX *inFormat);
int CreateAudioSessionInterface(int bufferBlockCount);
void UnloadAudBus_Service();
以下函数需要创建会话(CreateAudioSessionInterface)后才可调用
int GetIRPMinimumTime();
int GetIRPDefaultTime();
int GetCurrentLatency();
int GetSessionSupportedFormat(WAVEFORMATEX *outFormat);
long SessionControl(AUDIO_SESSION_CONTROL_WORD ControlWord, void *Parameter);
int WritePCMToDriver(unsigned char *pcmBuffer, int bufferLen);
void CloseAudioSessionInterface();
注意:
1、在SESSION_SessionFlushBuffer之后需要重新开始会话,即SESSION_StartSession
2、每次WritePCMToDriver之后需要Sleep一个IRP最短时间,即Sleep(GetIRPMinimumTime())
3、每次WritePCMToDriver之后需要检查返回值,是否为RETURN_FUNCTION_OK,若不,则循环WritePCMToDriver句,直至返回RETURN_FUNCTION_OK!
4、程序退出时一定要按照顺序,先停止会话,然后关闭会话,最后释放音频服务,若不则会导致声卡被占用!
5、其他说明请看ViPER_AudioOut.h
6、程序包里包含完整示例!
7、在运行部压缩包内示例的时候CPU占用过高是正常的,因为在示例程序中,写入缓冲WritePCMToDriver如果失败则直接进行再次尝试,中间没有Sleep,所以CPU占用会很高!在用本输出系统写程序的时候需要在这些地方加个Sleep(GetIRPMinimumTime()),暂停一个最短IRP时间就行了!
vipercn.com 2009
|