Decommissioned JACKRingBuffer in preference of QRingBuffer

which should be more portable compared to the implementeation of the JACK
ringbuffer as of version 1.9.14
This commit is contained in:
sergm
2020-09-05 20:52:25 +03:00
parent bf76f11886
commit 3f2bdfcb8c
4 changed files with 7 additions and 75 deletions

View File

@@ -221,7 +221,6 @@ if(JACK_FOUND)
include_directories(${JACK_INCLUDE_DIRS})
set(mt32emu_qt_SOURCES ${mt32emu_qt_SOURCES}
src/JACKClient.cpp
src/JACKRingBuffer.cpp
src/mididrv/JACKMidiDriver.cpp
src/audiodrv/JACKAudioDriver.cpp
)

View File

@@ -1,47 +0,0 @@
/* Copyright (C) 2011-2020 Jerome Fisher, Sergey V. Mikayev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "JACKRingBuffer.h"
JACKRingBuffer::JACKRingBuffer(size_t byteSize) :
ringBuffer(jack_ringbuffer_create(byteSize))
{}
JACKRingBuffer::~JACKRingBuffer() {
jack_ringbuffer_free(ringBuffer);
}
void *JACKRingBuffer::readPointer(size_t &bytesAvailable) const {
jack_ringbuffer_data_t data[2];
jack_ringbuffer_get_read_vector(ringBuffer, data);
bytesAvailable = data[0].len;
return data[0].buf;
}
void JACKRingBuffer::advanceReadPointer(size_t bytesRead) {
jack_ringbuffer_read_advance(ringBuffer, bytesRead);
}
void *JACKRingBuffer::writePointer(size_t &bytesAvailable) const {
jack_ringbuffer_data_t data[2];
jack_ringbuffer_get_write_vector(ringBuffer, data);
bytesAvailable = data[0].len;
return data[0].buf;
}
void JACKRingBuffer::advanceWritePointer(size_t bytesWritten) {
jack_ringbuffer_write_advance(ringBuffer, bytesWritten);
}

View File

@@ -1,21 +0,0 @@
#ifndef JACK_RING_BUFFER_H
#define JACK_RING_BUFFER_H
#include <jack/ringbuffer.h>
class JACKRingBuffer {
public:
explicit JACKRingBuffer(size_t byteSize);
~JACKRingBuffer();
void *readPointer(size_t &bytesAvailable) const;
void advanceReadPointer(size_t bytesRead);
void *writePointer(size_t &bytesAvailable) const;
void advanceWritePointer(size_t bytesWritten);
private:
jack_ringbuffer_t * const ringBuffer;
};
#endif

View File

@@ -19,7 +19,7 @@
#include "../Master.h"
#include "../QSynth.h"
#include "../JACKClient.h"
#include "../JACKRingBuffer.h"
#include "../QRingBuffer.h"
static const uint CHANNEL_COUNT = 2;
static const uint MINIMUM_JACK_BUFFER_COUNT = 2;
@@ -27,7 +27,7 @@ static const uint FRAME_BYTE_SIZE = sizeof(float[CHANNEL_COUNT]);
class JACKAudioProcessor : QThread {
SynthRoute &synthRoute;
JACKRingBuffer * const buffer;
Utility::QRingBuffer * const buffer;
volatile bool stopProcessing;
// Used to block this thread until there is some available space in the buffer.
@@ -42,8 +42,9 @@ class JACKAudioProcessor : QThread {
// free some buffer space in the meantime.
int currentRetrievals = bufferDataRetrievals.available();
if (stopProcessing) return;
size_t bytesAvailable;
float *writePointer = static_cast<float *>(buffer->writePointer(bytesAvailable));
quint32 bytesAvailable;
bool freeSpaceContiguous;
float *writePointer = static_cast<float *>(buffer->writePointer(bytesAvailable, freeSpaceContiguous));
quint32 framesToRender = quint32(bytesAvailable / FRAME_BYTE_SIZE);
if (framesToRender == 0) {
bufferDataRetrievals.acquire(currentRetrievals + 1);
@@ -59,7 +60,7 @@ public:
synthRoute(useSynthRoute),
// JACKRingBuffer needs a bit of spare space to accommodate the entire requested size.
// Adding 1 FRAME_BYTE_SIZE does the trick yet ensures proper alignment of pointers.
buffer(new JACKRingBuffer((bufferSizeFrames + 1) * FRAME_BYTE_SIZE)),
buffer(new Utility::QRingBuffer((bufferSizeFrames + 1) * FRAME_BYTE_SIZE)),
stopProcessing()
{}
@@ -78,7 +79,7 @@ public:
}
float *getAvailableChunk(quint32 &chunkSizeFrames) const {
size_t bytesAvailable;
quint32 bytesAvailable;
float *readPointer = static_cast<float *>(buffer->readPointer(bytesAvailable));
quint32 framesAvailable = quint32(bytesAvailable / FRAME_BYTE_SIZE);
chunkSizeFrames = qMin(chunkSizeFrames, framesAvailable);