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

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

Issue 2028083002: Revert of 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
54 } // namespace 52 } // namespace
55 53
56 // Public methods. 54 // Public methods.
57 55
58 AudioRecorderImpl::AudioRecorderImpl() 56 AudioRecorderImpl::AudioRecorderImpl()
59 : is_recording_(false), 57 : is_recording_(false),
60 stream_(nullptr), 58 stream_(nullptr),
61 total_buffer_frames_(0), 59 total_buffer_frames_(0),
62 buffer_frame_index_(0) { 60 buffer_frame_index_(0) {
63 } 61 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 108 }
111 109
112 total_buffer_frames_ = kProcessIntervalMs * params.sample_rate() / 1000; 110 total_buffer_frames_ = kProcessIntervalMs * params.sample_rate() / 1000;
113 buffer_ = media::AudioBus::Create(params.channels(), total_buffer_frames_); 111 buffer_ = media::AudioBus::Create(params.channels(), total_buffer_frames_);
114 buffer_frame_index_ = 0; 112 buffer_frame_index_ = 0;
115 113
116 stream_ = input_stream_for_testing_ 114 stream_ = input_stream_for_testing_
117 ? input_stream_for_testing_.get() 115 ? input_stream_for_testing_.get()
118 : media::AudioManager::Get()->MakeAudioInputStream( 116 : media::AudioManager::Get()->MakeAudioInputStream(
119 params, media::AudioDeviceDescription::kDefaultDeviceId, 117 params, media::AudioDeviceDescription::kDefaultDeviceId,
120 base::Bind(&OnLogMessage)); 118 media::AudioManager::LogCallback());
121 119
122 if (!stream_ || !stream_->Open()) { 120 if (!stream_ || !stream_->Open()) {
123 LOG(ERROR) << "Failed to open an input stream."; 121 LOG(ERROR) << "Failed to open an input stream.";
124 if (stream_) { 122 if (stream_) {
125 stream_->Close(); 123 stream_->Close();
126 stream_ = nullptr; 124 stream_ = nullptr;
127 } 125 }
128 return; 126 return;
129 } 127 }
130 stream_->SetVolume(stream_->GetMaxVolume()); 128 stream_->SetVolume(stream_->GetMaxVolume());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 194
197 void AudioRecorderImpl::OnError(media::AudioInputStream* /* stream */) { 195 void AudioRecorderImpl::OnError(media::AudioInputStream* /* stream */) {
198 LOG(ERROR) << "Error during sound recording."; 196 LOG(ERROR) << "Error during sound recording.";
199 media::AudioManager::Get()->GetTaskRunner()->PostTask( 197 media::AudioManager::Get()->GetTaskRunner()->PostTask(
200 FROM_HERE, 198 FROM_HERE,
201 base::Bind(&AudioRecorderImpl::StopAndCloseOnAudioThread, 199 base::Bind(&AudioRecorderImpl::StopAndCloseOnAudioThread,
202 base::Unretained(this))); 200 base::Unretained(this)));
203 } 201 }
204 202
205 } // namespace audio_modem 203 } // 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