Skip to content

Commit

Permalink
Move media/audio files into media namespace
Browse files Browse the repository at this point in the history
BUG=115187
TEST=compiles and runs without breaking audio tag; media_unittests, content_unittests

Review URL: https://chromiumcodereview.appspot.com/9805001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130180 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
vrk@google.com committed Apr 2, 2012
1 parent 103f19f commit 897bfb5
Show file tree
Hide file tree
Showing 128 changed files with 535 additions and 203 deletions.
4 changes: 2 additions & 2 deletions content/browser/browser_main_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void ImmediateShutdownAndExitProcess() {
}

// static
AudioManager* BrowserMainLoop::GetAudioManager() {
media::AudioManager* BrowserMainLoop::GetAudioManager() {
return g_current_browser_main_loop->audio_manager_.get();
}

Expand Down Expand Up @@ -327,7 +327,7 @@ void BrowserMainLoop::MainMessageLoopStart() {
hi_res_timer_manager_.reset(new HighResolutionTimerManager);

network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
audio_manager_.reset(AudioManager::Create());
audio_manager_.reset(media::AudioManager::Create());
online_state_observer_.reset(new BrowserOnlineStateObserver);

#if defined(OS_WIN)
Expand Down
9 changes: 6 additions & 3 deletions content/browser/browser_main_loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "ui/base/win/scoped_ole_initializer.h"
#endif

class AudioManager;
class BrowserOnlineStateObserver;
class CommandLine;
class HighResolutionTimerManager;
Expand All @@ -25,6 +24,10 @@ namespace base {
class SystemMonitor;
}

namespace media {
class AudioManager;
}

namespace net {
class NetworkChangeNotifier;
}
Expand Down Expand Up @@ -66,7 +69,7 @@ class BrowserMainLoop {
int GetResultCode() const { return result_code_; }

// Can be called on any thread.
static AudioManager* GetAudioManager();
static media::AudioManager* GetAudioManager();

private:
// For ShutdownThreadsAndCleanUp.
Expand All @@ -89,7 +92,7 @@ class BrowserMainLoop {
scoped_ptr<base::SystemMonitor> system_monitor_;
scoped_ptr<HighResolutionTimerManager> hi_res_timer_manager_;
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
scoped_ptr<AudioManager> audio_manager_;
scoped_ptr<media::AudioManager> audio_manager_;
// Per-process listener for online state changes.
scoped_ptr<BrowserOnlineStateObserver> online_state_observer_;
#if defined(OS_WIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const char AudioInputDeviceManager::kInvalidDeviceId[] = "";
// Starting id for the first capture session.
const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1;

AudioInputDeviceManager::AudioInputDeviceManager(AudioManager* audio_manager)
AudioInputDeviceManager::AudioInputDeviceManager(
media::AudioManager* audio_manager)
: listener_(NULL),
next_capture_session_id_(kFirstSessionId),
audio_manager_(audio_manager) {
Expand Down Expand Up @@ -127,7 +128,7 @@ void AudioInputDeviceManager::Start(
// the callback immediately.
if (session_id == kFakeOpenSessionId) {
event_handler->OnDeviceStarted(session_id,
AudioManagerBase::kDefaultDeviceId);
media::AudioManagerBase::kDefaultDeviceId);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#include "content/common/media/media_stream_options.h"
#include "media/audio/audio_device_name.h"

namespace media {
class AudioManager;
}

namespace media_stream {

Expand All @@ -39,7 +41,7 @@ class CONTENT_EXPORT AudioInputDeviceManager
static const int kInvalidSessionId;
static const char kInvalidDeviceId[];

explicit AudioInputDeviceManager(AudioManager* audio_manager);
explicit AudioInputDeviceManager(media::AudioManager* audio_manager);

// MediaStreamProvider implementation, called on IO thread.
virtual void Register(MediaStreamProviderListener* listener) OVERRIDE;
Expand Down Expand Up @@ -72,7 +74,7 @@ class CONTENT_EXPORT AudioInputDeviceManager
typedef std::map<int, media::AudioDeviceName> AudioInputDeviceMap;
AudioInputDeviceMap devices_;
// TODO(tommi): Is it necessary to store this as a member?
AudioManager* audio_manager_;
media::AudioManager* audio_manager_;

DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class AudioInputDeviceManagerTest : public testing::Test {
message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO));
io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO,
message_loop_.get()));
audio_manager_.reset(AudioManager::Create());
audio_manager_.reset(media::AudioManager::Create());

manager_ = new AudioInputDeviceManager(audio_manager_.get());
audio_input_listener_.reset(new MockAudioInputDeviceManagerListener());
Expand All @@ -129,7 +129,7 @@ class AudioInputDeviceManagerTest : public testing::Test {
scoped_ptr<BrowserThreadImpl> io_thread_;
scoped_refptr<AudioInputDeviceManager> manager_;
scoped_ptr<MockAudioInputDeviceManagerListener> audio_input_listener_;
scoped_ptr<AudioManager> audio_manager_;
scoped_ptr<media::AudioManager> audio_manager_;

private:
DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManagerTest);
Expand Down Expand Up @@ -414,11 +414,11 @@ TEST_F(AudioInputDeviceManagerTest, StartDeviceTwice) {
manager_->Start(second_session_id, second_event_handler.get());
EXPECT_CALL(*first_event_handler,
DeviceStarted(first_session_id,
AudioManagerBase::kDefaultDeviceId))
media::AudioManagerBase::kDefaultDeviceId))
.Times(1);
EXPECT_CALL(*second_event_handler,
DeviceStarted(second_session_id,
AudioManagerBase::kDefaultDeviceId))
media::AudioManagerBase::kDefaultDeviceId))
.Times(1);
message_loop_->RunAllPending();

Expand Down Expand Up @@ -502,7 +502,7 @@ TEST_F(AudioInputDeviceManagerTest, StartSessionTwice) {
manager_->Start(session_id, audio_input_event_handler.get());
EXPECT_CALL(*audio_input_event_handler,
DeviceStarted(session_id,
AudioManagerBase::kDefaultDeviceId))
media::AudioManagerBase::kDefaultDeviceId))
.Times(1);
message_loop_->RunAllPending();

