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

Unified Diff: media/audio/audio_device_thread.h

Issue 12379071: Use multiple shared memory buffers cyclically for audio capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: rebase Created 7 years, 10 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: media/audio/audio_device_thread.h
===================================================================
--- media/audio/audio_device_thread.h (revision 186213)
+++ media/audio/audio_device_thread.h (working copy)
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "base/shared_memory.h"
#include "base/sync_socket.h"
#include "base/synchronization/lock.h"
@@ -36,8 +37,10 @@
// thread owned by AudioDeviceThread.
class Callback {
public:
+ typedef std::vector<base::SharedMemoryHandle> SharedMemoryHandleVector;
+
Callback(const AudioParameters& audio_parameters,
- base::SharedMemoryHandle memory,
+ SharedMemoryHandleVector& memory,
int memory_length);
virtual ~Callback();
@@ -49,7 +52,8 @@
virtual void MapSharedMemory() = 0;
// Called whenever we receive notifications about pending data.
- virtual void Process(int pending_data) = 0;
+ // The |index| states which shared memory buffer is used.
+ virtual void Process(int pending_data, int index) = 0;
protected:
// Protected so that derived classes can access directly.
@@ -59,14 +63,14 @@
const int samples_per_ms_;
const int bytes_per_ms_;
- base::SharedMemory shared_memory_;
+ ScopedVector<base::SharedMemory> shared_memory_;
const int memory_length_;
private:
DISALLOW_COPY_AND_ASSIGN(Callback);
};
- AudioDeviceThread();
+ AudioDeviceThread(bool need_read_index);
~AudioDeviceThread();
// Starts the audio thread. The thread must not already be running.
@@ -98,6 +102,9 @@
// reliable initialization.
class Thread;
+ // Flag indicating whether need to read index from sync socket.
+ bool need_read_index_;
+
base::Lock thread_lock_;
scoped_refptr<AudioDeviceThread::Thread> thread_;

Powered by Google App Engine
This is Rietveld 408576698