Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: webrtc/voice_engine/audio_frame_pool.h

Issue 2665693002: Moves channel-dependent audio input processing to separate encoder task queue (Closed)
Patch Set: cleanup Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/voice_engine/audio_frame_pool.h
diff --git a/webrtc/voice_engine/audio_frame_pool.h b/webrtc/voice_engine/audio_frame_pool.h
new file mode 100644
index 0000000000000000000000000000000000000000..d1725e6e5078d9ac9237e2a0502bef71006683b3
--- /dev/null
+++ b/webrtc/voice_engine/audio_frame_pool.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_VOICE_ENGINE_AUDIO_FRAME_POOL_H_
+#define WEBRTC_VOICE_ENGINE_AUDIO_FRAME_POOL_H_
+
+#include <limits>
+#include <memory>
+#include <utility>
+
+#include "webrtc/base/checks.h"
+#include "webrtc/base/constructormagic.h"
+#include "webrtc/base/logging.h"
+#include "webrtc/base/swap_queue.h"
+#include "webrtc/modules/include/module_common_types.h"
+
+namespace webrtc {
+
+// Wraps usage of SwapQueue and creates a queue of allocated audio frames.
+// The user can then add or remove audio frames in an efficient manner and
+// thereby avoid continus resource allocations.
+class AudioFramePool {
+ public:
+ // Creates and allocates resources for a pool of |capacity| elements.
+ explicit AudioFramePool(size_t capacity);
+ ~AudioFramePool();
+
+ // Number of elements in the pool.
+ size_t size() const { return audio_frame_queue_.Size(); }
tommi 2017/03/28 13:01:40 thread check?
+
+ // Adds an audio frame to the pool.
+ void Push(std::unique_ptr<AudioFrame> audio_frame);
+
+ // Returns an audio frame from the pool.
+ std::unique_ptr<AudioFrame> Pop();
+
+ private:
+ // The internal swap queue is thread safe. Hence, not adding any extra locks
+ // in this wrapper even if consumer and producer are on separate threads.
+ SwapQueue<std::unique_ptr<AudioFrame>> audio_frame_queue_;
+
+ // Tracks minimum size (number of elements). Used for debugging purposes
+ // to find a suitable capacity.
+ size_t min_size_ = std::numeric_limits<std::size_t>::max();
+
+ RTC_DISALLOW_COPY_AND_ASSIGN(AudioFramePool);
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_VOICE_ENGINE_AUDIO_FRAME_POOL_H_

Powered by Google App Engine
This is Rietveld 408576698