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

Unified Diff: webrtc/modules/audio_mixer/source/memory_pool.h

Issue 2109133003: Added empty directory with myself as owner for new mixer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Renamed to avoid compilation crashes and added build file. Created 4 years, 6 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/modules/audio_mixer/source/memory_pool.h
diff --git a/webrtc/modules/audio_mixer/source/memory_pool.h b/webrtc/modules/audio_mixer/source/memory_pool.h
new file mode 100644
index 0000000000000000000000000000000000000000..0b88aa1fc0bf196c15b9fff13aecfc116f854138
--- /dev/null
+++ b/webrtc/modules/audio_mixer/source/memory_pool.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2011 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_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_MEMORY_POOL_H_
+#define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_MEMORY_POOL_H_
+
+#include <assert.h>
+
+#include "webrtc/typedefs.h"
+
+#if _WIN32
+#include "webrtc/modules/audio_conference_mixer/source/memory_pool_win.h"
+#else
+#include "webrtc/modules/audio_conference_mixer/source/memory_pool_posix.h"
+#endif
+
+namespace webrtc {
+
+template <class MemoryType>
+class MemoryPool {
+ public:
+ // Factory method, constructor disabled.
+ static int32_t CreateMemoryPool(MemoryPool*& memoryPool,
+ uint32_t initialPoolSize);
+
+ // Try to delete the memory pool. Fail with return value -1 if there is
+ // outstanding memory.
+ static int32_t DeleteMemoryPool(MemoryPool*& memoryPool);
+
+ // Get/return unused memory.
+ int32_t PopMemory(MemoryType*& memory);
+ int32_t PushMemory(MemoryType*& memory);
+
+ private:
+ MemoryPool(int32_t initialPoolSize);
+ ~MemoryPool();
+
+ MemoryPoolImpl<MemoryType>* _ptrImpl;
+};
+
+template <class MemoryType>
+MemoryPool<MemoryType>::MemoryPool(int32_t initialPoolSize) {
+ _ptrImpl = new MemoryPoolImpl<MemoryType>(initialPoolSize);
+}
+
+template <class MemoryType>
+MemoryPool<MemoryType>::~MemoryPool() {
+ delete _ptrImpl;
+}
+
+template <class MemoryType>
+int32_t MemoryPool<MemoryType>::CreateMemoryPool(MemoryPool*& memoryPool,
+ uint32_t initialPoolSize) {
+ memoryPool = new MemoryPool(initialPoolSize);
+ if (memoryPool == NULL) {
+ return -1;
+ }
+ if (memoryPool->_ptrImpl == NULL) {
+ delete memoryPool;
+ memoryPool = NULL;
+ return -1;
+ }
+ if (!memoryPool->_ptrImpl->Initialize()) {
+ delete memoryPool;
+ memoryPool = NULL;
+ return -1;
+ }
+ return 0;
+}
+
+template <class MemoryType>
+int32_t MemoryPool<MemoryType>::DeleteMemoryPool(MemoryPool*& memoryPool) {
+ if (memoryPool == NULL) {
+ return -1;
+ }
+ if (memoryPool->_ptrImpl == NULL) {
+ return -1;
+ }
+ if (memoryPool->_ptrImpl->Terminate() == -1) {
+ return -1;
+ }
+ delete memoryPool;
+ memoryPool = NULL;
+ return 0;
+}
+
+template <class MemoryType>
+int32_t MemoryPool<MemoryType>::PopMemory(MemoryType*& memory) {
+ return _ptrImpl->PopMemory(memory);
+}
+
+template <class MemoryType>
+int32_t MemoryPool<MemoryType>::PushMemory(MemoryType*& memory) {
+ if (memory == NULL) {
+ return -1;
+ }
+ return _ptrImpl->PushMemory(memory);
+}
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_MEMORY_POOL_H_
« no previous file with comments | « webrtc/modules/audio_mixer/source/audio_frame_manipulator.cc ('k') | webrtc/modules/audio_mixer/source/memory_pool_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698