diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-05-04 11:16:28 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-05-04 11:16:59 +0200 |
commit | 6ed3918317cb9b20ece88a46daaccc52d974b7bd (patch) | |
tree | f95bf412f06260e20c62aa7fa799f42554105283 /src/SampleQueue.h | |
parent | 957f67c0a5bf831ff743d03548e515ddc450e8cc (diff) | |
download | ODR-AudioEnc-6ed3918317cb9b20ece88a46daaccc52d974b7bd.tar.gz ODR-AudioEnc-6ed3918317cb9b20ece88a46daaccc52d974b7bd.tar.bz2 ODR-AudioEnc-6ed3918317cb9b20ece88a46daaccc52d974b7bd.zip |
Replace boost by C++11
std::thread doesn't support interruption like boost::thread, which
was used in the ALSA input. Everything else should be equivalent.
Diffstat (limited to 'src/SampleQueue.h')
-rw-r--r-- | src/SampleQueue.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/SampleQueue.h b/src/SampleQueue.h index 778526e..2df1934 100644 --- a/src/SampleQueue.h +++ b/src/SampleQueue.h @@ -1,8 +1,8 @@ /* - Copyright (C) 2013, 2014 + Copyright (C) 2013, 2014, 2015 Matthias P. Braendli, matthias.braendli@mpb.li - An implementation for a threadsafe queue using boost thread library + An implementation for a threadsafe queue using the C++11 thread library for audio samples. */ @@ -11,10 +11,12 @@ #define DEBUG_SAMPLE_QUEUE 0 -#include <boost/thread.hpp> +#include <mutex> #include <queue> - -#include <stdio.h> +#include <cassert> +#include <sstream> +#include <cstdio> +#include <cmath> /* This queue is meant to be used by two threads. One producer * that pushes elements into the queue, and one consumer that @@ -53,7 +55,7 @@ public: /* Push a bunch of samples into the buffer */ size_t push(const T *val, size_t len) { - boost::mutex::scoped_lock lock(m_mutex); + std::lock_guard<std::mutex> lock(m_mutex); assert(len % (m_channels * m_bytes_per_sample) == 0); @@ -81,7 +83,7 @@ public: size_t size() const { - boost::mutex::scoped_lock lock(m_mutex); + std::lock_guard<std::mutex> lock(m_mutex); return m_queue.size(); } @@ -103,7 +105,7 @@ public: */ size_t pop(T* buf, size_t len, size_t* overruns) { - boost::mutex::scoped_lock lock(m_mutex); + std::lock_guard<std::mutex> lock(m_mutex); assert(len % (m_channels * m_bytes_per_sample) == 0); @@ -163,7 +165,7 @@ public: private: std::deque<T> m_queue; - mutable boost::mutex m_mutex; + mutable std::mutex m_mutex; unsigned int m_channels; unsigned int m_bytes_per_sample; |