Ignore:
Timestamp:
May 30, 2007 7:31:46 AM (17 years ago)
Author:
bennylp
Message:

Workaround for ticket #289: Bug in WAV player when frame size is larger than file buffer size (thanks Samuel Vinson)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/pjproject-0.5-stable/pjmedia/src/pjmedia/wav_player.c

    r974 r1322  
    205205        ptime = 20; 
    206206 
     207    /* Normalize buff_size */ 
     208    if (buff_size < 1) buff_size = PJMEDIA_FILE_PORT_BUFSIZE; 
     209 
     210 
    207211    /* Create fport instance. */ 
    208212    fport = create_file_port(pool); 
     
    345349    /* Create file buffer. 
    346350     */ 
    347     if (buff_size < 1) buff_size = PJMEDIA_FILE_PORT_BUFSIZE; 
    348351    fport->bufsize = buff_size; 
    349352 
     353 
     354    /* samples_per_frame must be smaller than bufsize (because get_frame() 
     355     * doesn't handle this case). 
     356     */ 
     357    if (fport->base.info.samples_per_frame * BYTES_PER_SAMPLE >= 
     358        fport->bufsize) 
     359    { 
     360        pj_file_close(fport->fd); 
     361        return PJ_EINVAL; 
     362    } 
    350363 
    351364    /* Create buffer. */ 
     
    539552    return PJ_SUCCESS; 
    540553} 
     554 
Note: See TracChangeset for help on using the changeset viewer.