Ajout de la gestion de roulette de volume du clavier
This commit is contained in:
@@ -11,6 +11,9 @@ CAvReceiver::CAvReceiver(CAvReceiverGui *ReceiverGui)
|
||||
mReceiverPollTimer->setSingleShot(false);
|
||||
mReceiverPollTimer->setInterval(1000);
|
||||
connect(mReceiverPollTimer,SIGNAL(timeout()),this,SLOT(PollTimerExpired()));
|
||||
|
||||
connect(&mVolumeController,&CVolumeController::ExternalVolumeChanged,this,&CAvReceiver::ExternalVolumeChanged);
|
||||
mTempReceiverVolume = 0;
|
||||
}
|
||||
|
||||
CAvReceiver::~CAvReceiver()
|
||||
@@ -23,6 +26,7 @@ int CAvReceiver::Start()
|
||||
{
|
||||
mNetworkInterface->ConnectToMasterCtrl();
|
||||
mReceiverPollTimer->start();
|
||||
mVolumeController.Init(this);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -77,6 +81,7 @@ int CAvReceiver::ReceiverGeneralStatusReceived(QByteArray StatusData)
|
||||
Strm >> mReceiverStatus;
|
||||
Strm >> mZone2Status;
|
||||
mReceiverGui->UpdateReceiverStatus(mReceiverStatus, mZone2Status);
|
||||
mTempReceiverVolume = mReceiverStatus.mMainVolume;
|
||||
return RET_OK;
|
||||
}
|
||||
int CAvReceiver::SelectScenePressed(char Zone, char Scene)
|
||||
@@ -89,6 +94,7 @@ int CAvReceiver::SelectScenePressed(char Zone, char Scene)
|
||||
|
||||
int CAvReceiver::MainZoneVolumeChanged(float Value)
|
||||
{
|
||||
// qDebug("MainZoneVolumeChanged : %f",Value);
|
||||
QByteArray VolumeData;
|
||||
QDataStream Strm(&VolumeData,QIODevice::WriteOnly);
|
||||
Strm << Value;
|
||||
@@ -102,3 +108,47 @@ int CAvReceiver::Zone2VolumeChanged(float Value)
|
||||
Strm << Value;
|
||||
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_ZONE2_VOLUME_REQUEST,VolumeData);
|
||||
}
|
||||
|
||||
int CAvReceiver::Zone2InputSrcChanged(QString InputSrc)
|
||||
{
|
||||
QByteArray SourceData;
|
||||
QDataStream Strm(&SourceData,QIODevice::WriteOnly);
|
||||
Strm << InputSrc;
|
||||
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_ZONE2_INPUT_REQUEST,SourceData);
|
||||
}
|
||||
|
||||
//We need to implement this in a slot because the Windows API runs in a differen Thread and it crashes the MasterCtrl socket.
|
||||
void CAvReceiver::ExternalVolumeChanged(float Value)
|
||||
{
|
||||
float ValueInPercent;
|
||||
float Ret;
|
||||
if(Value > 0)
|
||||
{
|
||||
mTempReceiverVolume += Value;
|
||||
MainZoneVolumeChanged(mTempReceiverVolume);
|
||||
Ret = 0.04;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mTempReceiverVolume == -80.5)
|
||||
{
|
||||
Ret = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mTempReceiverVolume += Value;
|
||||
if(mTempReceiverVolume == -80.5)
|
||||
{
|
||||
MainZoneVolumeChanged(mTempReceiverVolume);
|
||||
Ret = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainZoneVolumeChanged(mTempReceiverVolume);
|
||||
Ret = 0.04;
|
||||
}
|
||||
}
|
||||
}
|
||||
mVolumeController.SetMasterVolume(Ret);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QTimer>
|
||||
#include "AvReceiverData.h"
|
||||
#include "VolumeController.h"
|
||||
|
||||
class CAvReceiverNetworkCtrlInterface;
|
||||
|
||||
@@ -23,18 +24,23 @@ public:
|
||||
int SelectScenePressed(char Zone, char Scene);
|
||||
int MainZoneVolumeChanged(float Value);
|
||||
int Zone2VolumeChanged(float Value);
|
||||
int Zone2InputSrcChanged(QString InputSrc);
|
||||
|
||||
|
||||
|
||||
CAvReceiverNetworkCtrlInterface *mNetworkInterface;
|
||||
CAvReceiverGui *mReceiverGui;
|
||||
QTimer *mReceiverPollTimer;
|
||||
CVolumeController mVolumeController;
|
||||
|
||||
private:
|
||||
CAvReceiverMainStatus mReceiverStatus;
|
||||
CAvReceiverMainStatus mZone2Status;
|
||||
float mTempReceiverVolume;
|
||||
|
||||
public slots:
|
||||
void PollTimerExpired();
|
||||
|
||||
void ExternalVolumeChanged(float Value);
|
||||
};
|
||||
|
||||
#endif // AVRECEIVER_H
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "AvReceiverGui.h"
|
||||
#include "ui_AvReceiverGui.h"
|
||||
#include "TrayVolumeCtrl.h"
|
||||
|
||||
#include "AvReceiver.h"
|
||||
|
||||
@@ -11,8 +12,15 @@ CAvReceiverGui::CAvReceiverGui(QWidget *parent) :
|
||||
mVolumeBarMovementTimer = new QTimer();
|
||||
mVolumeBarMovementTimer->setInterval(500);
|
||||
mVolumeBarMovementTimer->setSingleShot(true);
|
||||
connect(mVolumeBarMovementTimer,SIGNAL(timeout()),this,SLOT(VolumeBarMovementTimerExpired()));
|
||||
mLockZone2VolumeWithZone1 = false;
|
||||
|
||||
mTrayVolumeCtrlGuiHandle = 0;
|
||||
|
||||
|
||||
ui->mZone2InputComboBx->addItems(QStringList() << "AUDIO1" << "AUDIO2" << "AUDIO3" << "AUDIO4" << "AUDIO5" << "PHONO" << "TUNER" << "SERVER" << "Main Zone Sync");
|
||||
ui->mZone2InputComboBx->setEditable(false);
|
||||
|
||||
connect(mVolumeBarMovementTimer,SIGNAL(timeout()),this,SLOT(VolumeBarMovementTimerExpired()));
|
||||
connect(ui->mSpkBCheckBox,SIGNAL(clicked(bool)),this,SLOT(SpeakerBRadioClicked(bool)));
|
||||
connect(ui->mSpkACheckBox,SIGNAL(clicked(bool)),this,SLOT(SpeakerARadioClicked(bool)));
|
||||
connect(ui->MainZoneScene1Btn,SIGNAL(clicked(bool)),this,SLOT(MainZoneScene1BtnClicked(bool)));
|
||||
@@ -21,6 +29,8 @@ CAvReceiverGui::CAvReceiverGui(QWidget *parent) :
|
||||
connect(ui->MainZoneScene4Btn,SIGNAL(clicked(bool)),this,SLOT(MainZoneScene4BtnClicked(bool)));
|
||||
connect(ui->mMainZoneVolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(MainZoneVolumeSetChanged(int)));
|
||||
connect(ui->mZone2VolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(Zone2VolumeSetChanged(int)));
|
||||
connect(ui->mZone2InputComboBx,&QComboBox::currentTextChanged,this,&CAvReceiverGui::Zone2InputSelectionChanged);
|
||||
connect(ui->mZone2SyncVolumeChkBx,&QCheckBox::clicked,this,&CAvReceiverGui::Zone2LockVolumeChanged);
|
||||
}
|
||||
|
||||
CAvReceiverGui::~CAvReceiverGui()
|
||||
@@ -92,8 +102,12 @@ int CAvReceiverGui::UpdateReceiverStatus(CAvReceiverMainStatus Status, CAvReceiv
|
||||
|
||||
if(/*ui->mMainZoneVolumeSldBar->isSliderDown() == false && */mVolumeBarMovementTimer->isActive() == false)
|
||||
{
|
||||
ui->mMainZoneVolumeSldBar->setValue(ConvertVolumeToBarPosition(Status.mMainVolume));
|
||||
int SliderValue = ConvertVolumeToBarPosition(Status.mMainVolume);
|
||||
disconnect(ui->mMainZoneVolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(MainZoneVolumeSetChanged(int)));
|
||||
ui->mMainZoneVolumeSldBar->setValue(SliderValue);
|
||||
connect(ui->mMainZoneVolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(MainZoneVolumeSetChanged(int)));
|
||||
ui->mMainZoneSliderValueLbl->setText("");
|
||||
mTrayVolumeCtrlGuiHandle->SetMainZoneVolume(SliderValue,Status.mMainVolume);
|
||||
}
|
||||
|
||||
|
||||
@@ -146,11 +160,16 @@ int CAvReceiverGui::UpdateReceiverStatus(CAvReceiverMainStatus Status, CAvReceiv
|
||||
StatusText += "\n";
|
||||
|
||||
ui->mZone2StatusLabel->setText(StatusText);
|
||||
ui->mZone2InputComboBx->setCurrentText(Zone2Status.mInput);
|
||||
|
||||
if(/*ui->mZone2VolumeSldBar->isSliderDown() == false && */mVolumeBarMovementTimer->isActive() == false)
|
||||
{
|
||||
ui->mZone2VolumeSldBar->setValue(ConvertVolumeToBarPosition(Zone2Status.mMainVolume));
|
||||
int SliderValue = ConvertVolumeToBarPosition(Zone2Status.mMainVolume);
|
||||
disconnect(ui->mZone2VolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(Zone2VolumeSetChanged(int)));
|
||||
ui->mZone2VolumeSldBar->setValue(SliderValue);
|
||||
connect(ui->mZone2VolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(Zone2VolumeSetChanged(int)));
|
||||
ui->mZone2SliderValueLbl->setText("");
|
||||
mTrayVolumeCtrlGuiHandle->SetZone2Volume(SliderValue,Zone2Status.mMainVolume);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
@@ -192,26 +211,63 @@ float CAvReceiverGui::ConvertBarPositionToVolume(int position)
|
||||
|
||||
void CAvReceiverGui::MainZoneVolumeSetChanged(int value)
|
||||
{
|
||||
int BarPosition = ui->mMainZoneVolumeSldBar->value();
|
||||
// int BarPosition = ui->mMainZoneVolumeSldBar->value();
|
||||
int BarPosition = value;
|
||||
float Volume = ConvertBarPositionToVolume(BarPosition);
|
||||
|
||||
ui->mMainZoneSliderValueLbl->setText(QString("%1").arg(Volume));
|
||||
mProgramHandle->MainZoneVolumeChanged(Volume);
|
||||
mVolumeBarMovementTimer->start();
|
||||
|
||||
|
||||
if(mLockZone2VolumeWithZone1 == true)
|
||||
{
|
||||
ui->mZone2VolumeSldBar->setValue(BarPosition);
|
||||
mVolumeBarMovementTimer->start();
|
||||
//mProgramHandle->Zone2VolumeChanged(Volume);
|
||||
}
|
||||
}
|
||||
|
||||
void CAvReceiverGui::Zone2VolumeSetChanged(int value)
|
||||
{
|
||||
int BarPosition = ui->mZone2VolumeSldBar->value();
|
||||
// int BarPosition = ui->mZone2VolumeSldBar->value();
|
||||
int BarPosition = value;
|
||||
float Volume = ConvertBarPositionToVolume(BarPosition);
|
||||
|
||||
ui->mZone2SliderValueLbl->setText(QString("%1").arg(Volume));
|
||||
mProgramHandle->Zone2VolumeChanged(Volume);
|
||||
mVolumeBarMovementTimer->start();
|
||||
// mVolumeBarMovementTimer->start();
|
||||
|
||||
}
|
||||
|
||||
void CAvReceiverGui::VolumeBarMovementTimerExpired()
|
||||
{
|
||||
int BarPosition = ui->mMainZoneVolumeSldBar->value();
|
||||
float Volume = ConvertBarPositionToVolume(BarPosition);
|
||||
mProgramHandle->Zone2VolumeChanged(Volume);
|
||||
}
|
||||
|
||||
void CAvReceiverGui::Zone2LockVolumeChanged(bool checked)
|
||||
{
|
||||
mLockZone2VolumeWithZone1 = checked;
|
||||
if(checked)
|
||||
{
|
||||
//Set Zone 2 volume to main zone value
|
||||
int BarPosition = ui->mMainZoneVolumeSldBar->value();
|
||||
float Volume = ConvertBarPositionToVolume(BarPosition);
|
||||
|
||||
mProgramHandle->Zone2VolumeChanged(Volume);
|
||||
|
||||
ui->mZone2VolumeSldBar->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->mZone2VolumeSldBar->setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CAvReceiverGui::Zone2InputSelectionChanged()
|
||||
{
|
||||
QString Src = ui->mZone2InputComboBx->currentText();
|
||||
mProgramHandle->Zone2InputSrcChanged(Src);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ class CAvReceiver;
|
||||
#include "AvReceiverData.h"
|
||||
#include <QTimer>
|
||||
|
||||
class CTrayVolumeCtrl;
|
||||
|
||||
namespace Ui {
|
||||
class CAvReceiverGui;
|
||||
}
|
||||
@@ -24,6 +26,8 @@ public:
|
||||
int ConvertVolumeToBarPosition(float Volume);
|
||||
float ConvertBarPositionToVolume(int position);
|
||||
QTimer *mVolumeBarMovementTimer;
|
||||
bool mLockZone2VolumeWithZone1;
|
||||
CTrayVolumeCtrl *mTrayVolumeCtrlGuiHandle;
|
||||
|
||||
private:
|
||||
Ui::CAvReceiverGui *ui;
|
||||
@@ -38,6 +42,8 @@ public slots:
|
||||
void MainZoneVolumeSetChanged(int);
|
||||
void Zone2VolumeSetChanged(int);
|
||||
void VolumeBarMovementTimerExpired();
|
||||
void Zone2InputSelectionChanged();
|
||||
void Zone2LockVolumeChanged(bool checked);
|
||||
};
|
||||
|
||||
#endif // AVRECEIVERGUI_H
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>796</width>
|
||||
<height>447</height>
|
||||
<width>883</width>
|
||||
<height>453</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -213,6 +213,29 @@
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mZone2InputComboBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>580</x>
|
||||
<y>180</y>
|
||||
<width>121</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="mZone2SyncVolumeChkBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>590</x>
|
||||
<y>120</y>
|
||||
<width>171</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sync volume with Main zone</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
#include "VolumeController.h"
|
||||
#include <windows.h>
|
||||
#include <combaseapi.h>
|
||||
#include <AvReceiver.h>
|
||||
#include <initguid.h>
|
||||
#include <Functiondiscoverykeys_devpkey.h>
|
||||
|
||||
CVolumeController::CVolumeController(QObject *parent) : QObject(parent)
|
||||
{
|
||||
mDeviceEnumerator = NULL;
|
||||
mAudioDevice = NULL;
|
||||
mEndpointVolume = 0;
|
||||
mProgramPtr = 0;
|
||||
mVolumeControllerActive = false;
|
||||
}
|
||||
|
||||
CVolumeController::~CVolumeController()
|
||||
{
|
||||
if(mVolumeControllerActive == true)
|
||||
{
|
||||
if(mEndpointVolume != NULL)
|
||||
{
|
||||
mEndpointVolume->UnregisterControlChangeNotify(this);
|
||||
mEndpointVolume->Release();
|
||||
}
|
||||
if(mAudioDevice != NULL)
|
||||
mAudioDevice->Release();
|
||||
if(mDeviceEnumerator != NULL)
|
||||
mDeviceEnumerator->Release();
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
}
|
||||
|
||||
int CVolumeController::Init(CAvReceiver *ProgramPtr)
|
||||
{
|
||||
mProgramPtr = ProgramPtr;
|
||||
IPropertyStore *pProps = NULL;
|
||||
IMMDeviceCollection *pCollection = NULL;
|
||||
|
||||
CoInitialize(NULL);
|
||||
CoCreateGuid(&mMyGUID);
|
||||
|
||||
const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
|
||||
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
|
||||
HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL,CLSCTX_ALL, IID_IMMDeviceEnumerator,(void**)&mDeviceEnumerator);
|
||||
|
||||
hr = mDeviceEnumerator->EnumAudioEndpoints(eRender,DEVICE_STATE_ACTIVE,&pCollection);
|
||||
unsigned int count;
|
||||
hr = pCollection->GetCount(&count);
|
||||
|
||||
|
||||
// mDeviceEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &mAudioDevice); // Get the default audio output device
|
||||
|
||||
bool InterfaceFound = false;
|
||||
for(unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
hr = pCollection->Item(i,&mAudioDevice);
|
||||
mAudioDevice->OpenPropertyStore(STGM_READ,&pProps);
|
||||
PROPVARIANT DevName;
|
||||
// Initialize container for property value.
|
||||
PropVariantInit(&DevName);
|
||||
hr = pProps->GetValue(PKEY_Device_FriendlyName, &DevName); //Get the friendly name
|
||||
QString FriendlyName = QString("%1").arg(DevName.pwszVal);
|
||||
PropVariantClear(&DevName);
|
||||
qDebug("%s",qPrintable(FriendlyName));
|
||||
if(FriendlyName.contains("SPDIF"))
|
||||
{
|
||||
//We found our interface.
|
||||
InterfaceFound = true;
|
||||
qDebug("Audio interface found... binding callback.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(pProps != NULL)
|
||||
pProps->Release();
|
||||
|
||||
if(InterfaceFound == false)
|
||||
{
|
||||
qDebug("Audio interface not found");
|
||||
if(mAudioDevice != NULL)
|
||||
mAudioDevice->Release();
|
||||
if(mDeviceEnumerator != NULL)
|
||||
mDeviceEnumerator->Release();
|
||||
CoUninitialize();
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
mAudioDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL, (void**)&mEndpointVolume); // Activate the endpoint volume interface
|
||||
|
||||
mEndpointVolume->RegisterControlChangeNotify(this);// Set up the volume change callback
|
||||
|
||||
|
||||
mEndpointVolume->SetMasterVolumeLevelScalar(0.02,&mMyGUID);
|
||||
mEndpointVolume->GetMasterVolumeLevelScalar(&mMasterVolume);
|
||||
|
||||
return RET_OK;
|
||||
|
||||
}
|
||||
|
||||
int CVolumeController::SetMasterVolume(float Volume)
|
||||
{
|
||||
mEndpointVolume->SetMasterVolumeLevelScalar(Volume,&mMyGUID);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CVolumeController:: OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify)
|
||||
{
|
||||
if (pNotify)
|
||||
{
|
||||
if(pNotify->guidEventContext != mMyGUID)
|
||||
{
|
||||
// qDebug("Volume changed. Current %f, Requested: %f",mMasterVolume,pNotify->fMasterVolume);
|
||||
// float NewVolume;
|
||||
if(mMasterVolume > pNotify->fMasterVolume) //Volume decrease
|
||||
{
|
||||
// qDebug("Volume Decrease");
|
||||
emit ExternalVolumeChanged(-EXTERNAL_VOLUME_INCREMENT);
|
||||
}
|
||||
else if(mMasterVolume < pNotify->fMasterVolume) //Volume increase
|
||||
{
|
||||
// qDebug("Volume increase");
|
||||
emit ExternalVolumeChanged(EXTERNAL_VOLUME_INCREMENT);
|
||||
|
||||
}
|
||||
// qDebug("Setting interface volume to %f",NewVolume);
|
||||
// mEndpointVolume->SetMasterVolumeLevelScalar(NewVolume,&mMyGUID);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
mEndpointVolume->GetMasterVolumeLevelScalar(&mMasterVolume);
|
||||
// qDebug("Setting internal master volume: %f",mMasterVolume);
|
||||
}
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#ifndef VOLUMECONTROLLER_H
|
||||
#define VOLUMECONTROLLER_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QObject>
|
||||
#include <endpointvolume.h>
|
||||
#include <Mmdeviceapi.h>
|
||||
|
||||
#define EXTERNAL_VOLUME_INCREMENT 1
|
||||
|
||||
class CAvReceiver;
|
||||
|
||||
|
||||
class CVolumeController : public QObject, public IAudioEndpointVolumeCallback
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CVolumeController(QObject *parent = 0);
|
||||
~CVolumeController();
|
||||
int Init(CAvReceiver *ProgramPtr);
|
||||
bool mVolumeControllerActive;
|
||||
int SetMasterVolume(float Volume);
|
||||
|
||||
CAvReceiver *mProgramPtr;
|
||||
|
||||
private:
|
||||
IMMDeviceEnumerator *mDeviceEnumerator ;
|
||||
IMMDevice *mAudioDevice ;
|
||||
IAudioEndpointVolume *mEndpointVolume;
|
||||
GUID mMyGUID;
|
||||
float mMasterVolume;
|
||||
// CAudioNotificationCallback *mAudioNotificationObject;
|
||||
|
||||
|
||||
public:
|
||||
STDMETHODIMP QueryInterface(REFIID riid, void **ppv) {
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) AddRef() {return 2;}
|
||||
STDMETHODIMP_(ULONG) Release() {return 1;}
|
||||
STDMETHODIMP OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
signals:
|
||||
void ExternalVolumeChanged(float);
|
||||
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // VOLUMECONTROLLER_H
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef VOLUMECONTROLLER_H
|
||||
#define VOLUMECONTROLLER_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QObject>
|
||||
#include <endpointvolume.h>
|
||||
#include <Mmdeviceapi.h>
|
||||
|
||||
class CAvReceiver;
|
||||
|
||||
|
||||
class CVolumeController : public QObject, public IAudioEndpointVolumeCallback
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CVolumeController(QObject *parent = 0);
|
||||
~CVolumeController();
|
||||
int Init();
|
||||
|
||||
CAvReceiver *mProgramPtr;
|
||||
|
||||
private:
|
||||
IMMDeviceEnumerator *mDeviceEnumerator ;
|
||||
IMMDevice *mAudioDevice ;
|
||||
IAudioEndpointVolume *mEndpointVolume;
|
||||
// CAudioNotificationCallback *mAudioNotificationObject;
|
||||
|
||||
|
||||
public:
|
||||
STDMETHODIMP QueryInterface(REFIID riid, void **ppv) {
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) AddRef() {return 2;}
|
||||
|
||||
STDMETHODIMP_(ULONG) Release() {return 1;}
|
||||
|
||||
STDMETHODIMP OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // VOLUMECONTROLLER_H
|
||||
Reference in New Issue
Block a user