From 5552c365bfb319eed7cbbf6300a67028ab70db9e Mon Sep 17 00:00:00 2001 From: Edmunt Pienkowsky Date: Sat, 15 Jun 2024 07:54:35 +0200 Subject: [PATCH] Use more accurate int16_t type Use more accurate voice sample type. int16_t is architecture agnostic one. --- src/chan_quectel.c | 2 +- src/channel.c | 8 ++++---- src/cpvt.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/chan_quectel.c b/src/chan_quectel.c index a249350c..195ec390 100644 --- a/src/chan_quectel.c +++ b/src/chan_quectel.c @@ -1363,7 +1363,7 @@ static size_t pvt_get_audio_frame_size_r(unsigned int ptime, const unsigned int { size_t res = ptime; res *= sr / 1000; - res *= sizeof(short); + res *= sizeof(int16_t); return res; } diff --git a/src/channel.c b/src/channel.c index d5e3072e..873f2b9f 100644 --- a/src/channel.c +++ b/src/channel.c @@ -562,7 +562,7 @@ static struct ast_frame* channel_read_uac(struct cpvt* cpvt, struct pvt* pvt, si write_conference(pvt, buf, res); } - PVT_STAT(pvt, a_read_bytes) += res * sizeof(short); + PVT_STAT(pvt, a_read_bytes) += res * sizeof(int16_t); PVT_STAT(pvt, read_frames)++; if (res < frames) { PVT_STAT(pvt, read_sframes)++; @@ -623,7 +623,7 @@ static struct ast_frame* channel_read(struct ast_channel* channel) } if (CONF_UNIQ(pvt, uac) > TRIBOOL_FALSE && CPVT_IS_MASTER(cpvt)) { - f = channel_read_uac(cpvt, pvt, frame_size / sizeof(short), fmt); + f = channel_read_uac(cpvt, pvt, frame_size / sizeof(int16_t), fmt); } else { f = channel_read_tty(cpvt, pvt, frame_size, fmt); } @@ -633,7 +633,7 @@ static struct ast_frame* channel_read(struct ast_channel* channel) const int fd = ast_channel_fd(channel, 0); ast_debug(5, "[%s] Read - idx:%d state:%s audio:%d:%d - returning SILENCE frame\n", PVT_ID(pvt), cpvt->call_idx, call_state2str(cpvt->state), fd, pvt->audio_fd); - return cpvt_prepare_silence_voice_frame(cpvt, frame_size / sizeof(short), fmt); + return cpvt_prepare_silence_voice_frame(cpvt, frame_size / sizeof(int16_t), fmt); } else { ast_debug(8, "[%s] Read - idx:%d state:%s samples:%d\n", PVT_ID(pvt), cpvt->call_idx, call_state2str(cpvt->state), f->samples); return f; @@ -778,7 +778,7 @@ 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); + PVT_STAT(pvt, a_write_bytes) += res * sizeof(int16_t); if (res != samples) { PVT_STAT(pvt, write_tframes)++; ast_log(LOG_WARNING, "[%s][ALSA][PLAYBACK] Write: %d/%d\n", PVT_ID(pvt), res, samples); diff --git a/src/cpvt.c b/src/cpvt.c index 6b647a09..78466215 100644 --- a/src/cpvt.c +++ b/src/cpvt.c @@ -418,7 +418,7 @@ struct ast_frame* cpvt_prepare_voice_frame(struct cpvt* const cpvt, void* const f->frametype = AST_FRAME_VOICE; f->subclass.format = (struct ast_format*)fmt; f->samples = samples; - f->datalen = samples * sizeof(short); + f->datalen = samples * sizeof(int16_t); f->data.ptr = buf; f->offset = AST_FRIENDLY_OFFSET; f->src = AST_MODULE;