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

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

Issue 9316084: Switch back to 'int' instead of uint32 and call CancelIo before closing the socket handle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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
« no previous file with comments | « base/sync_socket_win.cc ('k') | content/renderer/media/audio_input_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/renderer/media/audio_device.h" 5 #include "content/renderer/media/audio_device.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 audio_thread_->SetThreadPriority(base::kThreadPriority_RealtimeAudio); 271 audio_thread_->SetThreadPriority(base::kThreadPriority_RealtimeAudio);
272 272
273 base::SharedMemory shared_memory(shared_memory_handle_, false); 273 base::SharedMemory shared_memory(shared_memory_handle_, false);
274 shared_memory.Map(media::TotalSharedMemorySizeInBytes(memory_length_)); 274 shared_memory.Map(media::TotalSharedMemorySizeInBytes(memory_length_));
275 base::CancelableSyncSocket* audio_socket = audio_socket_.get(); 275 base::CancelableSyncSocket* audio_socket = audio_socket_.get();
276 276
277 const int samples_per_ms = static_cast<int>(sample_rate_) / 1000; 277 const int samples_per_ms = static_cast<int>(sample_rate_) / 1000;
278 const int bytes_per_ms = channels_ * (bits_per_sample_ / 8) * samples_per_ms; 278 const int bytes_per_ms = channels_ * (bits_per_sample_ / 8) * samples_per_ms;
279 279
280 while (true) { 280 while (true) {
281 uint32 pending_data = 0; 281 int pending_data = 0;
282 size_t bytes_read = audio_socket->Receive(&pending_data, 282 size_t bytes_read = audio_socket->Receive(&pending_data,
283 sizeof(pending_data)); 283 sizeof(pending_data));
284 if (bytes_read != sizeof(pending_data)) { 284 if (bytes_read != sizeof(pending_data)) {
285 DCHECK_EQ(bytes_read, 0U); 285 DCHECK_EQ(bytes_read, 0U);
286 break; 286 break;
287 } 287 }
288 288
289 if (pending_data == 289 if (pending_data == media::AudioOutputController::kPauseMark) {
290 static_cast<uint32>(media::AudioOutputController::kPauseMark)) {
291 memset(shared_memory.memory(), 0, memory_length_); 290 memset(shared_memory.memory(), 0, memory_length_);
292 media::SetActualDataSizeInBytes(&shared_memory, memory_length_, 0); 291 media::SetActualDataSizeInBytes(&shared_memory, memory_length_, 0);
293 continue; 292 continue;
294 } 293 }
295 294
296 // Convert the number of pending bytes in the render buffer 295 // Convert the number of pending bytes in the render buffer
297 // into milliseconds. 296 // into milliseconds.
298 audio_delay_milliseconds_ = pending_data / bytes_per_ms; 297 audio_delay_milliseconds_ = pending_data / bytes_per_ms;
299 size_t num_frames = FireRenderCallback( 298 size_t num_frames = FireRenderCallback(
300 reinterpret_cast<int16*>(shared_memory.memory())); 299 reinterpret_cast<int16*>(shared_memory.memory()));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 // Close the socket to terminate the main thread function in the 333 // Close the socket to terminate the main thread function in the
335 // audio thread. 334 // audio thread.
336 audio_socket_->Shutdown(); // Stops blocking Receive calls. 335 audio_socket_->Shutdown(); // Stops blocking Receive calls.
337 // TODO(tommi): We must not do this from the IO thread. Fix. 336 // TODO(tommi): We must not do this from the IO thread. Fix.
338 base::ThreadRestrictions::ScopedAllowIO allow_wait; 337 base::ThreadRestrictions::ScopedAllowIO allow_wait;
339 audio_thread_->Join(); 338 audio_thread_->Join();
340 audio_thread_.reset(NULL); 339 audio_thread_.reset(NULL);
341 audio_socket_.reset(); 340 audio_socket_.reset();
342 } 341 }
343 } 342 }
OLDNEW
« no previous file with comments | « base/sync_socket_win.cc ('k') | content/renderer/media/audio_input_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698