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

Side by Side Diff: media/filters/audio_renderer_algorithm.h

Issue 205093002: Remove muting for extreme playbackRates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rip out muted_. Created 6 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
« no previous file with comments | « no previous file | media/filters/audio_renderer_algorithm.cc » ('j') | no next file with comments »
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 // AudioRendererAlgorithm buffers and transforms audio data. The owner of 5 // AudioRendererAlgorithm buffers and transforms audio data. The owner of
6 // this object provides audio data to the object through EnqueueBuffer() and 6 // this object provides audio data to the object through EnqueueBuffer() and
7 // requests data from the buffer via FillBuffer(). The owner also sets the 7 // requests data from the buffer via FillBuffer(). The owner also sets the
8 // playback rate, and the AudioRendererAlgorithm will stretch or compress the 8 // playback rate, and the AudioRendererAlgorithm will stretch or compress the
9 // buffered audio as necessary to match the playback rate when fulfilling 9 // buffered audio as necessary to match the playback rate when fulfilling
10 // FillBuffer() requests. 10 // FillBuffer() requests.
11 // 11 //
12 // This class is *not* thread-safe. Calls to enqueue and retrieve data must be 12 // This class is *not* thread-safe. Calls to enqueue and retrieve data must be
13 // locked if called from multiple threads. 13 // locked if called from multiple threads.
14 // 14 //
15 // AudioRendererAlgorithm uses the Waveform Similarity Overlap and Add (WSOLA) 15 // AudioRendererAlgorithm uses the Waveform Similarity Overlap and Add (WSOLA)
16 // algorithm to stretch or compress audio data to meet playback speeds less than 16 // algorithm to stretch or compress audio data to meet playback speeds less than
17 // or greater than the natural playback of the audio stream. The algorithm 17 // or greater than the natural playback of the audio stream. The algorithm
18 // preserves local properties of the audio, therefore, pitch and harmonics are 18 // preserves local properties of the audio, therefore, pitch and harmonics are
19 // are preserved. See audio_renderer_algorith.cc for a more elaborate 19 // are preserved. See audio_renderer_algorith.cc for a more elaborate
20 // description of the algorithm. 20 // description of the algorithm.
21 // 21 //
22 // Audio at very low or very high playback rates are muted to preserve quality.
23 //
24 22
25 #ifndef MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_H_ 23 #ifndef MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_H_
26 #define MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_H_ 24 #define MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_H_
27 25
28 #include "base/memory/ref_counted.h" 26 #include "base/memory/ref_counted.h"
29 #include "base/memory/scoped_ptr.h" 27 #include "base/memory/scoped_ptr.h"
30 #include "media/audio/audio_parameters.h" 28 #include "media/audio/audio_parameters.h"
31 #include "media/base/audio_buffer.h" 29 #include "media/base/audio_buffer.h"
32 #include "media/base/audio_buffer_queue.h" 30 #include "media/base/audio_buffer_queue.h"
33 31
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void IncreaseQueueCapacity(); 75 void IncreaseQueueCapacity();
78 76
79 // Returns the number of frames left in |audio_buffer_|, which may be larger 77 // Returns the number of frames left in |audio_buffer_|, which may be larger
80 // than QueueCapacity() in the event that EnqueueBuffer() delivered more data 78 // than QueueCapacity() in the event that EnqueueBuffer() delivered more data
81 // than |audio_buffer_| was intending to hold. 79 // than |audio_buffer_| was intending to hold.
82 int frames_buffered() { return audio_buffer_.frames(); } 80 int frames_buffered() { return audio_buffer_.frames(); }
83 81
84 // Returns the samples per second for this audio stream. 82 // Returns the samples per second for this audio stream.
85 int samples_per_second() { return samples_per_second_; } 83 int samples_per_second() { return samples_per_second_; }
86 84
87 // Is the sound currently muted?
88 bool is_muted() { return muted_; }
89
90 private: 85 private:
91 // Within |search_block_|, find the block of data that is most similar to 86 // Within |search_block_|, find the block of data that is most similar to
92 // |target_block_|, and write it in |optimal_block_|. This method assumes that 87 // |target_block_|, and write it in |optimal_block_|. This method assumes that
93 // there is enough data to perform a search, i.e. |search_block_| and 88 // there is enough data to perform a search, i.e. |search_block_| and
94 // |target_block_| can be extracted from the available frames. 89 // |target_block_| can be extracted from the available frames.
95 void GetOptimalBlock(); 90 void GetOptimalBlock();
96 91
97 // Read a maximum of |requested_frames| frames from |wsola_output_|. Returns 92 // Read a maximum of |requested_frames| frames from |wsola_output_|. Returns
98 // number of frames actually read. 93 // number of frames actually read.
99 int WriteCompletedFramesTo( 94 int WriteCompletedFramesTo(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 128
134 // Sample rate of audio stream. 129 // Sample rate of audio stream.
135 int samples_per_second_; 130 int samples_per_second_;
136 131
137 // Used by algorithm to scale output. 132 // Used by algorithm to scale output.
138 float playback_rate_; 133 float playback_rate_;
139 134
140 // Buffered audio data. 135 // Buffered audio data.
141 AudioBufferQueue audio_buffer_; 136 AudioBufferQueue audio_buffer_;
142 137
143 // True if the audio should be muted.
144 bool muted_;
145
146 // If muted, keep track of partial frames that should have been skipped over.
147 double muted_partial_frame_;
148
149 // How many frames to have in the queue before we report the queue is full. 138 // How many frames to have in the queue before we report the queue is full.
150 int capacity_; 139 int capacity_;
151 140
152 // Book keeping of the current time of generated audio, in frames. This 141 // Book keeping of the current time of generated audio, in frames. This
153 // should be appropriately updated when out samples are generated, regardless 142 // should be appropriately updated when out samples are generated, regardless
154 // of whether we push samples out when FillBuffer() is called or we store 143 // of whether we push samples out when FillBuffer() is called or we store
155 // audio in |wsola_output_| for the subsequent calls to FillBuffer(). 144 // audio in |wsola_output_| for the subsequent calls to FillBuffer().
156 // Furthermore, if samples from |audio_buffer_| are evicted then this 145 // Furthermore, if samples from |audio_buffer_| are evicted then this
157 // member variable should be updated based on |playback_rate_|. 146 // member variable should be updated based on |playback_rate_|.
158 // Note that this member should be updated ONLY by calling UpdateOutputTime(), 147 // Note that this member should be updated ONLY by calling UpdateOutputTime(),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // searched for a block (|optimal_block_|) that is most similar to 201 // searched for a block (|optimal_block_|) that is most similar to
213 // |target_block_|. 202 // |target_block_|.
214 scoped_ptr<AudioBus> target_block_; 203 scoped_ptr<AudioBus> target_block_;
215 204
216 DISALLOW_COPY_AND_ASSIGN(AudioRendererAlgorithm); 205 DISALLOW_COPY_AND_ASSIGN(AudioRendererAlgorithm);
217 }; 206 };
218 207
219 } // namespace media 208 } // namespace media
220 209
221 #endif // MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_H_ 210 #endif // MEDIA_FILTERS_AUDIO_RENDERER_ALGORITHM_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/audio_renderer_algorithm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698