Preserve stream capture settings and refine audio playback
This commit is contained in:
1 parent
198ebc0acb
commit
d60f8e4b1b
16 files changed
+244
-43
No files matched your search
@@ -68,6 +68,8 @@ extern "C" void __wrap_avcodec_free_context(AVCodecContext** context) {
|
||||
#ifdef TEST_NULL_AUDIO
|
||||
static std::atomic<ma_device_data_proc> originalAudioCallback{nullptr};
|
||||
static std::atomic<uint64_t> nonzeroSamples{0};
|
||||
static std::atomic<uint64_t> silenceGaps{0};
|
||||
static unsigned silentRun = 0; // Только callback; счётчик промежутков >=1мс между тестовыми тонами.
|
||||
static std::atomic<uint64_t> leftEnergy{0}, rightEnergy{0};
|
||||
static std::atomic<int64_t> playbackDelayUs{0};
|
||||
extern "C" int64_t __real_audio_stream_frame_time(ma_device*, unsigned int, int*);
|
||||
@@ -90,6 +92,8 @@ static void observeAudio(ma_device* device, void* out, const void* in, ma_uint32
|
||||
left += static_cast<int64_t>(pcm[2 * i]) * pcm[2 * i];
|
||||
right += static_cast<int64_t>(pcm[2 * i + 1]) * pcm[2 * i + 1];
|
||||
nonzero += pcm[2 * i] != 0; nonzero += pcm[2 * i + 1] != 0;
|
||||
if (pcm[2 * i] || pcm[2 * i + 1]) silentRun = 0;
|
||||
else if (++silentRun == 48) silenceGaps.fetch_add(1);
|
||||
}
|
||||
leftEnergy.fetch_add(left); rightEnergy.fetch_add(right); nonzeroSamples.fetch_add(nonzero);
|
||||
}
|
||||
@@ -145,6 +149,10 @@ class StreamViewTest : public QObject {
|
||||
private slots:
|
||||
void initTestCase() {
|
||||
debug_config_init(); debug_set_level(DEBUG_LEVEL_WARN); debug_set_category_level(DEBUG_CATEGORY_STREAM, DEBUG_LEVEL_INFO);
|
||||
if (qEnvironmentVariableIsSet("UTUN_TEST_DEBUG")) {
|
||||
debug_set_category_level(DEBUG_CATEGORY_STREAM, DEBUG_LEVEL_TRACE);
|
||||
debug_set_category_level(DEBUG_CATEGORY_DEBUG, DEBUG_LEVEL_TRACE);
|
||||
}
|
||||
debug_set_category_level(DEBUG_CATEGORY_SYS, DEBUG_LEVEL_ERROR);
|
||||
allocations = u_get_allocated_count(); ua = uasync_create(); QVERIFY(ua);
|
||||
inst = utun_instance_create_from_str(ua,
|
||||
@@ -266,8 +274,15 @@ private slots:
|
||||
});
|
||||
sender.start(100);
|
||||
QTRY_VERIFY_WITH_TIMEOUT(shown.count() > 0, 5000);
|
||||
QTest::qWait(400); // Пройти старт декодера и физическую задержку тестового устройства.
|
||||
#ifdef TEST_NULL_AUDIO
|
||||
uint64_t gapsBefore = silenceGaps.load();
|
||||
#endif
|
||||
int beforeSteady = shown.count(); QTest::qWait(1500);
|
||||
QVERIFY2(shown.count() >= beforeSteady + 30, "30fps video must keep advancing with 200ms physical audio latency");
|
||||
#ifdef TEST_NULL_AUDIO
|
||||
QCOMPARE(silenceGaps.load(), gapsBefore);
|
||||
#endif
|
||||
int beforeSwitch = shown.count(); revision++; rotation = 270;
|
||||
QTRY_VERIFY_WITH_TIMEOUT(shown.count() > beforeSwitch + 2, 5000);
|
||||
stream_info switched{}; QCOMPARE(stream_get_info(publisher, &switched), STREAM_OK);
|
||||
|
||||
Reference in new issue
Block a user