summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pjmedia/src/pjmedia/resample_port.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/pjmedia/src/pjmedia/resample_port.c b/pjmedia/src/pjmedia/resample_port.c
index 8898d6c8..44f7e39b 100644
--- a/pjmedia/src/pjmedia/resample_port.c
+++ b/pjmedia/src/pjmedia/resample_port.c
@@ -185,9 +185,11 @@ static pj_status_t resample_get_frame(pjmedia_port *this_port,
if (tmp_frame.type != PJMEDIA_FRAME_TYPE_AUDIO) {
frame->type = tmp_frame.type;
frame->timestamp = tmp_frame.timestamp;
- frame->size = tmp_frame.size;
+ /* Copy whatever returned as long as the buffer size is enough */
+ frame->size = tmp_frame.size < rport->base.info.bytes_per_frame ?
+ tmp_frame.size : rport->base.info.bytes_per_frame;
if (tmp_frame.size)
- pj_memcpy(frame->buf, tmp_frame.buf, tmp_frame.size);
+ pjmedia_copy_samples(frame->buf, tmp_frame.buf, frame->size >> 1);
return PJ_SUCCESS;
}