|
|
|
|
@ -37,10 +37,6 @@ static opus_codec_decoder_t* g_decoder = NULL;
|
|
|
|
|
static struct vj* g_vj = NULL; |
|
|
|
|
static struct call_tones* g_tones = NULL; |
|
|
|
|
|
|
|
|
|
/* диагностика ставок (DEBUG_CATEGORY_DEBUG): под g_mtx */ |
|
|
|
|
static uint32_t g_tx_feed = 0, g_tx_encode_fail = 0, g_rx_push = 0, g_rx_pull = 0; |
|
|
|
|
static uint64_t g_rate_last_tb = 0; |
|
|
|
|
|
|
|
|
|
static const struct call_audio_ops g_ops = { |
|
|
|
|
.on_media = call_audio_on_media, |
|
|
|
|
.get_stats = call_audio_get_stats, |
|
|
|
|
@ -78,7 +74,6 @@ void call_audio_on_media(struct UTUN_INSTANCE* inst, uint64_t call_id,
|
|
|
|
|
if (g_active && call_id == g_call_id && g_vj && opus && len > 0) { |
|
|
|
|
vj_push(g_vj, opus, len); |
|
|
|
|
g_last_media_tb = get_time_tb(); |
|
|
|
|
g_rx_push++; |
|
|
|
|
} |
|
|
|
|
pthread_mutex_unlock(&g_mtx); |
|
|
|
|
} |
|
|
|
|
@ -204,20 +199,6 @@ void call_audio_stop(void) {
|
|
|
|
|
|
|
|
|
|
/* ── аудио-поток: TX / RX ── */ |
|
|
|
|
|
|
|
|
|
/* Раз в ~1с логируем ставки TX/RX — диагностика «звонок не проходит» (DEBUG_CATEGORY_DEBUG).
|
|
|
|
|
* Вызывается из аудио-потока (pull_pcm); счётчики под g_mtx. */ |
|
|
|
|
static void call_audio_rate_tick(uint64_t now_tb) { |
|
|
|
|
uint32_t feed = 0, encfail = 0, push = 0, pull = 0, resync = 0; |
|
|
|
|
pthread_mutex_lock(&g_mtx); |
|
|
|
|
feed = g_tx_feed; encfail = g_tx_encode_fail; push = g_rx_push; pull = g_rx_pull; |
|
|
|
|
g_tx_feed = g_tx_encode_fail = g_rx_push = g_rx_pull = 0; |
|
|
|
|
if (g_vj) resync = vj_resyncs(g_vj); |
|
|
|
|
g_rate_last_tb = now_tb; |
|
|
|
|
pthread_mutex_unlock(&g_mtx); |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "%s: rates feed=%u/s encfail=%u push=%u/s pull=%u/s resync=%u", |
|
|
|
|
CALL_AUDIO_ID, feed, encfail, push, pull, resync); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int call_audio_feed_pcm(uint64_t call_id, const int16_t* pcm, int count) { |
|
|
|
|
if (!pcm || count != CALL_AUDIO_FRAME_SAMPLES) return -1; |
|
|
|
|
|
|
|
|
|
@ -232,8 +213,6 @@ int call_audio_feed_pcm(uint64_t call_id, const int16_t* pcm, int count) {
|
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
len = opus_codec_encode(g_encoder, pcm, count, opus, (int)sizeof(opus)); |
|
|
|
|
g_tx_feed++; |
|
|
|
|
if (len <= 0) g_tx_encode_fail++; |
|
|
|
|
ua = g_inst ? g_inst->ua : NULL; |
|
|
|
|
inst = g_inst; |
|
|
|
|
pthread_mutex_unlock(&g_mtx); |
|
|
|
|
@ -269,19 +248,11 @@ int call_audio_pull_pcm(uint64_t call_id, int16_t* out, int max_samples) {
|
|
|
|
|
j = g_vj; |
|
|
|
|
tones = g_tones; |
|
|
|
|
last_media = g_last_media_tb; |
|
|
|
|
g_rx_pull++; |
|
|
|
|
} |
|
|
|
|
pthread_mutex_unlock(&g_mtx); |
|
|
|
|
|
|
|
|
|
if (!active || !j || !tones) return 0; |
|
|
|
|
|
|
|
|
|
/* диагностика ставок: раз в ~1с (аудио-поток) */ |
|
|
|
|
{ |
|
|
|
|
uint64_t now_tb = get_time_tb(); |
|
|
|
|
if (g_rate_last_tb == 0) g_rate_last_tb = now_tb; |
|
|
|
|
else if (now_tb - g_rate_last_tb >= 10000) call_audio_rate_tick(now_tb); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* завершение: доигрываем тон (450мс), затем тишина. Тон стартует лениво
|
|
|
|
|
* здесь (аудио-поток) — begin_end лишь выставляет флаг, чтобы не гонять |
|
|
|
|
* генератор тонов с GUI-потоком. */ |
|
|
|
|
|