Made AudioPlayer's play and init method static

This commit is contained in:
andreja6
2018-04-26 21:41:07 -07:00
parent 78cdb01ef1
commit 6d49e266dd
3 changed files with 19 additions and 14 deletions

View File

@@ -5,9 +5,19 @@
#include <malloc.h>
#include <string.h>
#define NUM_SOUNDS 10
SDL_AudioSpec fmt;
static SDL_AudioSpec fmt;
AudioPlayer::AudioPlayer(void)
{
}
AudioPlayer::~AudioPlayer(void)
{
SDL_CloseAudio();
}
void AudioPlayer::init()
{
extern void mixaudio(void *unused, Uint8 *stream, int len);
fmt.freq = 22050;
@@ -25,12 +35,7 @@ AudioPlayer::AudioPlayer(void)
SDL_PauseAudio(0);
}
AudioPlayer::~AudioPlayer(void)
{
SDL_CloseAudio();
}
struct sample {
static struct sample {
Uint8 *data;
Uint32 dpos;
Uint32 dlen;

View File

@@ -6,5 +6,6 @@ class AudioPlayer
public:
AudioPlayer(void);
~AudioPlayer(void);
void PlaySound(std::string);
static void PlaySound(std::string);
static void init();
};

View File

@@ -40,7 +40,6 @@ static int index = 2;
static std::string cameraSound = "";
static float TIMERVAL = 60.0F;
static int SCOREVAL = 0;
static AudioPlayer soundSystem;
static G3D::TextureRef go = NULL;
static G3D::TextureRef go_ovr = NULL;
static G3D::TextureRef go_dn = NULL;
@@ -251,7 +250,7 @@ public:
void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{
soundSystem.PlaySound(cameraSound);
AudioPlayer::PlaySound(cameraSound);
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
if(button->name == "CenterCam")
centerCam = true;
@@ -285,7 +284,7 @@ void DeleteListener::onButton1MouseClick(BaseButtonInstance* button)
instances.erase(instances.begin() + i);
delete deleting;
selectedInstance = NULL;
soundSystem.PlaySound(GetFileInPath("/content/sounds/pageturn.wav"));
AudioPlayer::PlaySound(GetFileInPath("/content/sounds/pageturn.wav"));
}
@@ -880,13 +879,13 @@ void Demo::onUserInput(UserInput* ui) {
if(ui->keyPressed(SDL_MOUSE_WHEEL_UP_KEY))
{
soundSystem.PlaySound(cameraSound);
AudioPlayer::PlaySound(cameraSound);
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
cameraPos = cameraPos + frame.lookVector()*2;
}
if(ui->keyPressed(SDL_MOUSE_WHEEL_DOWN_KEY))
{
soundSystem.PlaySound(cameraSound);
AudioPlayer::PlaySound(cameraSound);
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
cameraPos = cameraPos - frame.lookVector()*2;
}
@@ -1469,7 +1468,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
int main(int argc, char** argv) {
//_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
//_CrtSetBreakAlloc(1279);
AudioPlayer::init();
GAppSettings settings;
settings.window.resizable = true;
//settings.window.fsaaSamples = 8;