diff options
author | Paul Adenot <[email protected]> | 2017-08-14 15:56:17 +0200 |
---|---|---|
committer | Paul Adenot <[email protected]> | 2017-08-29 10:09:08 +0100 |
commit | 42404c88bd636c5e8a960060bc03c0859b1d4e1b (patch) | |
tree | 60e93701a27529c8f358907c4f5af3b28c686008 /src/cubeb_ringbuffer.h | |
parent | c3edd7f49f684a5dc5be683b07d43c0d5c2a7b4f (diff) | |
download | cubeb-42404c88bd636c5e8a960060bc03c0859b1d4e1b.tar.gz cubeb-42404c88bd636c5e8a960060bc03c0859b1d4e1b.zip |
Add a thread reset API for the ring buffer class.
This allow reseting the consumer/producer thread id in the ring buffer
class, so that we can take into account the change in thread inherent to
the audio devices changes.
This fixes #320.
Diffstat (limited to 'src/cubeb_ringbuffer.h')
-rw-r--r-- | src/cubeb_ringbuffer.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cubeb_ringbuffer.h b/src/cubeb_ringbuffer.h index ac5bf8c..d40f2ff 100644 --- a/src/cubeb_ringbuffer.h +++ b/src/cubeb_ringbuffer.h @@ -226,6 +226,17 @@ public: { return storage_capacity() - 1; } + /** + * Reset the consumer and producer thread identifier, in case the thread are + * being changed. This has to be externally synchronized. This is no-op when + * asserts are disabled. + */ + void reset_thread_ids() + { +#ifndef DEBUG + consumer_id = producer_id = std::thread::id(); +#endif + } private: /** Return true if the ring buffer is empty. * |