diff options
author | Chun-Min Chang <[email protected]> | 2016-12-21 13:18:07 +0800 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2016-12-20 19:18:07 -1000 |
commit | a900d6e511c3286956c38ca60162790ca6e8e18d (patch) | |
tree | 12969af1e27b0d0d127127a60d770b52100f76fb /test/test_audio.cpp | |
parent | c1e1e45dee4367c6f839b903417998049ad1baeb (diff) | |
download | cubeb-a900d6e511c3286956c38ca60162790ca6e8e18d.tar.gz cubeb-a900d6e511c3286956c38ca60162790ca6e8e18d.zip |
Support multiple channels on Windows (#171)
* Multiple channel support on Windows
* Move up/down mixing code from cubeb_wasapi.cpp to standalone cubeb_mixer.cpp
Diffstat (limited to 'test/test_audio.cpp')
-rw-r--r-- | test/test_audio.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/test/test_audio.cpp b/test/test_audio.cpp index 77fdfb6..f517490 100644 --- a/test/test_audio.cpp +++ b/test/test_audio.cpp @@ -24,7 +24,6 @@ #define M_PI 3.14159265358979323846 #endif -#define NELEMS(x) ((int) (sizeof(x) / sizeof(x[0]))) #define VOLUME 0.2 float get_frequency(int channel_index) @@ -118,7 +117,7 @@ int supports_channel_count(const char* backend_id, int nchannels) (strcmp(backend_id, "opensl") != 0 && strcmp(backend_id, "audiotrack") != 0); } -int run_test(int num_channels, int sampling_rate, int is_float) +int run_test(int num_channels, layout_info layout, int sampling_rate, int is_float) { int r = CUBEB_OK; @@ -142,12 +141,13 @@ int run_test(int num_channels, int sampling_rate, int is_float) goto cleanup; } - fprintf(stderr, "Testing %d channel(s), %d Hz, %s (%s)\n", num_channels, sampling_rate, is_float ? "float" : "short", cubeb_get_backend_id(ctx)); + fprintf(stderr, "Testing %d channel(s), layout: %s, %d Hz, %s (%s)\n", num_channels, layout.name, sampling_rate, is_float ? "float" : "short", cubeb_get_backend_id(ctx)); cubeb_stream_params params; params.format = is_float ? CUBEB_SAMPLE_FLOAT32NE : CUBEB_SAMPLE_S16NE; params.rate = sampling_rate; params.channels = num_channels; + params.layout = layout.layout; synth = synth_create(params.channels, params.rate); if (synth == NULL) { @@ -200,6 +200,7 @@ int run_panning_volume_test(int is_float) params.format = is_float ? CUBEB_SAMPLE_FLOAT32NE : CUBEB_SAMPLE_S16NE; params.rate = 44100; params.channels = 2; + params.layout = CUBEB_LAYOUT_STEREO; synth = synth_create(params.channels, params.rate); if (synth == NULL) { @@ -259,7 +260,7 @@ TEST(cubeb, run_panning_volume_test_float) TEST(cubeb, run_channel_rate_test) { - int channel_values[] = { + unsigned int channel_values[] = { 1, 2, 3, @@ -274,13 +275,16 @@ TEST(cubeb, run_channel_rate_test) 48000, }; - for(int j = 0; j < NELEMS(channel_values); ++j) { - for(int i = 0; i < NELEMS(freq_values); ++i) { + for(unsigned int j = 0; j < ARRAY_LENGTH(channel_values); ++j) { + for(unsigned int i = 0; i < ARRAY_LENGTH(freq_values); ++i) { ASSERT_TRUE(channel_values[j] < MAX_NUM_CHANNELS); fprintf(stderr, "--------------------------\n"); - ASSERT_EQ(run_test(channel_values[j], freq_values[i], 0), CUBEB_OK); - ASSERT_EQ(run_test(channel_values[j], freq_values[i], 1), CUBEB_OK); + for (unsigned int k = 0 ; k < ARRAY_LENGTH(layout_infos); ++k ) { + if (layout_infos[k].channels == channel_values[j]) { + ASSERT_EQ(run_test(channel_values[j], layout_infos[k], freq_values[i], 0), CUBEB_OK); + ASSERT_EQ(run_test(channel_values[j], layout_infos[k], freq_values[i], 1), CUBEB_OK); + } + } } } } - |