mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 14:53:52 +00:00
Sound system refactor
This commit is contained in:
@@ -1,56 +1,30 @@
|
||||
#pragma once
|
||||
#ifndef __PL_SOUND_H__
|
||||
#define __PL_SOUND_H__
|
||||
|
||||
#include "PLCore.h"
|
||||
|
||||
enum SndCommandType
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
nullCmd,
|
||||
bufferCmd, // Param1: 0 Param2: Offset to sound header
|
||||
callBackCmd,
|
||||
flushCmd,
|
||||
quietCmd
|
||||
};
|
||||
struct AudioChannel;
|
||||
|
||||
struct SndChannel
|
||||
{
|
||||
};
|
||||
typedef void (*AudioChannelCallback_t)(PortabilityLayer::AudioChannel *channel);
|
||||
|
||||
struct SndCommand
|
||||
{
|
||||
SndCommandType cmd;
|
||||
intptr_t param1;
|
||||
intptr_t param2;
|
||||
};
|
||||
struct AudioChannel
|
||||
{
|
||||
virtual void Destroy(bool wait) = 0;
|
||||
virtual bool AddBuffer(const void *smBuffer, bool blocking) = 0;
|
||||
virtual bool AddCallback(AudioChannelCallback_t callback, bool blocking) = 0;
|
||||
virtual void ClearAllCommands() = 0;
|
||||
virtual void Stop() = 0;
|
||||
};
|
||||
|
||||
enum SndSynthType
|
||||
{
|
||||
sampledSynth
|
||||
};
|
||||
class SoundSystem
|
||||
{
|
||||
public:
|
||||
virtual AudioChannel *CreateChannel() = 0;
|
||||
|
||||
enum SndInitFlags
|
||||
{
|
||||
initNoInterp = 1,
|
||||
initMono = 2,
|
||||
};
|
||||
virtual void SetVolume(uint8_t vol) = 0;
|
||||
virtual uint8_t GetVolume() const = 0;
|
||||
|
||||
typedef SndChannel *SndChannelPtr;
|
||||
|
||||
typedef void(*SndCallBackProc)(SndChannelPtr channel, SndCommand *command);
|
||||
typedef SndCallBackProc SndCallBackUPP;
|
||||
|
||||
// Vol seems to be a packed stereo DWord
|
||||
|
||||
PLError_t GetDefaultOutputVolume(long *vol);
|
||||
PLError_t SetDefaultOutputVolume(long vol);
|
||||
|
||||
|
||||
SndCallBackUPP NewSndCallBackProc(SndCallBackProc callback);
|
||||
void DisposeSndCallBackUPP(SndCallBackUPP upp);
|
||||
PLError_t SndNewChannel(SndChannelPtr *outChannel, SndSynthType synthType, int initFlags, SndCallBackUPP callback);
|
||||
PLError_t SndDisposeChannel(SndChannelPtr channel, Boolean flush);
|
||||
PLError_t SndDoCommand(SndChannelPtr channel, const SndCommand *command, Boolean failIfFull);
|
||||
PLError_t SndDoImmediate(SndChannelPtr channel, const SndCommand *command);
|
||||
|
||||
#endif
|
||||
static SoundSystem *GetInstance();
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user