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

Side by Side Diff: content/renderer/media/speech_recognition_audio_sink_unittest.cc

Issue 2852803002: Remove base::SharedMemory::ShareToProcess. (Closed)
Patch Set: Compile error. Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/media/speech_recognition_audio_sink.h" 5 #include "content/renderer/media/speech_recognition_audio_sink.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 #include <utility> 10 #include <utility>
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 const blink::WebMediaStreamTrack& track, 122 const blink::WebMediaStreamTrack& track,
123 const media::AudioParameters& sink_params, 123 const media::AudioParameters& sink_params,
124 base::SharedMemoryHandle* foreign_memory_handle) { 124 base::SharedMemoryHandle* foreign_memory_handle) {
125 // Shared memory is allocated, mapped and shared. 125 // Shared memory is allocated, mapped and shared.
126 const uint32_t kSharedMemorySize = 126 const uint32_t kSharedMemorySize =
127 sizeof(media::AudioInputBufferParameters) + 127 sizeof(media::AudioInputBufferParameters) +
128 media::AudioBus::CalculateMemorySize(sink_params); 128 media::AudioBus::CalculateMemorySize(sink_params);
129 shared_memory_.reset(new base::SharedMemory()); 129 shared_memory_.reset(new base::SharedMemory());
130 ASSERT_TRUE(shared_memory_->CreateAndMapAnonymous(kSharedMemorySize)); 130 ASSERT_TRUE(shared_memory_->CreateAndMapAnonymous(kSharedMemorySize));
131 memset(shared_memory_->memory(), 0, kSharedMemorySize); 131 memset(shared_memory_->memory(), 0, kSharedMemorySize);
132 ASSERT_TRUE(shared_memory_->ShareToProcess(base::GetCurrentProcessHandle(), 132 *foreign_memory_handle = shared_memory_->handle().Duplicate();
133 foreign_memory_handle)); 133 ASSERT_TRUE(foreign_memory_handle->IsValid());
134 134
135 // Wrap the shared memory for the audio bus. 135 // Wrap the shared memory for the audio bus.
136 media::AudioInputBuffer* buffer = 136 media::AudioInputBuffer* buffer =
137 static_cast<media::AudioInputBuffer*>(shared_memory_->memory()); 137 static_cast<media::AudioInputBuffer*>(shared_memory_->memory());
138 138
139 audio_track_bus_ = media::AudioBus::WrapMemory(sink_params, buffer->audio); 139 audio_track_bus_ = media::AudioBus::WrapMemory(sink_params, buffer->audio);
140 audio_track_bus_->Zero(); 140 audio_track_bus_->Zero();
141 141
142 // Reference to the counter used to synchronize. 142 // Reference to the counter used to synchronize.
143 buffer->params.size = 0U; 143 buffer->params.size = 0U;
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 const uint32_t buffers_per_notification = Initialize(44100, 441, 16000, 1600); 539 const uint32_t buffers_per_notification = Initialize(44100, 441, 16000, 1600);
540 AssertConsumedBuffers(0U); 540 AssertConsumedBuffers(0U);
541 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); 541 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U);
542 EXPECT_CALL(*this, StoppedCallback()).Times(1); 542 EXPECT_CALL(*this, StoppedCallback()).Times(1);
543 543
544 native_track()->Stop(); 544 native_track()->Stop();
545 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); 545 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U);
546 } 546 }
547 547
548 } // namespace content 548 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/audio_message_filter_unittest.cc ('k') | content/renderer/pepper/pepper_platform_audio_output.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698