Skip to content

Commit

Permalink
🤏 [InputStream] Clear the samples when changing device
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFouchy committed Nov 3, 2023
1 parent acda094 commit 8599272
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/InputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ void InputStream::set_device(unsigned int device_id)
if (_backend.isStreamOpen())
_backend.closeStream();

{ // Clear the samples, they do not correspond to the new device. (Shouldn't really matter, but I guess this is technically more correct)
std::lock_guard const lock{_samples_mutex};
_samples.clear();
}

auto const info = _backend.getDeviceInfo(device_id);
RtAudio::StreamParameters params;
params.deviceId = device_id;
Expand Down

0 comments on commit 8599272

Please sign in to comment.