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 { }
|
void adjustVolume(Int8 direction) override { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method is called to provide information about the sound device.
|
||||||
|
*/
|
||||||
|
string about() const override { return "Sound disabled"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
SoundNull() = delete;
|
SoundNull() = delete;
|
||||||
|
|
|
@ -118,6 +118,8 @@ void SoundSDL2::setEnabled(bool state)
|
||||||
void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue,
|
void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue,
|
||||||
EmulationTiming* emulationTiming)
|
EmulationTiming* emulationTiming)
|
||||||
{
|
{
|
||||||
|
string pre_about = myAboutString;
|
||||||
|
|
||||||
// Do we need to re-open the sound device?
|
// Do we need to re-open the sound device?
|
||||||
// Only do this when absolutely necessary
|
// Only do this when absolutely necessary
|
||||||
if(myAudioSettings.sampleRate() != uInt32(myHardwareSpec.freq) ||
|
if(myAudioSettings.sampleRate() != uInt32(myHardwareSpec.freq) ||
|
||||||
|
@ -146,28 +148,9 @@ void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue,
|
||||||
initResampler();
|
initResampler();
|
||||||
|
|
||||||
// Show some info
|
// Show some info
|
||||||
ostringstream buf;
|
myAboutString = about();
|
||||||
buf << "Sound enabled:" << endl
|
if(myAboutString != pre_about)
|
||||||
<< " Volume: " << myVolume << endl
|
myOSystem.logMessage(myAboutString, 1);
|
||||||
<< " 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);
|
|
||||||
|
|
||||||
// And start the SDL sound subsystem ...
|
// And start the SDL sound subsystem ...
|
||||||
mute(false);
|
mute(false);
|
||||||
|
@ -239,6 +222,51 @@ void SoundSDL2::adjustVolume(Int8 direction)
|
||||||
myOSystem.frameBuffer().showMessage(message);
|
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)
|
void SoundSDL2::processFragment(float* stream, uInt32 length)
|
||||||
{
|
{
|
||||||
|
@ -270,7 +298,6 @@ void SoundSDL2::initResampler()
|
||||||
Resampler::Format formatTo =
|
Resampler::Format formatTo =
|
||||||
Resampler::Format(myHardwareSpec.freq, myHardwareSpec.samples, myHardwareSpec.channels > 1);
|
Resampler::Format(myHardwareSpec.freq, myHardwareSpec.samples, myHardwareSpec.channels > 1);
|
||||||
|
|
||||||
|
|
||||||
switch (myAudioSettings.resamplingQuality()) {
|
switch (myAudioSettings.resamplingQuality()) {
|
||||||
case AudioSettings::ResamplingQuality::nearestNeightbour:
|
case AudioSettings::ResamplingQuality::nearestNeightbour:
|
||||||
myResampler = make_unique<SimpleResampler>(formatFrom, formatTo, nextFragmentCallback);
|
myResampler = make_unique<SimpleResampler>(formatFrom, formatTo, nextFragmentCallback);
|
||||||
|
|
|
@ -96,6 +96,11 @@ class SoundSDL2 : public Sound
|
||||||
*/
|
*/
|
||||||
void adjustVolume(Int8 direction) override;
|
void adjustVolume(Int8 direction) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method is called to provide information about the sound device.
|
||||||
|
*/
|
||||||
|
string about() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
Invoked by the sound callback to process the next sound fragment.
|
Invoked by the sound callback to process the next sound fragment.
|
||||||
|
@ -141,6 +146,8 @@ class SoundSDL2 : public Sound
|
||||||
|
|
||||||
AudioSettings& myAudioSettings;
|
AudioSettings& myAudioSettings;
|
||||||
|
|
||||||
|
string myAboutString;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Callback function invoked by the SDL Audio library when it needs data
|
// Callback function invoked by the SDL Audio library when it needs data
|
||||||
static void callback(void* udata, uInt8* stream, int len);
|
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
|
buf << "Game console created:" << endl
|
||||||
<< " ROM file: " << myRomFile.getShortPath() << endl << endl
|
<< " ROM file: " << myRomFile.getShortPath() << endl << endl
|
||||||
<< getROMInfo(*myConsole) << endl;
|
<< getROMInfo(*myConsole);
|
||||||
logMessage(buf.str(), 1);
|
logMessage(buf.str(), 1);
|
||||||
|
|
||||||
myFrameBuffer->setCursorState();
|
myFrameBuffer->setCursorState();
|
||||||
|
|
|
@ -86,6 +86,11 @@ class Sound
|
||||||
*/
|
*/
|
||||||
virtual void adjustVolume(Int8 direction) = 0;
|
virtual void adjustVolume(Int8 direction) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method is called to provide information about the sound device.
|
||||||
|
*/
|
||||||
|
virtual string about() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// The OSystem for this sound object
|
// The OSystem for this sound object
|
||||||
OSystem& myOSystem;
|
OSystem& myOSystem;
|
||||||
|
|
Loading…
Reference in New Issue