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

Unified Diff: content/browser/renderer_host/media/audio_input_debug_writer.h

Issue 2390153006: Audio input debug recording refactoring to reduce thread hops and simplify object ownership (Closed)
Patch Set: Rebase Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_input_debug_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/audio_input_debug_writer.h
diff --git a/content/browser/renderer_host/media/audio_input_debug_writer.h b/content/browser/renderer_host/media/audio_input_debug_writer.h
index 3525ec8c69d71558ef4fd8fcecac74fa3e60b084..c618667ce05e056ad494adf2d31b88bddce8c03a 100644
--- a/content/browser/renderer_host/media/audio_input_debug_writer.h
+++ b/content/browser/renderer_host/media/audio_input_debug_writer.h
@@ -11,59 +11,40 @@
#include "base/files/file.h"
#include "base/macros.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
+#include "base/sequence_checker.h"
#include "content/common/content_export.h"
+#include "content/public/browser/browser_thread.h"
#include "media/audio/audio_input_writer.h"
#include "media/base/audio_parameters.h"
namespace media {
class AudioBus;
-class AudioBusRefCounted;
} // namespace media
namespace content {
-// Writes audio input data used for debugging purposes. Can be created on any
-// thread. Must be destroyed on the FILE thread. Write call can be made on any
-// thread. This object must be unregistered in Write caller before destroyed.
-// When created, it takes ownership of |file|.
+// Writes audio input data used for debugging purposes. All operations are
+// non-blocking.
class CONTENT_EXPORT AudioInputDebugWriter
: public NON_EXPORTED_BASE(media::AudioInputWriter) {
public:
- AudioInputDebugWriter(base::File file, const media::AudioParameters& params);
-
+ explicit AudioInputDebugWriter(const media::AudioParameters& params);
~AudioInputDebugWriter() override;
- // Write data from |data| to file.
+ void Start(const base::FilePath& file) override;
+ void Stop() override;
void Write(std::unique_ptr<media::AudioBus> data) override;
+ bool WillWrite() override;
private:
- // Write data from |data| to file. Called on the FILE thread.
- void DoWrite(std::unique_ptr<media::AudioBus> data);
-
- // Write wave header to file. Called on the FILE thread twice: on construction
- // of AudioInputDebugWriter size of the wave data is unknown, so the header is
- // written with zero sizes; then on destruction it is re-written with the
- // actual size info accumulated throughout the object lifetime.
- void WriteHeader();
-
- // The file to write to.
- base::File file_;
-
- // Number of written samples.
- uint64_t samples_;
-
- // Input audio parameters required to build wave header.
- media::AudioParameters params_;
-
- // Intermediate buffer to be written to file. Interleaved 16 bit audio data.
- std::unique_ptr<int16_t[]> interleaved_data_;
- int interleaved_data_size_;
-
- base::WeakPtrFactory<AudioInputDebugWriter> weak_factory_;
+ class AudioFileWriter;
+ using AudioFileWriterUniquePtr =
+ std::unique_ptr<AudioFileWriter, BrowserThread::DeleteOnFileThread>;
+ AudioFileWriterUniquePtr file_writer_;
+ const media::AudioParameters params_;
+ base::SequenceChecker client_sequence_checker_;
};
} // namspace content
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_input_debug_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698