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