Index: apps/codecs/mod.c =================================================================== --- apps/codecs/mod.c (Revision 30390) +++ apps/codecs/mod.c (Arbeitskopie) @@ -1155,8 +1155,8 @@ else return(i); } -STATICIRAM void synthrender(int32_t *renderbuffer, int samplecount) ICODE_ATTR; -void synthrender(int32_t *renderbuffer, int samplecount) +STATICIRAM int synthrender(int32_t *renderbuffer, int samplecount) ICODE_ATTR; +int synthrender(int32_t *renderbuffer, int samplecount) { /* 125bpm equals to 50Hz (= 0.02s) * => one tick = mixingrate/50, @@ -1192,12 +1192,13 @@ if (modplayer.currentline == 64) { modplayer.patterntableposition++; - if (modplayer.patterntableposition >= modsong.songlength) - /* This is for Noise Tracker + if (modplayer.patterntableposition >= modsong.songlength) { + /* For Noise Tracker: * modplayer.patterntableposition = * modsong.songendjumpposition; - * More compatible approach is restart from 0 */ - modplayer.patterntableposition=0; + * However, it's more compatible not to loop. */ + return i; + } modplayer.currentline = 0; } } @@ -1276,6 +1277,8 @@ p_left+=2; p_right+=2; } + + return samplecount; } /* this is the codec entry point */ @@ -1299,7 +1302,7 @@ size_t n; unsigned char *modfile; int old_patterntableposition; - int bytesdone; + int bytesdone, chunkdone; intptr_t param; if (codec_init()) { @@ -1323,7 +1326,7 @@ bytesdone = 0; old_patterntableposition = 0; - while (1) { + do { enum codec_command_action action = ci->get_command(¶m); if (action == CODEC_ACTION_HALT) @@ -1341,13 +1344,13 @@ old_patterntableposition=modplayer.patterntableposition; } - synthrender(samples, CHUNK_SIZE/2); + chunkdone = synthrender(samples, CHUNK_SIZE/2); - bytesdone += CHUNK_SIZE; + bytesdone += 2*chunkdone; - ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE/2); + ci->pcmbuf_insert(samples, NULL, chunkdone); - } + } while (chunkdone == CHUNK_SIZE / 2); return CODEC_OK; }