1 /* pcm_test.h 2 ** 3 ** Copyright 2020, The Android Open Source Project 4 ** 5 ** Redistribution and use in source and binary forms, with or without 6 ** modification, are permitted provided that the following conditions are met: 7 ** * Redistributions of source code must retain the above copyright 8 ** notice, this list of conditions and the following disclaimer. 9 ** * Redistributions in binary form must reproduce the above copyright 10 ** notice, this list of conditions and the following disclaimer in the 11 ** documentation and/or other materials provided with the distribution. 12 ** * Neither the name of The Android Open Source Project nor the names of 13 ** its contributors may be used to endorse or promote products derived 14 ** from this software without specific prior written permission. 15 ** 16 ** THIS SOFTWARE IS PROVIDED BY The Android Open Source Project ``AS IS'' AND 17 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 ** ARE DISCLAIMED. IN NO EVENT SHALL The Android Open Source Project BE LIABLE 20 ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 ** DAMAGE. 27 */ 28 29 #ifndef TINYALSA_TESTS_PCM_TEST_H_ 30 #define TINYALSA_TESTS_PCM_TEST_H_ 31 32 #include "tinyalsa/pcm.h" 33 34 namespace tinyalsa { 35 namespace testing { 36 37 #ifndef TEST_LOOPBACK_CARD 38 #define TEST_LOOPBACK_CARD 2 39 #endif 40 41 #ifndef TEST_LOOPBACK_PLAYBACK_DEVICE 42 #define TEST_LOOPBACK_PLAYBACK_DEVICE 0 43 #endif 44 45 #ifndef TEST_LOOPBACK_CAPTURE_DEVICE 46 #define TEST_LOOPBACK_CAPTURE_DEVICE 1 47 #endif 48 49 static constexpr unsigned int kLoopbackCard = TEST_LOOPBACK_CARD; 50 static constexpr unsigned int kLoopbackPlaybackDevice = TEST_LOOPBACK_PLAYBACK_DEVICE; 51 static constexpr unsigned int kLoopbackCaptureDevice = TEST_LOOPBACK_CAPTURE_DEVICE; 52 53 static constexpr unsigned int kDefaultChannels = 2; 54 static constexpr unsigned int kDefaultSamplingRate = 48000; 55 static constexpr unsigned int kDefaultPeriodSize = 1024; 56 static constexpr unsigned int kDefaultPeriodCount = 3; 57 static constexpr pcm_config kDefaultConfig = { 58 .channels = kDefaultChannels, 59 .rate = kDefaultSamplingRate, 60 .period_size = kDefaultPeriodSize, 61 .period_count = kDefaultPeriodCount, 62 .format = PCM_FORMAT_S16_LE, 63 .start_threshold = kDefaultPeriodSize, 64 .stop_threshold = kDefaultPeriodSize * kDefaultPeriodCount, 65 .silence_threshold = 0, 66 .silence_size = 0, 67 }; 68 69 } // namespace testing 70 } // namespace tinyalsa 71 72 #endif 73