Skip to content

Commit 18b0a17

Browse files
authored
small code reviews (#283)
* init * rabbit code rev * update version * code rev
1 parent 822e477 commit 18b0a17

File tree

10 files changed

+69
-13
lines changed

10 files changed

+69
-13
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
55
endif()
66

77

8-
project ("sdl2-hyper-sonic-drivers" VERSION 0.17.0 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards")
8+
project ("sdl2-hyper-sonic-drivers" VERSION 0.17.1 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards")
99
include (TestBigEndian)
1010
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
1111
if(IS_BIG_ENDIAN)

sdl2-hyper-sonic-drivers/sdl2-hyper-sonic-drivers.cpp

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,58 @@ void pcm_sound_append()
410410
}
411411
}
412412

413+
//void adldune2filestest()
414+
//{
415+
// auto mixer = audio::make_mixer<audio::sdl2::Mixer>(8, 44100, 1024);
416+
// mixer->init();
417+
//
418+
// auto device = devices::make_device<devices::Adlib, devices::Opl>(mixer);
419+
// drivers::westwood::ADLDriver drv(device, audio::mixer::eChannelGroup::Music);
420+
//
421+
// SDL_InitSubSystem(SDL_INIT_EVENTS);
422+
// SDL_InitSubSystem(SDL_INIT_VIDEO);
423+
//
424+
// auto window = SDL_CreateWindow("a", 0, 0, 320, 200, 0);
425+
//
426+
// for (int f = 0; f <= 0; f++)
427+
// {
428+
// const std::string fn = "adl/DUNE" + std::to_string(f) + ".ADL";
429+
// utils::ILogger::instance->info(std::format("opening file: {}", fn), utils::ILogger::eCategory::Application);
430+
// auto adlf = std::make_shared<files::westwood::ADLFile>(fn);
431+
// drv.setADLFile(adlf);
432+
// for (int i = 0; i < adlf->getNumTracks(); i++)
433+
// {
434+
// utils::ILogger::instance->info(std::format("playing track: {}", i), utils::ILogger::eCategory::Application);
435+
// drv.play(i);
436+
// while (drv.isPlaying())
437+
// {
438+
// utils::delayMillis(200);
439+
// SDL_Event e;
440+
// while (SDL_PollEvent(&e))
441+
// switch (e.type)
442+
// {
443+
// case SDL_QUIT:
444+
// goto QUIT;
445+
// case SDL_KEYDOWN:
446+
// //case SDL_KEYUP:
447+
// if (e.key.keysym.sym == SDLK_ESCAPE)
448+
// goto QUIT;
449+
// if (e.key.keysym.sym == SDLK_RETURN)
450+
// drv.stop();
451+
// break;
452+
//
453+
// default:
454+
// std::cout << "event: " << e.type << std::endl;
455+
// }
456+
// }
457+
// drv.stopAllChannels();
458+
// utils::delayMillis(1000);
459+
// }
460+
// }
461+
//QUIT:
462+
// SDL_DestroyWindow(window);
463+
//}
464+
413465
int main(int argc, char* argv[])
414466
{
415467
//newMixerTest();
@@ -419,8 +471,9 @@ int main(int argc, char* argv[])
419471
//midi_adlib();
420472
//testMT32();
421473

422-
pcm_sound_append();
423-
return 0;
474+
//pcm_sound_append();
475+
//adldune2filestest();
476+
//return 0;
424477
//sdlMixer();
425478
//SDL_Delay(100);
426479
//renderMixer();

sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IMixer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace HyperSonicDrivers::audio
5757
virtual bool isPaused(const uint8_t id) const noexcept = 0;
5858

5959
virtual bool isActive() const noexcept = 0;
60-
virtual bool isActive(const mixer::eChannelGroup group) = 0;
60+
virtual bool isActive(const mixer::eChannelGroup group) const noexcept = 0;
6161

6262
virtual bool isChannelGroupMuted(const mixer::eChannelGroup group) const noexcept = 0;
6363
virtual void muteChannelGroup(const mixer::eChannelGroup group) noexcept = 0;

sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ namespace HyperSonicDrivers::audio::sdl2
150150
{ return !ch->isEnded(); });
151151
}
152152

