- Timestamp:
- Jan 21, 2011 1:30:37 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/wav_player.c
r3405 r3407 108 108 static pj_status_t fill_buffer(struct file_reader_port *fport) 109 109 { 110 pj_size_t data_left = fport->data_left; 111 pj_ssize_t bufsize = (fport->bufsize > data_left) ? data_left : fport->bufsize; 112 pj_ssize_t size_left = bufsize; 110 pj_ssize_t size_left = fport->bufsize; 113 111 unsigned size_to_read; 114 112 pj_ssize_t size; … … 122 120 size = size_to_read = size_left; 123 121 status = pj_file_read(fport->fd, 124 //&fport->buf[fport->bufsize-size_left], 125 &fport->buf[bufsize-size_left], 122 &fport->buf[fport->bufsize-size_left], 126 123 &size); 127 124 if (status != PJ_SUCCESS) … … 132 129 } 133 130 131 if (size > (pj_ssize_t)fport->data_left) { 132 /* We passed the end of the data chunk, 133 * only count the portion read from the data chunk. 134 */ 135 size = (pj_ssize_t)fport->data_left; 136 } 137 134 138 size_left -= size; 135 139 fport->data_left -= size; … … 139 143 * encountered EOF. Rewind the file. 140 144 */ 141 if (size < (pj_ssize_t)size_to_read || fport->data_left <= 0) {145 if (size < (pj_ssize_t)size_to_read) { 142 146 fport->eof = PJ_TRUE; 143 //fport->eofpos = fport->buf + fport->bufsize - size_left; 144 fport->eofpos = fport->buf + bufsize - size_left; 147 fport->eofpos = fport->buf + fport->bufsize - size_left; 145 148 146 149 if (fport->options & PJMEDIA_FILE_NO_LOOP) { 147 150 /* Zero remaining buffer */ 148 151 if (fport->fmt_tag == PJMEDIA_WAVE_FMT_TAG_PCM) { 149 pj_bzero(fport->eofpos, size_left + 150 (fport->bufsize - data_left)); 152 pj_bzero(fport->eofpos, size_left); 151 153 } else if (fport->fmt_tag == PJMEDIA_WAVE_FMT_TAG_ULAW) { 152 154 int val = pjmedia_linear2ulaw(0); 153 pj_memset(fport->eofpos, val, size_left + 154 (fport->bufsize - data_left)); 155 pj_memset(fport->eofpos, val, size_left); 155 156 } else if (fport->fmt_tag == PJMEDIA_WAVE_FMT_TAG_ALAW) { 156 157 int val = pjmedia_linear2alaw(0); 157 pj_memset(fport->eofpos, val, size_left + 158 (fport->bufsize - data_left)); 158 pj_memset(fport->eofpos, val, size_left); 159 159 } 160 160 } … … 332 332 status = pj_file_getpos(fport->fd, &pos); 333 333 fport->start_data = (unsigned)pos; 334 fport->data_len = wave_hdr.data_hdr.len; 335 fport->data_left = wave_hdr.data_hdr.len; 336 337 /* Validate length. This is unnecessary since we only play data chunks. */ 338 /* 339 if (wave_hdr.data_hdr.len != fport->fsize - fport->start_data) { 334 fport->data_len = wave_hdr.data_hdr.len; 335 fport->data_left = wave_hdr.data_hdr.len; 336 337 /* Validate length. */ 338 if (wave_hdr.data_hdr.len > fport->fsize - fport->start_data) { 340 339 pj_file_close(fport->fd); 341 340 return PJMEDIA_EWAVEUNSUPP; 342 341 } 343 */344 342 if (wave_hdr.data_hdr.len < ptime * wave_hdr.fmt_hdr.sample_rate * 345 343 wave_hdr.fmt_hdr.nchan / 1000)
Note: See TracChangeset
for help on using the changeset viewer.