Slow progress on this laptop.

This commit is contained in:
2025-07-22 13:59:00 -05:00
parent e1ff9f229b
commit 9e214f3ab5
7 changed files with 54 additions and 160 deletions

View File

@@ -8,6 +8,8 @@
/// @desc A PulseAudio implementation of the AudioSubsystem class.
/// @edit 2024-08-29
#pragma once
#include <pulse/pulseaudio.h>
#include <pulse/thread-mainloop.h>
#include <iostream>
@@ -16,22 +18,28 @@
#include <pulse/stream.h>
#include <pulse/introspect.h>
#pragma once
#include <ReMixer/SoundSubsystem.h>
#include <ReMixer/stream.h>
#include <format>
#include <map>
#include "ReMixer/IAudioDevice.hpp"
namespace ReMixer
{
namespace PulseAudio {
class PulseDevice : public IAudioDevice {
public:
PulseDevice(const AudioDeviceInfo& info);
PulseDevice(const AudioDeviceInfo& info, uint32_t buffer_size_frames);
~PulseDevice() override;
bool Initialize(const AudioFormat &requestedFormat, uint32_t bufferSizeFrames) override;
void Shutdown() override;
bool Start() override;
bool Stop() override;
bool IsRunning() const override;
void
};
@@ -102,4 +110,4 @@ namespace ReMixer
};
}
}

View File

@@ -1,8 +1,21 @@
//
// Created by dawsh on 7/18/25.
//
#pragma once
#ifndef WASAPIDEVICE_HPP
#define WASAPIDEVICE_HPP
#include <ReMixer/IAudioDevice.hpp>
#endif //WASAPIDEVICE_HPP
namespace ReMixer {
namespace Wasapi {
class WasapiDevice : public IAudioDevice {
public:
WasapiDevice(const AudioDeviceInfo& info);
~WasapiDevice();
bool Initialize(const AudioFormat& requested_format, uint32_t buffer_size_frames) override;
void Shutdown() override;
bool Start() override;
bool Stop() override;
bool IsRunning() const override;
SetPl
};
}
}

View File

