forked from len0rd/rockbox
Fix a fixme in flac and make the usage of the read_filebuf codec api more consistent with its actual contract.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15303 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
35f23267bf
commit
4bde8982f1
2 changed files with 9 additions and 19 deletions
|
|
@ -77,8 +77,7 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
|
||||||
uint32_t offset_hi,offset_lo;
|
uint32_t offset_hi,offset_lo;
|
||||||
uint16_t blocksize;
|
uint16_t blocksize;
|
||||||
int endofmetadata=0;
|
int endofmetadata=0;
|
||||||
int blocklength;
|
uint32_t blocklength;
|
||||||
int n;
|
|
||||||
|
|
||||||
ci->memset(fc,0,sizeof(FLACContext));
|
ci->memset(fc,0,sizeof(FLACContext));
|
||||||
nseekpoints=0;
|
nseekpoints=0;
|
||||||
|
|
@ -113,9 +112,7 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
|
||||||
|
|
||||||
if ((buf[0] & 0x7f) == 0) /* 0 is the STREAMINFO block */
|
if ((buf[0] & 0x7f) == 0) /* 0 is the STREAMINFO block */
|
||||||
{
|
{
|
||||||
/* FIXME: Don't trust the value of blocklength, use actual return
|
if (ci->read_filebuf(buf, blocklength) < blocklength) return false;
|
||||||
* value in bytes instead */
|
|
||||||
ci->read_filebuf(buf, blocklength);
|
|
||||||
|
|
||||||
fc->filesize = ci->filesize;
|
fc->filesize = ci->filesize;
|
||||||
fc->min_blocksize = (buf[0] << 8) | buf[1];
|
fc->min_blocksize = (buf[0] << 8) | buf[1];
|
||||||
|
|
@ -140,9 +137,8 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
|
||||||
} else if ((buf[0] & 0x7f) == 3) { /* 3 is the SEEKTABLE block */
|
} else if ((buf[0] & 0x7f) == 3) { /* 3 is the SEEKTABLE block */
|
||||||
while ((nseekpoints < MAX_SUPPORTED_SEEKTABLE_SIZE) &&
|
while ((nseekpoints < MAX_SUPPORTED_SEEKTABLE_SIZE) &&
|
||||||
(blocklength >= 18)) {
|
(blocklength >= 18)) {
|
||||||
n=ci->read_filebuf(buf,18);
|
if (ci->read_filebuf(buf,18) < 18) return false;
|
||||||
if (n < 18) return false;
|
blocklength-=18;
|
||||||
blocklength-=n;
|
|
||||||
|
|
||||||
seekpoint_hi=(buf[0] << 24) | (buf[1] << 16) |
|
seekpoint_hi=(buf[0] << 24) | (buf[1] << 16) |
|
||||||
(buf[2] << 8) | buf[3];
|
(buf[2] << 8) | buf[3];
|
||||||
|
|
|
||||||
|
|
@ -1204,8 +1204,6 @@ unsigned short LoadSIDFromMemory(void *pSidData, unsigned short *load_addr,
|
||||||
|
|
||||||
enum codec_status codec_main(void)
|
enum codec_status codec_main(void)
|
||||||
{
|
{
|
||||||
size_t n, bytesfree;
|
|
||||||
unsigned char *p;
|
|
||||||
unsigned int filesize;
|
unsigned int filesize;
|
||||||
|
|
||||||
unsigned short load_addr, init_addr, play_addr;
|
unsigned short load_addr, init_addr, play_addr;
|
||||||
|
|
@ -1229,20 +1227,16 @@ next_track:
|
||||||
|
|
||||||
codec_set_replaygain(ci->id3);
|
codec_set_replaygain(ci->id3);
|
||||||
|
|
||||||
/* Load SID file */
|
/* Load SID file the read_filebuf callback will return the full requested
|
||||||
p = sidfile;
|
* size if at all possible, so there is no need to loop */
|
||||||
bytesfree=sizeof(sidfile);
|
filesize = ci->read_filebuf(sidfile, sizeof(sidfile));
|
||||||
while ((n = ci->read_filebuf(p, bytesfree)) > 0) {
|
|
||||||
p += n;
|
|
||||||
bytesfree -= n;
|
|
||||||
}
|
|
||||||
filesize = p-sidfile;
|
|
||||||
|
|
||||||
if (filesize == 0)
|
if (filesize == 0)
|
||||||
return CODEC_ERROR;
|
return CODEC_ERROR;
|
||||||
|
|
||||||
c64Init(44100);
|
c64Init(44100);
|
||||||
LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, &subSongsMax, &subSong, &song_speed, filesize);
|
LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr,
|
||||||
|
&subSongsMax, &subSong, &song_speed, filesize);
|
||||||
sidPoke(24, 15); /* Turn on full volume */
|
sidPoke(24, 15); /* Turn on full volume */
|
||||||
cpuJSR(init_addr, subSong); /* Start the song initialize */
|
cpuJSR(init_addr, subSong); /* Start the song initialize */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue