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

Side by Side Diff: content/browser/renderer_host/media/audio_input_sync_writer.cc

Issue 2822123002: Avoid log spam in AudioSyncReader. (Closed)
Patch Set: Created 3 years, 8 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 (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/browser/renderer_host/media/audio_input_sync_writer.h" 5 #include "content/browser/renderer_host/media/audio_input_sync_writer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility>
8 9
9 #include "base/format_macros.h" 10 #include "base/format_macros.h"
10 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "content/browser/renderer_host/media/media_stream_manager.h" 15 #include "content/browser/renderer_host/media/media_stream_manager.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 17
17 using media::AudioBus; 18 using media::AudioBus;
(...skipping 22 matching lines...) Expand all
40 shared_memory_segment_count_(shared_memory_segment_count), 41 shared_memory_segment_count_(shared_memory_segment_count),
41 current_segment_id_(0), 42 current_segment_id_(0),
42 creation_time_(base::Time::Now()), 43 creation_time_(base::Time::Now()),
43 audio_bus_memory_size_(AudioBus::CalculateMemorySize(params)), 44 audio_bus_memory_size_(AudioBus::CalculateMemorySize(params)),
44 next_buffer_id_(0), 45 next_buffer_id_(0),
45 next_read_buffer_index_(0), 46 next_read_buffer_index_(0),
46 number_of_filled_segments_(0), 47 number_of_filled_segments_(0),
47 write_count_(0), 48 write_count_(0),
48 write_to_fifo_count_(0), 49 write_to_fifo_count_(0),
49 write_error_count_(0), 50 write_error_count_(0),
51 had_socket_error_(false),
50 trailing_write_to_fifo_count_(0), 52 trailing_write_to_fifo_count_(0),
51 trailing_write_error_count_(0) { 53 trailing_write_error_count_(0) {
52 DCHECK_GT(shared_memory_segment_count, 0); 54 DCHECK_GT(shared_memory_segment_count, 0);
53 DCHECK_EQ(shared_memory_size % shared_memory_segment_count, 0u); 55 DCHECK_EQ(shared_memory_size % shared_memory_segment_count, 0u);
54 shared_memory_segment_size_ = 56 shared_memory_segment_size_ =
55 shared_memory_size / shared_memory_segment_count; 57 shared_memory_size / shared_memory_segment_count;
56 DVLOG(1) << "shared_memory_size: " << shared_memory_size; 58 DVLOG(1) << "shared_memory_size: " << shared_memory_size;
57 DVLOG(1) << "shared_memory_segment_count: " << shared_memory_segment_count; 59 DVLOG(1) << "shared_memory_segment_count: " << shared_memory_segment_count;
58 DVLOG(1) << "audio_bus_memory_size: " << audio_bus_memory_size_; 60 DVLOG(1) << "audio_bus_memory_size: " << audio_bus_memory_size_;
59 61
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); 322 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr);
321 buffer->params.volume = volume; 323 buffer->params.volume = volume;
322 buffer->params.size = audio_bus_memory_size_; 324 buffer->params.size = audio_bus_memory_size_;
323 buffer->params.key_pressed = key_pressed; 325 buffer->params.key_pressed = key_pressed;
324 buffer->params.hardware_delay_bytes = hardware_delay_bytes; 326 buffer->params.hardware_delay_bytes = hardware_delay_bytes;
325 buffer->params.id = next_buffer_id_; 327 buffer->params.id = next_buffer_id_;
326 } 328 }
327 329
328 bool AudioInputSyncWriter::SignalDataWrittenAndUpdateCounters() { 330 bool AudioInputSyncWriter::SignalDataWrittenAndUpdateCounters() {
329 if (socket_->Send(&current_segment_id_, sizeof(current_segment_id_)) != 331 if (socket_->Send(&current_segment_id_, sizeof(current_segment_id_)) !=
330 sizeof(current_segment_id_)) { 332 sizeof(current_segment_id_) &&
333 !had_socket_error_) {
334 had_socket_error_ = true;
tommi (sloooow) - chröme 2017/04/18 09:39:28 Can we ever recover from this? If not, can we have
Max Morin 2017/04/18 09:55:28 In the case in the bug (other end of sync socket i
tommi (sloooow) - chröme 2017/04/19 10:44:35 Yes I think that would be a safer change to make a
Max Morin 2017/04/19 11:51:00 Makes sense. I changed it.
331 const std::string error_message = "AISW: No room in socket buffer."; 335 const std::string error_message = "AISW: No room in socket buffer.";
332 LOG(WARNING) << error_message; 336 PLOG(WARNING) << error_message;
333 AddToNativeLog(error_message); 337 AddToNativeLog(error_message);
334 TRACE_EVENT_INSTANT0("audio", 338 TRACE_EVENT_INSTANT0("audio",
335 "AudioInputSyncWriter: No room in socket buffer", 339 "AudioInputSyncWriter: No room in socket buffer",
336 TRACE_EVENT_SCOPE_THREAD); 340 TRACE_EVENT_SCOPE_THREAD);
337 return false; 341 return false;
338 } 342 }
339 343
340 if (++current_segment_id_ >= shared_memory_segment_count_) 344 if (++current_segment_id_ >= shared_memory_segment_count_)
341 current_segment_id_ = 0; 345 current_segment_id_ = 0;
342 ++number_of_filled_segments_; 346 ++number_of_filled_segments_;
343 CHECK_LE(number_of_filled_segments_, 347 CHECK_LE(number_of_filled_segments_,
344 static_cast<int>(shared_memory_segment_count_)); 348 static_cast<int>(shared_memory_segment_count_));
345 ++next_buffer_id_; 349 ++next_buffer_id_;
346 350
347 return true; 351 return true;
348 } 352 }
349 353
350 } // namespace content 354 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698