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

Side by Side Diff: media/audio/audio_device_thread.h

Issue 2060833002: Implementation of 'AudioContext.getOutputTimestamp' method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implementation of 'AudioContext.getOutputTimestamp' method 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_
6 #define MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ 6 #define MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
13 #include "base/sync_socket.h" 13 #include "base/sync_socket.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "media/audio/audio_io.h"
15 #include "media/base/audio_parameters.h" 16 #include "media/base/audio_parameters.h"
16 #include "media/base/media_export.h" 17 #include "media/base/media_export.h"
17 18
18 namespace base { 19 namespace base {
19 class MessageLoop; 20 class MessageLoop;
20 } 21 }
21 22
22 namespace media { 23 namespace media {
23 class AudioBus; 24 class AudioBus;
25 struct AudioTimestamp;
24 26
25 // Data transfer between browser and render process uses a combination 27 // Data transfer between browser and render process uses a combination
26 // of sync sockets and shared memory. To read from the socket and render 28 // of sync sockets and shared memory. To read from the socket and render
27 // data, we use a worker thread, a.k.a. the AudioDeviceThread, which reads 29 // data, we use a worker thread, a.k.a. the AudioDeviceThread, which reads
28 // data from the browser via the socket and fills the shared memory from the 30 // data from the browser via the socket and fills the shared memory from the
29 // audio thread via the AudioDeviceThread::Callback interface/class. 31 // audio thread via the AudioDeviceThread::Callback interface/class.
30 // For more details see the documentation in audio_device.h. 32 // For more details see the documentation in audio_device.h.
31 // 33 //
32 // TODO(tommi): Multiple audio input/output device instances should be able to 34 // TODO(tommi): Multiple audio input/output device instances should be able to
33 // share the same thread instead of spinning one per instance. 35 // share the same thread instead of spinning one per instance.
(...skipping 10 matching lines...) Expand all
44 int total_segments); 46 int total_segments);
45 virtual ~Callback(); 47 virtual ~Callback();
46 48
47 // One time initialization for the callback object on the audio thread. 49 // One time initialization for the callback object on the audio thread.
48 void InitializeOnAudioThread(); 50 void InitializeOnAudioThread();
49 51
50 // Derived implementations must call shared_memory_.Map appropriately 52 // Derived implementations must call shared_memory_.Map appropriately
51 // before Process can be called. 53 // before Process can be called.
52 virtual void MapSharedMemory() = 0; 54 virtual void MapSharedMemory() = 0;
53 55
54 // Called whenever we receive notifications about pending input data. 56 // Called whenever we receive notifications about pending input data.
hongchan 2016/06/14 17:10:38 Let's expand the comment to reflect the change of
Mikhail 2016/06/17 09:36:57 Done.
55 virtual void Process(uint32_t pending_data) = 0; 57 virtual void Process(uint32_t pending_data,
58 const AudioTimestamp& timestamp) = 0;
56 59
57 protected: 60 protected:
58 // Protected so that derived classes can access directly. 61 // Protected so that derived classes can access directly.
59 // The variables are 'const' since values are calculated/set in the 62 // The variables are 'const' since values are calculated/set in the
60 // constructor and must never change. 63 // constructor and must never change.
61 const AudioParameters audio_parameters_; 64 const AudioParameters audio_parameters_;
62 const double samples_per_ms_; 65 const double samples_per_ms_;
63 const double bytes_per_ms_; 66 const double bytes_per_ms_;
64 const uint32_t bytes_per_frame_; 67 const uint32_t bytes_per_frame_;
65 68
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 112
110 base::Lock thread_lock_; 113 base::Lock thread_lock_;
111 scoped_refptr<AudioDeviceThread::Thread> thread_; 114 scoped_refptr<AudioDeviceThread::Thread> thread_;
112 115
113 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); 116 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread);
114 }; 117 };
115 118
116 } // namespace media. 119 } // namespace media.
117 120
118 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ 121 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698