No more SDL
This commit is contained in:
parent
0ad3f792ee
commit
aa7d36b7d3
17
Makefile
17
Makefile
|
@ -10,7 +10,7 @@ endif
|
|||
UNAME_P != uname -m
|
||||
|
||||
#CC specifies which compiler we're using
|
||||
CC = clang -std=c99
|
||||
CC = musl-clang -std=c99
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
DEFFALGS += -DDEBUG
|
||||
|
@ -88,16 +88,16 @@ ifeq ($(UNAME), Windows_NT)
|
|||
EXT = .exe
|
||||
else
|
||||
LINKER_FLAGS =
|
||||
ELIBS = editor engine
|
||||
CLIBS = glfw SDL2 SDL2_mixer m
|
||||
ELIBS = editor engine glfw3 m pthread
|
||||
CLIBS =
|
||||
EXT =
|
||||
endif
|
||||
|
||||
ELIBS != $(call prefix, $(ELIBS), -l)
|
||||
CLIBS != $(call prefix, $(CLIBS), -l)
|
||||
|
||||
#LELIBS = -Wl,-Bstatic $(ELIBS) -Wl,-Bdynamic $(CLIBS)
|
||||
LELIBS = $(ELIBS) $(CLIBS)
|
||||
#LELIBS = -Wl,-Bstatic $(ELIBS)# -Wl,-Bdynamic $(CLIBS)
|
||||
LELIBS = $(ELIBS) #$(CLIBS)
|
||||
|
||||
objects = $(bsobjects) $(eobjects) $(pinobjects)
|
||||
DEPENDS = $(objects:.o=.d)
|
||||
|
@ -123,7 +123,7 @@ editor: $(yuginec:.%.c=$(objprefix)%.o) $(EDITOR) $(ENGINE)
|
|||
$(CC) $< $(LINK)
|
||||
@echo Finished build
|
||||
|
||||
$(ENGINE): $(eobjects)
|
||||
$(ENGINE): $(eobjects) bin/libglfw3.a
|
||||
@echo Making library engine.a
|
||||
@ar -r $(ENGINE) $(eobjects)
|
||||
@cp -u -r $(ehead) $(INCLUDE)
|
||||
|
@ -143,6 +143,11 @@ pinball: $(ENGINE) $(pinobjects)
|
|||
@$(CC) $(pinobjects) $(LINK) -o $@
|
||||
@mv pinball paladin/pinball
|
||||
|
||||
bin/libglfw3.a:
|
||||
@echo Making GLFW
|
||||
make glfw/build
|
||||
cp glfw/build/src/libglfw3.a bin/libglfw3.a
|
||||
|
||||
$(objprefix)/%.o:%.c
|
||||
@mkdir -p $(@D)
|
||||
@echo Making C object $@
|
||||
|
|
90464
source/engine/miniaudio.h
Normal file
90464
source/engine/miniaudio.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,6 @@
|
|||
#define MINIAUDIO_IMPLEMENTATION
|
||||
|
||||
|
||||
#include "sound.h"
|
||||
#include "resources.h"
|
||||
|
||||
|
@ -7,31 +10,32 @@ static int mus_ch = -1;
|
|||
|
||||
void sound_init()
|
||||
{
|
||||
/*
|
||||
int flags = MIX_INIT_MP3 | MIX_INIT_OGG;
|
||||
int err = Mix_Init(flags);
|
||||
if ((err&flags) != flags) {
|
||||
printf("MIX did not init!!");
|
||||
}
|
||||
*/
|
||||
//mus_ch = Mix_AllocateChannels(1);
|
||||
|
||||
mus_ch = Mix_AllocateChannels(1);
|
||||
|
||||
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048);
|
||||
//Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048);
|
||||
}
|
||||
|
||||
void audio_open(const char *device)
|
||||
{
|
||||
Mix_OpenAudioDevice(44100, MIX_DEFAULT_FORMAT, 2, 2048, device, 0);
|
||||
//Mix_OpenAudioDevice(44100, MIX_DEFAULT_FORMAT, 2, 2048, device, 0);
|
||||
}
|
||||
|
||||
void audio_close()
|
||||
{
|
||||
Mix_CloseAudio();
|
||||
//Mix_CloseAudio();
|
||||
}
|
||||
|
||||
struct sound *make_sound(const char *wav)
|
||||
{
|
||||
struct sound *new = calloc(1, sizeof(struct sound));
|
||||
new->sound = Mix_LoadWAV(wav);
|
||||
//new->sound = Mix_LoadWAV(wav);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
@ -39,20 +43,20 @@ struct sound *make_sound(const char *wav)
|
|||
struct music *make_music(const char *ogg)
|
||||
{
|
||||
struct music *sound = calloc(1, sizeof(struct music));
|
||||
sound->music = Mix_LoadMUS(make_path(ogg));
|
||||
//sound->music = Mix_LoadMUS(make_path(ogg));
|
||||
|
||||
return sound;
|
||||
}
|
||||
|
||||
void play_sound(struct sound *sound)
|
||||
{
|
||||
Mix_VolumeChunk(sound->sound, sound->volume);
|
||||
Mix_PlayChannel(-1, sound->sound, 0);
|
||||
//Mix_VolumeChunk(sound->sound, sound->volume);
|
||||
//Mix_PlayChannel(-1, sound->sound, 0);
|
||||
}
|
||||
|
||||
void play_music(struct sound *music)
|
||||
{
|
||||
Mix_PlayChannel(mus_ch, music->sound, -1);
|
||||
//Mix_PlayChannel(mus_ch, music->sound, -1);
|
||||
}
|
||||
|
||||
void music_set(struct sound *music)
|
||||
|
@ -62,57 +66,60 @@ void music_set(struct sound *music)
|
|||
|
||||
void music_volume(unsigned char vol)
|
||||
{
|
||||
Mix_Volume(mus_ch, vol);
|
||||
//Mix_Volume(mus_ch, vol);
|
||||
}
|
||||
|
||||
int music_playing()
|
||||
{
|
||||
return Mix_Playing(mus_ch);
|
||||
//return Mix_Playing(mus_ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int music_paused()
|
||||
{
|
||||
return Mix_Paused(mus_ch);
|
||||
//return Mix_Paused(mus_ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void music_resume()
|
||||
{
|
||||
Mix_Resume(mus_ch);
|
||||
//Mix_Resume(mus_ch);
|
||||
}
|
||||
|
||||
void music_pause()
|
||||
{
|
||||
Mix_Pause(mus_ch);
|
||||
//Mix_Pause(mus_ch);
|
||||
}
|
||||
|
||||
void music_stop()
|
||||
{
|
||||
Mix_HaltChannel(mus_ch);
|
||||
//Mix_HaltChannel(mus_ch);
|
||||
}
|
||||
|
||||
|
||||
void audio_init()
|
||||
{
|
||||
audioDriver = SDL_GetAudioDeviceName(0,0);
|
||||
//audioDriver = SDL_GetAudioDeviceName(0,0);
|
||||
}
|
||||
|
||||
void play_raw(int device, void *data, int size)
|
||||
{
|
||||
SDL_QueueAudio(device, data, size);
|
||||
//SDL_QueueAudio(device, data, size);
|
||||
}
|
||||
|
||||
void close_audio_device(int device)
|
||||
{
|
||||
SDL_CloseAudioDevice(device);
|
||||
//SDL_CloseAudioDevice(device);
|
||||
}
|
||||
|
||||
void clear_raw(int device)
|
||||
{
|
||||
SDL_ClearQueuedAudio(device);
|
||||
//SDL_ClearQueuedAudio(device);
|
||||
}
|
||||
|
||||
int open_device(const char *adriver)
|
||||
{
|
||||
/*
|
||||
SDL_AudioSpec audio_spec;
|
||||
SDL_memset(&audio_spec, 0, sizeof(audio_spec));
|
||||
audio_spec.freq = 48000;
|
||||
|
@ -121,5 +128,8 @@ int open_device(const char *adriver)
|
|||
audio_spec.samples = 4096;
|
||||
int dev = (int) SDL_OpenAudioDevice(adriver, 0, &audio_spec, NULL, 0);
|
||||
SDL_PauseAudioDevice(dev, 0);
|
||||
|
||||
return dev;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,23 @@
|
|||
#ifndef SOUND_H
|
||||
#define SOUND_H
|
||||
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
#include <miniaudio.h>
|
||||
|
||||
struct Mix_Chunk {
|
||||
int i;
|
||||
};
|
||||
|
||||
struct Mix_Music {
|
||||
int i;
|
||||
};
|
||||
|
||||
struct sound {
|
||||
Mix_Chunk *sound;
|
||||
struct Mix_Chunk *sound;
|
||||
unsigned char volume;
|
||||
};
|
||||
|
||||
struct music {
|
||||
Mix_Music *music;
|
||||
struct Mix_Music *music;
|
||||
unsigned char volume;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue