Changeset 5711
- Timestamp:
- Dec 7, 2017 3:03:50 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/wav_playlist.c
r4537 r5711 67 67 pj_off_t *fsize_list; 68 68 unsigned *start_data_list; 69 unsigned *data_len_list; 70 unsigned *data_left_list; 69 71 pj_off_t *fpos_list; 70 72 pj_oshandle_t *fd_list; /* list of file descriptors */ … … 133 135 return PJ_ECANCELLED; 134 136 } 137 138 if (size > (pj_ssize_t)fport->data_left_list[current_file]) { 139 /* We passed the end of the data chunk, 140 * only count the portion read from the data chunk. 141 */ 142 size = (pj_ssize_t)fport->data_left_list[current_file]; 143 } 135 144 136 145 size_left -= (pj_uint32_t)size; 137 fport->fpos_list[current_file] += size; 146 fport->data_left_list[current_file] -= (pj_uint32_t)size; 147 fport->fpos_list[current_file] += size; 138 148 139 149 /* If size is less than size_to_read, it indicates that we've … … 147 157 pj_file_setpos(fport->fd_list[current_file], 148 158 fport->fpos_list[current_file], PJ_SEEK_SET); 159 fport->data_left_list[current_file] = 160 fport->data_len_list[current_file]; 149 161 150 162 /* Move to next file */ … … 209 221 pj_file_setpos(fport->fd_list[0], fport->fpos_list[0], 210 222 PJ_SEEK_SET); 223 fport->data_left_list[0] = fport->data_len_list[0]; 211 224 } 212 225 … … 306 319 pj_pool_alloc(pool, sizeof(unsigned)*file_count); 307 320 if (!fport->start_data_list) { 321 return PJ_ENOMEM; 322 } 323 324 /* Create data len list */ 325 fport->data_len_list = (unsigned*) 326 pj_pool_alloc(pool, sizeof(unsigned)*file_count); 327 if (!fport->data_len_list) { 328 return PJ_ENOMEM; 329 } 330 331 /* Create data left list */ 332 fport->data_left_list = (unsigned*) 333 pj_pool_alloc(pool, sizeof(unsigned)*file_count); 334 if (!fport->data_left_list) { 308 335 return PJ_ENOMEM; 309 336 } … … 451 478 status = pj_file_getpos(fport->fd_list[index], &pos); 452 479 fport->start_data_list[index] = (unsigned)pos; 480 fport->data_len_list[index] = wavehdr.data_hdr.len; 481 fport->data_left_list[index] = wavehdr.data_hdr.len; 453 482 454 483 /* Validate length. */ 455 if (wavehdr.data_hdr.len !=fport->fsize_list[index] -484 if (wavehdr.data_hdr.len > fport->fsize_list[index] - 456 485 fport->start_data_list[index]) 457 486 { … … 459 488 goto on_error; 460 489 } 461 if (wavehdr.data_hdr.len < 400) { 490 if (wavehdr.data_hdr.len < ptime * wavehdr.fmt_hdr.sample_rate * 491 wavehdr.fmt_hdr.nchan / 1000) 492 { 462 493 status = PJMEDIA_EWAVETOOSHORT; 463 494 goto on_error; … … 501 532 502 533 } 503 534 535 /* If file is shorter than buffer size, adjust buffer size to file 536 * size. Otherwise EOF callback will be called multiple times when 537 * file_fill_buffer() is called. 538 */ 539 if (wavehdr.data_hdr.len < (unsigned)buff_size) 540 buff_size = wavehdr.data_hdr.len; 541 542 /* Create file buffer. 543 */ 544 fport->bufsize = (pj_uint32_t)buff_size; 504 545 505 546 /* Set initial position of the file. */
Note: See TracChangeset
for help on using the changeset viewer.