Skip to content

Commit 2f79c75

Browse files
committed
Allign AudioInfo across the different objects
1 parent 4b51829 commit 2f79c75

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/api/SnapOutput.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ class SnapOutput : public AudioInfoSupport {
9191
resample.setOutput(output);
9292
vol_stream.setStream(resample); // adjust volume
9393
decoder_stream.setStream(&vol_stream); // decode to pcm
94+
95+
// synchronized audio information
96+
AudioInfo info = output.audioInfo();
97+
resample.begin(info, info);
98+
vol_stream.setAudioInfo(info);
99+
decoder_stream.setAudioInfo(info);
94100
}
95101

96102
AudioOutput &getOutput() { return *out; }
@@ -122,9 +128,12 @@ class SnapOutput : public AudioInfoSupport {
122128

123129
// writes the audio data to the decoder
124130
size_t audioWrite(const void *src, size_t size) {
125-
ESP_LOGD(TAG, "%zu", size);
131+
ESP_LOGI(TAG, "audioWrite: %zu", size);
126132
time_last_write = millis();
127133
size_t result = decoder_stream.write((const uint8_t *)src, size);
134+
if (result != size){
135+
ESP_LOGW(TAG, "Could not write all data %zu -> %zu", size, result);
136+
}
128137

129138
return result;
130139
}
@@ -198,6 +207,9 @@ class SnapOutput : public AudioInfoSupport {
198207
return false;
199208
}
200209

210+
// determine default audio info from output
211+
audio_info = out->audioInfo();
212+
201213
// open volume control: allow amplification
202214
auto vol_cfg = vol_stream.defaultConfig();
203215
vol_cfg.copyFrom(audio_info);

0 commit comments

Comments
 (0)