Properly handle the Wiimote speaker data format being unknown.
This commit is contained in:
parent
a27f5fe301
commit
d4e8e3a6a3
|
@ -69,7 +69,7 @@ void Wiimote::SpeakerData(wm_speaker_data* sd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO consider using static max size instead of new
|
// TODO consider using static max size instead of new
|
||||||
s16 *samples = new s16[sd->length * 2];
|
std::unique_ptr<s16[]> samples(new s16[sd->length * 2]);
|
||||||
|
|
||||||
unsigned int sample_rate_dividend;
|
unsigned int sample_rate_dividend;
|
||||||
u8 volume_divisor;
|
u8 volume_divisor;
|
||||||
|
@ -99,6 +99,11 @@ void Wiimote::SpeakerData(wm_speaker_data* sd)
|
||||||
sample_rate_dividend = 6000000;
|
sample_rate_dividend = 6000000;
|
||||||
volume_divisor = 0x40;
|
volume_divisor = 0x40;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ERROR_LOG(WII_IPC_WIIMOTE, "Unknown speaker format %x\n", m_reg_speaker.format);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Speaker Pan
|
// Speaker Pan
|
||||||
unsigned int vol = (unsigned int)(m_options->settings[4]->GetValue() * 100);
|
unsigned int vol = (unsigned int)(m_options->settings[4]->GetValue() * 100);
|
||||||
|
@ -115,7 +120,7 @@ void Wiimote::SpeakerData(wm_speaker_data* sd)
|
||||||
right_volume = 255;
|
right_volume = 255;
|
||||||
|
|
||||||
g_sound_stream->GetMixer()->SetWiimoteSpeakerVolume(left_volume, right_volume);
|
g_sound_stream->GetMixer()->SetWiimoteSpeakerVolume(left_volume, right_volume);
|
||||||
g_sound_stream->GetMixer()->PushWiimoteSpeakerSamples(samples, sd->length, sample_rate);
|
g_sound_stream->GetMixer()->PushWiimoteSpeakerSamples(samples.get(), sd->length, sample_rate);
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIIMOTE_SPEAKER_DUMP
|
#ifdef WIIMOTE_SPEAKER_DUMP
|
||||||
|
@ -129,7 +134,7 @@ void Wiimote::SpeakerData(wm_speaker_data* sd)
|
||||||
OpenFStream(ofile, "rmtdump.bin", ofile.binary | ofile.out);
|
OpenFStream(ofile, "rmtdump.bin", ofile.binary | ofile.out);
|
||||||
wav.Start("rmtdump.wav", 6000/*Common::swap16(m_reg_speaker.sample_rate)*/);
|
wav.Start("rmtdump.wav", 6000/*Common::swap16(m_reg_speaker.sample_rate)*/);
|
||||||
}
|
}
|
||||||
wav.AddMonoSamples(samples, sd->length*2);
|
wav.AddMonoSamples(samples.get(), sd->length*2);
|
||||||
if (ofile.good())
|
if (ofile.good())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < sd->length; i++)
|
for (int i = 0; i < sd->length; i++)
|
||||||
|
@ -139,8 +144,6 @@ void Wiimote::SpeakerData(wm_speaker_data* sd)
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete[] samples;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue