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

Commit

Permalink
Use more accurate int16_t type
Browse files Browse the repository at this point in the history
Use more accurate voice sample type.
int16_t is architecture agnostic one.
  • Loading branch information
RoEdAl committed Jun 15, 2024
1 parent cf76e2e commit 5552c36
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/chan_quectel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)++;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/cpvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5552c36

Please sign in to comment.