media/libcubeb/tests/test_latency.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 #ifdef NDEBUG
     2 #undef NDEBUG
     3 #endif
     4 #include <stdlib.h>
     5 #include <cubeb/cubeb.h>
     6 #include <assert.h>
     7 #include <stdio.h>
     9 #define LOG(msg) fprintf(stderr, "%s\n", msg);
    11 int main(int argc, char * argv[])
    12 {
    13   cubeb * ctx = NULL;
    14   int rv;
    15   uint32_t max_channels;
    16   uint32_t preferred_rate;
    17   uint32_t latency_ms;
    19   LOG("latency_test start");
    20   rv = cubeb_init(&ctx, "Cubeb audio test");
    21   assert(rv == CUBEB_OK && "Cubeb init failed.");
    22   LOG("cubeb_init ok");
    24   rv = cubeb_get_max_channel_count(ctx, &max_channels);
    25   assert(rv == CUBEB_OK && "Could not query the max channe count.");
    26   assert(max_channels > 0 && "Invalid max channel count.");
    27   LOG("cubeb_get_max_channel_count ok");
    29   rv = cubeb_get_preferred_sample_rate(ctx, &preferred_rate);
    30   assert(rv == CUBEB_OK && "Could not query the preferred sample rate.");
    31   assert(preferred_rate && "Invalid preferred sample rate.");
    32   LOG("cubeb_get_preferred_sample_rate ok");
    34   cubeb_stream_params params = {
    35     CUBEB_SAMPLE_FLOAT32NE,
    36     preferred_rate,
    37     max_channels
    38   };
    39   rv = cubeb_get_min_latency(ctx, params, &latency_ms);
    40   assert(rv == CUBEB_OK && "Could not query the minimal latency.");
    41   assert(latency_ms && "Invalid minimal latency.");
    42   LOG("cubeb_get_min_latency ok");
    44   cubeb_destroy(ctx);
    45   LOG("cubeb_destroy ok");
    47   return EXIT_SUCCESS;
    48 }

mercurial