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

Side by Side Diff: content/browser/renderer_host/media/audio_sync_reader.h

Issue 10832285: Switch OnMoreData() to use AudioBus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 8 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) 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 CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_
7 7
8 #include "base/file_descriptor_posix.h" 8 #include "base/file_descriptor_posix.h"
9 #include "base/process.h" 9 #include "base/process.h"
10 #include "base/sync_socket.h" 10 #include "base/sync_socket.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "media/audio/audio_output_controller.h" 13 #include "media/audio/audio_output_controller.h"
14 #include "media/base/audio_bus.h"
14 15
15 namespace base { 16 namespace base {
16 class SharedMemory; 17 class SharedMemory;
17 } 18 }
18 19
19 // A AudioOutputController::SyncReader implementation using SyncSocket. This 20 // A AudioOutputController::SyncReader implementation using SyncSocket. This
20 // is used by AudioOutputController to provide a low latency data source for 21 // is used by AudioOutputController to provide a low latency data source for
21 // transmitting audio packets between the browser process and the renderer 22 // transmitting audio packets between the browser process and the renderer
22 // process. 23 // process.
23 class AudioSyncReader : public media::AudioOutputController::SyncReader { 24 class AudioSyncReader : public media::AudioOutputController::SyncReader {
24 public: 25 public:
25 explicit AudioSyncReader(base::SharedMemory* shared_memory); 26 AudioSyncReader(base::SharedMemory* shared_memory,
27 const media::AudioParameters& params);
26 28
27 virtual ~AudioSyncReader(); 29 virtual ~AudioSyncReader();
28 30
29 // media::AudioOutputController::SyncReader implementations. 31 // media::AudioOutputController::SyncReader implementations.
30 virtual void UpdatePendingBytes(uint32 bytes) OVERRIDE; 32 virtual void UpdatePendingBytes(uint32 bytes) OVERRIDE;
31 virtual uint32 Read(void* data, uint32 size) OVERRIDE; 33 virtual int Read(media::AudioBus* audio_bus) OVERRIDE;
32 virtual void Close() OVERRIDE; 34 virtual void Close() OVERRIDE;
33 virtual bool DataReady() OVERRIDE; 35 virtual bool DataReady() OVERRIDE;
34 36
35 bool Init(); 37 bool Init();
36 bool PrepareForeignSocketHandle(base::ProcessHandle process_handle, 38 bool PrepareForeignSocketHandle(base::ProcessHandle process_handle,
37 #if defined(OS_WIN) 39 #if defined(OS_WIN)
38 base::SyncSocket::Handle* foreign_handle); 40 base::SyncSocket::Handle* foreign_handle);
39 #else 41 #else
40 base::FileDescriptor* foreign_handle); 42 base::FileDescriptor* foreign_handle);
41 #endif 43 #endif
42 44
43 private: 45 private:
44 base::SharedMemory* shared_memory_; 46 base::SharedMemory* shared_memory_;
45 base::Time previous_call_time_; 47 base::Time previous_call_time_;
46 48
47 // Socket for transmitting audio data. 49 // Socket for transmitting audio data.
48 scoped_ptr<base::CancelableSyncSocket> socket_; 50 scoped_ptr<base::CancelableSyncSocket> socket_;
49 51
50 // Socket to be used by the renderer. The reference is released after 52 // Socket to be used by the renderer. The reference is released after
51 // PrepareForeignSocketHandle() is called and ran successfully. 53 // PrepareForeignSocketHandle() is called and ran successfully.
52 scoped_ptr<base::CancelableSyncSocket> foreign_socket_; 54 scoped_ptr<base::CancelableSyncSocket> foreign_socket_;
53 55
56 // Shared memory wrapper used for transfering audio data to Read() callers.
scherkus (not reviewing) 2012/08/27 20:46:55 s/transfering/transferring
DaleCurtis 2012/08/29 04:34:43 Done.
57 scoped_ptr<media::AudioBus> audio_bus_;
58
59 // Maximum amount of audio data which can be transferred in one Read() call.
60 int packet_size_;
61
54 DISALLOW_COPY_AND_ASSIGN(AudioSyncReader); 62 DISALLOW_COPY_AND_ASSIGN(AudioSyncReader);
55 }; 63 };
56 64
57 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ 65 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698