153-
bool Mixer::isActive(const mixer::eChannelGroup group)
153+
bool Mixer::isActive(const mixer::eChannelGroup group) const noexcept
154154
{
155155
std::scoped_lock lck(m_mutex);
156156

sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ namespace HyperSonicDrivers::audio::sdl2
4444
bool isPaused(const uint8_t id) const noexcept override;
4545

4646
bool isActive() const noexcept override;
47-
bool isActive(const mixer::eChannelGroup group) override;
47+
bool isActive(const mixer::eChannelGroup group) const noexcept override;
4848

49-
bool isChannelGroupMuted(const mixer::eChannelGroup group) const noexcept override;;
49+
bool isChannelGroupMuted(const mixer::eChannelGroup group) const noexcept override;
5050
void muteChannelGroup(const mixer::eChannelGroup group) noexcept override;
5151
void unmuteChannelGroup(const mixer::eChannelGroup group) noexcept override;
5252

sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/devices/MT32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace HyperSonicDrivers::devices
3434

3535
eDeviceName MT32::getName() const noexcept
3636
{
37-
return eDeviceName::MT32;
37+
return eDeviceName::Mt32;
3838
}
3939

4040
void MT32::lcd_message(const std::string& msg) noexcept

sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/devices/types.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ namespace HyperSonicDrivers::devices
1313
Adlib,
1414
SbPro,
1515
SbPro2,
16-
MT32
16+
Mt32
1717
};
1818
}

sdl2-hyper-sonic-drivers/src/std/IDeviceTypesFormatter.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ namespace std
2727
case SbPro2:
2828
str = "SbPro2";
2929
break;
30-
case MT32:
31-
str = "MT32";
30+
case Mt32:
31+
str = "Mt32";
3232
break;
3333
}
3434

sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/IMixerMock.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace HyperSonicDrivers::audio
4444
bool isActive(const uint8_t id) const noexcept override { return true; };
4545
bool isPaused(const uint8_t id) const noexcept override { return false; }
4646
bool isActive() const noexcept override { return true; };
47-
bool isActive(const mixer::eChannelGroup group) override { return true; };
47+
bool isActive(const mixer::eChannelGroup group) const noexcept override { return true; };
4848
bool isChannelGroupMuted(const mixer::eChannelGroup group) const noexcept override { return false; };
4949
void muteChannelGroup(const mixer::eChannelGroup group) noexcept override {};
5050
void unmuteChannelGroup(const mixer::eChannelGroup group) noexcept override {};

sdl2-hyper-sonic-drivers/test/std/IDeviceTypesFormatterTest.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ namespace std
66
{
77
TEST(IDeviceTypesFormatter, Music)
88
{
9-
ASSERT_STRCASEEQ(std::format("{}", HyperSonicDrivers::devices::eDeviceName::Adlib).c_str(), "Adlib");
9+
EXPECT_STRCASEEQ(std::format("{}", HyperSonicDrivers::devices::eDeviceName::Adlib).c_str(), "Adlib");
10+
EXPECT_STRCASEEQ(std::format("{}", HyperSonicDrivers::devices::eDeviceName::Mt32).c_str(), "Mt32");
11+
EXPECT_STRCASEEQ(std::format("{}", HyperSonicDrivers::devices::eDeviceName::SbPro).c_str(), "SbPro");
12+
EXPECT_STRCASEEQ(std::format("{}", HyperSonicDrivers::devices::eDeviceName::SbPro2).c_str(), "SbPro2");
1013
}
1114
}
1215

0 commit comments

Comments
 (0)