Hi,
As per subject ocp exits with division by zero regularly after a track finished.
ad 1 "ocp" received signal SIGFPE, Arithmetic exception
0x00007ffff72b9980 in flacIdler (cpifaceSession=0x7ffff765c3c0 ) at flacplay.c:634
634 bitrate = (postPOS - prePOS) * 8 * samplerate_for_bitrate / samples_for_bitrate;
#0 0x00007ffff72b9980 in flacIdler (cpifaceSession=0x7ffff765c3c0 ) at flacplay.c:634
#1 0x00007ffff72b9ad1 in flacIdle (cpifaceSession=0x7ffff765c3c0 ) at flacplay.c:675
#2 0x00007ffff72b890b in flacLooped (cpifaceSession=0x7ffff765c3c0 , LoopMod=0) at flacpplay.c:199
#3 0x00007ffff76343e6 in plmpDrawScreen () at cpiface.c:2379
#4 0x00007ffff76348f5 in plmpCallBack () at cpiface.c:2572
#5 0x00007ffff7cb66a4 in fsMain (argc=1, argv=0x7fffffffe798) at pfsmain.c:304
#6 0x00007ffff7fb46dd in init_modules (argc=1, argv=0x7fffffffe798) at pmain.c:954
#7 0x00007ffff7fb493a in bootup (argc=1, argv=0x7fffffffe798, ConfigDir=0x55555555a2a0 "_", DataDir=0x55555555b300 "/usr/share/ocp/data/", ProgramDir=0x55555555a9d0 "/usr/lib/ocp/") at pmain.c:1023
#8 0x0000555555556b00 in runocp (handle=0x55555555a350, argc=1, argv=0x7fffffffe798) at kickload.c:545
#9 0x0000555555556c3d in main (argc=1, argv=0x7fffffffe798) at kickload.c:589
Code error is obvious:
60
61 static int samples_for_bitrate;
62 static int samplerate_for_bitrate;
63 static int bitrate;
64
[...]
616 samples_for_bitrate = 0;
617 prePOS = flacfile->getpos (flacfile);
618 #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
619 if ((FLAC__seekable_stream_decoder_get_state(decoder)==FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM)||(!FLAC__seekable_stream_decoder_process_single
620 #else
621 if ((FLAC__stream_decoder_get_state(decoder)==FLAC__STREAM_DECODER_END_OF_STREAM)||(!FLAC__stream_decoder_process_single(decoder)))
622 #endif
623 {
624 if (donotloop)
625 {
626 eof_flacfile=1;
627 break;
628 } else {
629 flacPendingSeek = 1;
630 flacPendingSeekPos = 0;
631 }
632 }
633 postPOS = flacfile->getpos (flacfile);
634 bitrate = (postPOS - prePOS) * 8 * samplerate_for_bitrate / samples_for_bitrate;
At first I simply commented out line 616, and during the first song bitrate seemed good, but at second song that was wrong...
So my second attempt is below - not great, not terrible....
--- ocp/playflac/flacplay.c.old 2022-08-19 13:25:12.492653739 +0200
+++ ocp/playflac/flacplay.c 2022-08-19 13:25:34.219729675 +0200
@@ -631,7 +631,7 @@
}
}
postPOS = flacfile->getpos (flacfile);
-
bitrate = (postPOS - prePOS) * 8 * samplerate_for_bitrate / samples_for_bitrate;
-
bitrate = samples_for_bitrate != 0 ? (postPOS - prePOS) * 8 * samplerate_for_bitrate / samples_for_bitrate : 0;
}
}
Should I create PR or you will modify this?