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
3 // found in the LICENSE file.
5 #ifndef PAPPI_TESTS_TEST_AUDIO_H_
6 #define PAPPI_TESTS_TEST_AUDIO_H_
10 #include "ppapi/c/ppb_audio.h"
11 #include "ppapi/c/ppb_audio_config.h"
12 #include "ppapi/c/ppb_core.h"
13 #include "ppapi/tests/test_case.h"
15 class TestAudio
: public TestCase
{
17 explicit TestAudio(TestingInstance
* instance
);
20 // TestCase implementation.
22 virtual void RunTests(const std::string
& filter
);
25 std::string
TestCreation();
26 std::string
TestDestroyNoStop();
27 std::string
TestFailures();
28 std::string
TestAudioCallback1();
29 std::string
TestAudioCallback2();
30 std::string
TestAudioCallback3();
31 std::string
TestAudioCallback4();
33 #if defined(__native_client__)
34 std::string
TestAudioThreadCreatorIsRequired();
35 std::string
TestAudioThreadCreatorIsCalled();
38 // Calls |audio_callback_method_| (where |user_data| is "this").
39 static void AudioCallbackTrampoline(void* sample_buffer
,
40 uint32_t buffer_size_in_bytes
,
43 static void AudioCallbackTrampoline1_0(void* sample_buffer
,
44 uint32_t buffer_size_in_bytes
,
47 typedef void (TestAudio::*AudioCallbackMethod
)(void* sample_buffer
,
48 uint32_t buffer_size_in_bytes
,
49 PP_TimeDelta latency
);
51 // Method called by |AudioCallbackTrampoline()|. Set only when the callback
52 // can't be running (before |StartPlayback()|, after |StopPlayback()| or
53 // releasing the last reference to the audio resource).
54 AudioCallbackMethod audio_callback_method_
;
56 // An |AudioCallbackMethod| that just clears |sample_buffer|.
57 void AudioCallbackTrivial(void* sample_buffer
,
58 uint32_t buffer_size_in_bytes
,
59 PP_TimeDelta latency
);
61 // |AudioCallbackMethod| used by |TestAudioCallbackN()|.
62 void AudioCallbackTest(void* sample_buffer
,
63 uint32_t buffer_size_in_bytes
,
64 PP_TimeDelta latency
);
66 PP_Resource
CreateAudioConfig(PP_AudioSampleRate sample_rate
,
67 uint32_t requested_sample_frame_count
);
69 // Used by |TestAudioCallbackN()|.
70 NestedEvent audio_callback_event_
;
74 // Raw C-level interfaces, set in |Init()|; do not modify them elsewhere.
75 const PPB_Audio_1_1
* audio_interface_
;
76 const PPB_Audio_1_0
* audio_interface_1_0_
;
77 const PPB_AudioConfig
* audio_config_interface_
;
78 const PPB_Core
* core_interface_
;
81 #endif // PAPPI_TESTS_TEST_AUDIO_H_