From 7dca5a263a38729a1cc14fd6cacda5745d8f458a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Wed, 31 Dec 2014 15:49:49 +0000 Subject: [PATCH] [GB.SDL2] * NEW: Font.DefaultHeight is a new constant that returns the height of the default font. [GB.SDL2.AUDIO] * NEW: Sound.Play method has been implemented. git-svn-id: svn://localhost/gambas/trunk@6784 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.sdl2/src/audio/c_channel.c | 4 ++-- gb.sdl2/src/audio/c_channel.h | 2 ++ gb.sdl2/src/audio/c_sound.c | 9 ++++----- gb.sdl2/src/c_font.c | 2 ++ 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gb.sdl2/src/audio/c_channel.c b/gb.sdl2/src/audio/c_channel.c index 7a2ca377c..c01aa057d 100644 --- a/gb.sdl2/src/audio/c_channel.c +++ b/gb.sdl2/src/audio/c_channel.c @@ -82,7 +82,7 @@ static void channel_finished_cb(int channel) ch->free = (write(_pipe[1], &buf, 1) == 1); } -static void return_channel(int channel, CSOUND *sound) +void CHANNEL_return(int channel, CSOUND *sound) { CCHANNEL *ch = NULL; @@ -176,7 +176,7 @@ static void update_channel_effect(CCHANNEL *_object) BEGIN_METHOD(Channels_get, GB_INTEGER index) - return_channel(VARG(index), NULL); + CHANNEL_return(VARG(index), NULL); END_METHOD diff --git a/gb.sdl2/src/audio/c_channel.h b/gb.sdl2/src/audio/c_channel.h index 5175ca4a4..e56bd0aa0 100644 --- a/gb.sdl2/src/audio/c_channel.h +++ b/gb.sdl2/src/audio/c_channel.h @@ -48,6 +48,8 @@ extern GB_DESC ChannelsDesc[]; bool CHANNEL_init(void); void CHANNEL_exit(void); +int CHANNEL_play_sound(int channel, CSOUND *sound, int loops, int fadein); +void CHANNEL_return(int channel, CSOUND *sound); #endif /* __C_CHANNEL_H */ diff --git a/gb.sdl2/src/audio/c_sound.c b/gb.sdl2/src/audio/c_sound.c index ec6ceab98..47991fe78 100644 --- a/gb.sdl2/src/audio/c_sound.c +++ b/gb.sdl2/src/audio/c_sound.c @@ -23,6 +23,7 @@ #define __C_SOUND_C +#include "c_channel.h" #include "c_sound.h" #define THIS ((CSOUND *)_object) @@ -106,18 +107,16 @@ BEGIN_PROPERTY(Sound_Volume) END_PROPERTY -#if 0 BEGIN_METHOD(Sound_Play, GB_INTEGER loops; GB_FLOAT fadein) int loops = VARGOPT(loops, 0); int channel; GB.Ref(THIS); - channel = play_channel(-1, THIS, loops, MISSING(fadein) ? 0 : (int)(VARG(fadein) * 1000)); - return_channel(channel, THIS); + channel = CHANNEL_play_sound(-1, THIS, loops, MISSING(fadein) ? 0 : (int)(VARG(fadein) * 1000)); + CHANNEL_return(channel, THIS); END_METHOD -#endif //------------------------------------------------------------------------- @@ -136,7 +135,7 @@ GB_DESC SoundDesc[] = GB_PROPERTY("Volume", "i", Sound_Volume), - //GB_METHOD("Play", "Channel", CSOUND_play, "[(Loops)i(FadeIn)f]"), + GB_METHOD("Play", "Channel", Sound_Play, "[(Loops)i(FadeIn)f]"), GB_END_DECLARE }; diff --git a/gb.sdl2/src/c_font.c b/gb.sdl2/src/c_font.c index 33124cc36..3cf3f10ea 100644 --- a/gb.sdl2/src/c_font.c +++ b/gb.sdl2/src/c_font.c @@ -501,6 +501,8 @@ GB_DESC FontDesc[] = { GB_DECLARE("Font", sizeof(CFONT)), GB_NOT_CREATABLE(), + GB_CONSTANT("DefaultHeight", "i", DEFAULT_FONT_HEIGHT), + GB_STATIC_METHOD("Load", NULL, Font_Load, "(Path)s[(Name)s]"), GB_STATIC_METHOD("_get", "Font", Font_get, "(Font)s"), GB_STATIC_METHOD("_exit", NULL, Font_exit, NULL),