Close a window for a race with the system linker
[chromium-blink-merge.git] / ppapi / tests / test_audio.h
blob63e06f48e21e038c0b24b1ba2e0e1e07ae7d0c02
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_
8 #include <string>
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 {
16 public:
17 explicit TestAudio(TestingInstance* instance);
18 ~TestAudio();
20 // TestCase implementation.
21 virtual bool Init();
22 virtual void RunTests(const std::string& filter);
24 private:
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();
36 #endif
38 // Calls |audio_callback_method_| (where |user_data| is "this").
39 static void AudioCallbackTrampoline(void* sample_buffer,
40 uint32_t buffer_size_in_bytes,
41 PP_TimeDelta latency,
42 void* user_data);
43 static void AudioCallbackTrampoline1_0(void* sample_buffer,
44 uint32_t buffer_size_in_bytes,
45 void* user_data);
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_;
72 bool test_done_;
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_