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

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

Issue 10154007: Change the way audio mixer gets "pending bytes" (amount of data currently buffered (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
« no previous file with comments | « no previous file | media/audio/audio_output_mixer.cc » ('j') | media/audio/audio_output_mixer.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // AudioOutputMixer is a class that implements browser-side audio mixer. 5 // AudioOutputMixer is a class that implements browser-side audio mixer.
6 // AudioOutputMixer implements both AudioOutputDispatcher and 6 // AudioOutputMixer implements both AudioOutputDispatcher and
7 // AudioSourceCallback interfaces. 7 // AudioSourceCallback interfaces.
8 8
9 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_ 9 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_
10 #define MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_ 10 #define MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_
11 11
12 #include <map> 12 #include <map>
13 #include <set>
13 14
14 #include "base/basictypes.h" 15 #include "base/basictypes.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
18 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
19 #include "base/timer.h" 20 #include "base/timer.h"
20 #include "media/audio/audio_io.h" 21 #include "media/audio/audio_io.h"
21 #include "media/audio/audio_manager.h" 22 #include "media/audio/audio_manager.h"
22 #include "media/audio/audio_output_dispatcher.h" 23 #include "media/audio/audio_output_dispatcher.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 virtual ~AudioOutputMixer(); 55 virtual ~AudioOutputMixer();
55 56
56 // Called by |close_timer_|. Closes physical stream. 57 // Called by |close_timer_|. Closes physical stream.
57 void ClosePhysicalStream(); 58 void ClosePhysicalStream();
58 59
59 // The |lock_| must be acquired whenever we modify |proxies_| in the audio 60 // 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 // manager thread or accessing it in the hardware audio thread. Read in the
61 // audio manager thread is safe. 62 // audio manager thread is safe.
62 base::Lock lock_; 63 base::Lock lock_;
63 64
65 // Information for each each in-flight buffer.
66 struct BufferData {
67 explicit BufferData(int len) : length(len) { }
68 int length;
69 };
70 typedef std::map<void*, BufferData> BufferMap;
71 BufferMap buffer_data_;
72
64 // List of audio output proxies currently being played. 73 // List of audio output proxies currently being played.
65 // For every proxy we store aux structure containing data necessary for 74 // For every proxy we store aux structure containing data necessary for
66 // mixing. 75 // mixing.
67 struct ProxyData { 76 struct ProxyData {
68 AudioOutputStream::AudioSourceCallback* audio_source_callback; 77 AudioOutputStream::AudioSourceCallback* audio_source_callback;
69 double volume; 78 double volume;
70 int pending_bytes; 79 int pending_bytes;
80 std::set<void*> buffers; // Used to catch when we stop prebuffering and
81 // start releasing buffers.
82 bool prebuffering;
71 }; 83 };
72 typedef std::map<AudioOutputProxy*, ProxyData> ProxyMap; 84 typedef std::map<AudioOutputProxy*, ProxyData> ProxyMap;
73 ProxyMap proxies_; 85 ProxyMap proxies_;
74 86
75 // Physical stream for this mixer. 87 // Physical stream for this mixer.
76 scoped_ptr<AudioOutputStream> physical_stream_; 88 scoped_ptr<AudioOutputStream> physical_stream_;
77 89
78 // Temporary buffer used when mixing. Allocated in the constructor 90 // Temporary buffer used when mixing. Allocated in the constructor
79 // to avoid constant allocation/deallocation in the callback. 91 // to avoid constant allocation/deallocation in the callback.
80 scoped_array<uint8> mixer_data_; 92 scoped_array<uint8> mixer_data_;
81 93
82 // Used to post delayed tasks to ourselves that we cancel inside Shutdown(). 94 // Used to post delayed tasks to ourselves that we cancel inside Shutdown().
83 base::WeakPtrFactory<AudioOutputMixer> weak_this_; 95 base::WeakPtrFactory<AudioOutputMixer> weak_this_;
84 base::DelayTimer<AudioOutputMixer> close_timer_; 96 base::DelayTimer<AudioOutputMixer> close_timer_;
85 97
86 DISALLOW_COPY_AND_ASSIGN(AudioOutputMixer); 98 DISALLOW_COPY_AND_ASSIGN(AudioOutputMixer);
87 }; 99 };
88 100
89 } // namespace media 101 } // namespace media
90 102
91 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_ 103 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_output_mixer.cc » ('j') | media/audio/audio_output_mixer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698