// Copyright (C) 2020 Daniel Mall
#ifndef CAUDIOSOKOL_H
#define CAUDIOSOKOL_H
#include "CAudioMixer.h"

//! queue structure for all loaded sounds
class CAudio_Sokol : public CAudio
{
public:
	virtual ~CAudio_Sokol();
	void SetToBegin();
	void AdvanceFrames(int nAdvanceFrames);

public:
	uint32_t m_nLength = 0;
	uint32_t m_nLengthTrue = 0;
	int16_t* m_pBufferTrue = nullptr;
	int16_t* m_pBuffer = nullptr;
	bool m_bLoop = false;
	bool m_bSoundCount = true;
	bool m_bFree = false;
	uint8_t m_nVolume;
	CAudio_Sokol* m_pNext = nullptr;
};

//! audio mixer
class CAudioMixer_Sokol : public CAudioMixer
{
public:
	//! play music on loop
	virtual void PlayMusic(CAudio* pAudio, int nVolume) override;

	//! play sound one time
	virtual void PlaySound(CAudio* pAudio, int nVolume) override;

	//! turn on audio mixer
	virtual void TurnOnAudioMixer() override;

	//! turn off audio mixer
	virtual void TurnOffAudioMixer() override;

	//! turn on audio mixer music
	virtual void TurnOnMusic() override;

	//! turn off audio mixer music
	virtual void TurnOffMusic() override;

	//! turn on audio mixer sounds
	virtual void TurnOnSounds() override;

	//! turn off audio mixer sounds
	virtual void TurnOffSounds() override;

	//! remove the music and sounds from the audio queue
	virtual void ClearAudioQueue() override;

	//! start audio so call once at the start of program
	virtual void AudioDeviceOpen() override;

	//! end audio so call once at the end of program
	virtual void AudioDeviceClose() override;

	//! load audio from a file
	virtual CAudio* CreateAudioFromFile(std::string szFilename, bool bLoop, int nVolume) override;

	//! load audio from memory
	virtual CAudio* CreateAudioFromMemory(std::string szId, const unsigned char* pBuffer, int nBufferSize, bool bLoop, int nVolume) override;

	//! push audio to the output audio buffer
	virtual void PushAudioToDeviceQueue() override;
};

#endif
