diff options
Diffstat (limited to 'lib/rbcodec/codecs/sid.c')
-rw-r--r-- | lib/rbcodec/codecs/sid.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/rbcodec/codecs/sid.c b/lib/rbcodec/codecs/sid.c index 1a6d04155d..6e39d3f759 100644 --- a/lib/rbcodec/codecs/sid.c +++ b/lib/rbcodec/codecs/sid.c | |||
@@ -1253,6 +1253,7 @@ enum codec_status codec_run(void) | |||
1253 | unsigned char subSongsMax, subSong, song_speed; | 1253 | unsigned char subSongsMax, subSong, song_speed; |
1254 | unsigned char *sidfile = NULL; | 1254 | unsigned char *sidfile = NULL; |
1255 | intptr_t param; | 1255 | intptr_t param; |
1256 | bool resume; | ||
1256 | 1257 | ||
1257 | if (codec_init()) { | 1258 | if (codec_init()) { |
1258 | return CODEC_ERROR; | 1259 | return CODEC_ERROR; |
@@ -1269,15 +1270,10 @@ enum codec_status codec_run(void) | |||
1269 | return CODEC_ERROR; | 1270 | return CODEC_ERROR; |
1270 | } | 1271 | } |
1271 | 1272 | ||
1272 | c64Init(SAMPLE_RATE); | 1273 | param = ci->id3->elapsed; |
1273 | LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, | 1274 | resume = param != 0; |
1274 | &subSongsMax, &subSong, &song_speed, (unsigned short)filesize); | ||
1275 | sidPoke(24, 15); /* Turn on full volume */ | ||
1276 | cpuJSR(init_addr, subSong); /* Start the song initialize */ | ||
1277 | 1275 | ||
1278 | 1276 | goto sid_start; | |
1279 | /* Set the elapsed time to the current subsong (in seconds) */ | ||
1280 | ci->set_elapsed(subSong*1000); | ||
1281 | 1277 | ||
1282 | /* The main decoder loop */ | 1278 | /* The main decoder loop */ |
1283 | while (1) { | 1279 | while (1) { |
@@ -1287,20 +1283,26 @@ enum codec_status codec_run(void) | |||
1287 | break; | 1283 | break; |
1288 | 1284 | ||
1289 | if (action == CODEC_ACTION_SEEK_TIME) { | 1285 | if (action == CODEC_ACTION_SEEK_TIME) { |
1286 | sid_start: | ||
1290 | /* New time is ready in param */ | 1287 | /* New time is ready in param */ |
1291 | 1288 | ||
1292 | /* Start playing from scratch */ | 1289 | /* Start playing from scratch */ |
1293 | c64Init(SAMPLE_RATE); | 1290 | c64Init(SAMPLE_RATE); |
1294 | LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, | 1291 | LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, |
1295 | &subSongsMax, &subSong, &song_speed, (unsigned short)filesize); | 1292 | &subSongsMax, &subSong, &song_speed, |
1293 | (unsigned short)filesize); | ||
1296 | sidPoke(24, 15); /* Turn on full volume */ | 1294 | sidPoke(24, 15); /* Turn on full volume */ |
1297 | subSong = param / 1000; /* Now use the current seek time in seconds as subsong */ | 1295 | if (!resume || (resume && param)) |
1296 | subSong = param / 1000; /* Now use the current seek time in | ||
1297 | seconds as subsong */ | ||
1298 | cpuJSR(init_addr, subSong); /* Start the song initialize */ | 1298 | cpuJSR(init_addr, subSong); /* Start the song initialize */ |
1299 | nSamplesToRender = 0; /* Start the rendering from scratch */ | 1299 | nSamplesToRender = 0; /* Start the rendering from scratch */ |
1300 | 1300 | ||
1301 | /* Set the elapsed time to the current subsong (in seconds) */ | 1301 | /* Set the elapsed time to the current subsong (in seconds) */ |
1302 | ci->set_elapsed(subSong*1000); | 1302 | ci->set_elapsed(subSong*1000); |
1303 | ci->seek_complete(); | 1303 | ci->seek_complete(); |
1304 | |||
1305 | resume = false; | ||
1304 | } | 1306 | } |
1305 | 1307 | ||
1306 | nSamplesRendered = 0; | 1308 | nSamplesRendered = 0; |