diff options
author | henrika@chromium.org <henrika@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-09 08:49:35 +0000 |
---|---|---|
committer | henrika@chromium.org <henrika@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-09 08:49:35 +0000 |
commit | 33e8bb03d5cebb026ff15ca29f402c052b9c6f86 (patch) | |
tree | 482a3e39c79dcd19e9447780f3b15c64c32b04fe /content | |
parent | 66c68e2fb905cc8df045c73727f0d9f755e96791 (diff) | |
download | chromium_src-33e8bb03d5cebb026ff15ca29f402c052b9c6f86.zip chromium_src-33e8bb03d5cebb026ff15ca29f402c052b9c6f86.tar.gz chromium_src-33e8bb03d5cebb026ff15ca29f402c052b9c6f86.tar.bz2 |
Removes usage of the term low-latency in AudioInputRendererHost.
BUG=none
TEST=content_unittests and WebRTC demo applications
Review URL: https://chromiumcodereview.appspot.com/9332002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/renderer_host/media/audio_input_renderer_host.cc | 54 | ||||
-rw-r--r-- | content/browser/renderer_host/media/audio_input_renderer_host.h | 26 | ||||
-rw-r--r-- | content/common/media/audio_messages.h | 11 | ||||
-rw-r--r-- | content/renderer/media/audio_input_device.cc | 11 | ||||
-rw-r--r-- | content/renderer/media/audio_input_device.h | 6 | ||||
-rw-r--r-- | content/renderer/media/audio_input_message_filter.cc | 8 | ||||
-rw-r--r-- | content/renderer/media/audio_input_message_filter.h | 23 | ||||
-rw-r--r-- | content/renderer/pepper_plugin_delegate_impl.cc | 12 |
8 files changed, 66 insertions, 85 deletions
diff --git a/content/browser/renderer_host/media/audio_input_renderer_host.cc b/content/browser/renderer_host/media/audio_input_renderer_host.cc index 6722edc..4ab9413e 100644 --- a/content/browser/renderer_host/media/audio_input_renderer_host.cc +++ b/content/browser/renderer_host/media/audio_input_renderer_host.cc @@ -116,29 +116,26 @@ void AudioInputRendererHost::DoCompleteCreation( return; } - if (entry->controller->LowLatencyMode()) { - AudioInputSyncWriter* writer = - static_cast<AudioInputSyncWriter*>(entry->writer.get()); + AudioInputSyncWriter* writer = + static_cast<AudioInputSyncWriter*>(entry->writer.get()); #if defined(OS_WIN) - base::SyncSocket::Handle foreign_socket_handle; + base::SyncSocket::Handle foreign_socket_handle; #else - base::FileDescriptor foreign_socket_handle; + base::FileDescriptor foreign_socket_handle; #endif - // If we failed to prepare the sync socket for the renderer then we fail - // the construction of audio input stream. - if (!writer->PrepareForeignSocketHandle(peer_handle(), - &foreign_socket_handle)) { - DeleteEntryOnError(entry); - return; - } - - Send(new AudioInputMsg_NotifyLowLatencyStreamCreated( - entry->stream_id, foreign_memory_handle, - foreign_socket_handle, entry->shared_memory.created_size())); + // If we failed to prepare the sync socket for the renderer then we fail + // the construction of audio input stream. + if (!writer->PrepareForeignSocketHandle(peer_handle(), + &foreign_socket_handle)) { + DeleteEntryOnError(entry); return; } + + Send(new AudioInputMsg_NotifyStreamCreated(entry->stream_id, + foreign_memory_handle, foreign_socket_handle, + entry->shared_memory.created_size())); } void AudioInputRendererHost::DoSendRecordingMessage( @@ -202,21 +199,14 @@ void AudioInputRendererHost::OnStartDevice(int stream_id, int session_id) { audio_input_man->Start(session_id, this); } -void AudioInputRendererHost::OnCreateStream( - int stream_id, const AudioParameters& params, bool low_latency, - const std::string& device_id) { +void AudioInputRendererHost::OnCreateStream(int stream_id, + const AudioParameters& params, + const std::string& device_id) { VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id=" << stream_id << ")"; DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(LookupById(stream_id) == NULL); - // Prevent the renderer process from asking for a normal-latency - // input stream. - if (!low_latency) { - NOTREACHED() << "Current implementation only supports low-latency mode."; - return; - } - AudioParameters audio_params(params); // Select the hardware packet size if not specified. @@ -225,19 +215,20 @@ void AudioInputRendererHost::OnCreateStream( } uint32 packet_size = audio_params.GetPacketSize(); + // Create a new AudioEntry structure. scoped_ptr<AudioEntry> entry(new AudioEntry()); - // Create the shared memory and share with the renderer process. + + // Create the shared memory and share it with the renderer process + // using a new SyncWriter object. if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) { // If creation of shared memory failed then send an error message. SendErrorMessage(stream_id); return; } - // This is a low latency mode, hence we need to construct a SyncWriter first. scoped_ptr<AudioInputSyncWriter> writer( new AudioInputSyncWriter(&entry->shared_memory)); - // Then try to initialize the sync writer. if (!writer->Init()) { SendErrorMessage(stream_id); return; @@ -245,6 +236,9 @@ void AudioInputRendererHost::OnCreateStream( // If we have successfully created the SyncWriter then assign it to the // entry and construct an AudioInputController. + // TODO(henrika): replace CreateLowLatency() with Create() as soon + // as satish has ensured that Speech Input also uses the default low- + // latency path. See crbug.com/112472 for details. entry->writer.reset(writer.release()); entry->controller = media::AudioInputController::CreateLowLatency( resource_context_->audio_manager(), @@ -385,7 +379,7 @@ void AudioInputRendererHost::CloseAndDeleteStream(AudioEntry* entry) { if (!entry->pending_close) { entry->controller->Close(base::Bind(&AudioInputRendererHost::OnStreamClosed, - this , entry)); + this, entry)); entry->pending_close = true; } } diff --git a/content/browser/renderer_host/media/audio_input_renderer_host.h b/content/browser/renderer_host/media/audio_input_renderer_host.h index 1ec5ed1..bb3dc9b 100644 --- a/content/browser/renderer_host/media/audio_input_renderer_host.h +++ b/content/browser/renderer_host/media/audio_input_renderer_host.h @@ -5,19 +5,14 @@ // AudioInputRendererHost serves audio related requests from audio capturer // which lives inside the render process and provide access to audio hardware. // -// OnCreateStream() request is only available in the low latency mode. It will -// creates a shared memory, a SyncWriter and a AudioInputController for the -// input stream. - -// OnCloseStream() will close the input stream. -// -// Create stream sequence: +// Create stream sequence (AudioInputController = AIC): // -// OnCreateStream -> AudioInputController::CreateLowLatency() -> -// DoCompleteCreation -> AudioInputMsg_NotifyLowLatencyStreamCreated +// AudioInputHostMsg_CreateStream -> OnCreateStream -> AIC::CreateLowLatency -> +// <- AudioInputMsg_NotifyStreamCreated <- DoCompleteCreation <- OnCreated <- // // Close stream sequence: -// OnCloseStream -> AudioInputController::Close +// +// AudioInputHostMsg_CloseStream -> OnCloseStream -> AIC::Close -> // // For the OnStartDevice() request, AudioInputRendererHost starts the device // referenced by the session id, and an OnDeviceStarted() callback with the @@ -43,19 +38,17 @@ // // This class is owned by BrowserRenderProcessHost and instantiated on UI // thread. All other operations and method calls happen on IO thread, so we -// need to be extra careful about the lifetime of this object. AudioManager is a -// singleton and created in IO thread, audio input streams are also created in -// the IO thread, so we need to destroy them also in IO thread. +// need to be extra careful about the lifetime of this object. // -// This implementation supports low latency audio only. -// For low latency audio, a SyncSocket pair is used to signal buffer readiness -// without having to route messages using the IO thread. +// To ensure low latency audio, a SyncSocket pair is used to signal buffer +// readiness without having to route messages using the IO thread. #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ #pragma once #include <map> +#include <string> #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" @@ -147,7 +140,6 @@ class CONTENT_EXPORT AudioInputRendererHost // required properties. void OnCreateStream(int stream_id, const AudioParameters& params, - bool low_latency, const std::string& device_id); // Record the audio input stream referenced by |stream_id|. diff --git a/content/common/media/audio_messages.h b/content/common/media/audio_messages.h index 31f3e4b..43ab347 100644 --- a/content/common/media/audio_messages.h +++ b/content/common/media/audio_messages.h @@ -55,17 +55,17 @@ IPC_MESSAGE_CONTROL4(AudioMsg_NotifyStreamCreated, uint32 /* length */) #endif -// Tell the renderer process that a low latency audio input stream has been -// created, renderer process would be given a SyncSocket that it should read +// Tell the renderer process that an audio input stream has been created. +// The renderer process would be given a SyncSocket that it should read // from from then on. #if defined(OS_WIN) -IPC_MESSAGE_CONTROL4(AudioInputMsg_NotifyLowLatencyStreamCreated, +IPC_MESSAGE_CONTROL4(AudioInputMsg_NotifyStreamCreated, int /* stream id */, base::SharedMemoryHandle /* handle */, base::SyncSocket::Handle /* socket handle */, uint32 /* length */) #else -IPC_MESSAGE_CONTROL4(AudioInputMsg_NotifyLowLatencyStreamCreated, +IPC_MESSAGE_CONTROL4(AudioInputMsg_NotifyStreamCreated, int /* stream id */, base::SharedMemoryHandle /* handle */, base::FileDescriptor /* socket handle */, @@ -99,10 +99,9 @@ IPC_MESSAGE_CONTROL2(AudioHostMsg_CreateStream, AudioParameters /* params */) // Request that got sent to browser for creating an audio input stream -IPC_MESSAGE_CONTROL4(AudioInputHostMsg_CreateStream, +IPC_MESSAGE_CONTROL3(AudioInputHostMsg_CreateStream, int /* stream_id */, AudioParameters /* params */, - bool /* low-latency */, std::string /* device_id */) // Start buffering and play the audio stream specified by stream_id. diff --git a/content/renderer/media/audio_input_device.cc b/content/renderer/media/audio_input_device.cc index 05de9d0..ac12175 100644 --- a/content/renderer/media/audio_input_device.cc +++ b/content/renderer/media/audio_input_device.cc @@ -110,8 +110,7 @@ void AudioInputDevice::InitializeOnIOThread() { // and create the stream when getting a OnDeviceReady() callback. if (!session_id_) { Send(new AudioInputHostMsg_CreateStream( - stream_id_, audio_parameters_, true, - AudioManagerBase::kDefaultDeviceId)); + stream_id_, audio_parameters_, AudioManagerBase::kDefaultDeviceId)); } else { Send(new AudioInputHostMsg_StartDevice(stream_id_, session_id_)); pending_device_ready_ = true; @@ -154,7 +153,7 @@ void AudioInputDevice::SetVolumeOnIOThread(double volume) { Send(new AudioInputHostMsg_SetVolume(stream_id_, volume)); } -void AudioInputDevice::OnLowLatencyCreated( +void AudioInputDevice::OnStreamCreated( base::SharedMemoryHandle handle, base::SyncSocket::Handle socket_handle, uint32 length) { @@ -168,9 +167,9 @@ void AudioInputDevice::OnLowLatencyCreated( #endif DCHECK(length); DCHECK(!audio_thread_.get()); + DVLOG(1) << "OnStreamCreated (stream_id=" << stream_id_ << ")"; - DVLOG(1) << "OnLowLatencyCreated (stream_id=" << stream_id_ << ")"; - // Takes care of the case when Stop() is called before OnLowLatencyCreated(). + // Takes care of the case when Stop() is called before OnStreamCreated(). if (!stream_id_) { base::SharedMemory::CloseHandle(handle); // Close the socket handler. @@ -242,7 +241,7 @@ void AudioInputDevice::OnDeviceReady(const std::string& device_id) { stream_id_ = 0; } else { Send(new AudioInputHostMsg_CreateStream(stream_id_, audio_parameters_, - true, device_id)); + device_id)); } pending_device_ready_ = false; diff --git a/content/renderer/media/audio_input_device.h b/content/renderer/media/audio_input_device.h index 66c771e..116ab45 100644 --- a/content/renderer/media/audio_input_device.h +++ b/content/renderer/media/audio_input_device.h @@ -149,9 +149,9 @@ class CONTENT_EXPORT AudioInputDevice // Methods called on IO thread ---------------------------------------------- // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter - virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, - base::SyncSocket::Handle socket_handle, - uint32 length) OVERRIDE; + virtual void OnStreamCreated(base::SharedMemoryHandle handle, + base::SyncSocket::Handle socket_handle, + uint32 length) OVERRIDE; virtual void OnVolume(double volume) OVERRIDE; virtual void OnStateChanged(AudioStreamState state) OVERRIDE; virtual void OnDeviceReady(const std::string& device_id) OVERRIDE; diff --git a/content/renderer/media/audio_input_message_filter.cc b/content/renderer/media/audio_input_message_filter.cc index 70ad606..30e4b01 100644 --- a/content/renderer/media/audio_input_message_filter.cc +++ b/content/renderer/media/audio_input_message_filter.cc @@ -42,8 +42,8 @@ bool AudioInputMessageFilter::Send(IPC::Message* message) { bool AudioInputMessageFilter::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(AudioInputMessageFilter, message) - IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyLowLatencyStreamCreated, - OnLowLatencyStreamCreated) + IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamCreated, + OnStreamCreated) IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamVolume, OnStreamVolume) IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamStateChanged, OnStreamStateChanged) @@ -68,7 +68,7 @@ void AudioInputMessageFilter::OnChannelClosing() { channel_ = NULL; } -void AudioInputMessageFilter::OnLowLatencyStreamCreated( +void AudioInputMessageFilter::OnStreamCreated( int stream_id, base::SharedMemoryHandle handle, #if defined(OS_WIN) @@ -89,7 +89,7 @@ void AudioInputMessageFilter::OnLowLatencyStreamCreated( return; } // Forward message to the stream delegate. - delegate->OnLowLatencyCreated(handle, socket_handle, length); + delegate->OnStreamCreated(handle, socket_handle, length); } void AudioInputMessageFilter::OnStreamVolume(int stream_id, double volume) { diff --git a/content/renderer/media/audio_input_message_filter.h b/content/renderer/media/audio_input_message_filter.h index 1536be9..a537e70 100644 --- a/content/renderer/media/audio_input_message_filter.h +++ b/content/renderer/media/audio_input_message_filter.h @@ -6,8 +6,6 @@ // audio capturers. Created on render thread, AudioMessageFilter is operated on // IO thread (secondary thread of render process), it intercepts audio messages // and process them on IO thread since these messages are time critical. -// This implementation only supports low-latency (based on SyncSocket) -// messaging. #ifndef CONTENT_RENDERER_MEDIA_AUDIO_INPUT_MESSAGE_FILTER_H_ #define CONTENT_RENDERER_MEDIA_AUDIO_INPUT_MESSAGE_FILTER_H_ @@ -26,11 +24,11 @@ class CONTENT_EXPORT AudioInputMessageFilter public: class CONTENT_EXPORT Delegate { public: - // Called when a low-latency audio input stream has been created in the - // browser process. - virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, - base::SyncSocket::Handle socket_handle, - uint32 length) = 0; + // Called when an audio input stream has been created in the browser + // process. + virtual void OnStreamCreated(base::SharedMemoryHandle handle, + base::SyncSocket::Handle socket_handle, + uint32 length) = 0; // Called when notification of input stream volume is received from the // browser process. @@ -66,15 +64,14 @@ class CONTENT_EXPORT AudioInputMessageFilter virtual void OnFilterRemoved() OVERRIDE; virtual void OnChannelClosing() OVERRIDE; - // Received when browser process has created an audio input stream of low - // latency. - void OnLowLatencyStreamCreated(int stream_id, base::SharedMemoryHandle handle, + // Received when browser process has created an audio input stream. + void OnStreamCreated(int stream_id, base::SharedMemoryHandle handle, #if defined(OS_WIN) - base::SyncSocket::Handle socket_handle, + base::SyncSocket::Handle socket_handle, #else - base::FileDescriptor socket_descriptor, + base::FileDescriptor socket_descriptor, #endif - uint32 length); + uint32 length); // Notification of volume property of an audio input stream. void OnStreamVolume(int stream_id, double volume); diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc index e4129d6..9c7d225 100644 --- a/content/renderer/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper_plugin_delegate_impl.cc @@ -357,9 +357,9 @@ class PlatformAudioInputImpl void StopCaptureOnIOThread(); void ShutDownOnIOThread(); - virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, - base::SyncSocket::Handle socket_handle, - uint32 length) OVERRIDE; + virtual void OnStreamCreated(base::SharedMemoryHandle handle, + base::SyncSocket::Handle socket_handle, + uint32 length) OVERRIDE; virtual void OnVolume(double volume) OVERRIDE {} @@ -433,7 +433,7 @@ void PlatformAudioInputImpl::InitializeOnIOThread( const AudioParameters& params) { stream_id_ = filter_->AddDelegate(this); filter_->Send(new AudioInputHostMsg_CreateStream( - stream_id_, params, true, AudioManagerBase::kDefaultDeviceId)); + stream_id_, params, AudioManagerBase::kDefaultDeviceId)); } void PlatformAudioInputImpl::StartCaptureOnIOThread() { @@ -459,7 +459,7 @@ void PlatformAudioInputImpl::ShutDownOnIOThread() { // PepperPluginDelegateImpl::CreateAudioInput. } -void PlatformAudioInputImpl::OnLowLatencyCreated( +void PlatformAudioInputImpl::OnStreamCreated( base::SharedMemoryHandle handle, base::SyncSocket::Handle socket_handle, uint32 length) { @@ -481,7 +481,7 @@ void PlatformAudioInputImpl::OnLowLatencyCreated( } else { main_message_loop_proxy_->PostTask( FROM_HERE, - base::Bind(&PlatformAudioInputImpl::OnLowLatencyCreated, this, + base::Bind(&PlatformAudioInputImpl::OnStreamCreated, this, handle, socket_handle, length)); } } |