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

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

Issue 9691001: Audio software mixer. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 8 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
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 <vector>
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 class MEDIA_EXPORT AudioOutputMixer
26 : public AudioOutputDispatcher,
27 public AudioOutputStream::AudioSourceCallback {
28 public:
29 AudioOutputMixer(AudioManager* audio_manager,
30 const AudioParameters& params,
31 base::TimeDelta close_delay);
32
33 // AudioOutputDispatcher interface.
34 virtual bool StreamOpened() OVERRIDE;
35 virtual AudioOutputStream* StreamStarted(
36 AudioOutputStream::AudioSourceCallback* callback,
37 AudioOutputProxy* stream_proxy) OVERRIDE;
38 virtual void StreamStopped(AudioOutputStream* physical_stream,
39 AudioOutputProxy* stream_proxy) OVERRIDE;
40 virtual void StreamVolumeSet(AudioOutputStream* physical_stream,
41 double volume) OVERRIDE;
42 virtual void StreamClosed(AudioOutputProxy* stream_proxy) OVERRIDE;
43 virtual void Shutdown() OVERRIDE;
44
45 // AudioSourceCallback interface.
46 virtual uint32 OnMoreData(AudioOutputStream* stream,
47 uint8* dest,
48 uint32 max_size,
49 AudioBuffersState buffers_state) OVERRIDE;
50 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE;
51 virtual void WaitTillDataReady() OVERRIDE;
52
53 private:
54 friend class base::RefCountedThreadSafe<AudioOutputMixer>;
55 ~AudioOutputMixer();
tommi (sloooow) - chröme 2012/04/03 13:47:51 virtual
enal1 2012/04/04 18:46:55 Done.
56
57 // Called by |close_timer_|. Closes physical stream.
58 void ClosePhysicalStream();
59
60 // The |lock_| must be acquired whenever we modify |proxies_| in the audio
61 // manager thread or accessing it in the hardware audio thread. Read in the
62 // audio manager thread is safe.
63 base::Lock lock_;
64
65 // List of audio output proxies.
66 typedef std::vector<AudioOutputProxy*> ProxyList;
vrk (LEFT CHROMIUM) 2012/03/30 22:25:58 Instead of a vector of AudioOutputProxies, please
enal1 2012/04/04 18:46:55 AudioOutputProxy needs to store volume, as it is p
67 ProxyList proxies_;
68
69 // Physical stream for this mixer.
70 scoped_ptr<AudioOutputStream> physical_stream_;
71
72 // Temporary buffer used when mixing. Allocated in the constructor
73 // to avoid constant allocation/deallocation in the callback.
74 scoped_array<uint8> mixer_data_;
75
76 // Used to post delayed tasks to ourselves that we cancel inside Shutdown().
77 base::WeakPtrFactory<AudioOutputMixer> weak_this_;
78 base::DelayTimer<AudioOutputMixer> close_timer_;
79
80 DISALLOW_COPY_AND_ASSIGN(AudioOutputMixer);
81 };
82
83 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698