diff options
author | Jean-Yves Avenard <[email protected]> | 2018-03-19 14:57:07 +0100 |
---|---|---|
committer | Paul Adenot <[email protected]> | 2018-03-19 14:57:07 +0100 |
commit | 789eaaa3b0d77b55e110353972d6713889f510ea (patch) | |
tree | fbeb48958ab83c329193f37c54133c9bc68aac4a /test/test_audio.cpp | |
parent | c88a484e1aac878419946334c49d35d6948beec7 (diff) | |
download | cubeb-789eaaa3b0d77b55e110353972d6713889f510ea.tar.gz cubeb-789eaaa3b0d77b55e110353972d6713889f510ea.zip |
Multi-channels support for windows/mac/linux (#426)
* Add QUAD and QUAD_LFE layouts.
* Remove dual mono layout.
It makes no sense to have a case for those as the data structure
used (a bitmask) do not allow to represent this channel layout (a
channel can only be present once). As such it was a non-functional
layout
* Fix up cubeb_pulse compilation using C++ keyword.
* Remove the concept of preferred layout.
Channel layout is derived by the content being played. The concept of
preferred layout is meaningless. Either we have a layout defined, or
we don't. There's no in-between.
So we remove it.
* Remove CHANNEL_MONO concept.
* Add cubeb_sample_size convenience method.
* Rework cubeb_mixer.
This completely replace the existing remixer which had serious limitations:
1- Had no memory bound checks
2- Could only downmix 5.1 and 7.1 to stereo.
This mixer allows to convert from any sane layout to any other and work directly on interleaved samples.
This cubeb_mixer doesn't have an API compatible with the previous one.
This commit is non-fonctional, and was split for ease of review.
* Fix remixing on mac, windows and pulse backend.
* Make cubeb_mixer creation infallible.
Rather than ignore nonsensical layouts, we attempt to play it according to the stream channels count instead. The audio data will be played as-is, dropping the extra channels or inserting silence where needed.
* User proper sample size when calculating offsets.
Should the user data be of a different type to what the AudioUnit output is set to, we would have written outside the end of our allocated buffer.
* Fix input mixing and clarify frames vs samples terminology
* If a layout is unknown or invalid, always treat it as plain stereo or mono.
Diffstat (limited to 'test/test_audio.cpp')
-rw-r--r-- | test/test_audio.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/test/test_audio.cpp b/test/test_audio.cpp index df51366..2e6c34a 100644 --- a/test/test_audio.cpp +++ b/test/test_audio.cpp @@ -94,7 +94,7 @@ int supports_channel_count(string backend_id, int nchannels) (backend_id != "opensl" && backend_id != "audiotrack"); } -int run_test(int num_channels, layout_info layout, int sampling_rate, int is_float) +int run_test(int num_channels, int sampling_rate, int is_float) { int r = CUBEB_OK; @@ -116,13 +116,13 @@ int run_test(int num_channels, layout_info layout, int sampling_rate, int is_flo return CUBEB_OK; } - 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)); + fprintf(stderr, "Testing %d channel(s), %d Hz, %s (%s)\n", num_channels, 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; + params.layout = CUBEB_LAYOUT_UNDEFINED; params.prefs = CUBEB_STREAM_PREF_NONE; synth_state synth(params.channels, params.rate); @@ -246,12 +246,8 @@ TEST(cubeb, run_channel_rate_test) for(auto freq : freq_values) { ASSERT_TRUE(channels < MAX_NUM_CHANNELS); fprintf(stderr, "--------------------------\n"); - for (auto layout : layout_infos) { - if (layout.channels == channels) { - ASSERT_EQ(run_test(channels, layout, freq, 0), CUBEB_OK); - ASSERT_EQ(run_test(channels, layout, freq, 1), CUBEB_OK); - } - } + ASSERT_EQ(run_test(channels, freq, 0), CUBEB_OK); + ASSERT_EQ(run_test(channels, freq, 1), CUBEB_OK); } } } |