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

Side by Side Diff: media/audio/audio_low_latency_input_output_unittest.cc

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
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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/environment.h" 6 #include "base/environment.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 template <typename StreamTraits> 304 template <typename StreamTraits>
305 class StreamWrapper { 305 class StreamWrapper {
306 public: 306 public:
307 typedef typename StreamTraits::StreamType StreamType; 307 typedef typename StreamTraits::StreamType StreamType;
308 308
309 explicit StreamWrapper(AudioManager* audio_manager) 309 explicit StreamWrapper(AudioManager* audio_manager)
310 : com_init_(ScopedCOMInitializer::kMTA), 310 : com_init_(ScopedCOMInitializer::kMTA),
311 audio_manager_(audio_manager), 311 audio_manager_(audio_manager),
312 format_(AudioParameters::AUDIO_PCM_LOW_LATENCY), 312 format_(AudioParameters::AUDIO_PCM_LOW_LATENCY),
313 channel_layout_(CHANNEL_LAYOUT_STEREO), 313 channel_layout_(CHANNEL_LAYOUT_STEREO),
314 bits_per_sample_(16) { 314 bits_per_sample_(16),
315 use_browser_mixer_(false) {
315 // Use native/mixing sample rate and N*10ms frame size as default, 316 // Use native/mixing sample rate and N*10ms frame size as default,
316 // where N is platform dependent. 317 // where N is platform dependent.
317 sample_rate_ = StreamTraits::HardwareSampleRate(); 318 sample_rate_ = StreamTraits::HardwareSampleRate();
318 #if defined(OS_MACOSX) 319 #if defined(OS_MACOSX)
319 // 10ms buffer size works well for 44.1, 48, 96 and 192kHz. 320 // 10ms buffer size works well for 44.1, 48, 96 and 192kHz.
320 samples_per_packet_ = (sample_rate_ / 100); 321 samples_per_packet_ = (sample_rate_ / 100);
321 #elif defined(OS_LINUX) || defined(OS_OPENBSD) 322 #elif defined(OS_LINUX) || defined(OS_OPENBSD)
322 // 10ms buffer size works well for 44.1, 48, 96 and 192kHz. 323 // 10ms buffer size works well for 44.1, 48, 96 and 192kHz.
323 samples_per_packet_ = (sample_rate_ / 100); 324 samples_per_packet_ = (sample_rate_ / 100);
324 #elif defined(OS_WIN) 325 #elif defined(OS_WIN)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return CreateStream(); 357 return CreateStream();
357 } 358 }
358 359
359 AudioParameters::Format format() const { return format_; } 360 AudioParameters::Format format() const { return format_; }
360 int channels() const { 361 int channels() const {
361 return ChannelLayoutToChannelCount(channel_layout_); 362 return ChannelLayoutToChannelCount(channel_layout_);
362 } 363 }
363 int bits_per_sample() const { return bits_per_sample_; } 364 int bits_per_sample() const { return bits_per_sample_; }
364 int sample_rate() const { return sample_rate_; } 365 int sample_rate() const { return sample_rate_; }
365 int samples_per_packet() const { return samples_per_packet_; } 366 int samples_per_packet() const { return samples_per_packet_; }
367 bool use_browser_mixer() const { return use_browser_mixer_; }
366 368
367 private: 369 private:
368 StreamType* CreateStream() { 370 StreamType* CreateStream() {
369 StreamType* stream = StreamTraits::CreateStream(audio_manager_, 371 StreamType* stream = StreamTraits::CreateStream(audio_manager_,
370 AudioParameters(format_, channel_layout_, sample_rate_, 372 AudioParameters(format_, use_browser_mixer_, channel_layout_,
371 bits_per_sample_, samples_per_packet_)); 373 sample_rate_, bits_per_sample_, samples_per_packet_));
372 EXPECT_TRUE(stream); 374 EXPECT_TRUE(stream);
373 return stream; 375 return stream;
374 } 376 }
375 377
376 ScopedCOMInitializer com_init_; 378 ScopedCOMInitializer com_init_;
377 AudioManager* audio_manager_; 379 AudioManager* audio_manager_;
378 AudioParameters::Format format_; 380 AudioParameters::Format format_;
379 ChannelLayout channel_layout_; 381 ChannelLayout channel_layout_;
380 int bits_per_sample_; 382 int bits_per_sample_;
381 int sample_rate_; 383 int sample_rate_;
382 int samples_per_packet_; 384 int samples_per_packet_;
385 bool use_browser_mixer_;
383 }; 386 };
384 387
385 typedef StreamWrapper<AudioInputStreamTraits> AudioInputStreamWrapper; 388 typedef StreamWrapper<AudioInputStreamTraits> AudioInputStreamWrapper;
386 typedef StreamWrapper<AudioOutputStreamTraits> AudioOutputStreamWrapper; 389 typedef StreamWrapper<AudioOutputStreamTraits> AudioOutputStreamWrapper;
387 390
388 // This test is intended for manual tests and should only be enabled 391 // This test is intended for manual tests and should only be enabled
389 // when it is required to make a real-time test of audio in full duplex and 392 // when it is required to make a real-time test of audio in full duplex and
390 // at the same time create a text file which contains measured delay values. 393 // at the same time create a text file which contains measured delay values.
391 // The file can later be analyzed off line using e.g. MATLAB. 394 // The file can later be analyzed off line using e.g. MATLAB.
392 // MATLAB example: 395 // MATLAB example:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 aos->Stop(); 452 aos->Stop();
450 ais->Stop(); 453 ais->Stop();
451 454
452 // All Close() operations that run on the mocked audio thread, 455 // All Close() operations that run on the mocked audio thread,
453 // should be synchronous and not post additional close tasks to 456 // should be synchronous and not post additional close tasks to
454 // mocked the audio thread. Hence, there is no need to call 457 // mocked the audio thread. Hence, there is no need to call
455 // message_loop()->RunAllPending() after the Close() methods. 458 // message_loop()->RunAllPending() after the Close() methods.
456 aos->Close(); 459 aos->Close();
457 ais->Close(); 460 ais->Close();
458 } 461 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698