Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/renderer_host/media/audio_input_debug_writer.h" | |
| 6 | |
| 7 #include "content/public/browser/browser_thread.h" | |
| 8 #include "media/base/audio_bus.h" | |
| 9 | |
| 10 namespace content { | |
| 11 | |
| 12 AudioInputDebugWriter::AudioInputDebugWriter(base::File file) | |
| 13 : file_(file.Pass()), | |
| 14 interleaved_data_size_(0), | |
| 15 weak_factory_(this) { | |
| 16 } | |
| 17 | |
| 18 AudioInputDebugWriter::~AudioInputDebugWriter() { | |
| 19 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 20 } | |
| 21 | |
| 22 void AudioInputDebugWriter::Write(scoped_ptr<media::AudioBus> data) { | |
| 23 BrowserThread::PostTask( | |
| 24 BrowserThread::FILE, | |
| 25 FROM_HERE, | |
| 26 base::Bind(&AudioInputDebugWriter::DoWrite, | |
| 27 weak_factory_.GetWeakPtr(), | |
| 28 base::Passed(&data))); | |
| 29 } | |
| 30 | |
| 31 void AudioInputDebugWriter::DoWrite(scoped_ptr<media::AudioBus> data) { | |
| 32 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 33 | |
| 34 int data_size_bytes = 2 * data->frames() * data->channels(); | |
|
tommi (sloooow) - chröme
2015/08/07 12:09:51
Can you add a note here saying that we convert the
Henrik Grunell
2015/08/17 15:05:16
Done.
| |
| 35 if (!interleaved_data_ || interleaved_data_size_ != data_size_bytes) { | |
| 36 interleaved_data_.reset(new char[data_size_bytes]); | |
| 37 interleaved_data_size_ = data_size_bytes; | |
| 38 } | |
| 39 | |
| 40 data->ToInterleaved(data->frames(), 2, interleaved_data_.get()); | |
| 41 file_.WriteAtCurrentPos(interleaved_data_.get(), interleaved_data_size_); | |
|
tommi (sloooow) - chröme
2015/08/07 12:09:51
nit: should the second parameter be data_size_byte
Henrik Grunell
2015/08/17 15:05:16
Sure, agree it's slightly better. Done.
| |
| 42 } | |
| 43 | |
| 44 } // namspace content | |
| OLD | NEW |