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

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

Issue 10990079: Clean up scoped_com_initializer.h. Remove #ifdefs for non-Windows (this is in base/win, no one sho… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "base/test/test_timeouts.h" 12 #include "base/test/test_timeouts.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "base/win/scoped_com_initializer.h"
15 #include "build/build_config.h" 14 #include "build/build_config.h"
16 #include "media/audio/audio_io.h" 15 #include "media/audio/audio_io.h"
17 #include "media/audio/audio_manager_base.h" 16 #include "media/audio/audio_manager_base.h"
18 #include "media/audio/audio_util.h" 17 #include "media/audio/audio_util.h"
18 #include "media/base/seekable_buffer.h"
19 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h"
21
19 #if defined(OS_LINUX) || defined(OS_OPENBSD) 22 #if defined(OS_LINUX) || defined(OS_OPENBSD)
20 #include "media/audio/linux/audio_manager_linux.h" 23 #include "media/audio/linux/audio_manager_linux.h"
21 #elif defined(OS_MACOSX) 24 #elif defined(OS_MACOSX)
22 #include "media/audio/mac/audio_manager_mac.h" 25 #include "media/audio/mac/audio_manager_mac.h"
23 #elif defined(OS_WIN) 26 #elif defined(OS_WIN)
27 #include "base/win/scoped_com_initializer.h"
24 #include "media/audio/win/audio_manager_win.h" 28 #include "media/audio/win/audio_manager_win.h"
25 #elif defined(OS_ANDROID) 29 #elif defined(OS_ANDROID)
26 #include "media/audio/android/audio_manager_android.h" 30 #include "media/audio/android/audio_manager_android.h"
27 #endif 31 #endif
28 #include "media/base/seekable_buffer.h"
29 #include "testing/gmock/include/gmock/gmock.h"
30 #include "testing/gtest/include/gtest/gtest.h"
31
32 using base::win::ScopedCOMInitializer;
33 32
34 namespace media { 33 namespace media {
35 34
36 #if defined(OS_LINUX) || defined(OS_OPENBSD) 35 #if defined(OS_LINUX) || defined(OS_OPENBSD)
37 typedef AudioManagerLinux AudioManagerAnyPlatform; 36 typedef AudioManagerLinux AudioManagerAnyPlatform;
38 #elif defined(OS_MACOSX) 37 #elif defined(OS_MACOSX)
39 typedef AudioManagerMac AudioManagerAnyPlatform; 38 typedef AudioManagerMac AudioManagerAnyPlatform;
40 #elif defined(OS_WIN) 39 #elif defined(OS_WIN)
41 typedef AudioManagerWin AudioManagerAnyPlatform; 40 typedef AudioManagerWin AudioManagerAnyPlatform;
42 #elif defined(OS_ANDROID) 41 #elif defined(OS_ANDROID)
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 }; 317 };
319 318
320 // Traits template holding a trait of StreamType. It encapsulates 319 // Traits template holding a trait of StreamType. It encapsulates
321 // AudioInputStream and AudioOutputStream stream types. 320 // AudioInputStream and AudioOutputStream stream types.
322 template <typename StreamTraits> 321 template <typename StreamTraits>
323 class StreamWrapper { 322 class StreamWrapper {
324 public: 323 public:
325 typedef typename StreamTraits::StreamType StreamType; 324 typedef typename StreamTraits::StreamType StreamType;
326 325
327 explicit StreamWrapper(AudioManager* audio_manager) 326 explicit StreamWrapper(AudioManager* audio_manager)
328 : com_init_(ScopedCOMInitializer::kMTA), 327 :
328 #if defined(OS_WIN)
329 com_init_(base::win::ScopedCOMInitializer::kMTA),
330 #endif
329 audio_manager_(audio_manager), 331 audio_manager_(audio_manager),
330 format_(AudioParameters::AUDIO_PCM_LOW_LATENCY), 332 format_(AudioParameters::AUDIO_PCM_LOW_LATENCY),
331 #if defined(OS_ANDROID) 333 #if defined(OS_ANDROID)
332 channel_layout_(CHANNEL_LAYOUT_MONO), 334 channel_layout_(CHANNEL_LAYOUT_MONO),
333 #else 335 #else
334 channel_layout_(CHANNEL_LAYOUT_STEREO), 336 channel_layout_(CHANNEL_LAYOUT_STEREO),
335 #endif 337 #endif
336 bits_per_sample_(16) { 338 bits_per_sample_(16) {
337 // Use native/mixing sample rate and N*10ms frame size as default, 339 // Use native/mixing sample rate and N*10ms frame size as default,
338 // where N is platform dependent. 340 // where N is platform dependent.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 384
383 private: 385 private:
384 StreamType* CreateStream() { 386 StreamType* CreateStream() {
385 StreamType* stream = StreamTraits::CreateStream(audio_manager_, 387 StreamType* stream = StreamTraits::CreateStream(audio_manager_,
386 AudioParameters(format_, channel_layout_, sample_rate_, 388 AudioParameters(format_, channel_layout_, sample_rate_,
387 bits_per_sample_, samples_per_packet_)); 389 bits_per_sample_, samples_per_packet_));
388 EXPECT_TRUE(stream); 390 EXPECT_TRUE(stream);
389 return stream; 391 return stream;
390 } 392 }
391 393
392 ScopedCOMInitializer com_init_; 394 #if defined(OS_WIN)
395 base::win::ScopedCOMInitializer com_init_;
396 #endif
397
393 AudioManager* audio_manager_; 398 AudioManager* audio_manager_;
394 AudioParameters::Format format_; 399 AudioParameters::Format format_;
395 ChannelLayout channel_layout_; 400 ChannelLayout channel_layout_;
396 int bits_per_sample_; 401 int bits_per_sample_;
397 int sample_rate_; 402 int sample_rate_;
398 int samples_per_packet_; 403 int samples_per_packet_;
399 }; 404 };
400 405
401 typedef StreamWrapper<AudioInputStreamTraits> AudioInputStreamWrapper; 406 typedef StreamWrapper<AudioInputStreamTraits> AudioInputStreamWrapper;
402 typedef StreamWrapper<AudioOutputStreamTraits> AudioOutputStreamWrapper; 407 typedef StreamWrapper<AudioOutputStreamTraits> AudioOutputStreamWrapper;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 472
468 // All Close() operations that run on the mocked audio thread, 473 // All Close() operations that run on the mocked audio thread,
469 // should be synchronous and not post additional close tasks to 474 // should be synchronous and not post additional close tasks to
470 // mocked the audio thread. Hence, there is no need to call 475 // mocked the audio thread. Hence, there is no need to call
471 // message_loop()->RunAllPending() after the Close() methods. 476 // message_loop()->RunAllPending() after the Close() methods.
472 aos->Close(); 477 aos->Close();
473 ais->Close(); 478 ais->Close();
474 } 479 }
475 480
476 } // namespace media 481 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698