Skip to content

Commit

Permalink
revert accidental refactor to isPlaying
Browse files Browse the repository at this point in the history
  • Loading branch information
Raffaello committed Nov 12, 2023
1 parent 4767248 commit 7d17db8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions sdl2-hyper-sonic-drivers/examples/pcm-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main(int argc, char* argv[])
}

drv.play(wavSound);
while(drv.isActive(wavSound))
while(drv.isPlaying(wavSound))
{
cout << "is playing" << endl;
delayMillis(1000);
Expand All @@ -49,7 +49,7 @@ int main(int argc, char* argv[])
delayMillis(500);

drv.play(vocSound);
while (drv.isActive(vocSound))
while (drv.isPlaying(vocSound))
{
cout << "is playing" << endl;
delayMillis(1000);
Expand All @@ -67,7 +67,7 @@ int main(int argc, char* argv[])
drv.play(vocSound, 255, -127 * sig);
}

while(drv.isActive())
while(drv.isPlaying())
{
cout << "is playing" << endl;
delayMillis(1000);
Expand Down
2 changes: 1 addition & 1 deletion sdl2-hyper-sonic-drivers/sdl2-hyper-sonic-drivers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void pcm_sound_append()
drivers::PCMDriver drv(mixer);

drv.play(s2);
while (drv.isActive())
while (drv.isPlaying())
{
utils::delayMillis(100);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace HyperSonicDrivers::drivers
{
}

bool PCMDriver::isActive() const noexcept
bool PCMDriver::isPlaying() const noexcept
{
for (const auto& [stream, _] : m_PCMStreams_channels)
{
Expand All @@ -21,7 +21,7 @@ namespace HyperSonicDrivers::drivers
return false;
}

bool PCMDriver::isActive(const std::shared_ptr<audio::PCMSound>& sound) const noexcept
bool PCMDriver::isPlaying(const std::shared_ptr<audio::PCMSound>& sound) const noexcept
{
for (const auto& [stream, _] : m_PCMStreams_channels)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace HyperSonicDrivers::drivers
explicit PCMDriver(const std::shared_ptr<audio::IMixer>& mixer, const uint8_t max_channels = 0xFF);
~PCMDriver() = default;

bool isActive() const noexcept;
bool isActive(const std::shared_ptr<audio::PCMSound>& sound) const noexcept;
bool isPlaying() const noexcept;
bool isPlaying(const std::shared_ptr<audio::PCMSound>& sound) const noexcept;
std::optional<uint8_t> play(
const std::shared_ptr<audio::PCMSound>& sound,
const uint8_t volume = audio::mixer::Channel_max_volume,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ namespace HyperSonicDrivers::drivers
auto sound = std::make_shared<audio::PCMSound>(audio::mixer::eChannelGroup::Plain, true, 44100, 1, sound_data);
auto ch_id = drv.play(sound);

ASSERT_TRUE(drv.isActive(sound));
ASSERT_TRUE(drv.isActive());
ASSERT_TRUE(drv.isPlaying(sound));
ASSERT_TRUE(drv.isPlaying());
ASSERT_TRUE(ch_id.has_value());
EXPECT_EQ(ch_id.value(), 0);

drv.stop(ch_id.value());
EXPECT_FALSE(drv.isActive(sound));
EXPECT_FALSE(drv.isActive());
EXPECT_FALSE(drv.isPlaying(sound));
EXPECT_FALSE(drv.isPlaying());
}

TEST(PCMDriver, play_stop1)
Expand All @@ -41,14 +41,14 @@ namespace HyperSonicDrivers::drivers
auto sound = std::make_shared<audio::PCMSound>(audio::mixer::eChannelGroup::Plain, true, 44100, 1, sound_data);
auto ch_id = drv.play(sound);

ASSERT_TRUE(drv.isActive(sound));
ASSERT_TRUE(drv.isActive());
ASSERT_TRUE(drv.isPlaying(sound));
ASSERT_TRUE(drv.isPlaying());
ASSERT_TRUE(ch_id.has_value());
EXPECT_EQ(ch_id.value(), 0);

drv.stop(sound);
EXPECT_FALSE(drv.isActive(sound));
EXPECT_FALSE(drv.isActive());
EXPECT_FALSE(drv.isPlaying(sound));
EXPECT_FALSE(drv.isPlaying());
}

TEST(PCMDriver, play_stop2)
Expand All @@ -62,14 +62,14 @@ namespace HyperSonicDrivers::drivers
auto sound = std::make_shared<audio::PCMSound>(audio::mixer::eChannelGroup::Plain, true, 44100, 1, sound_data);
auto ch_id = drv.play(sound);

ASSERT_TRUE(drv.isActive(sound));
ASSERT_TRUE(drv.isActive());
ASSERT_TRUE(drv.isPlaying(sound));
ASSERT_TRUE(drv.isPlaying());
ASSERT_TRUE(ch_id.has_value());
EXPECT_EQ(ch_id.value(), 0);

drv.stop();
EXPECT_FALSE(drv.isActive(sound));
EXPECT_FALSE(drv.isActive());
EXPECT_FALSE(drv.isPlaying(sound));
EXPECT_FALSE(drv.isPlaying());
}

TEST(PCMDriver, play_stop_complex)
Expand All @@ -89,14 +89,14 @@ namespace HyperSonicDrivers::drivers
EXPECT_TRUE(drv.play(sound2).has_value());
EXPECT_TRUE(drv.play(sound2).has_value());

ASSERT_TRUE(drv.isActive(sound));
ASSERT_TRUE(drv.isActive());
ASSERT_TRUE(drv.isPlaying(sound));
ASSERT_TRUE(drv.isPlaying());
ASSERT_TRUE(ch_id.has_value());
EXPECT_EQ(ch_id.value(), 0);

drv.stop(ch_id.value());
EXPECT_FALSE(drv.isActive(sound));
EXPECT_TRUE(drv.isActive());
EXPECT_FALSE(drv.isPlaying(sound));
EXPECT_TRUE(drv.isPlaying());
}
}

Expand Down

0 comments on commit 7d17db8

Please sign in to comment.