mirror of https://github.com/stella-emu/stella.git
Fix spelling mistake in nearestNeightBour.
Use new C++20 feature 'using enum ...' in switch statements. I'm not convinced this is best in all cases; for now I use it sparingly.
This commit is contained in:
parent
7d99a6132d
commit
bff2fdd817
|
@ -35,7 +35,7 @@ namespace {
|
|||
constexpr AudioSettings::ResamplingQuality normalizeResamplingQuality(int numericResamplingQuality)
|
||||
{
|
||||
return (
|
||||
numericResamplingQuality >= static_cast<int>(AudioSettings::ResamplingQuality::nearestNeightbour) &&
|
||||
numericResamplingQuality >= static_cast<int>(AudioSettings::ResamplingQuality::nearestNeighbour) &&
|
||||
numericResamplingQuality <= static_cast<int>(AudioSettings::ResamplingQuality::lanczos_3)
|
||||
) ? static_cast<AudioSettings::ResamplingQuality>(numericResamplingQuality) : AudioSettings::DEFAULT_RESAMPLING_QUALITY;
|
||||
}
|
||||
|
@ -53,7 +53,8 @@ void AudioSettings::normalize(Settings& settings)
|
|||
{
|
||||
const int settingPreset = settings.getInt(SETTING_PRESET);
|
||||
const Preset preset = normalizedPreset(settingPreset);
|
||||
if (static_cast<int>(preset) != settingPreset) settings.setValue(SETTING_PRESET, static_cast<int>(DEFAULT_PRESET));
|
||||
if (static_cast<int>(preset) != settingPreset)
|
||||
settings.setValue(SETTING_PRESET, static_cast<int>(DEFAULT_PRESET));
|
||||
|
||||
switch (settings.getInt(SETTING_SAMPLE_RATE)) {
|
||||
case 44100:
|
||||
|
@ -187,7 +188,7 @@ void AudioSettings::setPreset(AudioSettings::Preset preset)
|
|||
myPresetFragmentSize = 1024;
|
||||
myPresetBufferSize = 6;
|
||||
myPresetHeadroom = 5;
|
||||
myPresetResamplingQuality = ResamplingQuality::nearestNeightbour;
|
||||
myPresetResamplingQuality = ResamplingQuality::nearestNeighbour;
|
||||
break;
|
||||
|
||||
case Preset::highQualityMediumLag:
|
||||
|
|
|
@ -35,9 +35,9 @@ class AudioSettings
|
|||
};
|
||||
|
||||
enum class ResamplingQuality {
|
||||
nearestNeightbour = 1,
|
||||
lanczos_2 = 2,
|
||||
lanczos_3 = 3
|
||||
nearestNeighbour = 1,
|
||||
lanczos_2 = 2,
|
||||
lanczos_3 = 3
|
||||
};
|
||||
|
||||
static constexpr string_view SETTING_PRESET = "audio.preset";
|
||||
|
@ -135,7 +135,7 @@ class AudioSettings
|
|||
uInt32 myPresetFragmentSize{0};
|
||||
uInt32 myPresetBufferSize{0};
|
||||
uInt32 myPresetHeadroom{0};
|
||||
ResamplingQuality myPresetResamplingQuality{ResamplingQuality::nearestNeightbour};
|
||||
ResamplingQuality myPresetResamplingQuality{ResamplingQuality::nearestNeighbour};
|
||||
|
||||
bool myIsPersistent{true};
|
||||
};
|
||||
|
|
|
@ -214,10 +214,11 @@ size_t FSNodeZIP::read(ByteBuffer& buffer, size_t) const
|
|||
{
|
||||
switch(_error)
|
||||
{
|
||||
case zip_error::NONE: break;
|
||||
case zip_error::NOT_A_FILE: throw runtime_error("ZIP file contains errors/not found");
|
||||
case zip_error::NOT_READABLE: throw runtime_error("ZIP file not readable");
|
||||
case zip_error::NO_ROMS: throw runtime_error("ZIP file doesn't contain any ROMs");
|
||||
using enum zip_error;
|
||||
case NONE: break;
|
||||
case NOT_A_FILE: throw runtime_error("ZIP file contains errors/not found");
|
||||
case NOT_READABLE: throw runtime_error("ZIP file not readable");
|
||||
case NO_ROMS: throw runtime_error("ZIP file doesn't contain any ROMs");
|
||||
default: throw runtime_error("FSNodeZIP::read default case hit");
|
||||
}
|
||||
|
||||
|
|
|
@ -53,45 +53,46 @@ MouseControl::MouseControl(Console& console, string_view mode)
|
|||
Controller::Type& type, int& id) {
|
||||
switch(axis)
|
||||
{
|
||||
case MouseControl::Type::NoControl:
|
||||
using enum MouseControl::Type;
|
||||
case NoControl:
|
||||
msg << "not used";
|
||||
break;
|
||||
case MouseControl::Type::LeftPaddleA:
|
||||
case LeftPaddleA:
|
||||
type = Controller::Type::Paddles;
|
||||
id = 0;
|
||||
msg << "Left Paddle A";
|
||||
break;
|
||||
case MouseControl::Type::LeftPaddleB:
|
||||
case LeftPaddleB:
|
||||
type = Controller::Type::Paddles;
|
||||
id = 1;
|
||||
msg << "Left Paddle B";
|
||||
break;
|
||||
case MouseControl::Type::RightPaddleA:
|
||||
case RightPaddleA:
|
||||
type = Controller::Type::Paddles;
|
||||
id = 2;
|
||||
msg << "Right Paddle A";
|
||||
break;
|
||||
case MouseControl::Type::RightPaddleB:
|
||||
case RightPaddleB:
|
||||
type = Controller::Type::Paddles;
|
||||
id = 3;
|
||||
msg << "Right Paddle B";
|
||||
break;
|
||||
case MouseControl::Type::LeftDriving:
|
||||
case LeftDriving:
|
||||
type = Controller::Type::Driving;
|
||||
id = 0;
|
||||
msg << "Left Driving";
|
||||
break;
|
||||
case MouseControl::Type::RightDriving:
|
||||
case RightDriving:
|
||||
type = Controller::Type::Driving;
|
||||
id = 1;
|
||||
msg << "Right Driving";
|
||||
break;
|
||||
case MouseControl::Type::LeftMindLink:
|
||||
case LeftMindLink:
|
||||
type = Controller::Type::MindLink;
|
||||
id = 0;
|
||||
msg << "Left MindLink";
|
||||
break;
|
||||
case MouseControl::Type::RightMindLink:
|
||||
case RightMindLink:
|
||||
type = Controller::Type::MindLink;
|
||||
id = 1;
|
||||
msg << "Right MindLink";
|
||||
|
|
|
@ -546,19 +546,20 @@ EventMode PhysicalJoystickHandler::getMode(const Controller::Type type)
|
|||
{
|
||||
switch(type)
|
||||
{
|
||||
case Controller::Type::Keyboard:
|
||||
case Controller::Type::KidVid:
|
||||
using enum Controller::Type;
|
||||
case Keyboard:
|
||||
case KidVid:
|
||||
return EventMode::kKeyboardMode;
|
||||
|
||||
case Controller::Type::Paddles:
|
||||
case Controller::Type::PaddlesIAxDr:
|
||||
case Controller::Type::PaddlesIAxis:
|
||||
case Paddles:
|
||||
case PaddlesIAxDr:
|
||||
case PaddlesIAxis:
|
||||
return EventMode::kPaddlesMode;
|
||||
|
||||
case Controller::Type::CompuMate:
|
||||
case CompuMate:
|
||||
return EventMode::kCompuMateMode;
|
||||
|
||||
case Controller::Type::Driving:
|
||||
case Driving:
|
||||
return EventMode::kDrivingMode;
|
||||
|
||||
default:
|
||||
|
@ -611,7 +612,7 @@ void PhysicalJoystickHandler::enableEmulationMappings()
|
|||
}
|
||||
|
||||
// enable right mode first, so that in case of mapping clashes the left controller has preference
|
||||
switch (myRightMode)
|
||||
switch(myRightMode)
|
||||
{
|
||||
case EventMode::kPaddlesMode:
|
||||
enableMappings(RightPaddlesEvents, EventMode::kPaddlesMode);
|
||||
|
@ -630,7 +631,7 @@ void PhysicalJoystickHandler::enableEmulationMappings()
|
|||
break;
|
||||
}
|
||||
|
||||
switch (myLeftMode)
|
||||
switch(myLeftMode)
|
||||
{
|
||||
case EventMode::kPaddlesMode:
|
||||
enableMappings(LeftPaddlesEvents, EventMode::kPaddlesMode);
|
||||
|
@ -906,13 +907,14 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value)
|
|||
|
||||
switch(j->type)
|
||||
{
|
||||
using enum PhysicalJoystick::Type;
|
||||
// Since the various controller classes deal with Stelladaptor
|
||||
// devices differently, we send the raw X and Y axis data directly,
|
||||
// and let the controller handle it
|
||||
// These events don't have to pass through handleEvent, since
|
||||
// they can never be remapped
|
||||
case PhysicalJoystick::Type::LEFT_STELLADAPTOR:
|
||||
case PhysicalJoystick::Type::LEFT_2600DAPTOR:
|
||||
case LEFT_STELLADAPTOR:
|
||||
case LEFT_2600DAPTOR:
|
||||
if(myOSystem.hasConsole()
|
||||
&& myOSystem.console().leftController().type() == Controller::Type::Driving)
|
||||
{
|
||||
|
@ -923,8 +925,8 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value)
|
|||
handleRegularAxisEvent(j, stick, axis, value);
|
||||
break; // axis on left controller (0)
|
||||
|
||||
case PhysicalJoystick::Type::RIGHT_STELLADAPTOR:
|
||||
case PhysicalJoystick::Type::RIGHT_2600DAPTOR:
|
||||
case RIGHT_STELLADAPTOR:
|
||||
case RIGHT_2600DAPTOR:
|
||||
if(myOSystem.hasConsole()
|
||||
&& myOSystem.console().rightController().type() == Controller::Type::Driving)
|
||||
{
|
||||
|
|
|
@ -280,19 +280,20 @@ EventMode PhysicalKeyboardHandler::getMode(const Controller::Type type)
|
|||
{
|
||||
switch(type)
|
||||
{
|
||||
case Controller::Type::Keyboard:
|
||||
case Controller::Type::KidVid:
|
||||
using enum Controller::Type;
|
||||
case Keyboard:
|
||||
case KidVid:
|
||||
return EventMode::kKeyboardMode;
|
||||
|
||||
case Controller::Type::Paddles:
|
||||
case Controller::Type::PaddlesIAxDr:
|
||||
case Controller::Type::PaddlesIAxis:
|
||||
case Paddles:
|
||||
case PaddlesIAxDr:
|
||||
case PaddlesIAxis:
|
||||
return EventMode::kPaddlesMode;
|
||||
|
||||
case Controller::Type::CompuMate:
|
||||
case CompuMate:
|
||||
return EventMode::kCompuMateMode;
|
||||
|
||||
case Controller::Type::Driving:
|
||||
case Driving:
|
||||
return EventMode::kDrivingMode;
|
||||
|
||||
default:
|
||||
|
|
|
@ -268,19 +268,20 @@ string SoundSDL2::about() const
|
|||
<< " Preset: ";
|
||||
switch(myAudioSettings.preset())
|
||||
{
|
||||
case AudioSettings::Preset::custom:
|
||||
using enum AudioSettings::Preset;
|
||||
case custom:
|
||||
buf << "Custom\n";
|
||||
break;
|
||||
case AudioSettings::Preset::lowQualityMediumLag:
|
||||
case lowQualityMediumLag:
|
||||
buf << "Low quality, medium lag\n";
|
||||
break;
|
||||
case AudioSettings::Preset::highQualityMediumLag:
|
||||
case highQualityMediumLag:
|
||||
buf << "High quality, medium lag\n";
|
||||
break;
|
||||
case AudioSettings::Preset::highQualityLowLag:
|
||||
case highQualityLowLag:
|
||||
buf << "High quality, low lag\n";
|
||||
break;
|
||||
case AudioSettings::Preset::ultraQualityMinimalLag:
|
||||
case ultraQualityMinimalLag:
|
||||
buf << "Ultra quality, minimal lag\n";
|
||||
break;
|
||||
default:
|
||||
|
@ -293,13 +294,14 @@ string SoundSDL2::about() const
|
|||
buf << " Resampling: ";
|
||||
switch(myAudioSettings.resamplingQuality())
|
||||
{
|
||||
case AudioSettings::ResamplingQuality::nearestNeightbour:
|
||||
using enum AudioSettings::ResamplingQuality;
|
||||
case nearestNeighbour:
|
||||
buf << "Quality 1, nearest neighbor\n";
|
||||
break;
|
||||
case AudioSettings::ResamplingQuality::lanczos_2:
|
||||
case lanczos_2:
|
||||
buf << "Quality 2, Lanczos (a = 2)\n";
|
||||
break;
|
||||
case AudioSettings::ResamplingQuality::lanczos_3:
|
||||
case lanczos_3:
|
||||
buf << "Quality 3, Lanczos (a = 3)\n";
|
||||
break;
|
||||
default:
|
||||
|
@ -341,17 +343,18 @@ void SoundSDL2::initResampler()
|
|||
|
||||
switch(myAudioSettings.resamplingQuality())
|
||||
{
|
||||
case AudioSettings::ResamplingQuality::nearestNeightbour:
|
||||
using enum AudioSettings::ResamplingQuality;
|
||||
case nearestNeighbour:
|
||||
myResampler = make_unique<SimpleResampler>(formatFrom, formatTo,
|
||||
nextFragmentCallback);
|
||||
break;
|
||||
|
||||
case AudioSettings::ResamplingQuality::lanczos_2:
|
||||
case lanczos_2:
|
||||
myResampler = make_unique<LanczosResampler>(formatFrom, formatTo,
|
||||
nextFragmentCallback, 2);
|
||||
break;
|
||||
|
||||
case AudioSettings::ResamplingQuality::lanczos_3:
|
||||
case lanczos_3:
|
||||
myResampler = make_unique<LanczosResampler>(formatFrom, formatTo,
|
||||
nextFragmentCallback, 3);
|
||||
break;
|
||||
|
|
|
@ -615,7 +615,7 @@ void VideoAudioDialog::addAudioTab()
|
|||
|
||||
// Resampling quality
|
||||
items.clear();
|
||||
VarList::push_back(items, "Low", static_cast<int>(AudioSettings::ResamplingQuality::nearestNeightbour));
|
||||
VarList::push_back(items, "Low", static_cast<int>(AudioSettings::ResamplingQuality::nearestNeighbour));
|
||||
VarList::push_back(items, "High", static_cast<int>(AudioSettings::ResamplingQuality::lanczos_2));
|
||||
VarList::push_back(items, "Ultra", static_cast<int>(AudioSettings::ResamplingQuality::lanczos_3));
|
||||
myResamplingPopup = new PopUpWidget(myTab, _font, xpos, ypos,
|
||||
|
|
|
@ -88,7 +88,7 @@ bool StellaLIBRETRO::create(bool logging)
|
|||
settings.setValue(AudioSettings::SETTING_FRAGMENT_SIZE, 128);
|
||||
settings.setValue(AudioSettings::SETTING_BUFFER_SIZE, 8);
|
||||
settings.setValue(AudioSettings::SETTING_HEADROOM, 0);
|
||||
settings.setValue(AudioSettings::SETTING_RESAMPLING_QUALITY, static_cast<int>(AudioSettings::ResamplingQuality::nearestNeightbour));
|
||||
settings.setValue(AudioSettings::SETTING_RESAMPLING_QUALITY, static_cast<int>(AudioSettings::ResamplingQuality::nearestNeighbour));
|
||||
settings.setValue(AudioSettings::SETTING_VOLUME, 100);
|
||||
settings.setValue(AudioSettings::SETTING_STEREO, audio_mode);
|
||||
|
||||
|
|
Loading…
Reference in New Issue