OLD | NEW |
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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/sync_socket.h" | 9 #include "base/sync_socket.h" |
10 #include "content/browser/media/capture/audio_mirroring_manager.h" | 10 #include "content/browser/media/capture/audio_mirroring_manager.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 IPC_MESSAGE_HANDLER(AudioMsg_NotifyStreamStateChanged, | 94 IPC_MESSAGE_HANDLER(AudioMsg_NotifyStreamStateChanged, |
95 OnNotifyStreamStateChanged) | 95 OnNotifyStreamStateChanged) |
96 IPC_MESSAGE_UNHANDLED(handled = false) | 96 IPC_MESSAGE_UNHANDLED(handled = false) |
97 IPC_END_MESSAGE_MAP() | 97 IPC_END_MESSAGE_MAP() |
98 EXPECT_TRUE(handled); | 98 EXPECT_TRUE(handled); |
99 | 99 |
100 delete message; | 100 delete message; |
101 return true; | 101 return true; |
102 } | 102 } |
103 | 103 |
104 void OnNotifyStreamCreated(int stream_id, | 104 void OnNotifyStreamCreated( |
105 base::SharedMemoryHandle handle, | 105 int stream_id, |
106 #if defined(OS_WIN) | 106 base::SharedMemoryHandle handle, |
107 base::SyncSocket::Handle socket_handle, | 107 base::SyncSocket::TransitDescriptor socket_descriptor, |
108 #else | 108 uint32 length) { |
109 base::FileDescriptor socket_descriptor, | |
110 #endif | |
111 uint32 length) { | |
112 // Maps the shared memory. | 109 // Maps the shared memory. |
113 shared_memory_.reset(new base::SharedMemory(handle, false)); | 110 shared_memory_.reset(new base::SharedMemory(handle, false)); |
114 CHECK(shared_memory_->Map(length)); | 111 CHECK(shared_memory_->Map(length)); |
115 CHECK(shared_memory_->memory()); | 112 CHECK(shared_memory_->memory()); |
116 shared_memory_length_ = length; | 113 shared_memory_length_ = length; |
117 | 114 |
118 // Create the SyncSocket using the handle. | 115 // Create the SyncSocket using the handle. |
119 base::SyncSocket::Handle sync_socket_handle; | 116 base::SyncSocket::Handle sync_socket_handle = |
120 #if defined(OS_WIN) | 117 base::SyncSocket::UnwrapHandle(socket_descriptor); |
121 sync_socket_handle = socket_handle; | |
122 #else | |
123 sync_socket_handle = socket_descriptor.fd; | |
124 #endif | |
125 sync_socket_.reset(new base::SyncSocket(sync_socket_handle)); | 118 sync_socket_.reset(new base::SyncSocket(sync_socket_handle)); |
126 | 119 |
127 // And then delegate the call to the mock method. | 120 // And then delegate the call to the mock method. |
128 OnStreamCreated(stream_id, length); | 121 OnStreamCreated(stream_id, length); |
129 } | 122 } |
130 | 123 |
131 void OnNotifyStreamStateChanged(int stream_id, | 124 void OnNotifyStreamStateChanged(int stream_id, |
132 media::AudioOutputIPCDelegate::State state) { | 125 media::AudioOutputIPCDelegate::State state) { |
133 switch (state) { | 126 switch (state) { |
134 case media::AudioOutputIPCDelegate::kPlaying: | 127 case media::AudioOutputIPCDelegate::kPlaying: |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } | 339 } |
347 | 340 |
348 TEST_F(AudioRendererHostTest, CreateUnifiedStreamAndClose) { | 341 TEST_F(AudioRendererHostTest, CreateUnifiedStreamAndClose) { |
349 Create(true); | 342 Create(true); |
350 Close(); | 343 Close(); |
351 } | 344 } |
352 | 345 |
353 // TODO(hclam): Add tests for data conversation in low latency mode. | 346 // TODO(hclam): Add tests for data conversation in low latency mode. |
354 | 347 |
355 } // namespace content | 348 } // namespace content |
OLD | NEW |