Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use clang-format for code fmt. #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions modules/audio-gorilla/include/moon/gorilla/audio.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
#include <gorilla/gau.h>

namespace Moon {
class Audio {
public:
static bool Initialize();
static void Update();
static void Terminate();
static ga_Mixer* GetMixer();
static ga_StreamManager* GetStreamMgr();
protected:
static gau_Manager* m_mgr;
static ga_Mixer* m_mixer;
static ga_StreamManager* m_streamMgr;
};
class Audio
{
public:
static bool Initialize();
static void Update();
static void Terminate();
static ga_Mixer* GetMixer();
static ga_StreamManager* GetStreamMgr();

protected:
static gau_Manager* m_mgr;
static ga_Mixer* m_mixer;
static ga_StreamManager* m_streamMgr;
};
};

#endif
4 changes: 2 additions & 2 deletions modules/audio-gorilla/include/moon/gorilla/mrb/music.hxx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef MMRB_MUSIC_H
#define MMRB_MUSIC_H

#include "moon/api.h"
#include <mruby.h>
#include <mruby/class.h>
#include <mruby/data.h>
#include "moon/api.h"

MOON_C_API const struct mrb_data_type music_data_type;
MOON_C_API void mmrb_music_init(mrb_state *mrb);
MOON_C_API void mmrb_music_init(mrb_state* mrb);

#endif
4 changes: 2 additions & 2 deletions modules/audio-gorilla/include/moon/gorilla/mrb/sound.hxx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef MMRB_SOUND_H
#define MMRB_SOUND_H

#include "moon/api.h"
#include <mruby.h>
#include <mruby/class.h>
#include <mruby/data.h>
#include "moon/api.h"

MOON_C_API const struct mrb_data_type sound_data_type;
MOON_C_API void mmrb_sound_init(mrb_state *mrb);
MOON_C_API void mmrb_sound_init(mrb_state* mrb);

#endif
13 changes: 8 additions & 5 deletions modules/audio-gorilla/include/moon/gorilla/music.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
#include "moon/gorilla/audio.hxx"

namespace Moon {
struct Music {
Music() : handle(NULL), loopSrc(NULL) { };
ga_Handle* handle;
gau_SampleSourceLoop* loopSrc;
};
struct Music
{
Music()
: handle(NULL)
, loopSrc(NULL){};
ga_Handle* handle;
gau_SampleSourceLoop* loopSrc;
};
};

#endif
78 changes: 44 additions & 34 deletions modules/audio-gorilla/src/audio.cxx
Original file line number Diff line number Diff line change
@@ -1,44 +1,54 @@
#include "moon/gorilla/audio.hxx"

namespace Moon {
gau_Manager* Audio::m_mgr = NULL;
ga_Mixer* Audio::m_mixer = NULL;
ga_StreamManager* Audio::m_streamMgr = NULL;
gau_Manager* Audio::m_mgr = NULL;
ga_Mixer* Audio::m_mixer = NULL;
ga_StreamManager* Audio::m_streamMgr = NULL;

bool Audio::Initialize() {
// setup Gorilla Audio
if (!m_mgr) {
if (gc_initialize(0) == GC_SUCCESS) {
m_mgr = gau_manager_create();
m_mixer = gau_manager_mixer(m_mgr);
m_streamMgr = gau_manager_streamManager(m_mgr);
} else {
return false;
}
bool
Audio::Initialize()
{
// setup Gorilla Audio
if (!m_mgr) {
if (gc_initialize(0) == GC_SUCCESS) {
m_mgr = gau_manager_create();
m_mixer = gau_manager_mixer(m_mgr);
m_streamMgr = gau_manager_streamManager(m_mgr);
} else {
return false;
}
return true;
};
}
return true;
};

void Audio::Update() {
if (m_mgr) gau_manager_update(m_mgr);
};
void
Audio::Update()
{
if (m_mgr)
gau_manager_update(m_mgr);
};

void Audio::Terminate() {
if (m_mgr) {
gau_manager_destroy(m_mgr);
gc_shutdown();
m_mgr = NULL;
m_mixer = NULL;
m_streamMgr = NULL;
}
};
void
Audio::Terminate()
{
if (m_mgr) {
gau_manager_destroy(m_mgr);
gc_shutdown();
m_mgr = NULL;
m_mixer = NULL;
m_streamMgr = NULL;
}
};

ga_Mixer* Audio::GetMixer() {
return m_mixer;
};
ga_Mixer*
Audio::GetMixer()
{
return m_mixer;
};

ga_StreamManager* Audio::GetStreamMgr() {
return m_streamMgr;
};
ga_StreamManager*
Audio::GetStreamMgr()
{
return m_streamMgr;
};
}

14 changes: 8 additions & 6 deletions modules/audio-gorilla/src/mrb_moon_audio.cxx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include <mruby.h>
#include <mruby/class.h>
#include "moon/gorilla/audio.hxx"
#include "moon/gorilla/mrb/music.hxx"
#include "moon/gorilla/mrb/sound.hxx"
#include <mruby.h>
#include <mruby/class.h>

/* Call once per step/frame to update the internal Audio module.
*/
static mrb_value
audio_update(mrb_state *mrb, mrb_value klass)
audio_update(mrb_state* mrb, mrb_value klass)
{
Moon::Audio::Update();
return klass;
Expand All @@ -16,9 +16,11 @@ audio_update(mrb_state *mrb, mrb_value klass)
MOON_C_API void
mrb_mruby_moon_audio_gorilla_gem_init(mrb_state* mrb)
{
struct RClass *moon_module = mrb_define_module(mrb, "Moon");
struct RClass *audio_module = mrb_define_module_under(mrb, moon_module, "Audio");
mrb_define_class_method(mrb, audio_module, "update", audio_update, MRB_ARGS_NONE());
struct RClass* moon_module = mrb_define_module(mrb, "Moon");
struct RClass* audio_module =
mrb_define_module_under(mrb, moon_module, "Audio");
mrb_define_class_method(mrb, audio_module, "update", audio_update,
MRB_ARGS_NONE());
mmrb_music_init(mrb);
mmrb_sound_init(mrb);
Moon::Audio::Initialize();
Expand Down
Loading