52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
#ifndef SOUNDMANAGER_H
|
|
#define SOUNDMANAGER_H
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <windows.h>
|
|
#include <dshow.h>
|
|
#include <mmdeviceapi.h>
|
|
#include <audioclient.h>
|
|
#include <audiopolicy.h>
|
|
|
|
class SoundManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SoundManager(QObject *parent = 0);
|
|
~SoundManager();
|
|
|
|
enum SoundChannel {
|
|
Channel1 = 0,
|
|
Channel2 = 1
|
|
};
|
|
|
|
bool loadSound(SoundChannel channel, const QString &filePath);
|
|
bool playSound(SoundChannel channel);
|
|
bool pauseSound(SoundChannel channel);
|
|
bool stopSound(SoundChannel channel);
|
|
void setVolume(SoundChannel channel, int volume); // 0-100
|
|
bool isPlaying(SoundChannel channel);
|
|
|
|
private:
|
|
struct SoundDevice {
|
|
IGraphBuilder *graphBuilder;
|
|
IMediaControl *mediaControl;
|
|
IMediaPosition *mediaPosition;
|
|
IBasicAudio *basicAudio;
|
|
IBaseFilter *audioRenderer;
|
|
IAudioSessionManager2 *sessionManager;
|
|
IAudioSessionControl *sessionControl;
|
|
bool isLoaded;
|
|
};
|
|
|
|
SoundDevice m_channels[2];
|
|
|
|
bool initializeChannel(SoundChannel channel);
|
|
void cleanupChannel(SoundChannel channel);
|
|
IBaseFilter* createAudioRenderer();
|
|
};
|
|
|
|
#endif // SOUNDMANAGER_H
|