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

Side by Side Diff: media/audio/audio_output_mixer.h

Issue 12082111: Delete AudioOutputMixer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix .gyp Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/audio_output_mixer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // AudioOutputMixer is a class that implements browser-side audio mixer.
6 // AudioOutputMixer implements both AudioOutputDispatcher and
7 // AudioSourceCallback interfaces.
8
9 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_
10 #define MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_
11
12 #include <map>
13
14 #include "base/basictypes.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h"
18 #include "base/synchronization/lock.h"
19 #include "base/timer.h"
20 #include "media/audio/audio_io.h"
21 #include "media/audio/audio_manager.h"
22 #include "media/audio/audio_output_dispatcher.h"
23 #include "media/audio/audio_parameters.h"
24
25 namespace media {
26
27 class MEDIA_EXPORT AudioOutputMixer
28 : public AudioOutputDispatcher,
29 public AudioOutputStream::AudioSourceCallback {
30 public:
31 AudioOutputMixer(AudioManager* audio_manager,
32 const AudioParameters& params,
33 const base::TimeDelta& close_delay);
34
35 // AudioOutputDispatcher interface.
36 virtual bool OpenStream() OVERRIDE;
37 virtual bool StartStream(AudioOutputStream::AudioSourceCallback* callback,
38 AudioOutputProxy* stream_proxy) OVERRIDE;
39 virtual void StopStream(AudioOutputProxy* stream_proxy) OVERRIDE;
40 virtual void StreamVolumeSet(AudioOutputProxy* stream_proxy,
41 double volume) OVERRIDE;
42 virtual void CloseStream(AudioOutputProxy* stream_proxy) OVERRIDE;
43 virtual void Shutdown() OVERRIDE;
44
45 // AudioSourceCallback interface.
46 virtual uint32 OnMoreData(uint8* dest,
47 uint32 max_size,
48 AudioBuffersState buffers_state) OVERRIDE;
49 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE;
50 virtual void WaitTillDataReady() OVERRIDE;
51
52 private:
53 friend class base::RefCountedThreadSafe<AudioOutputMixer>;
54 virtual ~AudioOutputMixer();
55
56 // Called by |close_timer_|. Closes physical stream.
57 void ClosePhysicalStream();
58
59 // The |lock_| must be acquired whenever we modify |proxies_| in the audio
60 // manager thread or accessing it in the hardware audio thread. Read in the
61 // audio manager thread is safe.
62 base::Lock lock_;
63
64 // List of audio output proxies currently being played.
65 // For every proxy we store aux structure containing data necessary for
66 // mixing.
67 struct ProxyData {
68 AudioOutputStream::AudioSourceCallback* audio_source_callback;
69 double volume;
70 int pending_bytes;
71 };
72 typedef std::map<AudioOutputProxy*, ProxyData> ProxyMap;
73 ProxyMap proxies_;
74
75 // Physical stream for this mixer.
76 scoped_ptr<AudioOutputStream> physical_stream_;
77
78 // Temporary buffer used when mixing. Allocated in the constructor
79 // to avoid constant allocation/deallocation in the callback.
80 scoped_array<uint8> mixer_data_;
81
82 // Used to post delayed tasks to ourselves that we cancel inside Shutdown().
83 base::WeakPtrFactory<AudioOutputMixer> weak_this_;
84 base::DelayTimer<AudioOutputMixer> close_timer_;
85
86 // Size of data in all in-flight buffers.
87 int pending_bytes_;
88
89 DISALLOW_COPY_AND_ASSIGN(AudioOutputMixer);
90 };
91
92 } // namespace media
93
94 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_
OLDNEW
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/audio_output_mixer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698