Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Improve statistics
Browse files Browse the repository at this point in the history
Fix ALSA capturing.
  • Loading branch information
RoEdAl committed Jun 14, 2024
1 parent 8633dfa commit 3b55a12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 0 additions & 3 deletions src/at_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ at_queue_task_t* at_queue_add(struct cpvt* cpvt, const at_queue_cmd_t* cmds, uns
PVT_STATE(pvt, at_tasks)++;
PVT_STATE(pvt, at_cmds) += cmdsno;

PVT_STAT(pvt, at_tasks)++;
PVT_STAT(pvt, at_cmds) += cmdsno;

if (e->cmdsno == 1u) {
ast_debug(4, "[%s][%s] \xE2\x86\xB5 [%s][%s] %s%s\n", PVT_ID(pvt), at_cmd2str(e->cmds[0].cmd), at_res2str(e->cmds[0].res),
tmp_esc_nstr(e->cmds[0].data, e->cmds[0].length), prio ? "after head" : "at tail", at_once ? " at once" : "");
Expand Down
20 changes: 13 additions & 7 deletions src/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ static struct ast_frame* channel_read_uac(struct cpvt* cpvt, struct pvt* pvt, si
if (avail_frames < 0) {
ast_log(LOG_ERROR, "[%s][ALSA][CAPTURE] Cannot determine available samples: %s\n", PVT_ID(pvt), snd_strerror((int)avail_frames));
return NULL;
} else if (frames < (size_t)avail_frames) {
} else if (frames > (size_t)avail_frames) {
ast_log(LOG_WARNING, "[%s][ALSA][CAPTURE] Not enough samples: %d/%d\n", PVT_ID(pvt), (int)avail_frames, (int)frames);
return NULL;
}
Expand Down Expand Up @@ -732,8 +732,15 @@ static int channel_write_tty(struct ast_channel* channel, struct ast_frame* f, s
iov.iov_base = f->data.ptr;
iov.iov_len = f->datalen;

if (iov_write(pvt, pvt->audio_fd, &iov, 1) >= 0) {
PVT_STAT(pvt, write_frames)++;
ssize_t res = iov_write(pvt, pvt->audio_fd, &iov, 1);

if (res >= 0) {
PVT_STAT(pvt, write_frames) += 1;
PVT_STAT(pvt, a_write_bytes) += res;
if (res != f->datalen) {
PVT_STAT(pvt, write_tframes)++;
ast_log(LOG_WARNING, "[%s][TTY][PLAYBACK] Write: %d/%d\n", PVT_ID(pvt), (int)res, f->datalen);
}
}
}

Expand Down Expand Up @@ -799,12 +806,11 @@ static int channel_write_uac(struct ast_channel* attribute_unused(channel), stru

default:
if (res >= 0) {
PVT_STAT(pvt, write_frames) += 1;
PVT_STAT(pvt, a_write_bytes) += res * sizeof(short);
if (res != samples) {
PVT_STAT(pvt, write_frames)++;
PVT_STAT(pvt, write_sframes)++;
PVT_STAT(pvt, write_tframes)++;
ast_log(LOG_WARNING, "[%s][ALSA][PLAYBACK] Write: %d/%d\n", PVT_ID(pvt), res, samples);
} else {
PVT_STAT(pvt, write_frames)++;
}
}
break;
Expand Down

0 comments on commit 3b55a12

Please sign in to comment.