Skip to content

Commit 740b2a6

Browse files
committed
Converters use standard notification
1 parent ee0f04f commit 740b2a6

File tree

5 files changed

+30
-53
lines changed

5 files changed

+30
-53
lines changed

src/AudioTools/AudioCodecs/AudioEncoded.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class EncodedAudioStream : public ReformatBaseStream {
345345
}
346346

347347
bool begin() {
348-
is_output_notify = false;
348+
//is_output_notify = false;
349349
reader.setByteCountFactor(10);
350350
setupReader();
351351
ReformatBaseStream::begin();
@@ -360,7 +360,7 @@ class EncodedAudioStream : public ReformatBaseStream {
360360
int availableForWrite() { return enc_out.availableForWrite(); }
361361

362362
size_t write(const uint8_t *data, size_t len) {
363-
addNotifyOnFirstWrite();
363+
//addNotifyOnFirstWrite();
364364
return enc_out.write(data, len);
365365
}
366366

src/AudioTools/CoreAudio/AudioIO.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,14 @@ class ReformatBaseStream : public ModifyingStream {
151151
TRACED();
152152
p_stream = &stream;
153153
p_print = &stream;
154-
setNotifyOnOutput(stream);
154+
//setNotifyOnOutput(stream);
155+
addNotifyAudioChange(stream);
155156
}
156157

157158
virtual void setOutput(AudioOutput &print) {
158159
TRACED();
159160
p_print = &print;
160-
setNotifyOnOutput(print);
161+
addNotifyAudioChange(print);
161162
}
162163

163164
virtual void setOutput(Print &print) override {
@@ -194,20 +195,20 @@ class ReformatBaseStream : public ModifyingStream {
194195
TransformationReader<ReformatBaseStream> reader;
195196
Stream *p_stream = nullptr;
196197
Print *p_print = nullptr;
197-
bool is_output_notify = false;
198-
AudioInfoSupport *p_notify_on_output = nullptr;
199-
200-
/// Define potential notification
201-
void setNotifyOnOutput(AudioInfoSupport &info) { p_notify_on_output = &info; }
202-
203-
/// Add notification on first call of write
204-
void addNotifyOnFirstWrite() {
205-
if (!is_output_notify) {
206-
if (p_notify_on_output != nullptr)
207-
addNotifyAudioChange(*p_notify_on_output);
208-
is_output_notify = true;
209-
}
210-
}
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+
// }
211212

212213
void setupReader() {
213214
if (getStream() != nullptr) {

src/AudioTools/CoreAudio/AudioStreamsConverter.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ChannelFormatConverterStreamT : public ReformatBaseStream {
2222

2323
bool begin(int fromChannels, int toChannels) {
2424
LOGI("begin %d -> %d channels", fromChannels, toChannels);
25-
is_output_notify = false;
25+
//is_output_notify = false;
2626
from_channels = fromChannels;
2727
to_channels = toChannels;
2828
factor = static_cast<float>(toChannels) / static_cast<float>(fromChannels);
@@ -40,7 +40,7 @@ class ChannelFormatConverterStreamT : public ReformatBaseStream {
4040
virtual size_t write(const uint8_t *data, size_t len) override {
4141
TRACED();
4242
if (p_print == nullptr) return 0;
43-
addNotifyOnFirstWrite();
43+
//addNotifyOnFirstWrite();
4444
if (from_channels == to_channels) {
4545
return p_print->write(data, len);
4646
}
@@ -169,7 +169,7 @@ class ChannelFormatConverterStream : public ReformatBaseStream {
169169

170170
bool begin(AudioInfo cfg, int toChannels) {
171171
assert(toChannels != 0);
172-
is_output_notify = false;
172+
//is_output_notify = false;
173173
to_channels = toChannels;
174174
from_channels = cfg.channels;
175175
bits_per_sample = cfg.bits_per_sample;
@@ -190,7 +190,7 @@ class ChannelFormatConverterStream : public ReformatBaseStream {
190190
virtual size_t write(const uint8_t *data, size_t len) override {
191191
LOGD("ChannelFormatConverterStream::write: %d", (int)len);
192192
if (p_print == nullptr) return 0;
193-
addNotifyOnFirstWrite();
193+
//addNotifyOnFirstWrite();
194194
switch (bits_per_sample) {
195195
case 8:
196196
return getConverter<int8_t>()->write(data, len);
@@ -354,14 +354,14 @@ class NumberFormatConverterStreamT : public ReformatBaseStream {
354354

355355
bool begin() override {
356356
LOGI("begin %d -> %d bits", (int)sizeof(TFrom), (int)sizeof(TTo));
357-
is_output_notify = false;
357+
//is_output_notify = false;
358358
return true;
359359
}
360360

361361
virtual size_t write(const uint8_t *data, size_t len) override {
362362
TRACED();
363363
if (p_print == nullptr) return 0;
364-
addNotifyOnFirstWrite();
364+
//addNotifyOnFirstWrite();
365365
if (sizeof(TFrom) == sizeof(TTo)) return p_print->write(data, len);
366366
size_t samples = len / sizeof(TFrom);
367367
size_t result_size = 0;
@@ -485,7 +485,7 @@ class NumberFormatConverterStream : public ReformatBaseStream {
485485
bool begin(int from_bit_per_samples, int to_bit_per_samples,
486486
float gain = 1.0) {
487487
assert(to_bit_per_samples > 0);
488-
is_output_notify = false;
488+
//is_output_notify = false;
489489
this->gain = gain;
490490
LOGI("begin %d -> %d bits", from_bit_per_samples, to_bit_per_samples);
491491
bool result = true;
@@ -761,7 +761,7 @@ class FormatConverterStream : public ReformatBaseStream {
761761
/// (Re-)Starts the processing: call setAudioInfo and setAudioInfoOut before
762762
bool begin() override {
763763
TRACED();
764-
is_output_notify = false;
764+
//is_output_notify = false;
765765
// build output chain
766766
if (getStream() != nullptr) {
767767
sampleRateConverter.setStream(*getStream());
@@ -797,7 +797,7 @@ class FormatConverterStream : public ReformatBaseStream {
797797

798798
virtual size_t write(const uint8_t *data, size_t len) override {
799799
LOGD("FormatConverterStream::write: %d", (int)len);
800-
addNotifyOnFirstWrite();
800+
//addNotifyOnFirstWrite();
801801
return channelFormatConverter.write(data, len);
802802
}
803803

src/AudioTools/CoreAudio/AudioTypes.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -297,30 +297,6 @@ class AudioTime {
297297
*/
298298
class NumberConverter {
299299
public:
300-
// static int32_t convertFrom24To32(int24_t value) {
301-
// return value.scale32();
302-
// }
303-
304-
// static int16_t convertFrom24To16(int24_t value) {
305-
// return value.scale16();
306-
// }
307-
308-
// static float convertFrom24ToFloat(int24_t value) {
309-
// return value.scaleFloat();
310-
// }
311-
312-
// static int16_t convertFrom32To16(int32_t value) {
313-
// return static_cast<float>(value) / INT32_MAX * INT16_MAX;
314-
// }
315-
316-
// static int16_t convert16(int value, int value_bits_per_sample){
317-
// return value * NumberConverter::maxValue(16) / NumberConverter::maxValue(value_bits_per_sample);
318-
// }
319-
320-
// static int16_t convert8(int value, int value_bits_per_sample){
321-
// return value * NumberConverter::maxValue(8) / NumberConverter::maxValue(value_bits_per_sample);
322-
// }
323-
324300
/// provides the biggest number for the indicated number of bits
325301
static int64_t maxValue(int value_bits_per_sample){
326302
switch(value_bits_per_sample){

src/AudioTools/CoreAudio/ResampleStream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ResampleStream : public ReformatBaseStream {
6262

6363
bool begin(ResampleConfig cfg) {
6464
LOGI("begin step_size: %f", cfg.step_size);
65-
is_output_notify = false;
65+
//is_output_notify = false;
6666
to_sample_rate = cfg.to_sample_rate;
6767
out_buffer.resize(cfg.buffer_size);
6868

@@ -161,7 +161,7 @@ class ResampleStream : public ReformatBaseStream {
161161

162162
size_t write(const uint8_t *data, size_t len) override {
163163
LOGD("ResampleStream::write: %d", (int)len);
164-
addNotifyOnFirstWrite();
164+
//addNotifyOnFirstWrite();
165165
size_t written = 0;
166166
switch (info.bits_per_sample) {
167167
case 16:

0 commit comments

Comments
 (0)