diff options
author | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-23 22:01:01 +0000 |
---|---|---|
committer | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-23 22:01:01 +0000 |
commit | 8b1937472aafb5933a2af5720ef6a4d4c69f5e30 (patch) | |
tree | 0911e5b92488612ceddeccc837ff60fcca9fc807 /content/renderer/media | |
parent | 9ad32ee696ec4f635cb9174f8451fdb7efbaac1d (diff) | |
download | chromium_src-8b1937472aafb5933a2af5720ef6a4d4c69f5e30.zip chromium_src-8b1937472aafb5933a2af5720ef6a4d4c69f5e30.tar.gz chromium_src-8b1937472aafb5933a2af5720ef6a4d4c69f5e30.tar.bz2 |
Remove PlatformFile from Media stream aec_dump
BUG=322664
Review URL: https://codereview.chromium.org/237913002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/media')
8 files changed, 39 insertions, 55 deletions
diff --git a/content/renderer/media/media_stream_audio_processor.cc b/content/renderer/media/media_stream_audio_processor.cc index 9532eb3..01cee0c 100644 --- a/content/renderer/media/media_stream_audio_processor.cc +++ b/content/renderer/media/media_stream_audio_processor.cc @@ -235,10 +235,10 @@ const media::AudioParameters& MediaStreamAudioProcessor::OutputFormat() const { return capture_converter_->sink_parameters(); } -void MediaStreamAudioProcessor::StartAecDump( - const base::PlatformFile& aec_dump_file) { +void MediaStreamAudioProcessor::StartAecDump(base::File aec_dump_file) { if (audio_processing_) - StartEchoCancellationDump(audio_processing_.get(), aec_dump_file); + StartEchoCancellationDump(audio_processing_.get(), + aec_dump_file.TakePlatformFile()); } void MediaStreamAudioProcessor::StopAecDump() { diff --git a/content/renderer/media/media_stream_audio_processor.h b/content/renderer/media/media_stream_audio_processor.h index 73bf234..2233007 100644 --- a/content/renderer/media/media_stream_audio_processor.h +++ b/content/renderer/media/media_stream_audio_processor.h @@ -6,7 +6,7 @@ #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ #include "base/atomicops.h" -#include "base/platform_file.h" +#include "base/files/file.h" #include "base/synchronization/lock.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" @@ -101,7 +101,7 @@ class CONTENT_EXPORT MediaStreamAudioProcessor : // Starts/Stops the Aec dump on the |audio_processing_|. // Called on the main render thread. // This method takes the ownership of |aec_dump_file|. - void StartAecDump(const base::PlatformFile& aec_dump_file); + void StartAecDump(base::File aec_dump_file); void StopAecDump(); protected: diff --git a/content/renderer/media/media_stream_dependency_factory.cc b/content/renderer/media/media_stream_dependency_factory.cc index c1590af..0b13677 100644 --- a/content/renderer/media/media_stream_dependency_factory.cc +++ b/content/renderer/media/media_stream_dependency_factory.cc @@ -166,14 +166,11 @@ MediaStreamDependencyFactory::MediaStreamDependencyFactory( p2p_socket_dispatcher_(p2p_socket_dispatcher), signaling_thread_(NULL), worker_thread_(NULL), - chrome_worker_thread_("Chrome_libJingle_WorkerThread"), - aec_dump_file_(base::kInvalidPlatformFileValue) { + chrome_worker_thread_("Chrome_libJingle_WorkerThread") { } MediaStreamDependencyFactory::~MediaStreamDependencyFactory() { CleanupPeerConnectionFactory(); - if (aec_dump_file_ != base::kInvalidPlatformFileValue) - base::ClosePlatformFile(aec_dump_file_); } blink::WebRTCPeerConnectionHandler* @@ -349,10 +346,8 @@ void MediaStreamDependencyFactory::CreatePeerConnectionFactory() { pc_factory_->SetOptions(factory_options); // |aec_dump_file| will be invalid when dump is not enabled. - if (aec_dump_file_ != base::kInvalidPlatformFileValue) { - StartAecDump(aec_dump_file_); - aec_dump_file_ = base::kInvalidPlatformFileValue; - } + if (aec_dump_file_.IsValid()) + StartAecDump(aec_dump_file_.Pass()); } bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { @@ -619,24 +614,23 @@ bool MediaStreamDependencyFactory::OnControlMessageReceived( void MediaStreamDependencyFactory::OnAecDumpFile( IPC::PlatformFileForTransit file_handle) { - DCHECK_EQ(aec_dump_file_, base::kInvalidPlatformFileValue); - base::PlatformFile file = - IPC::PlatformFileForTransitToPlatformFile(file_handle); - DCHECK_NE(file, base::kInvalidPlatformFileValue); + DCHECK(!aec_dump_file_.IsValid()); + base::File file = IPC::PlatformFileForTransitToFile(file_handle); + DCHECK(file.IsValid()); if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableAudioTrackProcessing)) { EnsureWebRtcAudioDeviceImpl(); - GetWebRtcAudioDevice()->EnableAecDump(file); + GetWebRtcAudioDevice()->EnableAecDump(file.Pass()); return; } // TODO(xians): Remove the following code after kEnableAudioTrackProcessing // is removed. if (PeerConnectionFactoryCreated()) - StartAecDump(file); + StartAecDump(file.Pass()); else - aec_dump_file_ = file; + aec_dump_file_ = file.Pass(); } void MediaStreamDependencyFactory::OnDisableAecDump() { @@ -648,16 +642,14 @@ void MediaStreamDependencyFactory::OnDisableAecDump() { // TODO(xians): Remove the following code after kEnableAudioTrackProcessing // is removed. - if (aec_dump_file_ != base::kInvalidPlatformFileValue) - base::ClosePlatformFile(aec_dump_file_); - aec_dump_file_ = base::kInvalidPlatformFileValue; + if (aec_dump_file_.IsValid()) + aec_dump_file_.Close(); } -void MediaStreamDependencyFactory::StartAecDump( - const base::PlatformFile& aec_dump_file) { +void MediaStreamDependencyFactory::StartAecDump(base::File aec_dump_file) { // |pc_factory_| always takes ownership of |aec_dump_file|. If StartAecDump() // fails, |aec_dump_file| will be closed. - if (!GetPcFactory()->StartAecDump(aec_dump_file)) + if (!GetPcFactory()->StartAecDump(aec_dump_file.TakePlatformFile())) VLOG(1) << "Could not start AEC dump."; } diff --git a/content/renderer/media/media_stream_dependency_factory.h b/content/renderer/media/media_stream_dependency_factory.h index cf3b11d..4c42ff4 100644 --- a/content/renderer/media/media_stream_dependency_factory.h +++ b/content/renderer/media/media_stream_dependency_factory.h @@ -8,8 +8,8 @@ #include <string> #include "base/basictypes.h" +#include "base/files/file.h" #include "base/memory/ref_counted.h" -#include "base/platform_file.h" #include "base/threading/thread.h" #include "content/common/content_export.h" #include "content/public/renderer/render_process_observer.h" @@ -185,7 +185,7 @@ class CONTENT_EXPORT MediaStreamDependencyFactory void OnAecDumpFile(IPC::PlatformFileForTransit file_handle); void OnDisableAecDump(); - void StartAecDump(const base::PlatformFile& aec_dump_file); + void StartAecDump(base::File aec_dump_file); // Helper method to create a WebRtcAudioDeviceImpl. void EnsureWebRtcAudioDeviceImpl(); @@ -206,7 +206,7 @@ class CONTENT_EXPORT MediaStreamDependencyFactory talk_base::Thread* worker_thread_; base::Thread chrome_worker_thread_; - base::PlatformFile aec_dump_file_; + base::File aec_dump_file_; DISALLOW_COPY_AND_ASSIGN(MediaStreamDependencyFactory); }; diff --git a/content/renderer/media/webrtc_audio_capturer.cc b/content/renderer/media/webrtc_audio_capturer.cc index 4b14af7..5ad35a2 100644 --- a/content/renderer/media/webrtc_audio_capturer.cc +++ b/content/renderer/media/webrtc_audio_capturer.cc @@ -609,11 +609,10 @@ void WebRtcAudioCapturer::SetCapturerSourceForTesting( static_cast<float>(params.sample_rate())); } -void WebRtcAudioCapturer::StartAecDump( - const base::PlatformFile& aec_dump_file) { +void WebRtcAudioCapturer::StartAecDump(base::File aec_dump_file) { DCHECK(thread_checker_.CalledOnValidThread()); - DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue); - audio_processor_->StartAecDump(aec_dump_file); + DCHECK(aec_dump_file.IsValid()); + audio_processor_->StartAecDump(aec_dump_file.Pass()); } void WebRtcAudioCapturer::StopAecDump() { diff --git a/content/renderer/media/webrtc_audio_capturer.h b/content/renderer/media/webrtc_audio_capturer.h index 6ac89d5..f433a1a 100644 --- a/content/renderer/media/webrtc_audio_capturer.h +++ b/content/renderer/media/webrtc_audio_capturer.h @@ -9,8 +9,8 @@ #include <string> #include "base/callback.h" +#include "base/files/file.h" #include "base/memory/ref_counted.h" -#include "base/platform_file.h" #include "base/synchronization/lock.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" @@ -117,7 +117,7 @@ class CONTENT_EXPORT WebRtcAudioCapturer const scoped_refptr<media::AudioCapturerSource>& source, media::AudioParameters params); - void StartAecDump(const base::PlatformFile& aec_dump_file); + void StartAecDump(base::File aec_dump_file); void StopAecDump(); protected: diff --git a/content/renderer/media/webrtc_audio_device_impl.cc b/content/renderer/media/webrtc_audio_device_impl.cc index e1aea4d..97d5d09 100644 --- a/content/renderer/media/webrtc_audio_device_impl.cc +++ b/content/renderer/media/webrtc_audio_device_impl.cc @@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/metrics/histogram.h" -#include "base/platform_file.h" #include "base/strings/string_util.h" #include "base/win/windows_version.h" #include "content/renderer/media/webrtc_audio_capturer.h" @@ -28,8 +27,7 @@ WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl() initialized_(false), playing_(false), recording_(false), - microphone_volume_(0), - aec_dump_file_(base::kInvalidPlatformFileValue) { + microphone_volume_(0) { DVLOG(1) << "WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()"; } @@ -444,7 +442,7 @@ void WebRtcAudioDeviceImpl::AddAudioCapturer( // Start the Aec dump if the Aec dump has been enabled and has not been // started. - if (aec_dump_file_ != base::kInvalidPlatformFileValue) + if (aec_dump_file_.IsValid()) MaybeStartAecDump(); } @@ -497,12 +495,11 @@ bool WebRtcAudioDeviceImpl::GetAuthorizedDeviceInfoForAudioRenderer( session_id, output_sample_rate, output_frames_per_buffer); } -void WebRtcAudioDeviceImpl::EnableAecDump( - const base::PlatformFile& aec_dump_file) { +void WebRtcAudioDeviceImpl::EnableAecDump(base::File aec_dump_file) { DCHECK(thread_checker_.CalledOnValidThread()); - DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue); - DCHECK_EQ(aec_dump_file_, base::kInvalidPlatformFileValue); - aec_dump_file_ = aec_dump_file; + DCHECK(aec_dump_file.IsValid()); + DCHECK(!aec_dump_file_.IsValid()); + aec_dump_file_ = aec_dump_file.Pass(); MaybeStartAecDump(); } @@ -510,9 +507,8 @@ void WebRtcAudioDeviceImpl::DisableAecDump() { DCHECK(thread_checker_.CalledOnValidThread()); // Simply invalidate the |aec_dump_file_| if we have not pass the ownership // to WebRtc. - if (aec_dump_file_ != base::kInvalidPlatformFileValue) { - base::ClosePlatformFile(aec_dump_file_); - aec_dump_file_ = base::kInvalidPlatformFileValue; + if (aec_dump_file_.IsValid()) { + aec_dump_file_.Close(); return; } @@ -526,18 +522,14 @@ void WebRtcAudioDeviceImpl::DisableAecDump() { void WebRtcAudioDeviceImpl::MaybeStartAecDump() { DCHECK(thread_checker_.CalledOnValidThread()); - DCHECK_NE(aec_dump_file_, base::kInvalidPlatformFileValue); + DCHECK(aec_dump_file_.IsValid()); // Start the Aec dump on the current default capturer. scoped_refptr<WebRtcAudioCapturer> default_capturer(GetDefaultCapturer()); if (!default_capturer) return; - default_capturer->StartAecDump(aec_dump_file_); - - // Invalidate the |aec_dump_file_| since the ownership of the file has been - // passed to WebRtc. - aec_dump_file_ = base::kInvalidPlatformFileValue; + default_capturer->StartAecDump(aec_dump_file_.Pass()); } } // namespace content diff --git a/content/renderer/media/webrtc_audio_device_impl.h b/content/renderer/media/webrtc_audio_device_impl.h index 5691aed..4cf36d4 100644 --- a/content/renderer/media/webrtc_audio_device_impl.h +++ b/content/renderer/media/webrtc_audio_device_impl.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/files/file.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -354,7 +355,7 @@ class CONTENT_EXPORT WebRtcAudioDeviceImpl // Enables the Aec dump. If the default capturer exists, it will call // StartAecDump() on the capturer and pass the ownership of the file to // WebRtc. Otherwise it will hold the file until a capturer is added. - void EnableAecDump(const base::PlatformFile& aec_dump_file); + void EnableAecDump(base::File aec_dump_file); // Disables the Aec dump. When this method is called, the ongoing Aec dump // on WebRtc will be stopped. @@ -450,7 +451,7 @@ class CONTENT_EXPORT WebRtcAudioDeviceImpl std::vector<int16> render_buffer_; // Used for start the Aec dump on the default capturer. - base::PlatformFile aec_dump_file_; + base::File aec_dump_file_; DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); }; |