int
is_windows_7()
{ #ifdef __MINGW32__
fprintf(stderr, "Warning: this test was built with MinGW.\n" "MinGW does not contain necessary version checking infrastructure. " "Claiming to be Windows 7, even if we're not.\n"); return 1; #endif #if (defined(_WIN32) || defined(__WIN32__)) && (!defined(__MINGW32__))
OSVERSIONINFOEX osvi;
DWORDLONG condition_mask = 0;
for (i = 0; i < ARRAY_LENGTH(stream); ++i) {
r = cubeb_stream_init(ctx, &stream[i], "test", NULL, NULL, NULL, ¶ms,
STREAM_LATENCY, test_data_callback,
test_state_callback, &dummy);
ASSERT_EQ(r, CUBEB_OK);
ASSERT_NE(stream[i], nullptr); if (early) {
r = cubeb_stream_start(stream[i]);
ASSERT_EQ(r, CUBEB_OK);
}
}
if (!early) { for (i = 0; i < ARRAY_LENGTH(stream); ++i) {
r = cubeb_stream_start(stream[i]);
ASSERT_EQ(r, CUBEB_OK);
}
}
if (delay_ms) {
delay(delay_ms);
}
if (!early) { for (i = 0; i < ARRAY_LENGTH(stream); ++i) {
r = cubeb_stream_stop(stream[i]);
ASSERT_EQ(r, CUBEB_OK);
}
}
for (i = 0; i < ARRAY_LENGTH(stream); ++i) { if (early) {
r = cubeb_stream_stop(stream[i]);
ASSERT_EQ(r, CUBEB_OK);
}
cubeb_stream_destroy(stream[i]);
}
cubeb_destroy(ctx);
}
TEST(cubeb, init_start_stop_destroy_multiple_streams)
{ /* Sometimes, when using WASAPI on windows 7 (vista and 8 are okay), and * calling Activate a lot on an AudioClient, 0x800700b7 is returned. This is * the HRESULT value for "Cannot create a file when that file already exists", * and is not documented as a possible return value for this call. Hence, we
* try to limit the number of streams we create in this test. */ if (!is_windows_7()) {
delay_callback = 0;
test_init_start_stop_destroy_multiple_streams(0, 0);
test_init_start_stop_destroy_multiple_streams(1, 0);
test_init_start_stop_destroy_multiple_streams(0, 150);
test_init_start_stop_destroy_multiple_streams(1, 150);
delay_callback = 1;
test_init_start_stop_destroy_multiple_streams(0, 0);
test_init_start_stop_destroy_multiple_streams(1, 0);
test_init_start_stop_destroy_multiple_streams(0, 150);
test_init_start_stop_destroy_multiple_streams(1, 150);
}
}
/* Sometimes, when using WASAPI on windows 7 (vista and 8 are okay), and * calling Activate a lot on an AudioClient, 0x800700b7 is returned. This is * the HRESULT value for "Cannot create a file when that file already exists", * and is not documented as a possible return value for this call. Hence, we
* try to limit the number of streams we create in this test. */ if (is_windows_7()) return;
/* position and latency before stream has started */
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
ASSERT_EQ(position, 0u);
r = cubeb_stream_get_latency(stream, &latency);
ASSERT_EQ(r, CUBEB_OK);
r = cubeb_stream_start(stream);
ASSERT_EQ(r, CUBEB_OK);
/* position and latency after while stream running */
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
r = cubeb_stream_get_latency(stream, &latency);
ASSERT_EQ(r, CUBEB_OK);
r = cubeb_stream_stop(stream);
ASSERT_EQ(r, CUBEB_OK);
/* position and latency after stream has stopped */
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
r = cubeb_stream_get_latency(stream, &latency);
ASSERT_EQ(r, CUBEB_OK);
/* stream position should not advance before starting playback */
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
ASSERT_EQ(position, 0u);
delay(500);
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
ASSERT_EQ(position, 0u);
/* stream position should advance during playback */
r = cubeb_stream_start(stream);
ASSERT_EQ(r, CUBEB_OK);
/* XXX let start happen */
delay(500);
/* stream should have prefilled */
ASSERT_TRUE(total_frames_written.load() > 0);
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
last_position = position;
/* stream position should not exceed total frames written */ for (i = 0; i < 5; ++i) {
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
ASSERT_GE(position, last_position);
ASSERT_LE(position, total_frames_written.load());
last_position = position;
delay(500);
}
/* test that the position is valid even when starting and
* stopping the stream. */ for (i = 0; i < 5; ++i) {
r = cubeb_stream_stop(stream);
ASSERT_EQ(r, CUBEB_OK);
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
ASSERT_TRUE(last_position < position);
last_position = position;
delay(500);
r = cubeb_stream_start(stream);
ASSERT_EQ(r, CUBEB_OK);
delay(500);
}
ASSERT_NE(last_position, 0u);
/* stream position should not advance after stopping playback */
r = cubeb_stream_stop(stream);
ASSERT_EQ(r, CUBEB_OK);
/* XXX allow stream to settle */
delay(500);
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
last_position = position;
delay(500);
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK); // The OpenSL backend performs client-side interpolation for its position and // its drain implementation isn't very accurate. if (strcmp(cubeb_get_backend_id(ctx), "opensl")) {
ASSERT_EQ(position, last_position);
}
r = cubeb_stream_start(stream);
ASSERT_EQ(r, CUBEB_OK);
delay(5000);
do_drain = 1;
for (;;) {
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK); if (got_drain) { break;
} else {
ASSERT_LE(position, total_frames_written.load());
}
delay(500);
}
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
ASSERT_TRUE(got_drain);
// Really, we should be able to rely on position reaching our final written // frame, but for now let's make sure it doesn't continue beyond that point. // ASSERT_LE(position, total_frames_written.load());
cubeb_stream_destroy(stream);
cubeb_destroy(ctx);
got_drain = 0;
do_drain = 0;
}
TEST(cubeb, DISABLED_eos_during_prefill)
{ // This test needs to be implemented.
}
TEST(cubeb, DISABLED_stream_destroy_pending_drain)
{ // This test needs to be implemented.
}
TEST(cubeb, stable_devid)
{ /* Test that the devid field of cubeb_device_info is stable * (ie. compares equal) over two invocations of
* cubeb_enumerate_devices(). */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.