diff options
author | Koalab99 <[email protected]> | 2020-05-29 17:22:22 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-29 17:22:22 +0200 |
commit | d5b033dfd3aa6234d2d1b3513627e4b6d13fb62f (patch) | |
tree | 1d2b44611ee1dbbbd1188da025c7116dbbb75581 /tools | |
parent | 4cd6a9289f3b0e86bae58c0de9ef35e3f7339536 (diff) | |
download | cubeb-d5b033dfd3aa6234d2d1b3513627e4b6d13fb62f.tar.gz cubeb-d5b033dfd3aa6234d2d1b3513627e4b6d13fb62f.zip |
Add input stream latency test (#590)
* Add input stream latency test
It calls the stream ops and ask for input latency if the output device
has type INPUT.
* Changes for pull 590
Co-authored-by: Corentin ARNOULD <[email protected]>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/cubeb-test.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/tools/cubeb-test.cpp b/tools/cubeb-test.cpp index e5d975f..863e9ee 100644 --- a/tools/cubeb-test.cpp +++ b/tools/cubeb-test.cpp @@ -57,7 +57,8 @@ public: void set_latency_testing(bool on); void set_latency_frames(uint32_t latency_frames); uint64_t get_stream_position() const; - uint32_t get_stream_latency() const; + uint32_t get_stream_output_latency() const; + uint32_t get_stream_input_latency() const; uint32_t get_max_channel_count() const; long user_data_cb(cubeb_stream* stm, void* user, const void* input_buffer, @@ -194,7 +195,7 @@ uint64_t cubeb_client::get_stream_position() const { return pos; } -uint32_t cubeb_client::get_stream_latency() const { +uint32_t cubeb_client::get_stream_output_latency() const { uint32_t latency = 0; int rv = cubeb_stream_get_latency(stream, &latency); if (rv != CUBEB_OK) { @@ -204,6 +205,16 @@ uint32_t cubeb_client::get_stream_latency() const { return latency; } +uint32_t cubeb_client::get_stream_input_latency() const { + uint32_t latency = 0; + int rv = cubeb_stream_get_input_latency(stream, &latency); + if (rv != CUBEB_OK) { + fprintf(stderr, "Could not get the latency of the input stream\n"); + return 0; + } + return latency; +} + uint32_t cubeb_client::get_max_channel_count() const { uint32_t channels = 0; int rv = cubeb_get_max_channel_count(context, &channels); @@ -437,8 +448,17 @@ bool choose_action(cubeb_client& cl, operation_data * op, int c) { fprintf(stderr, "max channel count (default output device): %u\n", channel_count); } else if (c == 'f') { uint64_t pos = cl.get_stream_position(); - uint64_t latency = cl.get_stream_latency(); - fprintf(stderr, "stream position %" PRIu64 " (latency %" PRIu64 ")\n", pos, latency); + uint32_t latency; + fprintf(stderr, "stream position %" PRIu64 ".", pos); + if(op->pm == PLAYBACK || op->pm == DUPLEX) { + latency = cl.get_stream_output_latency(); + fprintf(stderr, " (output latency %" PRIu32 ")", latency); + } + if(op->pm == RECORD || op->pm == DUPLEX) { + latency = cl.get_stream_input_latency(); + fprintf(stderr, " (input latency %" PRIu32 ")", latency); + } + fprintf(stderr, "\n"); } else if (c == 'i') { op->collection_device_type = CUBEB_DEVICE_TYPE_INPUT; fprintf(stderr, "collection device type changed to INPUT\n"); |