ES-DE/es-app/src/VolumeControl.h
Leon Styhre 76aa239855 Initial update to make the application build and run on Windows.
Much more work will be needed to get the Windows port working properly.
2020-07-03 20:23:51 +02:00

65 lines
1.4 KiB
C++

//
// VolumeControl.h
//
// Controls system audio volume.
//
#pragma once
#ifndef ES_APP_VOLUME_CONTROL_H
#define ES_APP_VOLUME_CONTROL_H
#include <memory>
#if defined (__APPLE__)
#error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__)
#include <unistd.h>
#include <fcntl.h>
#include <alsa/asoundlib.h>
#elif defined(_WIN64)
#include <Windows.h>
#include <endpointvolume.h>
//#include <mmeapi.h>
#endif
// Singleton pattern. Call getInstance() to get an object.
class VolumeControl
{
#if defined (__APPLE__)
#error TODO: Not implemented for MacOS yet!!!
#elif defined(__linux__)
static const char * mixerName;
static const char * mixerCard;
int mixerIndex;
snd_mixer_t* mixerHandle;
snd_mixer_elem_t* mixerElem;
snd_mixer_selem_id_t* mixerSelemId;
#elif defined(_WIN64)
HMIXER mixerHandle;
MIXERCONTROL mixerControl;
IAudioEndpointVolume * endpointVolume;
#endif
int originalVolume;
int internalVolume;
static std::weak_ptr<VolumeControl> sInstance;
VolumeControl();
VolumeControl(const VolumeControl & right);
VolumeControl & operator=(const VolumeControl & right);
public:
static std::shared_ptr<VolumeControl> & getInstance();
void init();
void deinit();
int getVolume() const;
void setVolume(int volume);
~VolumeControl();
};
#endif // ES_APP_VOLUME_CONTROL_H