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

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

Issue 10830268: Allow audio system to handle synchronized low-latency audio I/O (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 #include "media/base/audio_bus.h"
15 15
16 namespace base { 16 namespace base {
17 class SharedMemory; 17 class SharedMemory;
18 } 18 }
19 19
20 // A AudioOutputController::SyncReader implementation using SyncSocket. This 20 // A AudioOutputController::SyncReader implementation using SyncSocket. This
21 // 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
22 // transmitting audio packets between the browser process and the renderer 22 // transmitting audio packets between the browser process and the renderer
23 // process. 23 // process.
24 class AudioSyncReader : public media::AudioOutputController::SyncReader { 24 class AudioSyncReader : public media::AudioOutputController::SyncReader {
25 public: 25 public:
26 AudioSyncReader(base::SharedMemory* shared_memory, 26 AudioSyncReader(base::SharedMemory* shared_memory,
27 const media::AudioParameters& params); 27 const media::AudioParameters& params,
28 int input_channels);
28 29
29 virtual ~AudioSyncReader(); 30 virtual ~AudioSyncReader();
30 31
31 // media::AudioOutputController::SyncReader implementations. 32 // media::AudioOutputController::SyncReader implementations.
32 virtual void UpdatePendingBytes(uint32 bytes) OVERRIDE; 33 virtual void UpdatePendingBytes(uint32 bytes) OVERRIDE;
33 virtual int Read(media::AudioBus* audio_bus) OVERRIDE; 34 virtual int Read(media::AudioBus* source, media::AudioBus* dest) OVERRIDE;
34 virtual void Close() OVERRIDE; 35 virtual void Close() OVERRIDE;
35 virtual bool DataReady() OVERRIDE; 36 virtual bool DataReady() OVERRIDE;
36 37
37 bool Init(); 38 bool Init();
38 bool PrepareForeignSocketHandle(base::ProcessHandle process_handle, 39 bool PrepareForeignSocketHandle(base::ProcessHandle process_handle,
39 #if defined(OS_WIN) 40 #if defined(OS_WIN)
40 base::SyncSocket::Handle* foreign_handle); 41 base::SyncSocket::Handle* foreign_handle);
41 #else 42 #else
42 base::FileDescriptor* foreign_handle); 43 base::FileDescriptor* foreign_handle);
43 #endif 44 #endif
44 45
45 private: 46 private:
46 base::SharedMemory* shared_memory_; 47 base::SharedMemory* shared_memory_;
47 base::Time previous_call_time_; 48 base::Time previous_call_time_;
48 49
50 // Number of input channels for synchronized I/O.
51 int input_channels_;
52
49 // Socket for transmitting audio data. 53 // Socket for transmitting audio data.
50 scoped_ptr<base::CancelableSyncSocket> socket_; 54 scoped_ptr<base::CancelableSyncSocket> socket_;
51 55
52 // Socket to be used by the renderer. The reference is released after 56 // Socket to be used by the renderer. The reference is released after
53 // PrepareForeignSocketHandle() is called and ran successfully. 57 // PrepareForeignSocketHandle() is called and ran successfully.
54 scoped_ptr<base::CancelableSyncSocket> foreign_socket_; 58 scoped_ptr<base::CancelableSyncSocket> foreign_socket_;
55 59
56 // Shared memory wrapper used for transferring audio data to Read() callers. 60 // Shared memory wrapper used for transferring audio data to Read() callers.
57 scoped_ptr<media::AudioBus> audio_bus_; 61 scoped_ptr<media::AudioBus> output_bus_;
62
63 // Shared memory wrapper used for transferring audio data from Read() callers.
64 scoped_ptr<media::AudioBus> input_bus_;
58 65
59 // Maximum amount of audio data which can be transferred in one Read() call. 66 // Maximum amount of audio data which can be transferred in one Read() call.
60 int packet_size_; 67 int packet_size_;
61 68
62 DISALLOW_COPY_AND_ASSIGN(AudioSyncReader); 69 DISALLOW_COPY_AND_ASSIGN(AudioSyncReader);
63 }; 70 };
64 71
65 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ 72 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698