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

Side by Side Diff: chrome/renderer/audio_device.h

Issue 6002005: Implement renderer AudioDevice API for low-latency audio output... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/audio_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_RENDERER_AUDIO_DEVICE_H_
6 #define CHROME_RENDERER_AUDIO_DEVICE_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/scoped_ptr.h"
13 #include "base/shared_memory.h"
14 #include "base/threading/simple_thread.h"
15 #include "chrome/common/render_messages.h"
16 #include "chrome/renderer/audio_message_filter.h"
17
18 // Each instance of AudioDevice corresponds to one host stream.
19 // This class is not thread-safe, so its methods must be called from
20 // the same thread.
21 class AudioDevice : public AudioMessageFilter::Delegate,
22 public base::DelegateSimpleThread::Delegate {
23 public:
24 class RenderCallback {
25 public:
26 virtual void Render(const std::vector<float*>& audio_data,
27 size_t number_of_frames) = 0;
28 protected:
29 virtual ~RenderCallback() {}
30 };
31
32 // |buffer_size| is the number of sample-frames.
33 AudioDevice(size_t buffer_size,
34 int channels,
35 double sample_rate,
36 RenderCallback* callback);
37 virtual ~AudioDevice();
38
39 // Returns |true| on success.
40 bool Start();
41 bool Stop();
42
43 private:
44 // AudioMessageFilter::Delegate implementation.
45 virtual void OnRequestPacket(AudioBuffersState buffers_state);
46 virtual void OnStateChanged(const ViewMsg_AudioStreamState_Params& state);
47 virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length);
48 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle,
49 base::SyncSocket::Handle socket_handle,
50 uint32 length);
51 virtual void OnVolume(double volume);
52 virtual void OnDestroy();
53
54 // DelegateSimpleThread::Delegate implementation.
55 virtual void Run();
56
57 // Format
58 size_t buffer_size_; // in sample-frames
59 int channels_;
60 double sample_rate_;
61
62 // Calls the client's callback for rendering audio.
63 void FireRenderCallback();
64 RenderCallback* callback_;
65
66 // The client callback renders audio into here.
67 std::vector<float*> audio_data_;
68
69 // Callbacks for rendering audio occur on this thread.
70 scoped_ptr<base::DelegateSimpleThread> audio_thread_;
71
72 // IPC message stuff.
73 base::SharedMemory* shared_memory() { return shared_memory_.get(); }
74 base::SyncSocket* socket() { return socket_.get(); }
75 void* shared_memory_data() { return shared_memory()->memory(); }
76
77 static scoped_refptr<AudioMessageFilter> filter_;
78 int32 stream_id_;
79 scoped_ptr<base::SharedMemory> shared_memory_;
80 scoped_ptr<base::SyncSocket> socket_;
81
82 DISALLOW_COPY_AND_ASSIGN(AudioDevice);
83 };
84
85 #endif // CHROME_RENDERER_AUDIO_DEVICE_H_
OLDNEW
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/audio_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698