m_inputFrameBuffer: Use vector of SampleFrame
Also, refactor buffer resizing into one function, and avoid useless static method.
This commit is contained in:
@@ -96,6 +96,7 @@ private slots:
|
||||
|
||||
private:
|
||||
bool initJackClient();
|
||||
void resizeInputBuffer(jack_nframes_t nframes);
|
||||
|
||||
void startProcessing() override;
|
||||
void stopProcessing() override;
|
||||
@@ -106,7 +107,6 @@ private:
|
||||
|
||||
int processCallback(jack_nframes_t nframes);
|
||||
|
||||
static int setBufferSizeCallback(jack_nframes_t nframes, void* udata);
|
||||
static int staticProcessCallback(jack_nframes_t nframes, void* udata);
|
||||
static void shutdownCallback(void* _udata);
|
||||
|
||||
@@ -119,7 +119,7 @@ private:
|
||||
std::vector<jack_port_t*> m_outputPorts;
|
||||
std::vector<jack_port_t*> m_inputPorts;
|
||||
jack_default_audio_sample_t** m_tempOutBufs;
|
||||
std::vector<jack_default_audio_sample_t> m_inputFrameBuffer;
|
||||
std::vector<SampleFrame> m_inputFrameBuffer;
|
||||
SampleFrame* m_outBuf;
|
||||
SampleFrame* m_inBuf;
|
||||
|
||||
|
||||
@@ -158,9 +158,15 @@ bool AudioJack::initJackClient()
|
||||
clientName.toLatin1().constData(), jack_get_client_name(m_client));
|
||||
}
|
||||
|
||||
m_inputFrameBuffer.resize(channels() * jack_get_buffer_size(m_client));
|
||||
resizeInputBuffer(jack_get_buffer_size(m_client));
|
||||
|
||||
jack_set_buffer_size_callback(m_client, setBufferSizeCallback, this);
|
||||
// set buffer-size callback
|
||||
jack_set_buffer_size_callback(m_client,
|
||||
[](jack_nframes_t nframes, void* udata) -> int {
|
||||
static_cast<AudioJack*>(udata)->resizeInputBuffer(nframes);
|
||||
return 0;
|
||||
},
|
||||
this);
|
||||
|
||||
// set process-callback
|
||||
jack_set_process_callback(m_client, staticProcessCallback, this);
|
||||
@@ -192,6 +198,14 @@ bool AudioJack::initJackClient()
|
||||
|
||||
|
||||
|
||||
void AudioJack::resizeInputBuffer(jack_nframes_t nframes)
|
||||
{
|
||||
m_inputFrameBuffer.resize(nframes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AudioJack::startProcessing()
|
||||
{
|
||||
if (m_active || m_client == nullptr)
|
||||
@@ -298,12 +312,6 @@ void AudioJack::renamePort(AudioBusHandle* port)
|
||||
}
|
||||
|
||||
|
||||
int AudioJack::setBufferSizeCallback(jack_nframes_t nframes, void* udata)
|
||||
{
|
||||
auto thisClass = static_cast<AudioJack*>(udata);
|
||||
thisClass->m_inputFrameBuffer.resize(thisClass->channels() * nframes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AudioJack::processCallback(jack_nframes_t nframes)
|
||||
@@ -379,10 +387,10 @@ int AudioJack::processCallback(jack_nframes_t nframes)
|
||||
|
||||
for (jack_nframes_t frame = 0; frame < nframes; frame++)
|
||||
{
|
||||
m_inputFrameBuffer[frame * channels() + c] = jack_input_buffer[frame];
|
||||
m_inputFrameBuffer[frame][c] = static_cast<sample_t>(jack_input_buffer[frame]);
|
||||
}
|
||||
}
|
||||
audioEngine()->pushInputFrames ((SampleFrame*) m_inputFrameBuffer.data(), nframes);
|
||||
audioEngine()->pushInputFrames (m_inputFrameBuffer.data(), nframes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user