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

Side by Side Diff: media/filters/audio_renderer_base_unittest.cc

Issue 9395057: Fix muted audio when playback rate != 1.0 or 0.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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
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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/gtest_prod_util.h" 6 #include "base/gtest_prod_util.h"
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "media/base/data_buffer.h" 8 #include "media/base/data_buffer.h"
9 #include "media/base/mock_callback.h" 9 #include "media/base/mock_callback.h"
10 #include "media/base/mock_filter_host.h" 10 #include "media/base/mock_filter_host.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 177 }
178 178
179 // Attempts to consume |size| bytes from |renderer_|'s internal buffer, 179 // Attempts to consume |size| bytes from |renderer_|'s internal buffer,
180 // returning true if all |size| bytes were consumed, false if less than 180 // returning true if all |size| bytes were consumed, false if less than
181 // |size| bytes were consumed. 181 // |size| bytes were consumed.
182 // 182 //
183 // |muted| is optional and if passed will get set if the byte value of 183 // |muted| is optional and if passed will get set if the byte value of
184 // the consumed data is muted audio. 184 // the consumed data is muted audio.
185 bool ConsumeBufferedData(uint32 size, bool* muted) { 185 bool ConsumeBufferedData(uint32 size, bool* muted) {
186 scoped_array<uint8> buffer(new uint8[size]); 186 scoped_array<uint8> buffer(new uint8[size]);
187 uint32 bytes_read = renderer_->FillBuffer(buffer.get(), size, 187 uint32 bytes_per_frame = (decoder_->bits_per_channel() / 8) *
acolwell GONE FROM CHROMIUM 2012/02/22 07:51:40 It feels like we are doing this computation in a l
vrk (LEFT CHROMIUM) 2012/02/23 20:33:06 Done in AudioRendererBase.
188 base::TimeDelta()); 188 ChannelLayoutToChannelCount(decoder_->channel_layout());
189 if (bytes_read > 0 && muted) { 189 uint32 requested_frames = size / bytes_per_frame;
190 uint32 frames_read = renderer_->FillBuffer(
191 buffer.get(), requested_frames, base::TimeDelta());
192
193 if (frames_read > 0 && muted) {
190 *muted = (buffer[0] == kMutedAudio); 194 *muted = (buffer[0] == kMutedAudio);
191 } 195 }
192 return (bytes_read == size); 196 return (frames_read == requested_frames);
193 } 197 }
194 198
195 uint32 bytes_buffered() { 199 uint32 bytes_buffered() {
196 return renderer_->algorithm_->bytes_buffered(); 200 return renderer_->algorithm_->bytes_buffered();
197 } 201 }
198 202
199 uint32 buffer_capacity() { 203 uint32 buffer_capacity() {
200 return renderer_->algorithm_->QueueCapacity(); 204 return renderer_->algorithm_->QueueCapacity();
201 } 205 }
202 206
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 EXPECT_TRUE(ConsumeBufferedData(bytes_buffered() / 2, NULL)); 434 EXPECT_TRUE(ConsumeBufferedData(bytes_buffered() / 2, NULL));
431 435
432 renderer_->Pause(NewExpectedClosure()); 436 renderer_->Pause(NewExpectedClosure());
433 437
434 AbortPendingRead(); 438 AbortPendingRead();
435 439
436 Seek(base::TimeDelta::FromSeconds(1)); 440 Seek(base::TimeDelta::FromSeconds(1));
437 } 441 }
438 442
439 } // namespace media 443 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698