Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / renderer_host / media / audio_input_sync_writer.h
blob1ace401441faec0bff55226b875064876ae94216
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_
8 #include "base/memory/scoped_vector.h"
9 #include "base/process/process.h"
10 #include "base/sync_socket.h"
11 #include "base/time/time.h"
12 #include "media/audio/audio_input_controller.h"
13 #include "media/audio/audio_parameters.h"
14 #include "media/base/audio_bus.h"
16 #if defined(OS_POSIX)
17 #include "base/file_descriptor_posix.h"
18 #endif
20 namespace base {
21 class SharedMemory;
24 namespace content {
25 // A AudioInputController::SyncWriter implementation using SyncSocket. This
26 // is used by AudioInputController to provide a low latency data source for
27 // transmitting audio packets between the browser process and the renderer
28 // process.
29 class AudioInputSyncWriter : public media::AudioInputController::SyncWriter {
30 public:
31 explicit AudioInputSyncWriter(base::SharedMemory* shared_memory,
32 int shared_memory_segment_count,
33 const media::AudioParameters& params);
35 ~AudioInputSyncWriter() override;
37 // media::AudioInputController::SyncWriter implementation.
38 void UpdateRecordedBytes(uint32 bytes) override;
39 void Write(const media::AudioBus* data,
40 double volume,
41 bool key_pressed) override;
42 void Close() override;
44 bool Init();
45 bool PrepareForeignSocket(base::ProcessHandle process_handle,
46 base::SyncSocket::TransitDescriptor* descriptor);
48 private:
49 base::SharedMemory* shared_memory_;
50 uint32 shared_memory_segment_size_;
51 uint32 shared_memory_segment_count_;
52 uint32 current_segment_id_;
54 // Socket for transmitting audio data.
55 scoped_ptr<base::CancelableSyncSocket> socket_;
57 // Socket to be used by the renderer. The reference is released after
58 // PrepareForeignSocketHandle() is called and ran successfully.
59 scoped_ptr<base::CancelableSyncSocket> foreign_socket_;
61 // The time of the creation of this object.
62 base::Time creation_time_;
64 // The time of the last Write call.
65 base::Time last_write_time_;
67 // Size in bytes of each audio bus.
68 const int audio_bus_memory_size_;
70 // Vector of audio buses allocated during construction and deleted in the
71 // destructor.
72 ScopedVector<media::AudioBus> audio_buses_;
74 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputSyncWriter);
77 } // namespace content
79 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_