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

61 lines
1.3 KiB
C
Raw Normal View History

2024-02-05 22:25:30 -08:00
#pragma once
#include "ehs/EHS.h"
#include "BaseAudioDevice.h"
2024-09-03 05:37:23 -07:00
#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>
2024-02-05 22:25:30 -08:00
namespace ehs
{
2024-07-24 01:36:20 -07:00
class EHS_LIB_IO AudioDevice : public BaseAudioDevice
2024-02-05 22:25:30 -08:00
{
private:
2024-09-03 05:37:23 -07:00
static Array<AudioDevice> devices;
static AudioDevice defOut;
static AudioDevice defIn;
UInt_32 id;
Str_8 name;
pw_loop *loop;
pw_context *context;
pw_core *core;
pw_stream *stream;
static void RegistryEventGlobal(void *user_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);
2024-02-05 22:25:30 -08:00
public:
~AudioDevice() override;
AudioDevice();
AudioDevice(AudioDevice&& device) noexcept;
AudioDevice(const AudioDevice& device);
AudioDevice& operator=(AudioDevice&& device) noexcept;
AudioDevice& operator=(const AudioDevice& device);
void Release() override;
void OpenStream() override;
void CloseStream() override;
2024-09-03 05:37:23 -07:00
UInt_64 SendStream(void *data, UInt_64 size) override;
2024-02-05 22:25:30 -08:00
bool IsValid() const override;
2024-09-03 05:37:23 -07:00
static AudioDevice GetDefault(AudioDeviceType type);
2024-02-05 22:25:30 -08:00
2024-09-03 05:37:23 -07:00
static Array<AudioDevice> Get(AudioDeviceType type, AudioDeviceState state);
2024-02-05 22:25:30 -08:00
};
}