Skip to content

Commit 17b6eca

Browse files
committed
TransformationReader allow config for buffers
1 parent ed99d5e commit 17b6eca

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/AudioTools/CoreAudio/AudioIO.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ class TransformationReader {
4141
}
4242
}
4343

44+
/// Defines the read buffer size for individual reads
45+
void resizeReadBuffer(int size) {
46+
buffer.resize(size);
47+
}
48+
49+
/// Defines the queue size for result
50+
void resizeResultQueue(int size) {
51+
result_queue_buffer.resize(size);
52+
result_queue.begin();
53+
}
54+
4455
size_t readBytes(uint8_t *data, size_t len) {
4556
LOGD("TransformationReader::readBytes: %d", (int)len);
4657
if (!active) {
@@ -61,11 +72,11 @@ class TransformationReader {
6172
buffer.resize(size);
6273
}
6374

64-
if (rb.size() == 0) {
75+
if (result_queue_buffer.size() == 0) {
6576
// make sure that the ring buffer is big enough
6677
int rb_size = len * byte_count_factor;
6778
LOGI("buffer size: %d", rb_size);
68-
rb.resize(rb_size);
79+
result_queue_buffer.resize(rb_size);
6980
result_queue.begin();
7081
}
7182

@@ -102,15 +113,15 @@ class TransformationReader {
102113
}
103114

104115
void end() {
105-
rb.resize(0);
116+
result_queue_buffer.resize(0);
106117
buffer.resize(0);
107118
}
108119

109120
void setByteCountFactor(int f) { byte_count_factor = f; }
110121

111122
protected:
112-
RingBuffer<uint8_t> rb{0};
113-
QueueStream<uint8_t> result_queue{rb}; //
123+
RingBuffer<uint8_t> result_queue_buffer{0};
124+
QueueStream<uint8_t> result_queue{result_queue_buffer}; //
114125
Stream *p_stream = nullptr;
115126
Vector<uint8_t> buffer{0}; // we allocate memory only when needed
116127
T *p_transform = nullptr;
@@ -191,24 +202,13 @@ class ReformatBaseStream : public ModifyingStream {
191202
reader.end();
192203
}
193204

205+
/// Provides access to the TransformationReader
206+
TransformationReader<ReformatBaseStream> &getReader() {return reader;}
207+
194208
protected:
195209
TransformationReader<ReformatBaseStream> reader;
196210
Stream *p_stream = nullptr;
197211
Print *p_print = nullptr;
198-
// bool is_output_notify = false;
199-
// AudioInfoSupport *p_notify_on_output = nullptr;
200-
201-
// /// Define potential notification
202-
// void setNotifyOnOutput(AudioInfoSupport &info) { p_notify_on_output = &info; }
203-
204-
// /// Add notification on first call of write
205-
// void addNotifyOnFirstWrite() {
206-
// if (!is_output_notify) {
207-
// if (p_notify_on_output != nullptr)
208-
// addNotifyAudioChange(*p_notify_on_output);
209-
// is_output_notify = true;
210-
// }
211-
// }
212212

213213
void setupReader() {
214214
if (getStream() != nullptr) {

0 commit comments

Comments
 (0)