Expand Down
21 changes: 10 additions & 11 deletions content/browser/renderer_host/media/audio_input_renderer_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ AudioInputRendererHost::AudioEntry::~AudioEntry() {}

AudioInputRendererHost::AudioInputRendererHost(
content::ResourceContext* resource_context,
AudioManager* audio_manager)
media::AudioManager* audio_manager)
: resource_context_(resource_context),
audio_manager_(audio_manager) {
}
Expand Down Expand Up @@ -114,8 +114,8 @@ void AudioInputRendererHost::DoCompleteCreation(
return;
}

AudioInputSyncWriter* writer =
static_cast<AudioInputSyncWriter*>(entry->writer.get());
media::AudioInputSyncWriter* writer =
static_cast<media::AudioInputSyncWriter*>(entry->writer.get());

#if defined(OS_WIN)
base::SyncSocket::Handle foreign_socket_handle;
Expand Down Expand Up @@ -197,24 +197,23 @@ 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,
const std::string& device_id,
bool automatic_gain_control) {
void AudioInputRendererHost::OnCreateStream(
int stream_id, const media::AudioParameters& params,
const std::string& device_id, bool automatic_gain_control) {
VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id="
<< stream_id << ")";
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(LookupById(stream_id) == NULL);

AudioParameters audio_params(params);
media::AudioParameters audio_params(params);

DCHECK_GT(audio_params.frames_per_buffer(), 0);
uint32 buffer_size = audio_params.GetBytesPerBuffer();

// Create a new AudioEntry structure.
scoped_ptr<AudioEntry> entry(new AudioEntry());

uint32 mem_size = sizeof(AudioInputBufferParameters) + buffer_size;
uint32 mem_size = sizeof(media::AudioInputBufferParameters) + buffer_size;

// Create the shared memory and share it with the renderer process
// using a new SyncWriter object.
Expand All @@ -224,8 +223,8 @@ void AudioInputRendererHost::OnCreateStream(int stream_id,
return;
}

scoped_ptr<AudioInputSyncWriter> writer(
new AudioInputSyncWriter(&entry->shared_memory));
scoped_ptr<media::AudioInputSyncWriter> writer(
new media::AudioInputSyncWriter(&entry->shared_memory));

if (!writer->Init()) {
SendErrorMessage(stream_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ namespace content {
class ResourceContext;
}

namespace media {
class AudioManager;
class AudioParameters;
}

class CONTENT_EXPORT AudioInputRendererHost
: public content::BrowserMessageFilter,
Expand Down Expand Up @@ -99,7 +101,7 @@ class CONTENT_EXPORT AudioInputRendererHost

// Called from UI thread from the owner of this object.
AudioInputRendererHost(content::ResourceContext* resource_context,
AudioManager* audio_manager);
media::AudioManager* audio_manager);

// content::BrowserMessageFilter implementation.
virtual void OnChannelClosing() OVERRIDE;
Expand Down Expand Up @@ -139,7 +141,7 @@ class CONTENT_EXPORT AudioInputRendererHost
// successful this object would keep an internal entry of the stream for the
// required properties.
void OnCreateStream(int stream_id,
const AudioParameters& params,
const media::AudioParameters& params,
const std::string& device_id,
bool automatic_gain_control);

Expand Down Expand Up @@ -197,7 +199,7 @@ class CONTENT_EXPORT AudioInputRendererHost

// Used to get an instance of AudioInputDeviceManager.
content::ResourceContext* resource_context_;
AudioManager* audio_manager_;
media::AudioManager* audio_manager_;

// A map of stream IDs to audio sources.
typedef std::map<int, AudioEntry*> AudioEntryMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "base/process_util.h"
#include "base/shared_memory.h"

namespace media {

AudioInputSyncWriter::AudioInputSyncWriter(base::SharedMemory* shared_memory)
: shared_memory_(shared_memory) {
}
Expand Down Expand Up @@ -64,3 +66,5 @@ bool AudioInputSyncWriter::PrepareForeignSocketHandle(
}

#endif

} // namespace media
3 changes: 3 additions & 0 deletions content/browser/renderer_host/media/audio_input_sync_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace base {
class SharedMemory;
}

namespace media {
// A AudioInputController::SyncWriter implementation using SyncSocket. This
// is used by AudioInputController to provide a low latency data source for
// transmitting audio packets between the browser process and the renderer
Expand Down Expand Up @@ -51,4 +52,6 @@ class AudioInputSyncWriter : public media::AudioInputController::SyncWriter {
DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputSyncWriter);
};

} // namespace media

#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_
6 changes: 3 additions & 3 deletions content/browser/renderer_host/media/audio_renderer_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ AudioRendererHost::AudioEntry::~AudioEntry() {}
///////////////////////////////////////////////////////////////////////////////
// AudioRendererHost implementations.
AudioRendererHost::AudioRendererHost(
AudioManager* audio_manager,
media::AudioManager* audio_manager,
content::MediaObserver* media_observer)
: audio_manager_(audio_manager),
media_observer_(media_observer) {
Expand Down Expand Up @@ -192,11 +192,11 @@ bool AudioRendererHost::OnMessageReceived(const IPC::Message& message,
}

void AudioRendererHost::OnCreateStream(
int stream_id, const AudioParameters& params) {
int stream_id, const media::AudioParameters& params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(LookupById(stream_id) == NULL);

AudioParameters audio_params(params);
media::AudioParameters audio_params(params);
DCHECK_GT(audio_params.frames_per_buffer(), 0);

uint32 buffer_size = audio_params.GetBytesPerBuffer();
Expand Down
14 changes: 8 additions & 6 deletions content/browser/renderer_host/media/audio_renderer_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@
#include "media/audio/audio_output_controller.h"
#include "media/audio/simple_sources.h"

class AudioManager;
class AudioParameters;

namespace content {
class MediaObserver;
class ResourceContext;
} // namespace content

namespace media {
class AudioManager;
class AudioParameters;
}

class CONTENT_EXPORT AudioRendererHost
: public content::BrowserMessageFilter,
public media::AudioOutputController::EventHandler {
Expand Down Expand Up @@ -89,7 +91,7 @@ class CONTENT_EXPORT AudioRendererHost
typedef std::map<int, AudioEntry*> AudioEntryMap;

// Called from UI thread from the owner of this object.
AudioRendererHost(AudioManager* audio_manager,
AudioRendererHost(media::AudioManager* audio_manager,
content::MediaObserver* media_observer);

// content::BrowserMessageFilter implementation.
Expand Down Expand Up @@ -121,7 +123,7 @@ class CONTENT_EXPORT AudioRendererHost
// Creates an audio output stream with the specified format. If this call is
// successful this object would keep an internal entry of the stream for the
// required properties.
void OnCreateStream(int stream_id, const AudioParameters& params);
void OnCreateStream(int stream_id, const media::AudioParameters& params);

// Play the audio stream referenced by |stream_id|.
void OnPlayStream(int stream_id);
Expand Down Expand Up @@ -178,7 +180,7 @@ class CONTENT_EXPORT AudioRendererHost
// A map of stream IDs to audio sources.
AudioEntryMap audio_entries_;

AudioManager* audio_manager_;
media::AudioManager* audio_manager_;
content::MediaObserver* media_observer_;

DISALLOW_COPY_AND_ASSIGN(AudioRendererHost);
Expand Down
Loading

0 comments on commit 897bfb5

Please sign in to comment.