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

Side by Side Diff: components/audio_modem/audio_recorder_impl.cc

Issue 2028023002: Use valid log callback for audio modem's audio recorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | media/audio/mac/audio_auhal_mac.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/audio_modem/audio_recorder_impl.h" 5 #include "components/audio_modem/audio_recorder_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // and sends them to the whispernet decoder to process. 42 // and sends them to the whispernet decoder to process.
43 void ProcessSamples( 43 void ProcessSamples(
44 std::unique_ptr<media::AudioBus> bus, 44 std::unique_ptr<media::AudioBus> bus,
45 const AudioRecorderImpl::RecordedSamplesCallback& callback) { 45 const AudioRecorderImpl::RecordedSamplesCallback& callback) {
46 std::string samples; 46 std::string samples;
47 AudioBusToString(std::move(bus), &samples); 47 AudioBusToString(std::move(bus), &samples);
48 content::BrowserThread::PostTask( 48 content::BrowserThread::PostTask(
49 content::BrowserThread::UI, FROM_HERE, base::Bind(callback, samples)); 49 content::BrowserThread::UI, FROM_HERE, base::Bind(callback, samples));
50 } 50 }
51 51
52 void OnLogMessage(const std::string& message) {}
53
52 } // namespace 54 } // namespace
53 55
54 // Public methods. 56 // Public methods.
55 57
56 AudioRecorderImpl::AudioRecorderImpl() 58 AudioRecorderImpl::AudioRecorderImpl()
57 : is_recording_(false), 59 : is_recording_(false),
58 stream_(nullptr), 60 stream_(nullptr),
59 total_buffer_frames_(0), 61 total_buffer_frames_(0),
60 buffer_frame_index_(0) { 62 buffer_frame_index_(0) {
61 } 63 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 110 }
109 111
110 total_buffer_frames_ = kProcessIntervalMs * params.sample_rate() / 1000; 112 total_buffer_frames_ = kProcessIntervalMs * params.sample_rate() / 1000;
111 buffer_ = media::AudioBus::Create(params.channels(), total_buffer_frames_); 113 buffer_ = media::AudioBus::Create(params.channels(), total_buffer_frames_);
112 buffer_frame_index_ = 0; 114 buffer_frame_index_ = 0;
113 115
114 stream_ = input_stream_for_testing_ 116 stream_ = input_stream_for_testing_
115 ? input_stream_for_testing_.get() 117 ? input_stream_for_testing_.get()
116 : media::AudioManager::Get()->MakeAudioInputStream( 118 : media::AudioManager::Get()->MakeAudioInputStream(
117 params, media::AudioDeviceDescription::kDefaultDeviceId, 119 params, media::AudioDeviceDescription::kDefaultDeviceId,
118 media::AudioManager::LogCallback()); 120 base::Bind(&OnLogMessage));
119 121
120 if (!stream_ || !stream_->Open()) { 122 if (!stream_ || !stream_->Open()) {
121 LOG(ERROR) << "Failed to open an input stream."; 123 LOG(ERROR) << "Failed to open an input stream.";
122 if (stream_) { 124 if (stream_) {
123 stream_->Close(); 125 stream_->Close();
124 stream_ = nullptr; 126 stream_ = nullptr;
125 } 127 }
126 return; 128 return;
127 } 129 }
128 stream_->SetVolume(stream_->GetMaxVolume()); 130 stream_->SetVolume(stream_->GetMaxVolume());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 196
195 void AudioRecorderImpl::OnError(media::AudioInputStream* /* stream */) { 197 void AudioRecorderImpl::OnError(media::AudioInputStream* /* stream */) {
196 LOG(ERROR) << "Error during sound recording."; 198 LOG(ERROR) << "Error during sound recording.";
197 media::AudioManager::Get()->GetTaskRunner()->PostTask( 199 media::AudioManager::Get()->GetTaskRunner()->PostTask(
198 FROM_HERE, 200 FROM_HERE,
199 base::Bind(&AudioRecorderImpl::StopAndCloseOnAudioThread, 201 base::Bind(&AudioRecorderImpl::StopAndCloseOnAudioThread,
200 base::Unretained(this))); 202 base::Unretained(this)));
201 } 203 }
202 204
203 } // namespace audio_modem 205 } // namespace audio_modem
OLDNEW
« no previous file with comments | « no previous file | media/audio/mac/audio_auhal_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698