| OLD | NEW |
| 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 "ppapi/tests/test_audio.h" | 5 #include "ppapi/tests/test_audio.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "ppapi/c/ppb_audio_config.h" | 9 #include "ppapi/c/ppb_audio_config.h" |
| 10 #include "ppapi/c/ppb_audio.h" | 10 #include "ppapi/c/ppb_audio.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // frame counts. | 45 // frame counts. |
| 46 std::string TestAudio::TestCreation() { | 46 std::string TestAudio::TestCreation() { |
| 47 static const PP_AudioSampleRate kSampleRates[] = { | 47 static const PP_AudioSampleRate kSampleRates[] = { |
| 48 PP_AUDIOSAMPLERATE_44100, | 48 PP_AUDIOSAMPLERATE_44100, |
| 49 PP_AUDIOSAMPLERATE_48000 | 49 PP_AUDIOSAMPLERATE_48000 |
| 50 }; | 50 }; |
| 51 static const uint32_t kRequestFrameCounts[] = { | 51 static const uint32_t kRequestFrameCounts[] = { |
| 52 PP_AUDIOMINSAMPLEFRAMECOUNT, | 52 PP_AUDIOMINSAMPLEFRAMECOUNT, |
| 53 PP_AUDIOMAXSAMPLEFRAMECOUNT, | 53 PP_AUDIOMAXSAMPLEFRAMECOUNT, |
| 54 // Include some "okay-looking" frame counts; check their validity below. | 54 // Include some "okay-looking" frame counts; check their validity below. |
| 55 PP_AUDIOSAMPLERATE_44100 / 100, // 10ms @ 44.1kHz |
| 56 PP_AUDIOSAMPLERATE_48000 / 100, // 10ms @ 48kHz |
| 57 2 * PP_AUDIOSAMPLERATE_44100 / 100, // 20ms @ 44.1kHz |
| 58 2 * PP_AUDIOSAMPLERATE_48000 / 100, // 20ms @ 48kHz |
| 55 1024, | 59 1024, |
| 56 2048, | 60 2048, |
| 57 4096 | 61 4096 |
| 58 }; | 62 }; |
| 59 | 63 PP_AudioSampleRate sample_rate = audio_config_interface_->RecommendSampleRate( |
| 64 instance_->pp_instance()); |
| 65 ASSERT_TRUE(sample_rate == PP_AUDIOSAMPLERATE_NONE || |
| 66 sample_rate == PP_AUDIOSAMPLERATE_44100 || |
| 67 sample_rate == PP_AUDIOSAMPLERATE_48000); |
| 60 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSampleRates); i++) { | 68 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSampleRates); i++) { |
| 61 PP_AudioSampleRate sample_rate = kSampleRates[i]; | 69 PP_AudioSampleRate sample_rate = kSampleRates[i]; |
| 62 | 70 |
| 63 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(kRequestFrameCounts); j++) { | 71 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(kRequestFrameCounts); j++) { |
| 64 // Make a config, create the audio resource, and release the config. | 72 // Make a config, create the audio resource, and release the config. |
| 65 uint32_t request_frame_count = kRequestFrameCounts[j]; | 73 uint32_t request_frame_count = kRequestFrameCounts[j]; |
| 66 uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount( | 74 uint32_t frame_count = audio_config_interface_->RecommendSampleFrameCount( |
| 67 instance_->pp_instance(), sample_rate, request_frame_count); | 75 instance_->pp_instance(), sample_rate, request_frame_count); |
| 68 PP_Resource ac = audio_config_interface_->CreateStereo16Bit( | 76 PP_Resource ac = audio_config_interface_->CreateStereo16Bit( |
| 69 instance_->pp_instance(), sample_rate, frame_count); | 77 instance_->pp_instance(), sample_rate, frame_count); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // Test the other functions with an invalid audio resource. | 167 // Test the other functions with an invalid audio resource. |
| 160 ASSERT_FALSE(audio_interface_->IsAudio(0)); | 168 ASSERT_FALSE(audio_interface_->IsAudio(0)); |
| 161 ASSERT_EQ(0, audio_interface_->GetCurrentConfig(0)); | 169 ASSERT_EQ(0, audio_interface_->GetCurrentConfig(0)); |
| 162 ASSERT_FALSE(audio_interface_->StartPlayback(0)); | 170 ASSERT_FALSE(audio_interface_->StartPlayback(0)); |
| 163 ASSERT_FALSE(audio_interface_->StopPlayback(0)); | 171 ASSERT_FALSE(audio_interface_->StopPlayback(0)); |
| 164 | 172 |
| 165 PASS(); | 173 PASS(); |
| 166 } | 174 } |
| 167 | 175 |
| 168 // TODO(viettrungluu): Test that callbacks get called, playback happens, etc. | 176 // TODO(viettrungluu): Test that callbacks get called, playback happens, etc. |
| OLD | NEW |