OPTiMC: Fix CD audio mixer

This commit is contained in:
Cacodemon345
2022-11-20 20:42:24 +06:00
parent 3deacca28d
commit 276cdcdff5
2 changed files with 25 additions and 14 deletions

View File

@@ -384,18 +384,17 @@ ad1848_write(uint16_t addr, uint8_t val, void *priv)
if (updatefreq)
ad1848_updatefreq(ad1848);
if (ad1848->type >= AD1848_TYPE_CS4231) { /* TODO: configure CD volume for CS4248/AD1848 too */
temp = (ad1848->type == AD1848_TYPE_CS4231) ? 18 : 4;
if (ad1848->regs[temp] & 0x80)
ad1848->cd_vol_l = 0;
else
ad1848->cd_vol_l = ad1848_vols_5bits_aux_gain[ad1848->regs[temp] & 0x1f];
temp++;
if (ad1848->regs[temp] & 0x80)
ad1848->cd_vol_r = 0;
else
ad1848->cd_vol_r = ad1848_vols_5bits_aux_gain[ad1848->regs[temp] & 0x1f];
}
temp = (ad1848->type < AD1848_TYPE_CS4231) ? 2 : ((ad1848->type == AD1848_TYPE_CS4231) ? 18 : 4);
if (ad1848->regs[temp] & 0x80)
ad1848->cd_vol_l = 0;
else
ad1848->cd_vol_l = ad1848_vols_5bits_aux_gain[ad1848->regs[temp] & 0x1f];
temp++;
if (ad1848->regs[temp] & 0x80)
ad1848->cd_vol_r = 0;
else
ad1848->cd_vol_r = ad1848_vols_5bits_aux_gain[ad1848->regs[temp] & 0x1f];
break;
case 2:
@@ -600,7 +599,7 @@ ad1848_filter_cd_audio(int channel, double *buffer, void *priv)
}
void
ad1848_filter_aux2(void* priv, double* out_l, double* out_r)
ad1848_filter_aux2(void *priv, double *out_l, double *out_r)
{
ad1848_t *ad1848 = (ad1848_t *) priv;

View File

@@ -328,6 +328,18 @@ optimc_reg_read(uint16_t addr, void *p)
return temp;
}
static void
optimc_filter_cd_audio(int channel, double *buffer, void *p)
{
optimc_t *optimc = (optimc_t*) p;
if (optimc->cur_wss_enabled) {
ad1848_filter_cd_audio(channel, buffer, p);
} else {
sbpro_filter_cd_audio(channel, buffer, p);
}
}
static void *
optimc_init(const device_t *info)
{
@@ -392,7 +404,7 @@ optimc_init(const device_t *info)
io_sethandler(optimc->cur_addr + 4, 0x0002, sb_ct1345_mixer_read, NULL, NULL, sb_ct1345_mixer_write, NULL, NULL, optimc->sb);
sound_add_handler(optimc_get_buffer, optimc);
sound_set_cd_audio_filter(sbpro_filter_cd_audio, optimc->sb);
sound_set_cd_audio_filter(optimc_filter_cd_audio, optimc);
optimc->mpu = (mpu_t *) malloc(sizeof(mpu_t));
memset(optimc->mpu, 0, sizeof(mpu_t));