void (*PsndMix_32_to_16l)(short *dest, int *src, int count) = mix_32_to_16l_stereo;\r
\r
// master int buffer to mix to\r
-static int PsndBuffer[2*44100/50];\r
+static int PsndBuffer[2*(44100+100)/50];\r
\r
// dac\r
static unsigned short dac_info[312+4]; // pppppppp ppppllll, p - pos in buff, l - length to write for this sample\r
\r
// not all rates are supported in MCD mode due to mp3 decoder limitations\r
if (PicoAHW & PAHW_MCD) {\r
- if (PsndRate != 11025 && PsndRate != 22050 && PsndRate != 44100) PsndRate = 22050;\r
+ if (!(11025-100 <= PsndRate && PsndRate <= 11025+100) &&\r
+ !(22050-100 <= PsndRate && PsndRate <= 22050+100) &&\r
+ !(44100-100 <= PsndRate && PsndRate <= 44100+100))\r
+ PsndRate = 22050;\r
PicoOpt |= POPT_EN_STEREO; // force stereo\r
}\r
\r
\r
static void cdda_raw_update(int *buffer, int length)\r
{\r
- int ret, cdda_bytes;\r
- if (cdda_stream == NULL) return;\r
+ int ret, cdda_bytes, mult = 1;\r
+ if (cdda_stream == NULL)\r
+ return;\r
\r
cdda_bytes = length*4;\r
- if (PsndRate <= 22050) cdda_bytes *= 2;\r
- if (PsndRate < 22050) cdda_bytes *= 2;\r
+ if (PsndRate <= 22050 + 100) mult = 2;\r
+ if (PsndRate < 22050 - 100) mult = 4;\r
+ cdda_bytes *= mult;\r
\r
ret = pm_read(cdda_out_buffer, cdda_bytes, cdda_stream);\r
if (ret < cdda_bytes) {\r
}\r
\r
// now mix\r
- switch (PsndRate) {\r
- case 44100: mix_16h_to_32(buffer, cdda_out_buffer, length*2); break;\r
- case 22050: mix_16h_to_32_s1(buffer, cdda_out_buffer, length*2); break;\r
- case 11025: mix_16h_to_32_s2(buffer, cdda_out_buffer, length*2); break;\r
+ switch (mult) {\r
+ case 1: mix_16h_to_32(buffer, cdda_out_buffer, length*2); break;\r
+ case 2: mix_16h_to_32_s1(buffer, cdda_out_buffer, length*2); break;\r
+ case 4: mix_16h_to_32_s2(buffer, cdda_out_buffer, length*2); break;\r
}\r
}\r
\r
return; /* no file / EOF */
length_mp3 = length;
- if (PsndRate == 22050) { mix_samples = mix_16h_to_32_s1; length_mp3 <<= 1; shr = 1; }
- else if (PsndRate == 11025) { mix_samples = mix_16h_to_32_s2; length_mp3 <<= 2; shr = 2; }
+ if (PsndRate <= 11025 + 100) {
+ mix_samples = mix_16h_to_32_s2;
+ length_mp3 <<= 2; shr = 2;
+ }
+ else if (PsndRate <= 22050 + 100) {
+ mix_samples = mix_16h_to_32_s1;
+ length_mp3 <<= 1; shr = 1;
+ }
if (1152 - mp3_buffer_offs >= length_mp3) {
mix_samples(buffer, cdda_out_buffer + mp3_buffer_offs*2, length<<1);
\r
extern int crashed_940;\r
\r
-static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
+static short __attribute__((aligned(4))) sndBuffer[2*(44100+100)/50];\r
static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];\r
unsigned char *PicoDraw2FB = PicoDraw2FB_;\r
static int osd_fps_x;\r
if (!(Pico.video.reg[12]&1) && !(PicoOpt & POPT_DIS_32C_BORDER))\r
x += 32;\r
\r
- if (EOPT_WIZ_TEAR_FIX) {\r
+ if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {\r
pitch = 240;\r
p += (319 - x) * pitch + y;\r
} else\r
int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;\r
int target_fps = Pico.m.pal ? 50 : 60;\r
int frame_samples, snd_excess_add;\r
+ int snd_rate_oss = PsndRate;\r
gp2x_soc_t soc;\r
\r
soc = soc_detect();\r
+ if (soc == SOCID_POLLUX) {\r
+ /* POLLUX pain: DPLL1 / mclk_div / bitclk_div / 4 */\r
+ switch (PsndRate) {\r
+ case 44100: PsndRate = 44171; break; // 44170.673077\r
+ case 22050: PsndRate = 22086; break; // 22085.336538\r
+ case 11025: PsndRate = 11043; break; // 11042.668269\r
+ default: break;\r
+ }\r
+ }\r
\r
#define SOUND_RERATE_FLAGS (POPT_EN_FM|POPT_EN_PSG|POPT_EN_STEREO|POPT_EXT_FM|POPT_EN_MCD_CDDA)\r
if (PsndRate != PsndRate_old || Pico.m.pal != pal_old || ((PicoOpt & POPT_EXT_FM) && crashed_940) ||\r
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",\r
PsndRate, PsndLen, snd_excess_add, is_stereo, Pico.m.pal);\r
sndout_oss_setvol(currentConfig.volume, currentConfig.volume);\r
- sndout_oss_start(PsndRate, frame_samples, is_stereo);\r
+ sndout_oss_start(snd_rate_oss, frame_samples, is_stereo);\r
\r
/* Wiz's sound hardware needs more prebuffer */\r
if (soc == SOCID_POLLUX)\r
\r
void pemu_sound_stop(void)\r
{\r
+ /* get back from Wiz pain */\r
+ switch (PsndRate) {\r
+ case 44171: PsndRate = 44100; break;\r
+ case 22086: PsndRate = 22050; break;\r
+ case 11043: PsndRate = 11025; break;\r
+ default: break;\r
+ }\r
}\r
\r
void pemu_sound_wait(void)\r
int po_old = PicoOpt;\r
int eo_old = currentConfig.EmuOpt;\r
\r
+ pemu_sound_stop();\r
+\r
/* do one more frame for menu bg */\r
PicoOpt &= ~POPT_ALT_RENDERER;\r
PicoOpt |= POPT_EN_SOFTSCALE|POPT_ACC_SPRITES;\r