diff options
author | Matthew Gregan <[email protected]> | 2015-11-26 10:57:04 +1300 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2015-11-26 10:57:04 +1300 |
commit | 5fa112ab6bdd9e6871879462945376bf9588300b (patch) | |
tree | 7889f32a9d4d9ec87ffa1926677317159cdd0280 /test/test_audio.cpp | |
parent | 4098941b79ee3fc88a8f1b8ed9e6e022afb5fa7a (diff) | |
download | cubeb-5fa112ab6bdd9e6871879462945376bf9588300b.tar.gz cubeb-5fa112ab6bdd9e6871879462945376bf9588300b.zip |
tests: handle backends that do not support S16 (WASAPI) correctly.
Diffstat (limited to 'test/test_audio.cpp')
-rw-r--r-- | test/test_audio.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/test/test_audio.cpp b/test/test_audio.cpp index 73e9343..1ee8a87 100644 --- a/test/test_audio.cpp +++ b/test/test_audio.cpp @@ -107,6 +107,12 @@ int supports_float32(const char* backend_id) strcmp(backend_id, "audiotrack") != 0); } +/* The WASAPI backend only supports float. */ +int supports_int16(const char* backend_id) +{ + return strcmp(backend_id, "wasapi") != 0; +} + /* Some backends don't have code to deal with more than mono or stereo. */ int supports_channel_count(const char* backend_id, int nchannels) { @@ -132,6 +138,7 @@ int run_test(int num_channels, int sampling_rate, int is_float) backend_id = cubeb_get_backend_id(ctx); if ((is_float && !supports_float32(backend_id)) || + (!is_float && !supports_int16(backend_id)) || !supports_channel_count(backend_id, num_channels)) { /* don't treat this as a test failure. */ goto cleanup; @@ -169,22 +176,30 @@ cleanup: return r; } -int run_panning_volume_test() +int run_panning_volume_test(int is_float) { int r = CUBEB_OK; cubeb *ctx = NULL; synth_state* synth = NULL; cubeb_stream *stream = NULL; + const char * backend_id = NULL; r = cubeb_init(&ctx, "Cubeb audio test"); if (r != CUBEB_OK) { fprintf(stderr, "Error initializing cubeb library\n"); goto cleanup; } + backend_id = cubeb_get_backend_id(ctx); + + if ((is_float && !supports_float32(backend_id)) || + (!is_float && !supports_int16(backend_id))) { + /* don't treat this as a test failure. */ + goto cleanup; + } cubeb_stream_params params; - params.format = CUBEB_SAMPLE_S16NE; + params.format = is_float ? CUBEB_SAMPLE_FLOAT32NE : CUBEB_SAMPLE_S16NE; params.rate = 44100; params.channels = 2; @@ -195,7 +210,7 @@ int run_panning_volume_test() } r = cubeb_stream_init(ctx, &stream, "test tone", params, - 100, data_cb_short, state_cb, synth); + 100, is_float ? data_cb_float : data_cb_short, state_cb, synth); if (r != CUBEB_OK) { fprintf(stderr, "Error initializing cubeb stream: %d\n", r); goto cleanup; @@ -263,7 +278,8 @@ void run_channel_rate_test() int main(int argc, char *argv[]) { - assert(run_panning_volume_test() == CUBEB_OK); + assert(run_panning_volume_test(0) == CUBEB_OK); + assert(run_panning_volume_test(1) == CUBEB_OK); run_channel_rate_test(); return CUBEB_OK; |