我正在开发一个包装 Win32 的mixerXXX
API 函数的小型 OOP/RAII 库。
我正在编写一个封装MIXERLINE
结构的类,所以我的MixerLine
类有这个作为它的标题:
#pragma once
#define UNICODE
#include <stdio.h>
#include <string>
#include <windows.h>
#include "MixerDevice.h"
//////////////////////////////
class MixerLine {
private:
MIXERLINE _mixerLine;
public:
MixerLine(MixerDevice& parentMixer, DWORD destinationIndex);
~MixerLine();
};
但是我得到一个语法错误(在 VC9 中):
错误 2 错误 C2061:语法错误:标识符 'MixerDevice' d:\tfs\misc\winwavein\mixerline.h
为什么消息没有更多帮助?我不知道它有什么问题。
FWIW,文件中根本没有错误MixerDevice.h
。
编辑:这是原始的完整文件:
混合线.h
#pragma once
#define UNICODE
#include <stdio.h>
#include <string>
#include <windows.h>
#include "MixerDevice.h"
//////////////////////////////
class MixerLine {
private:
MIXERLINE _mixerLine;
public:
MixerLine(MixerDevice& parentMixer, DWORD destinationIndex);
~MixerLine();
// Properties
DWORD getDestinationLineIndex() {
return _mixerLine.dwDestination;
}
DWORD getSourceIndex() {
return _mixerLine.dwSource;
}
DWORD getLineId() {
return _mixerLine.dwLineID;
}
DWORD getStatus() {
return _mixerLine.fdwLine;
}
std:wstring getStatusString() {
switch( _mixerLine.fdwLine ) {
case MIXERLINE_LINEF_ACTIVE:
return L"MIXERLINE_LINEF_ACTIVE";
case MIXERLINE_LINEF_DISCONNECTED:
return L"MIXERLINE_LINEF_DISCONNECTED";
case MIXERLINE_LINEF_SOURCE:
return L"MIXERLINE_LINEF_SOURCE";
default:
return L"";
}
}
DWORD getUserData() {
return _mixerLine.dwUser;
}
DWORD getComponentType() {
return _mixerLine.dwComponentType;
}
};
MixerDevice.h
#pragma once
#define UNICODE
#include <memory>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <windows.h>
////////////////////////
#include "MixerLine.h"
class MixerDevice {
private:
DWORD _deviceId;
HMIXER _mixerHandle;
MIXERCAPS _mixerCaps;
public:
MixerDevice(DWORD deviceId);
~MixerDevice();
void enumerateLines();
// Properties
DWORD getDeviceId() {
return _deviceId;
}
HMIXEROBJ getHandle() {
return (HMIXEROBJ)_mixerHandle;
}
// Caps
WORD getManufacturerId() {
return _mixerCaps.wMid;
}
WORD getProductId() {
return _mixerCaps.wPid;
}
MMVERSION getDriverVersion() {
return _mixerCaps.vDriverVersion;
}
WCHAR* getProductName() {
return _mixerCaps.szPname;
}
DWORD getSupportBits() {
return _mixerCaps.fdwSupport;
}
DWORD getDestinationCount() {
return _mixerCaps.cDestinations;
}
};
MixerDevice.cpp(我要编译的文件):
#include "MixerDevice.h"
using namespace std;
MixerDevice::MixerDevice(DWORD deviceId) {
_deviceId = deviceId;
MMRESULT result;
result = mixerOpen( &_mixerHandle, deviceId, NULL, NULL, MIXER_OBJECTF_MIXER );
if( result != MMSYSERR_NOERROR ) throw new exception("Call to mixerOpen failed.", result);
result = mixerGetDevCaps( (UINT)_mixerHandle, &_mixerCaps, sizeof(MIXERCAPS) );
if( result != MMSYSERR_NOERROR ) throw new exception("Call to mixerGetDevCaps failed.", result);
}
MixerDevice::~MixerDevice() {
MMRESULT result = mixerClose( _mixerHandle );
if( result != MMSYSERR_NOERROR ) exit(666);
}
// Methods
void MixerDevice::enumerateLines() {
}