mirror of https://github.com/stella-emu/stella.git
Improvements to logging for sound settings.
- Now shows all settings from AudioSettings (preset, resampler, etc) - Only logs sound info when the settings have actually changed (similar to Framebuffer info)
This commit is contained in:
parent
b4dc729559
commit
ce9b832f68
|
@ -93,6 +93,11 @@ class SoundNull : public Sound
|
|||
*/
|
||||
void adjustVolume(Int8 direction) override { }
|
||||
|
||||
/**
|
||||
This method is called to provide information about the sound device.
|
||||
*/
|
||||
string about() const override { return "Sound disabled"; }
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
SoundNull() = delete;
|
||||
|
|
|
@ -118,6 +118,8 @@ void SoundSDL2::setEnabled(bool state)
|
|||
void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue,
|
||||
EmulationTiming* emulationTiming)
|
||||
{
|
||||
string pre_about = myAboutString;
|
||||
|
||||
// Do we need to re-open the sound device?
|
||||
// Only do this when absolutely necessary
|
||||
if(myAudioSettings.sampleRate() != uInt32(myHardwareSpec.freq) ||
|
||||
|
@ -146,28 +148,9 @@ void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue,
|
|||
initResampler();
|
||||
|
||||
// Show some info
|
||||
ostringstream buf;
|
||||
buf << "Sound enabled:" << endl
|
||||
<< " Volume: " << myVolume << endl
|
||||
<< " Frag size: " << uInt32(myHardwareSpec.samples) << endl
|
||||
<< " Frequency: " << uInt32(myHardwareSpec.freq) << endl
|
||||
<< " Channels: " << uInt32(myHardwareSpec.channels) << endl
|
||||
<< " Resampling: ";
|
||||
switch (myAudioSettings.resamplingQuality()) {
|
||||
case AudioSettings::ResamplingQuality::nearestNeightbour:
|
||||
buf << "quality 1, nearest neighbor" << endl;
|
||||
break;
|
||||
case AudioSettings::ResamplingQuality::lanczos_2:
|
||||
buf << "quality 2, nearest Lanczos (a = 2)" << endl;
|
||||
break;
|
||||
case AudioSettings::ResamplingQuality::lanczos_3:
|
||||
buf << "quality 3, nearest Lanczos (a = 3)" << endl;
|
||||
break;
|
||||
default:
|
||||
buf << "unknown resampler" << endl;
|
||||
break;
|
||||
}
|
||||
myOSystem.logMessage(buf.str(), 1);
|
||||
myAboutString = about();
|
||||
if(myAboutString != pre_about)
|
||||
myOSystem.logMessage(myAboutString, 1);
|
||||
|
||||
// And start the SDL sound subsystem ...
|
||||
mute(false);
|
||||
|
@ -239,6 +222,51 @@ void SoundSDL2::adjustVolume(Int8 direction)
|
|||
myOSystem.frameBuffer().showMessage(message);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string SoundSDL2::about() const
|
||||
{
|
||||
ostringstream buf;
|
||||
buf << "Sound enabled:" << endl
|
||||
<< " Volume: " << myVolume << endl
|
||||
<< " Channels: " << uInt32(myHardwareSpec.channels) << endl
|
||||
<< " Preset: ";
|
||||
switch (myAudioSettings.preset()) {
|
||||
case AudioSettings::Preset::custom:
|
||||
buf << "Custom" << endl;
|
||||
break;
|
||||
case AudioSettings::Preset::lowQualityMediumLag:
|
||||
buf << "Low quality, medium lag" << endl;
|
||||
break;
|
||||
case AudioSettings::Preset::highQualityMediumLag:
|
||||
buf << "High quality, medium lag" << endl;
|
||||
break;
|
||||
case AudioSettings::Preset::highQualityLowLag:
|
||||
buf << "High quality, low lag" << endl;
|
||||
break;
|
||||
case AudioSettings::Preset::veryHighQualityVeryLowLag:
|
||||
buf << "Very high quality, very low lag" << endl;
|
||||
break;
|
||||
}
|
||||
buf << " Sample rate: " << uInt32(myHardwareSpec.freq) << endl
|
||||
<< " Frag size: " << uInt32(myHardwareSpec.samples) << endl
|
||||
<< " Buffer size: " << myAudioSettings.bufferSize() << endl
|
||||
<< " Head room: " << myAudioSettings.headroom() << endl
|
||||
<< " Resampling: ";
|
||||
switch (myAudioSettings.resamplingQuality()) {
|
||||
case AudioSettings::ResamplingQuality::nearestNeightbour:
|
||||
buf << "quality 1, nearest neighbor" << endl;
|
||||
break;
|
||||
case AudioSettings::ResamplingQuality::lanczos_2:
|
||||
buf << "quality 2, Lanczos (a = 2)" << endl;
|
||||
break;
|
||||
case AudioSettings::ResamplingQuality::lanczos_3:
|
||||
buf << "quality 3, Lanczos (a = 3)" << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SoundSDL2::processFragment(float* stream, uInt32 length)
|
||||
{
|
||||
|
@ -270,7 +298,6 @@ void SoundSDL2::initResampler()
|
|||
Resampler::Format formatTo =
|
||||
Resampler::Format(myHardwareSpec.freq, myHardwareSpec.samples, myHardwareSpec.channels > 1);
|
||||
|
||||
|
||||
switch (myAudioSettings.resamplingQuality()) {
|
||||
case AudioSettings::ResamplingQuality::nearestNeightbour:
|
||||
myResampler = make_unique<SimpleResampler>(formatFrom, formatTo, nextFragmentCallback);
|
||||
|
|
|
@ -96,6 +96,11 @@ class SoundSDL2 : public Sound
|
|||
*/
|
||||
void adjustVolume(Int8 direction) override;
|
||||
|
||||
/**
|
||||
This method is called to provide information about the sound device.
|
||||
*/
|
||||
string about() const override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
Invoked by the sound callback to process the next sound fragment.
|
||||
|
@ -141,6 +146,8 @@ class SoundSDL2 : public Sound
|
|||
|
||||
AudioSettings& myAudioSettings;
|
||||
|
||||
string myAboutString;
|
||||
|
||||
private:
|
||||
// Callback function invoked by the SDL Audio library when it needs data
|
||||
static void callback(void* udata, uInt8* stream, int len);
|
||||
|
|
|
@ -351,7 +351,7 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
|
|||
}
|
||||
buf << "Game console created:" << endl
|
||||
<< " ROM file: " << myRomFile.getShortPath() << endl << endl
|
||||
<< getROMInfo(*myConsole) << endl;
|
||||
<< getROMInfo(*myConsole);
|
||||
logMessage(buf.str(), 1);
|
||||
|
||||
myFrameBuffer->setCursorState();
|
||||
|
|
|
@ -86,6 +86,11 @@ class Sound
|
|||
*/
|
||||
virtual void adjustVolume(Int8 direction) = 0;
|
||||
|
||||
/**
|
||||
This method is called to provide information about the sound device.
|
||||
*/
|
||||
virtual string about() const = 0;
|
||||
|
||||
protected:
|
||||
// The OSystem for this sound object
|
||||
OSystem& myOSystem;
|
||||
|
|
Loading…
Reference in New Issue