Skip to content

Commit

Permalink
IMusicDriver -> IAudioDriver (#269)
Browse files Browse the repository at this point in the history
* IMusicDriver -> IAudioDriver

* code rev
  • Loading branch information
Raffaello authored Nov 3, 2023
1 parent ed44d2d commit c6db69d
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace HyperSonicDrivers::devices
{
}

bool IDevice::acquire(drivers::IMusicDriver* owner)
bool IDevice::acquire(drivers::IAudioDriver* owner)
{
if (!m_acquired)
{
Expand All @@ -22,7 +22,7 @@ namespace HyperSonicDrivers::devices
return isOwned(owner);
}

bool IDevice::release(const drivers::IMusicDriver* owner)
bool IDevice::release(const drivers::IAudioDriver* owner)
{
if (isOwned(owner))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace HyperSonicDrivers
{
namespace drivers
{
class IMusicDriver;
class IAudioDriver;
}

namespace devices
Expand All @@ -34,10 +34,10 @@ namespace HyperSonicDrivers
std::optional<uint8_t> getChannelId() const noexcept { return m_hardware->getChannelId(); };

inline bool isAcquired() const noexcept { return m_acquired; }
inline bool isOwned(const drivers::IMusicDriver* owner) const noexcept { return m_owner == owner; }
inline bool isOwned(const drivers::IAudioDriver* owner) const noexcept { return m_owner == owner; }

bool acquire(drivers::IMusicDriver* owner);
bool release(const drivers::IMusicDriver* owner);
bool acquire(drivers::IAudioDriver* owner);
bool release(const drivers::IAudioDriver* owner);

// helpers methods
void setVolume(const uint8_t volume);
Expand All @@ -55,7 +55,7 @@ namespace HyperSonicDrivers
private:
// TODO: remove the atomic when removing the thread in MIDDrv
std::atomic<bool> m_acquired = false;
std::atomic<drivers::IMusicDriver*> m_owner = nullptr;
std::atomic<drivers::IAudioDriver*> m_owner = nullptr;
};

template<class T, class To = devices::IDevice, typename... Args>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace HyperSonicDrivers::drivers
{
IMusicDriver::IMusicDriver(const std::shared_ptr<devices::IDevice>& device) :
IAudioDriver::IAudioDriver(const std::shared_ptr<devices::IDevice>& device) :
m_device(device)
{
if (m_device == nullptr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
namespace HyperSonicDrivers::drivers
{
/**
* Common Interface for music drivers: MIDI, ADL, XMI, MUS...
* TODO/Rename: if not merged with IMidiDriver, this can be renamed as IMusicPlayer
* Common Interface for music/sfx (audio) drivers: MIDI, ADL, XMI, MUS...
* TODO/Rename: if not merged with IMidiDriver, this can be renamed as IAudioPlayer
* related to playing those files rather then using a driver,
* ADLDriver at the moment is both
*
**/
class IMusicDriver
class IAudioDriver
{
public:
IMusicDriver(IMusicDriver&) = delete;
IMusicDriver(IMusicDriver&&) = delete;
IMusicDriver& operator=(IMusicDriver&) = delete;
IAudioDriver(IAudioDriver&) = delete;
IAudioDriver(IAudioDriver&&) = delete;
IAudioDriver& operator=(IAudioDriver&) = delete;

explicit IMusicDriver(const std::shared_ptr<devices::IDevice>& device);
virtual ~IMusicDriver() = default;
explicit IAudioDriver(const std::shared_ptr<devices::IDevice>& device);
virtual ~IAudioDriver() = default;

virtual void play(const uint8_t track) noexcept = 0;
virtual void stop() noexcept = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace HyperSonicDrivers::drivers
const audio::mixer::eChannelGroup group,
const uint8_t volume,
const uint8_t pan
) : IMusicDriver(device),
) : IAudioDriver(device),
m_group(group), m_volume(volume), m_pan(pan)
{
// TODO: move the acquire logic where the callback is set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace HyperSonicDrivers::drivers
* This class is a wrapper around different midi drivers and has a embeeded timer processing track
* to send events to the device
**/
class MIDDriver : public IMusicDriver
class MIDDriver : public IAudioDriver
{
public:
[[deprecated("it will be replaced by another class without thread")]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace HyperSonicDrivers::drivers::westwood
const audio::mixer::eChannelGroup group,
const uint8_t volume,
const uint8_t pan) :
IMusicDriver(opl),
IAudioDriver(opl),
m_opl(opl->getOpl())
{
memset(m_channels.data(), 0, sizeof(m_channels));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace HyperSonicDrivers::drivers::westwood
/// the same file format(but need different offset adjustments);
/// Kyrandia 2 and LoL format(version 4) is different again.
/// </summary>
class ADLDriver : public IMusicDriver
class ADLDriver : public IAudioDriver
{
public:
explicit ADLDriver(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace HyperSonicDrivers::drivers
{
class IMusicDriverMock : public IMusicDriver
class IMusicDriverMock : public IAudioDriver
{
public:
IMusicDriverMock(const std::shared_ptr<devices::IDevice>& device) : IMusicDriver(device) {}
IMusicDriverMock(const std::shared_ptr<devices::IDevice>& device) : IAudioDriver(device) {}
void play(const uint8_t track) noexcept override {};
void stop() noexcept override {};
bool isPlaying() const noexcept override { return false; };
};

TEST(IMusicDriver, cstor_nullptr)
TEST(IAudioDriver, cstor_nullptr)
{
EXPECT_THROW(IMusicDriverMock md(nullptr), std::runtime_error);
}
Expand Down

0 comments on commit c6db69d

Please sign in to comment.