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 7d17db8 commit 5c1b38e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions sdl2-hyper-sonic-drivers/sdl2-hyper-sonic-drivers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ void playNotes(hardware::PCSpeaker *pcSpeaker, const hardware::PCSpeaker::eWaveF
{
auto start = std::chrono::steady_clock::now();
pcSpeaker->play(waveForm, freq, length);
while (pcSpeaker->isActive()) { SDL_Delay(10); }
while (pcSpeaker->isPlaying()) { SDL_Delay(10); }
pcSpeaker->play(waveForm, freq + 183, length * 2);
while (pcSpeaker->isActive()) { SDL_Delay(10); }
while (pcSpeaker->isPlaying()) { SDL_Delay(10); }
auto end = std::chrono::steady_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Elapsed Time (s) = " << elapsed_seconds.count() << " --- Expected (s) ~=" << length + length * 2 << "\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace HyperSonicDrivers::hardware
_setRemainingSamples(delay);
}

bool PCSpeaker::isActive() const noexcept
bool PCSpeaker::isPlaying() const noexcept
{
return _remainingSamples != 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace HyperSonicDrivers::hardware
void play(const eWaveForm waveForm, const int freq, const int32_t length);
/** Stop the currently playing note after delay ms. */
void stop(const int32_t delay = 0);
bool isActive() const noexcept;
bool isPlaying() const noexcept;
template<typename T> uint32_t readBuffer(T* buffer, uint32_t numSamples);
uint32_t getRate() const noexcept;
uint8_t getChannels() const noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace HyperSonicDrivers::hardware
{
PCSpeaker pcSpeaker(44100, 8);
pcSpeaker.play(PCSpeaker::eWaveForm::SINE, 440, 1);
EXPECT_TRUE(pcSpeaker.isActive());
EXPECT_TRUE(pcSpeaker.isPlaying());
}

TEST(PCSpeaker, readBuffer)
Expand Down Expand Up @@ -74,7 +74,7 @@ namespace HyperSonicDrivers::hardware
double tsum = 0.0;
uint32_t dsum = 0;

while (pcSpeaker->isActive())
while (pcSpeaker->isPlaying())
{
uint32_t d = this->readbuf();
dsum += d;
Expand Down

0 comments on commit 5c1b38e

Please sign in to comment.