Separate IO

Initial separation of input and output devices. Assisted by our super friend ChatGpt.
This commit is contained in:
ExtremesecrecyOne
2025-07-22 16:20:30 -07:00
parent 884eb31619
commit d8043d2041
9 changed files with 109 additions and 63 deletions
+18 -11
View File
@@ -31,18 +31,24 @@ namespace pipedal
bool isOnboarding_ = true;
bool isJackAudio_ = JACK_HOST ? true : false;
bool rebootRequired_ = false;
std::string alsaDevice_;
std::string alsaInputDevice_;
std::string alsaOutputDevice_;
uint64_t sampleRate_ = 0;
uint32_t bufferSize_ = 64;
uint32_t numberOfBuffers_ = 3;
public:
void SetAlsaInputDevice(const std::string &d){ alsaInputDevice_ = d; }
void SetAlsaOutputDevice(const std::string &d){ alsaOutputDevice_ = d; }
JackServerSettings();
JackServerSettings(
JackServerSettings(
const std::string alsaInputDevice,
uint64_t sampleRate, uint32_t bufferSize, uint32_t numberOfBuffers)
uint64_t sampleRate,
uint32_t bufferSize,
uint32_t numberOfBuffers)
: valid_(true),
alsaDevice_(alsaInputDevice),
alsaInputDevice_(alsaInputDevice),
alsaOutputDevice_(alsaInputDevice), // default same
sampleRate_(sampleRate),
bufferSize_(bufferSize),
numberOfBuffers_(numberOfBuffers),
@@ -53,16 +59,17 @@ namespace pipedal
uint64_t GetSampleRate() const { return sampleRate_; }
uint32_t GetBufferSize() const { return bufferSize_; }
uint32_t GetNumberOfBuffers() const { return numberOfBuffers_; }
const std::string &GetAlsaInputDevice() const { return alsaDevice_; }
const std::string &GetAlsaInputDevice() const { return alsaInputDevice_; }
const std::string &GetAlsaOutputDevice() const { return alsaOutputDevice_; }
void UseDummyAudioDevice() {
this->valid_ = true;
if (sampleRate_ == 0) sampleRate_ = 48000;
this->alsaDevice_ = "dummy:channels_2";
this->alsaInputDevice_ = "__DUMMY_AUDIO__dummy:channels_2";
this->alsaOutputDevice_ = "__DUMMY_AUDIO__dummy:channels_2";
}
bool IsDummyAudioDevice() const {
return
this->alsaDevice_.starts_with("__DUMMY_AUDIO__")
|| this->alsaDevice_.starts_with("dummy:");
return this->alsaInputDevice_.starts_with("__DUMMY_AUDIO__")
|| this->alsaOutputDevice_.starts_with("__DUMMY_AUDIO__");
}
void ReadJackDaemonConfiguration();
@@ -75,7 +82,7 @@ namespace pipedal
// this->rebootRequired_ = true;
// this->sampleRate_ = sampleRate;
// this->bufferSize_ = bufferSize;
// this->numberOfBuffers_ = numberOfBuffers;
// this->numberOfBuffers_ = numberOfBuffers;
// }
void WriteDaemonConfig(); // requires root perms.
void SetRebootRequired(bool value)
@@ -89,7 +96,7 @@ namespace pipedal
bool Equals(const JackServerSettings &other)
{
return this->alsaDevice_ == other.alsaDevice_ && this->sampleRate_ == other.sampleRate_ && this->bufferSize_ == other.bufferSize_ && this->numberOfBuffers_ == other.numberOfBuffers_;
return this->alsaInputDevice_ == other.alsaInputDevice_ && this->alsaOutputDevice_ == other.alsaOutputDevice_ && this->sampleRate_ == other.sampleRate_ && this->bufferSize_ == other.bufferSize_ && this->numberOfBuffers_ == other.numberOfBuffers_;
}
DECLARE_JSON_MAP(JackServerSettings);