Buncha Edits
This commit is contained in:
@@ -63,7 +63,7 @@ target_link_libraries(ReMixer-Test PUBLIC ReMixer)
|
||||
|
||||
add_executable(pacat pacat_simple.cpp
|
||||
src/windows/ReMixer.cpp
|
||||
include/ReMixer/PulseDevice.h)
|
||||
include/ReMixer/PulseSubsystem.h)
|
||||
target_link_libraries(pacat pulse-simple pulse)
|
||||
|
||||
add_executable(vorbis_decode vorbis_decode.cpp)
|
||||
|
8
include/Backend/ALSA/AlsaDevice.hpp
Normal file
8
include/Backend/ALSA/AlsaDevice.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by dawsh on 7/18/25.
|
||||
//
|
||||
|
||||
#ifndef ALSADEVICE_HPP
|
||||
#define ALSADEVICE_HPP
|
||||
|
||||
#endif //ALSADEVICE_HPP
|
8
include/Backend/JACK/JackDevice.hpp
Normal file
8
include/Backend/JACK/JackDevice.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by dawsh on 7/18/25.
|
||||
//
|
||||
|
||||
#ifndef JACKDEVICE_HPP
|
||||
#define JACKDEVICE_HPP
|
||||
|
||||
#endif //JACKDEVICE_HPP
|
8
include/Backend/Pulse/PulseStream.hpp
Normal file
8
include/Backend/Pulse/PulseStream.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by dawsh on 7/18/25.
|
||||
//
|
||||
|
||||
#ifndef PULSESTREAM_HPP
|
||||
#define PULSESTREAM_HPP
|
||||
|
||||
#endif //PULSESTREAM_HPP
|
8
include/Backend/WASAPI/WasapiDevice.hpp
Normal file
8
include/Backend/WASAPI/WasapiDevice.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by dawsh on 7/18/25.
|
||||
//
|
||||
|
||||
#ifndef WASAPIDEVICE_HPP
|
||||
#define WASAPIDEVICE_HPP
|
||||
|
||||
#endif //WASAPIDEVICE_HPP
|
8
include/Backend/WASAPI/WasapiStream.hpp
Normal file
8
include/Backend/WASAPI/WasapiStream.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by dawsh on 7/18/25.
|
||||
//
|
||||
|
||||
#ifndef WASAPISTREAM_HPP
|
||||
#define WASAPISTREAM_HPP
|
||||
|
||||
#endif //WASAPISTREAM_HPP
|
@@ -22,12 +22,22 @@ namespace ReMixer {
|
||||
using CaptureCallback = 0;
|
||||
using DeviceStateCallback = 0;
|
||||
|
||||
/// 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.
|
||||
/// A single application might have one IAudioDevice instance per type (e.g. one default output device, on default input device).
|
||||
/// @see IStream.hpp
|
||||
class IAudioDevice {
|
||||
public:
|
||||
Event<> Connected;
|
||||
Event<> Disconnected;
|
||||
|
||||
|
||||
virtual ~IAudioDevice() = default;
|
||||
|
||||
virtual bool Initialize(const AudioFormat& requestedFormat, uint32_t bufferSizeFrames) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual bool IsInitialized() const = 0;
|
||||
|
||||
virtual bool Start() = 0;
|
||||
virtual bool Stop() = 0;
|
||||
virtual bool IsRunning() const = 0;
|
||||
@@ -41,6 +51,18 @@ 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.
|
||||
/// @param requested_format is the desired format for this stream.
|
||||
/// @param buffer_size_frames is the desired buffer size in frames for this stream.
|
||||
/// @see struct AudioFormat.
|
||||
virtual IStream* CreateStream(StreamDirection type, const AudioFormat& requested_format, uint32_t buffer_size_frames) = 0;
|
||||
|
||||
// Future: EnumerateStreams(), GetActiveStreams(), etc.
|
||||
// Future: Device event callbacks (e.g. unplugged, device changed)
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
/// (c) 2024 Redacted Software
|
||||
/// This work is explicitly dedicated to the public domain, for the hopeful betterment of the software industry.
|
||||
|
||||
/// @file stream.h
|
||||
/// @file IStream.hpp
|
||||
/// @desc An audio stream class that interfaces with pulseaudio, etc, to play back sounds.
|
||||
/// @edit 2024-08-06
|
||||
|
||||
@@ -32,6 +32,40 @@ 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,
|
||||
/// handling buffers, and callbacks. An IAudioDevice will create and manage IStream instances.
|
||||
/// @see IAudioDevice.
|
||||
class IStream {
|
||||
public:
|
||||
virtual ~IStream() = default;
|
||||
|
||||
virtual bool Initialize() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual bool IsInitialized() const = 0;
|
||||
|
||||
virtual bool Start() = 0;
|
||||
virtual bool Stop() = 0;
|
||||
virtual bool IsRunning() const = 0;
|
||||
|
||||
virtual void SetPlaybackCallback(PlaybackCallback callback, void* userData = nullptr) = 0;
|
||||
virtual void SetCaptureCallback(CaptureCallback callback, void* userData = nullptr) = 0;
|
||||
};
|
||||
|
||||
/// The stream class is an abstract class that represents distinct output / input channels on an audio system.
|
||||
/// Each audio system implements their concept of streams as a derivation of this class.
|
||||
class Stream {
|
@@ -2,11 +2,17 @@
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <Event.h>
|
||||
#include <ReMixer/AudioFormat.hpp>
|
||||
#include <ReMixer/Sound.hpp>
|
||||
#include <ReMixer/SoundHandle.hpp>
|
||||
#include <ReMixer/IAudioDevice.hpp>
|
||||
|
||||
#include "Sound.hpp"
|
||||
|
||||
namespace ReMixer {
|
||||
|
||||
|
||||
/// TODO: Support JACK
|
||||
/// TOOD: Support ALSA
|
||||
/// TODO: Support PulseAudio
|
||||
|
@@ -9,12 +9,15 @@
|
||||
/// @edit 2024-08-29
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <pulse/pulseaudio.h>
|
||||
#include <pulse/simple.h>
|
||||
#include <filesystem>
|
||||
#include <ReMixer/stream.h>
|
||||
#include <ReMixer/IStream.hpp>
|
||||
#include <ReMixer/ReMixer.h>
|
||||
#include <ReMixer/AudioFormat.hpp>
|
||||
#include <iterator>
|
||||
#include <vorbis/vorbisfile.h>
|
||||
#include <algorithm>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "sound.h"
|
||||
#include <ReMixer/Sound.hpp>
|
||||
|
||||
namespace ReMixer {
|
||||
class SoundHandle {
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include "stream.h"
|
||||
#include "IStream.hpp"
|
||||
|
||||
class TakenStreamIDException : public std::exception
|
||||
{
|
||||
|
4
main.cpp
4
main.cpp
@@ -14,9 +14,9 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include <ReMixer/stream.h>
|
||||
#include <ReMixer/IStream.hpp>
|
||||
#include <ReMixer/Sound.hpp>
|
||||
#include <ReMixer/PulseDevice.h>
|
||||
#include <include/Backend/Pulse/PulseDevice.h>
|
||||
#include <ReMixer/ReMixer.h>
|
||||
|
||||
#include "ReMixer/Frequency.hpp"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <ReMixer/PulseDevice.h>
|
||||
#include <../../include/Backend/Pulse/PulseDevice.h>
|
||||
|
||||
void ReMixer::PulseAudioSubsystem::Play(ReMixer::PulseStream &stream, const ReMixer::Sound &sound) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <ReMixer/stream.h>
|
||||
#include <ReMixer/IStream.hpp>
|
||||
#include <ReMixer/Sound.hpp>
|
||||
#include <uuid/uuid.h>
|
||||
#include <iostream>
|
@@ -1 +0,0 @@
|
||||
#include <ReMixer/SoundSubsystem.h>
|
@@ -1,3 +0,0 @@
|
||||
//
|
||||
// Created by Josh on 8/22/2024.
|
||||
//
|
Reference in New Issue
Block a user