- float fs;
- index = num_track - Pico_mcd->scd.TOC.First_Track;
-
- stat(tmp_name, &file_stat);
-
- fs = (float) file_stat.st_size; // used to calculate lenght
+ int fs;
+ index = num_track - 1;
+
+ ret = fseek(tmp_file, 0, SEEK_END);
+ fs = ftell(tmp_file); // used to calculate lenght
+ fseek(tmp_file, 0, SEEK_SET);
+
+#if DONT_OPEN_MANY_FILES
+ // some systems (like PSP) can't have many open files at a time,
+ // so we work with their names instead.
+ fclose(tmp_file);
+ tmp_file = (void *) strdup(tmp_name);
+#endif
+ Tracks[index].KBtps = (short) mp3_get_bitrate(tmp_file, fs);
+ Tracks[index].KBtps >>= 3;
+ if (ret != 0 || Tracks[index].KBtps <= 0)
+ {
+ cdprintf("Error track %i: rate %i", index, Tracks[index].KBtps);
+#if !DONT_OPEN_MANY_FILES
+ fclose(tmp_file);
+#else
+ free(tmp_file);
+#endif
+ continue;
+ }