@@ -1,5 +1,5 @@
#pragma once
#include "AudioFormat.hpp"
#include <ReMixer/AudioFormat.hpp>
#include "ReMixer.h"
namespace ReMixer {
@@ -18,9 +18,23 @@ namespace ReMixer {
class IAudioDevice;
using PlaybackCallback = std::;
using CaptureCallback = 0;
using DeviceStateCallback = 0;
/// Playback callback: client fills the buffer with audio data.
/// @param outputBuffer (raw bytes)
/// @param framesToRender
/// @param userData (passed at initalization)
/// @return number of frames actually rendered. If less than framesToRender, indicates end of stream or underrun.
using PlaybackCallback = std::function<size_t(void* outputBuffer, uint32_t framesToRender, void* userData)>;
/// Capture callback: client receives audio data from the device.
/// @param inputBuffer (raw bytes)
/// @param framesCaptured
/// @param userData (passed at init)
/// @return void (or could return a status)
using CaptureCallback = std::function<void(void* outputBuffer, uint32_t framesToRender, void* userData)>;
/// Device state change callback (e.g. device unplugged, format changed).
/// Arguments: device, newStatus.
using DeviceStateCallback = std::function<void(IAudioDevice& device, bool isRunning)>; // Simplified for now.
/// Represents the physical or logical audio hardware device. It's responsible for managing the connection to the
/// underlying audio API, enumerating streams, and providing device-specific properties.
@@ -42,6 +56,10 @@ namespace ReMixer {
virtual bool Stop() = 0;
virtual bool IsRunning() const = 0;
virtual void SetPlaybackCallback(PlaybackCallback callback, void* user_data = nullptr) = 0;
virtual void SetCaptureCallback(CaptureCallback callback, void* user_data = nullptr);
virtual AudioDeviceInfo GetInfo() const = 0;
virtual AudioFormat GetActualFormat() const = 0;
virtual uint32_t GetActualBufferSizeFrames() const = 0;
@@ -51,7 +69,6 @@ namespace ReMixer {
template <typename T>
T* AsPlatformSpecific() { return dynamic_cast<T>(*this); }
virtual AudioDeviceInfo GetInfo() const = 0;
/// @param type indicates if it's a playback or capture stream.

View File

@@ -32,19 +32,6 @@ namespace ReMixer {
STEREO = true
};
/// Playback callback: client fills the buffer with audio data.
/// @param outputBuffer (raw bytes)
/// @param framesToRender
/// @param userData (passed at initalization)
/// @return number of frames actually rendered. If less than framesToRender, indicates end of stream or underrun.
using PlaybackCallback = std::function<size_t(void* outputBuffer, uint32_t framesToRender, void* userData)>;
/// Capture callback: client receives audio data from the device.
/// @param inputBuffer (raw bytes)
/// @param framesCaptured
/// @param userData (passed at init)
/// @return void (or could return a status)
using CaptureCallback = std::function<void(void* outputBuffer, uint32_t framesToRender, void* userData)>;
/// Represents an audio data pathway (e.g. a playback stream, a capture stream).
/// It's responsible for managing the actual flow of audio data to or from the device,

View File

@@ -1,75 +0,0 @@
#pragma once
#include <Event.h>
namespace ReMixer {
class Stream;
/// TODO: Equalizer Effect
/// TODO: Compressor Effect
/// TODO: Reverb Effect
/// TODO: Chorus Effect
/// TODO: Distortion Effect
/// TODO: Echo Effect
/// TODO: Flange Effect
/// TODO: Pitch Shift Effect
/// TODO: Tremolo Effect
/// TODO: Positional Sound Object?
/// Physical representation of Pulse-Code-Modulated sound data.
class PCM { };
class Decibels { };
enum class SoundApi
{
PulseAudio, /// Currently supported.
ALSA, /// Not yet supported.
PipeWire, /// Not yet supported.
WASAPI, /// Work-in-progress support.
OSS, /// Not yet supported.
CoreAudio /// Support not planned.
};
class AudioDevice {};
class PlaybackDevice : public AudioDevice {};
class RecordingDevice : public AudioDevice {};
/// An abstract class that defines the SoundSubsystem which will be used by the higher-level ReMixer API.
/// Since it is common for sound APIs to operate on a separate (or even multiple) threads,
/// The subsystem also functions as a "controller" that manages these separate threads.
/// Therefore, it is safe to use in a single-threaded application.
class SoundSubsystem
{
public:
SoundSubsystem() {}
std::vector<AudioDevice> GetAudioDevices();
std::vector<PlaybackDevice> GetPlaybackDevices();
std::vector<RecordingDevice> GetRecordingDevices();
std::string GetPlaybackDevice();
std::string GetRecordingDevice();
void SetPlaybackDevice();
void SetRecordingDevice();
void SetMasterVolume(Decibels db);
protected:
private:
};
/// A Windows Sound API implementation of the SoundSubsystem.
class WASAPISubsystem : public SoundSubsystem
{
public:
protected:
private:
};
}

View File

@@ -1,48 +0,0 @@
/// ReMixer
/// A Public Domain C++ Audio Playback Library
/// By william @ RedactedSoftware. Thanks to Dawsh & Maxine.
/// (c) 2024 Redacted Software
/// This work is explicitly dedicated to the public domain, for the hopeful betterment of the software industry.
/// @file StreamManager.h
/// @desc This class manages internal creation and storage of active Streams.
/// @edit 2024-08-06
#pragma once
#include <map>
#include "IStream.hpp"
class TakenStreamIDException : public std::exception
{
};
//class StreamManager {
//public:
//static std::map<uint16_t, Stream *> streamList;
//StreamManager();
//StreamManager(const StreamManager&);
// Get stream using handle
//static Stream *GetStream(uint16_t handle)
//{
// return streamList.at(handle);
//}
// Return Stream handle
// TODO:
/*static Stream* CreateStream()
{
// Can we create the stream here and assign the handle on our side?
// or do you need to change it from outside
}
static void AddStream(Stream* stream)
{
streamList.emplace(stream->handle, stream);
}
// Iterator maybe?
// Fuck if I know what type is returned.
auto begin() { return streamList.begin(); };
auto end() { return streamList.end(); };
};*/

View File

@@ -1,8 +0,0 @@
//
// Created by josh on 7/16/25.
//
#ifndef WASAPIDEVICE_HPP
#define WASAPIDEVICE_HPP
#endif //WASAPIDEVICE_HPP