| OLD | NEW |
| 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 "media/audio/audio_debug_file_writer.h" | 5 #include "media/audio/audio_debug_file_writer.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <array> | 8 #include <array> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // fails, so it will continue to post data to be recorded, which won't | 293 // fails, so it will continue to post data to be recorded, which won't |
| 294 // be written to the file. This also won't be reflected in WillWrite(). It's | 294 // be written to the file. This also won't be reflected in WillWrite(). It's |
| 295 // fine, because this situation is rare, and all the posting is expected to | 295 // fine, because this situation is rare, and all the posting is expected to |
| 296 // happen in case of success anyways. This allows us to save on thread hops | 296 // happen in case of success anyways. This allows us to save on thread hops |
| 297 // for error reporting and to avoid dealing with lifetime issues. It also | 297 // for error reporting and to avoid dealing with lifetime issues. It also |
| 298 // means file_.IsValid() should always be checked before issuing writes to it. | 298 // means file_.IsValid() should always be checked before issuing writes to it. |
| 299 PLOG(ERROR) << "Could not open debug recording file, error=" | 299 PLOG(ERROR) << "Could not open debug recording file, error=" |
| 300 << file_.error_details(); | 300 << file_.error_details(); |
| 301 } | 301 } |
| 302 | 302 |
| 303 AudioDebugFileWriter::AudioDebugFileWriter( | 303 AudioDebugFileWriter::AudioDebugFileWriter(const AudioParameters& params) |
| 304 const AudioParameters& params, | 304 : params_(params) { |
| 305 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) | |
| 306 : params_(params), file_task_runner_(std::move(file_task_runner)) { | |
| 307 client_sequence_checker_.DetachFromSequence(); | 305 client_sequence_checker_.DetachFromSequence(); |
| 308 } | 306 } |
| 309 | 307 |
| 310 AudioDebugFileWriter::~AudioDebugFileWriter() { | 308 AudioDebugFileWriter::~AudioDebugFileWriter() { |
| 311 // |file_writer_| will be deleted on |task_runner_|. | 309 // |file_writer_| will be deleted on |task_runner_|. |
| 312 } | 310 } |
| 313 | 311 |
| 314 void AudioDebugFileWriter::Start(const base::FilePath& file_name) { | 312 void AudioDebugFileWriter::Start(const base::FilePath& file_name) { |
| 315 DCHECK(client_sequence_checker_.CalledOnValidSequence()); | 313 DCHECK(client_sequence_checker_.CalledOnValidSequence()); |
| 316 DCHECK(!file_writer_); | 314 DCHECK(!file_writer_); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 344 // here, but it's fine: we can afford missing some data or scheduling some | 342 // here, but it's fine: we can afford missing some data or scheduling some |
| 345 // no-op writes. | 343 // no-op writes. |
| 346 return !!file_writer_; | 344 return !!file_writer_; |
| 347 } | 345 } |
| 348 | 346 |
| 349 const base::FilePath::CharType* AudioDebugFileWriter::GetFileNameExtension() { | 347 const base::FilePath::CharType* AudioDebugFileWriter::GetFileNameExtension() { |
| 350 return FILE_PATH_LITERAL("wav"); | 348 return FILE_PATH_LITERAL("wav"); |
| 351 } | 349 } |
| 352 | 350 |
| 353 } // namspace media | 351 } // namspace media |
| OLD | NEW |