46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <VUtils/Environment.h>
|
|
#include <jack/jack.h>
|
|
#include <string>
|
|
#include <mutex>
|
|
#include <VUtils/Logging.h>
|
|
#include "Types.h"
|
|
#include "AudioGrabber.h"
|
|
|
|
class JackClient {
|
|
public:
|
|
static JackClient &get() {
|
|
static JackClient client;
|
|
return client;
|
|
}
|
|
void start();
|
|
static int processSamples(jack_nframes_t frames, void *arg);
|
|
static void onExit();
|
|
void connect(const char *port_name, jack_port_t* channel);
|
|
void fillSamples(stereoSample *pFrame, uint32_t i) {
|
|
std::lock_guard<std::mutex> lockGuard(guard);
|
|
for (int j = 0; j < i; ++j) {
|
|
pFrame[j].l = samples[j].l;
|
|
pFrame[j].r = samples[j].r;
|
|
}
|
|
m_newDataAvailable = false;
|
|
}
|
|
bool isData();
|
|
std::string getPort(bool isLeft);
|
|
bool checkPort(const std::string& port);
|
|
VUtils::Environment* env{};
|
|
int getFrames();
|
|
AudioGrabber *grabber;
|
|
private:
|
|
std::mutex guard;
|
|
stereoSample samples[BUFFER_SIZE]{};
|
|
stereoSample ringBuffer[BUFFER_SIZE]{};
|
|
int samplesAdded = 0;
|
|
jack_port_t *input_port_l = nullptr;
|
|
jack_port_t *input_port_r = nullptr;
|
|
bool m_newDataAvailable = false;
|
|
jack_client_t *client = nullptr;
|
|
jack_options_t options = jack_options_t(JackNoStartServer | JackUseExactName);
|
|
void addFrames(jack_default_audio_sample_t *pDouble, jack_default_audio_sample_t *pDouble1, jack_nframes_t i);
|
|
}; |