Skip to content

Commit 77b3657

Browse files
authored
Check fractional samples per frame in wav_playlist (#4500)
1 parent f2922c2 commit 77b3657

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

pjmedia/src/pjmedia/wav_player.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,11 @@ PJ_DEF(pj_status_t) pjmedia_wav_player_port_create( pj_pool_t *pool_,
417417
/* It seems like we have a valid WAVE file. */
418418

419419
/* Check compatibility of sample rate and ptime.
420-
* Some combinations result in a fractional number of samples per frame
421-
* which we do not support.
422-
* One such case would be for example 10ms @ 22050Hz which would yield
423-
* 220.5 samples per frame.
424-
*/
420+
* Some combinations result in a fractional number of samples per frame
421+
* which we do not support.
422+
* One such case would be for example 10ms @ 22050Hz which would yield
423+
* 220.5 samples per frame.
424+
*/
425425
if (0 != (ptime * wave_hdr.fmt_hdr.sample_rate *
426426
wave_hdr.fmt_hdr.nchan % 1000))
427427
{

pjmedia/src/pjmedia/wav_playlist.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,22 @@ PJ_DEF(pj_status_t) pjmedia_wav_playlist_create(pj_pool_t *pool_,
571571
goto on_error;
572572
}
573573

574+
/* Check compatibility of sample rate and ptime.
575+
* Some combinations result in a fractional number of samples per frame
576+
* which we do not support.
577+
* One such case would be for example 10ms @ 22050Hz which would yield
578+
* 220.5 samples per frame.
579+
*/
580+
if (0 != (ptime * wavehdr.fmt_hdr.sample_rate *
581+
wavehdr.fmt_hdr.nchan % 1000))
582+
{
583+
PJ_LOG(3,(THIS_FILE,
584+
"Cannot create wav playlist port: incompatible sample "
585+
"rate/ptime"));
586+
status = PJMEDIA_ENOTCOMPATIBLE;
587+
goto on_error;
588+
}
589+
574590
/* It seems like we have a valid WAVE file. */
575591

576592
/* Update port info if we don't have one, otherwise check

0 commit comments

Comments
 (0)