Fixed Mat and CMakeLists

This commit is contained in:
2024-09-16 16:18:49 -07:00
parent 25762b0c29
commit 681c0d09be
8 changed files with 620 additions and 424 deletions

View File

@@ -5,5 +5,5 @@
#if defined(EHS_OS_WINDOWS)
#include "AudioDevice_W32.h"
#elif defined(EHS_OS_LINUX)
#include "AudioDevice_ALSA.h"
#endif
#include "AudioDevice_PW.h"
#endif

View File

@@ -3,16 +3,15 @@
#include "ehs/EHS.h"
#include "BaseAudioDevice.h"
#include <spa/param/audio/format-utils.h>
#include <pipewire/pipewire.h>
#include <pipewire/loop.h>
#include <pipewire/context.h>
#include <pipewire/stream.h>
#include <pipewire/keys.h>
#include <spa/param/audio/format-utils.h>
namespace ehs
{
class EHS_LIB_IO AudioDevice : public BaseAudioDevice
class EHS_LIB_IO AudioDevice final : public BaseAudioDevice
{
private:
static Array<AudioDevice> devices;
@@ -24,11 +23,14 @@ namespace ehs
pw_loop *loop;
pw_context *context;
pw_core *core;
pw_stream *stream;
pw_stream *input;
pw_stream *output;
static void RegistryEventGlobal(void *user_data, UInt_32 id, UInt_32 permissions, const char *type, UInt_32 version, const spa_dict *props);
static void RegistryEventGlobal(void *data, UInt_32 id, UInt_32 permissions, const char *type, UInt_32 version, const spa_dict *props);
static void RegistryEventGlobalRemove(void *user_data, UInt_32 id);
static void RegistryEventGlobalRemove(void *data, UInt_32 id);
static void OnParamChanged(void *data, UInt_32 id, const spa_pod *param);
public:
~AudioDevice() override;
@@ -43,18 +45,23 @@ namespace ehs
AudioDevice& operator=(const AudioDevice& device);
void Release() override;
void OpenStream() override;
void CloseStream() override;
UInt_64 SendStream(void *data, UInt_64 size) override;
UInt_64 SendStream(const void *data, UInt_64 size) override;
UInt_64 ReceiveStream(void *data, UInt_64 size) override;
bool IsStreaming() const override;
bool IsValid() const override;
static AudioDevice GetDefault(AudioDeviceType type);
static Array<AudioDevice> Get(AudioDeviceType type, AudioDeviceState state);
private:
Str_8 GetCategory() const;
};
}

View File

@@ -12,7 +12,7 @@ struct IMMDevice;
namespace ehs
{
class EHS_LIB_IO AudioDevice : public BaseAudioDevice
class EHS_LIB_IO AudioDevice final : public BaseAudioDevice
{
private:
IMMDevice* hdl;

View File

@@ -10,8 +10,8 @@ namespace ehs
{
enum class AudioDeviceType
{
OUTPUT = 0x0,
INPUT = 0x1,
OUTPUT = 0x0,
ALL = 0x2
};
@@ -28,13 +28,12 @@ namespace ehs
protected:
AudioDeviceType type;
DataType dataType;
UInt_16 bitDepth;
UInt_16 byteDepth;
UInt_32 sampleRate;
UInt_32 channels;
UInt_32 period;
UInt_32 latency;
UInt_64 maxFrames;
bool streaming;
public:
virtual ~BaseAudioDevice() = default;
@@ -45,19 +44,15 @@ namespace ehs
BaseAudioDevice& operator=(const BaseAudioDevice& device);
virtual void Release();
virtual void OpenStream();
virtual void CloseStream();
virtual UInt_64 SendStream(void *data, UInt_64 size);
virtual UInt_64 SendStream(const void *data, UInt_64 size);
virtual UInt_64 GetAvailFrames() const;
virtual UInt_64 ReceiveStream(void *data, UInt_64 size);
virtual Byte* Map(UInt_64* offset, UInt_64* frames);
virtual void UnMap(UInt_64 offset, UInt_64 frames);
void BridgeStreams(UInt_64 bufferSize);
AudioDeviceType GetType() const;
@@ -89,7 +84,7 @@ namespace ehs
UInt_64 GetMaxFrames() const;
bool IsStreaming() const;
virtual bool IsStreaming() const;
virtual bool IsValid() const;