summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/codecs/flac.c12
-rw-r--r--apps/codecs/sid.c16
2 files changed, 9 insertions, 19 deletions
diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c
index 2eb0deb9f5..d1c52833a6 100644
--- a/apps/codecs/flac.c
+++ b/apps/codecs/flac.c
@@ -77,8 +77,7 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
77 uint32_t offset_hi,offset_lo; 77 uint32_t offset_hi,offset_lo;
78 uint16_t blocksize; 78 uint16_t blocksize;
79 int endofmetadata=0; 79 int endofmetadata=0;
80 int blocklength; 80 uint32_t blocklength;
81 int n;
82 81
83 ci->memset(fc,0,sizeof(FLACContext)); 82 ci->memset(fc,0,sizeof(FLACContext));
84 nseekpoints=0; 83 nseekpoints=0;
@@ -113,9 +112,7 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
113 112
114 if ((buf[0] & 0x7f) == 0) /* 0 is the STREAMINFO block */ 113 if ((buf[0] & 0x7f) == 0) /* 0 is the STREAMINFO block */
115 { 114 {
116 /* FIXME: Don't trust the value of blocklength, use actual return 115 if (ci->read_filebuf(buf, blocklength) < blocklength) return false;
117 * value in bytes instead */
118 ci->read_filebuf(buf, blocklength);
119 116
120 fc->filesize = ci->filesize; 117 fc->filesize = ci->filesize;
121 fc->min_blocksize = (buf[0] << 8) | buf[1]; 118 fc->min_blocksize = (buf[0] << 8) | buf[1];
@@ -140,9 +137,8 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
140 } else if ((buf[0] & 0x7f) == 3) { /* 3 is the SEEKTABLE block */ 137 } else if ((buf[0] & 0x7f) == 3) { /* 3 is the SEEKTABLE block */
141 while ((nseekpoints < MAX_SUPPORTED_SEEKTABLE_SIZE) && 138 while ((nseekpoints < MAX_SUPPORTED_SEEKTABLE_SIZE) &&
142 (blocklength >= 18)) { 139 (blocklength >= 18)) {
143 n=ci->read_filebuf(buf,18); 140 if (ci->read_filebuf(buf,18) < 18) return false;
144 if (n < 18) return false; 141 blocklength-=18;
145 blocklength-=n;
146 142
147 seekpoint_hi=(buf[0] << 24) | (buf[1] << 16) | 143 seekpoint_hi=(buf[0] << 24) | (buf[1] << 16) |
148 (buf[2] << 8) | buf[3]; 144 (buf[2] << 8) | buf[3];
diff --git a/apps/codecs/sid.c b/apps/codecs/sid.c
index 1c98714357..c6d3c43170 100644
--- a/apps/codecs/sid.c
+++ b/apps/codecs/sid.c
@@ -1204,8 +1204,6 @@ unsigned short LoadSIDFromMemory(void *pSidData, unsigned short *load_addr,
1204 1204
1205enum codec_status codec_main(void) 1205enum codec_status codec_main(void)
1206{ 1206{
1207 size_t n, bytesfree;
1208 unsigned char *p;
1209 unsigned int filesize; 1207 unsigned int filesize;
1210 1208
1211 unsigned short load_addr, init_addr, play_addr; 1209 unsigned short load_addr, init_addr, play_addr;
@@ -1229,20 +1227,16 @@ next_track:
1229 1227
1230 codec_set_replaygain(ci->id3); 1228 codec_set_replaygain(ci->id3);
1231 1229
1232 /* Load SID file */ 1230 /* Load SID file the read_filebuf callback will return the full requested
1233 p = sidfile; 1231 * size if at all possible, so there is no need to loop */
1234 bytesfree=sizeof(sidfile); 1232 filesize = ci->read_filebuf(sidfile, sizeof(sidfile));
1235 while ((n = ci->read_filebuf(p, bytesfree)) > 0) {
1236 p += n;
1237 bytesfree -= n;
1238 }
1239 filesize = p-sidfile;
1240 1233
1241 if (filesize == 0) 1234 if (filesize == 0)
1242 return CODEC_ERROR; 1235 return CODEC_ERROR;
1243 1236
1244 c64Init(44100); 1237 c64Init(44100);
1245 LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, &subSongsMax, &subSong, &song_speed, filesize); 1238 LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr,
1239 &subSongsMax, &subSong, &song_speed, filesize);
1246 sidPoke(24, 15); /* Turn on full volume */ 1240 sidPoke(24, 15); /* Turn on full volume */
1247 cpuJSR(init_addr, subSong); /* Start the song initialize */ 1241 cpuJSR(init_addr, subSong); /* Start the song initialize */
1248 1242