summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host/audio_renderer_host.h
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-14 19:55:48 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-14 19:55:48 +0000
commitdda6fa35a307c5a77b85602159f434fd7c252836 (patch)
tree4515656a0a870939dbcf6892b48baa02c99c26ca /chrome/browser/renderer_host/audio_renderer_host.h
parent5a23ee545578c03fa81a23d59d7f57528b1592e4 (diff)
downloadchromium_src-dda6fa35a307c5a77b85602159f434fd7c252836.zip
chromium_src-dda6fa35a307c5a77b85602159f434fd7c252836.tar.gz
chromium_src-dda6fa35a307c5a77b85602159f434fd7c252836.tar.bz2
Rollback my change that seems to break some tests.
TBR Review URL: http://codereview.chromium.org/21375 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9825 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/audio_renderer_host.h')
-rw-r--r--chrome/browser/renderer_host/audio_renderer_host.h78
1 files changed, 36 insertions, 42 deletions
diff --git a/chrome/browser/renderer_host/audio_renderer_host.h b/chrome/browser/renderer_host/audio_renderer_host.h
index bcdf640..df2c14e 100644
--- a/chrome/browser/renderer_host/audio_renderer_host.h
+++ b/chrome/browser/renderer_host/audio_renderer_host.h
@@ -6,16 +6,17 @@
// lives inside the render process and provide access to audio hardware. It maps
// an internal ID to AudioRendererHost::IPCAudioSource in a map, which is the
// actual object providing audio packets through IPC. It creates the actual
-// AudioOutputStream object when requested by the renderer provided with
-// render view id and stream id.
+// AudioOutputStream object when requested by the renderer and returns an
+// internal ID. It then delegates calls to the AudioOutputStream object indexed
+// by the internal id.
//
// AudioRendererHost::IPCAudioSource is a container of AudioOutputStream and
// provide audio packets to the associated AudioOutputStream through IPC. It
// transforms the pull data model to a push model used for IPC. When asked by
// AudioOutputStream for an audio packet, it would send a message to renderer,
// passing a SharedMemoryHandle for filling the buffer.
-// NotifyPacketReady(|render_view_id|, |stream_id|) would be called when the
-// buffer is filled and ready to be consumed.
+// NotifyPacketReady(|stream_id|) would be called when the buffer is filled
+// and ready to be consumed.
//
// This class is owned by BrowserRenderProcessHost, and instantiated on UI
// thread, but all other operations and method calls (except Destroy()) happens
@@ -40,8 +41,7 @@
#ifndef CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_
#define CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_
-#include <map>
-
+#include "base/id_map.h"
#include "base/ref_counted.h"
#include "base/shared_memory.h"
#include "chrome/common/ipc_message.h"
@@ -52,55 +52,55 @@ class MessageLoop;
class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> {
public:
+ static const int32 INVALID_ID = 0;
+
explicit AudioRendererHost(MessageLoop* message_loop);
~AudioRendererHost();
// Creates an audio output stream with the specified format, returns the
- // true if successful. If this call is successful this object would keep an
- // internal entry of the stream about the required properties, renderer
- // process handle and IPC channel for sending buffer request messages.
- bool CreateStream(IPC::Message::Sender* sender, base::ProcessHandle handle,
- int32 render_view_id, int32 stream_id,
- AudioManager::Format format, int channels, int sample_rate,
- int bits_per_sample, size_t packet_size);
+ // stream id if successful, otherwise INVALID_ID. If this call is successful
+ // this object would keep an internal entry of the stream about the
+ // required properties, renderer process handle and IPC channel for sending
+ // buffer request messages.
+ int32 CreateStream(IPC::Message::Sender* sender, base::ProcessHandle handle,
+ AudioManager::Format format, int channels, int sample_rate,
+ int bits_per_sample, size_t packet_size);
// Start the audio output strean, return false if stream doesn't exist or the
// cannot start.
- bool Start(int32 render_view_id, int32 stream_id);
+ bool Start(int32 stream_id);
// Stop the audio output stream, return false if stream doesn't exist or
// cannot stop.
- bool Stop(int32 render_view_id, int32 stream_id);
+ bool Stop(int32 stream_id);
// Close the audio output stream, return false if stream doesn't exist or
// cannot close. If this call is successful, the AudioOutputStream correspond
- // to (|render_view_id|, |stream_id|) would go unmanaged by this class,
- // subsequent calls to this object with the same
- // (|render_view_id|, |stream_id|) would fail.
- bool Close(int32 render_view_id, int32 stream_id);
+ // to |stream_id| would go unmanaged by this class, subsequent calls to
+ // this object with the same |stream_id| would fail.
+ bool Close(int32 stream_id);
// Set the volume for the stream specified, returns true if successful, false
// if stream doesn't exist or cann't set volume.
- bool SetVolume(int32 render_view_id, int32 stream_id,
- double left_channel, double right_channel);
+ bool SetVolume(
+ int32 stream_id, double left_channel, double right_channel);
// Get the volume of the stream specified, returns true if successful, false
// is stream doesn't exist or can't get volume.
- bool GetVolume(int32 render_view_id, int32 stream_id,
- double* left_channel, double* right_channel);
+ bool GetVolume(
+ int32 stream_id, double* left_channel, double* right_channel);
// Notify packet has been prepared for stream specified by |stream_id|. The
- // buffer associated with (|render_view_id|, |stream_id|) has been filled and
- // is ready to be consumed.
- void NotifyPacketReady(int32 render_view_id, int32 stream_id);
+ // buffer associated with |stream_id| has been filled and is ready to be
+ // consumed.
+ void NotifyPacketReady(int32 stream_id);
// Called from UI thread from the owner of this object.
void Destroy();
- // Destroy the stream specified by (|render_view_id|, |stream_id|) and remove
- // it from map.
+ // Destroy the stream specified by |stream_id| and remove it from map.
// *DO NOT* call this method other than from IPCAudioSource.
- void DestroySource(int32 render_view_id, int32 stream_id);
+ void DestroySource(int32 stream_id);
private:
// Methods called on IO thread.
@@ -117,8 +117,7 @@ class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> {
class IPCAudioSource : public AudioOutputStream::AudioSourceCallback {
public:
IPCAudioSource(AudioRendererHost* host, // Host of this source.
- int32 render_view_id, // Routing ID to RenderView.
- int32 stream_id, // ID of this source.
+ int32 id, // ID of this source.
AudioOutputStream* stream, // Stream associated.
IPC::Message::Sender* sender, // IPC sender to user.
base::ProcessHandle process, // Render process handle.
@@ -136,28 +135,23 @@ class AudioRendererHost : public base::RefCountedThreadSafe<AudioRendererHost> {
// consumed.
void NotifyPacketReady();
- int32 render_view_id() { return render_view_id_; }
- int32 stream_id() { return stream_id_; }
+ int32 id() { return id_; }
AudioOutputStream* stream() { return stream_; }
private:
AudioRendererHost* host_;
- int32 render_view_id_;
- int32 stream_id_;
+ int32 id_;
AudioOutputStream* stream_;
IPC::Message::Sender* sender_;
base::SharedMemory shared_memory_;
base::SharedMemoryHandle foreign_memory_handle_;
};
- // Look up a IPCAudioSource with a tuple of render view id and stream id.
- // Return NULL if not found.
- IPCAudioSource* Lookup(int render_view_id, int stream_id);
-
// A map of id to audio sources.
- typedef std::pair<int32, int32> SourceID;
- typedef std::map<SourceID, IPCAudioSource*> SourceMap;
- SourceMap sources_;
+ IDMap<IPCAudioSource> sources_;
+
+ // An internal id for streams.
+ int32 next_id_;
// Only used for DCHECKs to make sure all methods calls are from the same
// thread as this object is created.