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

Side by Side Diff: content/renderer/media/audio_device.h

Issue 7631033: Very early implementation for HTMLMediaElement / Web Audio API integration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Low-latency audio rendering unit utilizing audio output stream provided 5 // Low-latency audio rendering unit utilizing audio output stream provided
6 // by browser process through IPC. 6 // by browser process through IPC.
7 // 7 //
8 // Relationship of classes. 8 // Relationship of classes.
9 // 9 //
10 // AudioOutputController AudioDevice 10 // AudioOutputController AudioDevice
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include <vector> 50 #include <vector>
51 51
52 #include "base/basictypes.h" 52 #include "base/basictypes.h"
53 #include "base/memory/scoped_ptr.h" 53 #include "base/memory/scoped_ptr.h"
54 #include "base/shared_memory.h" 54 #include "base/shared_memory.h"
55 #include "base/threading/simple_thread.h" 55 #include "base/threading/simple_thread.h"
56 #include "content/renderer/media/audio_message_filter.h" 56 #include "content/renderer/media/audio_message_filter.h"
57 57
58 struct AudioParameters; 58 struct AudioParameters;
59 59
60 class AudioDevice 60
61 : public AudioMessageFilter::Delegate, 61 class AudioSink : public base::RefCountedThreadSafe<AudioSink> {
scherkus (not reviewing) 2011/08/23 15:16:01 what's the reasoning behind using an AudioSink as
Chris Rogers 2011/08/24 00:41:52 The idea is that there can be more than one kind o
62 public base::DelegateSimpleThread::Delegate,
63 public base::RefCountedThreadSafe<AudioDevice> {
64 public: 62 public:
65 class RenderCallback { 63 class RenderCallback {
66 public: 64 public:
67 virtual void Render(const std::vector<float*>& audio_data, 65 virtual void Render(const std::vector<float*>& audio_data,
68 size_t number_of_frames, 66 size_t number_of_frames,
69 size_t audio_delay_milliseconds) = 0; 67 size_t audio_delay_milliseconds) = 0;
70 protected: 68 protected:
71 virtual ~RenderCallback() {} 69 virtual ~RenderCallback() {}
72 }; 70 };
73 71
72 // Starts audio playback. Returns |true| on success.
73 virtual bool Start() = 0;
74
75 // Stops audio playback. Returns |true| on success.
76 virtual bool Stop() = 0;
77
78 // Sets the playback volume, with range [0.0, 1.0] inclusive.
79 // Returns |true| on success.
80 virtual bool SetVolume(double volume) = 0;
81 };
82
83
84 class AudioDevice
85 : public AudioMessageFilter::Delegate,
86 public base::DelegateSimpleThread::Delegate,
87 public AudioSink {
88 public:
89
74 // Methods called on main render thread ------------------------------------- 90 // Methods called on main render thread -------------------------------------
75 AudioDevice(size_t buffer_size, 91 AudioDevice(size_t buffer_size,
76 int channels, 92 int channels,
77 double sample_rate, 93 double sample_rate,
78 RenderCallback* callback); 94 RenderCallback* callback);
79 virtual ~AudioDevice(); 95 virtual ~AudioDevice();
80 96
81 // Starts audio playback. Returns |true| on success. 97 // Starts audio playback. Returns |true| on success.
82 bool Start(); 98 bool Start();
scherkus (not reviewing) 2011/08/23 15:16:01 Start/Stop/SetVolume() should become virtual and O
Chris Rogers 2011/08/24 00:41:52 Done.
83 99
84 // Stops audio playback. Returns |true| on success. 100 // Stops audio playback. Returns |true| on success.
85 bool Stop(); 101 bool Stop();
86 102
87 // Sets the playback volume, with range [0.0, 1.0] inclusive. 103 // Sets the playback volume, with range [0.0, 1.0] inclusive.
88 // Returns |true| on success. 104 // Returns |true| on success.
89 bool SetVolume(double volume); 105 bool SetVolume(double volume);
90 106
91 // Gets the playback volume, with range [0.0, 1.0] inclusive. 107 // Gets the playback volume, with range [0.0, 1.0] inclusive.
92 // Returns |true| on success. 108 // Returns |true| on success.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 178
163 // Data transfer between browser and render process uses a combination 179 // Data transfer between browser and render process uses a combination
164 // of sync sockets and shared memory to provide lowest possible latency. 180 // of sync sockets and shared memory to provide lowest possible latency.
165 scoped_ptr<base::SharedMemory> shared_memory_; 181 scoped_ptr<base::SharedMemory> shared_memory_;
166 scoped_ptr<base::SyncSocket> socket_; 182 scoped_ptr<base::SyncSocket> socket_;
167 183
168 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDevice); 184 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDevice);
169 }; 185 };
170 186
171 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ 187 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698