Skip to content

Commit

Permalink
code rev
Browse files Browse the repository at this point in the history
  • Loading branch information
Raffaello committed Nov 15, 2023
1 parent 046f2f4 commit 2563cab
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
14 changes: 12 additions & 2 deletions sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,21 @@ namespace HyperSonicDrivers::audio

virtual void renderBuffer(IAudioStream* stream) = 0;
inline void renderBuffer(const std::shared_ptr<devices::IDevice>& device) { renderBuffer(device->getHardware()->getAudioStream().get()); };

/**
* It flushes the AudioStream until it detects the silence.
* It returns false if it reached max iterations but it didn't flush it completely.
* It returns true when silence is detected or nothing more to read from the stream
**/
virtual bool renderFlush(IAudioStream* stream) = 0;
inline bool renderFlush(const std::shared_ptr<devices::IDevice>& device) { return renderFlush(device->getHardware()->getAudioStream().get()); };

virtual bool renderBuffer(IAudioStream* stream, drivers::IAudioDriver& drv, const int track) = 0;
inline bool renderBuffer(const std::shared_ptr<devices::IDevice>& device, drivers::IAudioDriver& drv, const int track) { return renderBuffer(device->getHardware()->getAudioStream().get(), drv, track); };
/**
* this is doing the render until the drv is play the track and call the render flush after all
* it returns the renderFlush returned value
**/
virtual bool renderBufferFlush(IAudioStream* stream, drivers::IAudioDriver& drv, const int track) = 0;
inline bool renderBufferFlush(const std::shared_ptr<devices::IDevice>& device, drivers::IAudioDriver& drv, const int track) { return renderBufferFlush(device->getHardware()->getAudioStream().get(), drv, track); };
protected:
std::shared_ptr<IMixer> m_mixer;
std::unique_ptr<files::WAVFile> m_out;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace HyperSonicDrivers::audio::sdl2
return false;
}

bool Renderer::renderBuffer(IAudioStream* stream, drivers::IAudioDriver& drv, const int track)
bool Renderer::renderBufferFlush(IAudioStream* stream, drivers::IAudioDriver& drv, const int track)
{
drv.play(track);
while (drv.isPlaying())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ namespace HyperSonicDrivers::audio::sdl2

void openOutputFile(const std::filesystem::path& path) override;
void closeOutputFile() noexcept override;

void renderBuffer(IAudioStream* stream) override;

using IRenderer::renderBuffer;
bool renderFlush(IAudioStream* stream) override;
using IRenderer::renderFlush;
using IRenderer::renderBufferFlush;

bool renderBuffer(IAudioStream* stream, drivers::IAudioDriver& drv, const int track) override;
void renderBuffer(IAudioStream* stream) override;
bool renderFlush(IAudioStream* stream) override;
bool renderBufferFlush(IAudioStream* stream, drivers::IAudioDriver& drv, const int track) override;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace HyperSonicDrivers::audio::sdl2
auto af = std::make_shared<files::westwood::ADLFile>("../fixtures/DUNE0.ADL");
drv1.setADLFile(af);

ASSERT_TRUE(r.renderBuffer(opl, drv1, 4));
ASSERT_TRUE(r.renderBufferFlush(opl, drv1, 4));
r.closeOutputFile();
}

Expand Down

0 comments on commit 2563cab

Please sign in to comment.