EHS/include/ehs/io/audio/BaseAudioDevice.h

102 lines
2.1 KiB
C
Raw Normal View History

2024-02-05 22:25:30 -08:00
#pragma once
#include "ehs/EHS.h"
#include "ehs/Str.h"
#include "ehs/Vector.h"
#include "ehs/Array.h"
#include "ehs/DataType.h"
namespace ehs
{
enum class AudioDeviceType
{
INPUT = 0x1,
2024-09-16 16:18:49 -07:00
OUTPUT = 0x0,
2024-02-05 22:25:30 -08:00
ALL = 0x2
};
enum class AudioDeviceState
{
ACTIVE = 0x1,
DISABLED = 0x2,
NOT_PRESENT = 0x4,
UNPLUGGED = 0x8
};
2024-07-24 01:36:20 -07:00
class EHS_LIB_IO BaseAudioDevice
2024-02-05 22:25:30 -08:00
{
protected:
AudioDeviceType type;
DataType dataType;
2024-09-16 16:18:49 -07:00
UInt_16 byteDepth;
2024-02-05 22:25:30 -08:00
UInt_32 sampleRate;
UInt_32 channels;
UInt_32 period;
UInt_32 latency;
UInt_64 maxFrames;
public:
virtual ~BaseAudioDevice() = default;
BaseAudioDevice();
BaseAudioDevice(const BaseAudioDevice& device);
BaseAudioDevice& operator=(const BaseAudioDevice& device);
virtual void OpenStream();
virtual void CloseStream();
2024-09-16 16:18:49 -07:00
virtual UInt_64 SendStream(const void *data, UInt_64 size);
2024-02-05 22:25:30 -08:00
2024-09-16 16:18:49 -07:00
virtual UInt_64 ReceiveStream(void *data, UInt_64 size);
2024-02-05 22:25:30 -08:00
2024-09-16 16:18:49 -07:00
void BridgeStreams(UInt_64 bufferSize);
2024-02-05 22:25:30 -08:00
AudioDeviceType GetType() const;
2024-09-03 05:37:23 -07:00
void SetDataType(DataType newDataType);
2024-02-05 22:25:30 -08:00
DataType GetDataType() const;
UInt_8 GetByteDepth() const;
UInt_16 GetBitDepth() const;
2024-09-03 05:37:23 -07:00
void SetSampleRate(UInt_32 newSampleRate);
2024-02-05 22:25:30 -08:00
UInt_32 GetSampleRate() const;
2024-09-03 05:37:23 -07:00
void SetChannels(UInt_32 newChannels);
2024-02-05 22:25:30 -08:00
UInt_16 GetChannels() const;
UInt_32 GetFrameSize() const;
2024-09-03 05:37:23 -07:00
void SetPeriod(UInt_32 newPeriod);
2024-02-05 22:25:30 -08:00
UInt_32 GetPeriod() const;
2024-09-03 05:37:23 -07:00
void SetLatency(UInt_32 newLatency);
2024-02-05 22:25:30 -08:00
UInt_32 GetLatency() const;
UInt_64 GetMaxFrames() const;
2024-09-16 16:18:49 -07:00
virtual bool IsStreaming() const;
2024-02-05 22:25:30 -08:00
virtual bool IsValid() const;
/// Retrieves the default audio input/output device.
/// @param [in] type The audio device type to retrieve.
/// @param [out] device The default audio device.
2024-09-03 05:37:23 -07:00
static BaseAudioDevice GetDefault(AudioDeviceType type);
2024-02-05 22:25:30 -08:00
/// Retrieves a list of audio input/output devices.
/// @param [in] type The audio device type to retrieve.
/// @param [in] state The audio device state to retrieve.
/// @param [out] devices The list of audio devices.
2024-09-03 05:37:23 -07:00
static Array<BaseAudioDevice> Get(AudioDeviceType type, AudioDeviceState state);
2024-02-05 22:25:30 -08:00
};
}