mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 14:57:46 -04:00
unify helix mp3 code, some sound adjustments
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@726 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
8af2da7273
commit
9615b3dfde
4 changed files with 67 additions and 151 deletions
|
@ -405,24 +405,24 @@ int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
static int mp3_samples_ready = 0, mp3_buffer_offs = 0;
|
||||
static int mp3_play_bufsel = 0, mp3_job_started = 0;
|
||||
|
||||
void mp3_update(int *buffer, int length, int stereo)
|
||||
{
|
||||
int length_mp3;
|
||||
int cdda_on;
|
||||
|
||||
// playback was started, track not ended
|
||||
cdda_on = loaded_mp3 && shared_ctl->mp3_offs < shared_ctl->mp3_len;
|
||||
|
||||
if (!cdda_on) return;
|
||||
|
||||
if (!(PicoOpt&0x200)) {
|
||||
if (!(PicoOpt & POPT_EXT_FM)) {
|
||||
mp3_update_local(buffer, length, stereo);
|
||||
return;
|
||||
}
|
||||
|
||||
// check if playback was started, track not ended
|
||||
if (loaded_mp3 == NULL || shared_ctl->mp3_offs >= shared_ctl->mp3_len)
|
||||
return;
|
||||
|
||||
length_mp3 = length;
|
||||
if (PsndRate == 22050) length_mp3 <<= 1; // mp3s are locked to 44100Hz stereo
|
||||
else if (PsndRate == 11025) length_mp3 <<= 2; // so make length 44100ish
|
||||
|
@ -475,13 +475,15 @@ void mp3_update(int *buffer, int length, int stereo)
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
void mp3_start_play(FILE *f, int pos) // pos is 0-1023
|
||||
{
|
||||
int byte_offs = 0;
|
||||
|
||||
if (!(PicoOpt&0x800)) { // cdda disabled?
|
||||
if (!(PicoOpt & POPT_EN_MCD_CDDA) || f == NULL)
|
||||
return;
|
||||
|
||||
if (!(PicoOpt & POPT_EXT_FM)) {
|
||||
mp3_start_play_local(f, pos);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -522,31 +524,7 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
|
|||
mp3_job_started = 0;
|
||||
shared_ctl->mp3_buffsel = 1; // will change to 0 on first decode
|
||||
|
||||
if (PicoOpt & POPT_EXT_FM)
|
||||
{
|
||||
add_job_940(JOB940_MP3RESET);
|
||||
if (CHECK_BUSY(JOB940_MP3RESET)) wait_busy_940(JOB940_MP3RESET);
|
||||
}
|
||||
else
|
||||
mp3_start_local();
|
||||
add_job_940(JOB940_MP3RESET);
|
||||
if (CHECK_BUSY(JOB940_MP3RESET)) wait_busy_940(JOB940_MP3RESET);
|
||||
}
|
||||
|
||||
|
||||
int mp3_get_offset(void)
|
||||
{
|
||||
unsigned int offs1024 = 0;
|
||||
int cdda_on;
|
||||
|
||||
cdda_on = (PicoAHW & PAHW_MCD) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) &&
|
||||
(Pico_mcd->scd.Status_CDC & 1) && loaded_mp3;
|
||||
|
||||
if (cdda_on) {
|
||||
offs1024 = shared_ctl->mp3_offs << 7;
|
||||
offs1024 /= shared_ctl->mp3_len >> 3;
|
||||
}
|
||||
printf("offs1024=%u (%i/%i)\n", offs1024, shared_ctl->mp3_offs, shared_ctl->mp3_len);
|
||||
|
||||
return offs1024;
|
||||
}
|
||||
|
||||
|
||||
|
|
24
gp2x/emu.c
24
gp2x/emu.c
|
@ -409,6 +409,7 @@ void plat_status_msg_busy_next(const char *msg)
|
|||
{
|
||||
plat_status_msg_clear();
|
||||
pemu_update_display("", msg);
|
||||
emu_status_msg("");
|
||||
|
||||
/* assumption: msg_busy_next gets called only when
|
||||
* something slow is about to happen */
|
||||
|
@ -600,22 +601,26 @@ static void updateSound(int len)
|
|||
void pemu_sound_start(void)
|
||||
{
|
||||
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;
|
||||
int target_fps = Pico.m.pal ? 50 : 60;
|
||||
|
||||
PsndOut = NULL;
|
||||
|
||||
// prepare sound stuff
|
||||
if (currentConfig.EmuOpt & 4)
|
||||
if (currentConfig.EmuOpt & EOPT_EN_SOUND)
|
||||
{
|
||||
int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;
|
||||
int target_fps = Pico.m.pal ? 50 : 60;
|
||||
int snd_excess_add;
|
||||
if (PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old ||
|
||||
((PicoOpt&0x200) && crashed_940)) {
|
||||
gp2x_soc_t soc;
|
||||
|
||||
#define SOUND_RERATE_FLAGS (POPT_EN_FM|POPT_EN_PSG|POPT_EN_STEREO|POPT_EXT_FM|POPT_EN_MCD_CDDA)
|
||||
if (PsndRate != PsndRate_old || Pico.m.pal != pal_old || ((PicoOpt & POPT_EXT_FM) && crashed_940) ||
|
||||
((PicoOpt ^ PicoOpt_old) & SOUND_RERATE_FLAGS)) {
|
||||
PsndRerate(Pico.m.frame_count ? 1 : 0);
|
||||
}
|
||||
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
|
||||
snd_excess_add = ((PsndRate - PsndLen * target_fps)<<16) / target_fps;
|
||||
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
|
||||
PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);
|
||||
sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);
|
||||
PsndRate, PsndLen, snd_excess_add, is_stereo, Pico.m.pal);
|
||||
sndout_oss_start(PsndRate, 16, is_stereo);
|
||||
sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
|
||||
PicoWriteSound = updateSound;
|
||||
plat_update_volume(0, 0);
|
||||
|
@ -624,6 +629,11 @@ void pemu_sound_start(void)
|
|||
PsndRate_old = PsndRate;
|
||||
PicoOpt_old = PicoOpt;
|
||||
pal_old = Pico.m.pal;
|
||||
|
||||
/* Wiz's sound hardware needs more prebuffer */
|
||||
soc = soc_detect();
|
||||
if (soc == SOCID_POLLUX)
|
||||
updateSound(PsndLen);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue