many stuffs
This commit is contained in:
parent
ce81cbd9d8
commit
a88fce53e2
27 changed files with 4343 additions and 16 deletions
|
|
@ -4,5 +4,6 @@
|
|||
#include <fishbone/client.h>
|
||||
#include <fishbone/sound.h>
|
||||
#include <fishbone/mixer.h>
|
||||
#include <fishbone/thread.h>
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,4 +3,20 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include <fishbone/config.h>
|
||||
|
||||
#ifdef _FISHBONE
|
||||
#if defined(FISHBONE_AUDIO_USE_SDL2) || defined(FISHBONE_WINDOW_USE_SDL2) || defined(FISHBONE_THREAD_USE_SDL2)
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
#define STB_VORBIS_HEADER_ONLY
|
||||
#include <jar_xm.h>
|
||||
#include <jar_mod.h>
|
||||
#include <dr_mp3.h>
|
||||
#include <dr_wav.h>
|
||||
#include <dr_flac.h>
|
||||
#include <stb_vorbis.c>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,12 +7,22 @@ namespace fishbone {
|
|||
|
||||
#include <fishbone/machdep.h>
|
||||
#include <fishbone/sound.h>
|
||||
#include <fishbone/thread.h>
|
||||
|
||||
namespace fishbone {
|
||||
class Mixer {
|
||||
public:
|
||||
fishbone::Mutex mutex;
|
||||
|
||||
public:
|
||||
Mixer();
|
||||
~Mixer();
|
||||
|
||||
void read(short* buffer, size_t frames);
|
||||
fishbone::Sound* open(const char* path);
|
||||
|
||||
static const int rate = 44100;
|
||||
std::vector<fishbone::SoundLoader*> loaders;
|
||||
std::vector<fishbone::Sound*> sounds;
|
||||
std::vector<fishbone::Sound*> sounds;
|
||||
};
|
||||
}; // namespace fishbone
|
||||
|
||||
|
|
|
|||
|
|
@ -10,13 +10,44 @@ namespace fishbone {
|
|||
#include <fishbone/machdep.h>
|
||||
#include <fishbone/mixer.h>
|
||||
|
||||
#ifdef _FISHBONE
|
||||
#if defined(FISHBONE_SOUND_USE_SDL2)
|
||||
typedef size_t FISHBONE_SOUNDDRV_HANDLE;
|
||||
#endif
|
||||
#else
|
||||
typedef void* FISHBONE_SOUNDDRV_HANDLE;
|
||||
#endif
|
||||
|
||||
namespace fishbone {
|
||||
class SoundDriver {
|
||||
FISHBONE_SOUNDDRV_HANDLE sound;
|
||||
|
||||
public:
|
||||
SoundDriver();
|
||||
~SoundDriver();
|
||||
|
||||
fishbone::Mixer mixer;
|
||||
};
|
||||
|
||||
class SoundLoader {
|
||||
public:
|
||||
SoundLoader();
|
||||
~SoundLoader();
|
||||
|
||||
virtual Sound* open(void* buffer, size_t size);
|
||||
virtual int read(Sound* sound, short* buffer, size_t frames);
|
||||
};
|
||||
|
||||
class Sound {
|
||||
SoundLoader* loader;
|
||||
|
||||
public:
|
||||
Sound(SoundLoader* loader);
|
||||
|
||||
int read(short* buffer, size_t frames);
|
||||
|
||||
int rate;
|
||||
int channels;
|
||||
};
|
||||
}; // namespace fishbone
|
||||
|
||||
|
|
|
|||
44
engine/include/fishbone/thread.h
Normal file
44
engine/include/fishbone/thread.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#ifndef __FISHBONE_THREAD_H__
|
||||
#define __FISHBONE_THREAD_H__
|
||||
|
||||
namespace fishbone {
|
||||
class Thread;
|
||||
class Mutex;
|
||||
}; // namespace fishbone
|
||||
|
||||
#include <fishbone/machdep.h>
|
||||
|
||||
#ifdef _FISHBONE
|
||||
#if defined(FISHBONE_THREAD_USE_SDL2)
|
||||
typedef SDL_mutex* FISHBONE_MUTEX_HANDLE;
|
||||
typedef SDL_Thread* FISHBONE_THREAD_HANDLE;
|
||||
#endif
|
||||
#else
|
||||
typedef void* FISHBONE_MUTEX_HANDLE;
|
||||
typedef void* FISHBONE_THREAD_HANDLE;
|
||||
#endif
|
||||
|
||||
namespace fishbone {
|
||||
class Thread {
|
||||
FISHBONE_THREAD_HANDLE thread;
|
||||
|
||||
public:
|
||||
Thread(void (*call)(fishbone::Thread* thread, void* arg), void* arg);
|
||||
~Thread();
|
||||
|
||||
void join();
|
||||
};
|
||||
|
||||
class Mutex {
|
||||
FISHBONE_MUTEX_HANDLE mutex;
|
||||
|
||||
public:
|
||||
Mutex();
|
||||
~Mutex();
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
};
|
||||
}; // namespace fishbone
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue