diff options
| author | Brandon Low <lostlogic@rockbox.org> | 2006-04-14 17:00:22 +0000 |
|---|---|---|
| committer | Brandon Low <lostlogic@rockbox.org> | 2006-04-14 17:00:22 +0000 |
| commit | 348d9ece4b9b9f57c5ee0201106bfb19d7efa758 (patch) | |
| tree | 020c127a2747895b2929657ac3a5170c7d1503d0 /apps | |
| parent | 86c7e1a947bec94217f81e2007018f20c7e17a9b (diff) | |
| download | rockbox-348d9ece4b9b9f57c5ee0201106bfb19d7efa758.zip rockbox-348d9ece4b9b9f57c5ee0201106bfb19d7efa758.tar.gz rockbox-348d9ece4b9b9f57c5ee0201106bfb19d7efa758.tar.bz2 rockbox-348d9ece4b9b9f57c5ee0201106bfb19d7efa758.tar.xz | |
Fix some unlikely buffer problems. Doesn't fix any reported bugs, but fixes some possible ones.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9663 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/playback.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/apps/playback.c b/apps/playback.c index 90b04ae..d9a9673 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1371,7 +1371,7 @@ static bool loadcodec(bool start_play) size = filesize(fd); /* Never load a partial codec */ - if (filebuflen - filebufused < size + AUDIO_REBUFFER_GUESS_SIZE) { + if (filebuflen - filebufused < size) { logf("Not enough space"); fill_bytesleft = 0; close(fd); @@ -1466,6 +1466,7 @@ static bool audio_load_track(int offset, bool start_play) if (current_fd >= 0) { + logf("Nonzero fd in alt"); close(current_fd); current_fd = -1; } @@ -1533,6 +1534,19 @@ static bool audio_load_track(int offset, bool start_play) /* Load the codec. */ tracks[track_widx].codecbuf = &filebuf[buf_widx]; if (!loadcodec(start_play)) { + + if (tracks[track_widx].codecsize) + { + /* Must undo the buffer write of the partial codec */ + logf("Partial codec loaded"); + fill_bytesleft += tracks[track_widx].codecsize; + filebufused -= tracks[track_widx].codecsize; + if (buf_widx < tracks[track_widx].codecsize) + buf_widx += filebuflen; + buf_widx -= tracks[track_widx].codecsize; + tracks[track_widx].codecsize = 0; + } + /* Set filesize to zero to indicate no file was loaded. */ tracks[track_widx].filesize = 0; tracks[track_widx].filerem = 0; |