aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/test_audio.cpp
diff options
context:
space:
mode:
authorPaul Adenot <[email protected]>2016-01-13 17:16:50 +0100
committerPaul Adenot <[email protected]>2016-01-13 17:36:53 +0100
commit46e32bdac90233b0a4e59d9b7d4319a28bf496ae (patch)
tree0e7d58fc9709e8a0d2e59d1a00ea7158e29e9a0c /test/test_audio.cpp
parent23a17cb4f9ed2de78a0df5ecdfefbbe47dc83c35 (diff)
downloadcubeb-46e32bdac90233b0a4e59d9b7d4319a28bf496ae.tar.gz
cubeb-46e32bdac90233b0a4e59d9b7d4319a28bf496ae.zip
Preparatory work for the input and duplex code
This is changing all the signatures of the `cubeb_stream_init` implementations, the signature of the `data_callback` type, so that cubeb can support audio input. `cubeb_stream_init` now has two `cubeb_stream_params` pointers, one for input, one for output. If two pointers are passed, a "duplex" stream is opened. If only one pointer is passed, an input-only or output-only stream is created. Duplex streams have the same sample rate, and sample type. They don't have to have the same number of channels. `data_callback` now has two pointers to audio buffers: an input buffer (`NULL` if this is an output-only stream) containing input data (e.g. a microphone), and an output buffer, to be filled, as usual, with the audio frames to play. The two buffers always have the exact same number of audio frames, and are temporally correlated in a way that ensures the minimal loop-back latency on the system if one directly copies the input buffer to the output buffer. No functionnal changes are present in this patch, just signature changes. Asserts have been added to prevent users to try to use the input code path for now. Actual implementations with the input code for different platforms will follow. Green `mozilla-central` push: <https://treeherder.mozilla.org/#/jobs?repo=try&revision=15b4dd3cbbe8>
Diffstat (limited to 'test/test_audio.cpp')
-rw-r--r--test/test_audio.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/test_audio.cpp b/test/test_audio.cpp
index 6a6ebf5..c6b143f 100644
--- a/test/test_audio.cpp
+++ b/test/test_audio.cpp
@@ -73,10 +73,10 @@ void synth_run_float(synth_state* synth, float* audiobuffer, long nframes)
}
}
-long data_cb_float(cubeb_stream *stream, void *user, void *buffer, long nframes)
+long data_cb_float(cubeb_stream *stream, void *user, void * inputbuffer, void *outputbuffer, long nframes)
{
synth_state *synth = (synth_state *)user;
- synth_run_float(synth, (float*)buffer, nframes);
+ synth_run_float(synth, (float*)outputbuffer, nframes);
return nframes;
}
@@ -92,10 +92,10 @@ void synth_run_16bit(synth_state* synth, short* audiobuffer, long nframes)
}
}
-long data_cb_short(cubeb_stream *stream, void *user, void *buffer, long nframes)
+long data_cb_short(cubeb_stream *stream, void *user, void * inputbuffer, void *outputbuffer, long nframes)
{
synth_state *synth = (synth_state *)user;
- synth_run_16bit(synth, (short*)buffer, nframes);
+ synth_run_16bit(synth, (short*)outputbuffer, nframes);
return nframes;
}
@@ -160,7 +160,7 @@ int run_test(int num_channels, int sampling_rate, int is_float)
goto cleanup;
}
- r = cubeb_stream_init(ctx, &stream, "test tone", params,
+ r = cubeb_stream_init(ctx, &stream, "test tone", nullptr, &params,
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);
@@ -212,7 +212,7 @@ int run_panning_volume_test(int is_float)
goto cleanup;
}
- r = cubeb_stream_init(ctx, &stream, "test tone", params,
+ r = cubeb_stream_init(ctx, &stream, "test tone", NULL, &params,
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);