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

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

Issue 9691001: Audio software mixer. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 9 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_ 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/lock.h"
11 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.h"
12 #include "media/audio/audio_io.h" 13 #include "media/audio/audio_io.h"
13 #include "media/audio/audio_parameters.h" 14 #include "media/audio/audio_parameters.h"
14 15
15 class AudioOutputDispatcher; 16 class AudioOutputDispatcher;
16 17
17 // AudioOutputProxy is an audio otput stream that uses resources more 18 // AudioOutputProxy is an audio otput stream that uses resources more
18 // efficiently than a regular audio output stream: it opens audio 19 // efficiently than a regular audio output stream: it opens audio
19 // device only when sound is playing, i.e. between Start() and Stop() 20 // device only when sound is playing, i.e. between Start() and Stop()
20 // (there is still one physical stream per each audio output proxy in 21 // (there is still one physical stream per each audio output proxy in
21 // playing state). 22 // playing state).
22 // 23 //
23 // AudioOutputProxy uses AudioOutputDispatcher to open and close 24 // AudioOutputProxy uses AudioOutputDispatcher to open and close
24 // physical output streams. 25 // physical output streams.
25 class MEDIA_EXPORT AudioOutputProxy 26 class MEDIA_EXPORT AudioOutputProxy
26 : public AudioOutputStream, 27 : public AudioOutputStream,
27 public NON_EXPORTED_BASE(base::NonThreadSafe) { 28 public NON_EXPORTED_BASE(base::NonThreadSafe) {
28 public: 29 public:
29 // Caller keeps ownership of |dispatcher|. 30 // Caller keeps ownership of |dispatcher|.
30 explicit AudioOutputProxy(AudioOutputDispatcher* dispatcher); 31 explicit AudioOutputProxy(AudioOutputDispatcher* dispatcher);
31 32
33 // Accessors.
34 AudioSourceCallback* audio_source_callback() const {
35 return audio_source_callback_;
36 }
37
38 int pending_bytes() const {
39 return pending_bytes_;
40 }
41
42 void set_pending_bytes(int pending_bytes) {
43 pending_bytes_ = pending_bytes;
44 }
45
32 // AudioOutputStream interface. 46 // AudioOutputStream interface.
33 virtual bool Open() OVERRIDE; 47 virtual bool Open() OVERRIDE;
34 virtual void Start(AudioSourceCallback* callback) OVERRIDE; 48 virtual void Start(AudioSourceCallback* callback) OVERRIDE;
35 virtual void Stop() OVERRIDE; 49 virtual void Stop() OVERRIDE;
36 virtual void SetVolume(double volume) OVERRIDE; 50 virtual void SetVolume(double volume) OVERRIDE;
37 virtual void GetVolume(double* volume) OVERRIDE; 51 virtual void GetVolume(double* volume) OVERRIDE;
38 virtual void Close() OVERRIDE; 52 virtual void Close() OVERRIDE;
39 53
40 private: 54 private:
41 enum State { 55 enum State {
(...skipping 10 matching lines...) Expand all
52 State state_; 66 State state_;
53 67
54 // The actual audio stream. Must be set to NULL in any state other 68 // The actual audio stream. Must be set to NULL in any state other
55 // than kPlaying. 69 // than kPlaying.
56 AudioOutputStream* physical_stream_; 70 AudioOutputStream* physical_stream_;
57 71
58 // Need to save volume here, so that we can restore it in case the stream 72 // Need to save volume here, so that we can restore it in case the stream
59 // is stopped, and then started again. 73 // is stopped, and then started again.
60 double volume_; 74 double volume_;
61 75
76 // Callback.
77 AudioSourceCallback* audio_source_callback_;
78
79 // Lock protecting |volume_| -- we can read it in the hardware audio thread.
80 base::Lock lock_;
81
82 // Number of pending bytes in the buffer.
83 // Initialized in Start() and after that accessed only in the hardware thread.
84 int pending_bytes_;
85
62 DISALLOW_COPY_AND_ASSIGN(AudioOutputProxy); 86 DISALLOW_COPY_AND_ASSIGN(AudioOutputProxy);
63 }; 87 };
64 88
65 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_ 89 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698