77#include < mruby/data.h>
88#include < mruby/numeric.h>
99
10- static void music_free (mrb_state* mrb, void * p) {
10+ static void
11+ music_free (mrb_state* mrb, void * p)
12+ {
1113 Moon::Music* music = (Moon::Music*)p;
1214 if (music) {
1315 if (music->handle ) {
@@ -17,9 +19,11 @@ static void music_free(mrb_state* mrb, void* p) {
1719 }
1820}
1921
20- MOON_C_API const struct mrb_data_type music_data_type = {" Music" , music_free};
22+ MOON_C_API const struct mrb_data_type music_data_type = { " Music" , music_free };
2123
22- static inline Moon::Music* get_music (mrb_state* mrb, mrb_value self) {
24+ static inline Moon::Music*
25+ get_music (mrb_state* mrb, mrb_value self)
26+ {
2327 return (Moon::Music*)mrb_data_get_ptr (mrb, self, &music_data_type);
2428}
2529
@@ -28,7 +32,9 @@ static inline Moon::Music* get_music(mrb_state* mrb, mrb_value self) {
2832 * @param [String] format type of the file
2933 * @return [Music]
3034 */
31- static mrb_value music_initialize (mrb_state* mrb, mrb_value self) {
35+ static mrb_value
36+ music_initialize (mrb_state* mrb, mrb_value self)
37+ {
3238 char * filename;
3339 char * format;
3440 Moon::Music* music;
@@ -43,8 +49,8 @@ static mrb_value music_initialize(mrb_state* mrb, mrb_value self) {
4349
4450 if (exists (filename)) {
4551 music->handle = gau_create_handle_buffered_file (
46- Moon::Audio::GetMixer (), Moon::Audio::GetStreamMgr (), filename, format,
47- NULL , 0 , &(music->loopSrc ));
52+ Moon::Audio::GetMixer (), Moon::Audio::GetStreamMgr (), filename, format,
53+ NULL , 0 , &(music->loopSrc ));
4854 } else {
4955 mrb_raisef (mrb, E_SCRIPT_ERROR , " cannot load such file -- %S" ,
5056 mrb_str_new_cstr (mrb, filename));
@@ -62,7 +68,9 @@ static mrb_value music_initialize(mrb_state* mrb, mrb_value self) {
6268 * @param [Float] pan
6369 * @return [nil]
6470 */
65- static mrb_value music_play (mrb_state* mrb, mrb_value self) {
71+ static mrb_value
72+ music_play (mrb_state* mrb, mrb_value self)
73+ {
6674 mrb_float gain = 1.0 ;
6775 mrb_float pitch = 1.0 ;
6876 mrb_float pan = 0.0 ;
@@ -79,7 +87,9 @@ static mrb_value music_play(mrb_state* mrb, mrb_value self) {
7987/* Stops the playback.
8088 * @return [nil]
8189 */
82- static mrb_value music_stop (mrb_state* mrb, mrb_value self) {
90+ static mrb_value
91+ music_stop (mrb_state* mrb, mrb_value self)
92+ {
8393 Moon::Music* music = get_music (mrb, self);
8494 ga_handle_stop (music->handle );
8595 return mrb_nil_value ();
@@ -89,7 +99,9 @@ static mrb_value music_stop(mrb_state* mrb, mrb_value self) {
8999 *
90100 * @return [Boolean] Returns true if currently playing, else false.
91101 */
92- static mrb_value music_is_playing (mrb_state* mrb, mrb_value self) {
102+ static mrb_value
103+ music_is_playing (mrb_state* mrb, mrb_value self)
104+ {
93105 Moon::Music* music = get_music (mrb, self);
94106 return mrb_bool_value (ga_handle_playing (music->handle ));
95107}
@@ -98,7 +110,9 @@ static mrb_value music_is_playing(mrb_state* mrb, mrb_value self) {
98110 *
99111 * @return [Boolean] Returns true if currently stopped, else false.
100112 */
101- static mrb_value music_is_stopped (mrb_state* mrb, mrb_value self) {
113+ static mrb_value
114+ music_is_stopped (mrb_state* mrb, mrb_value self)
115+ {
102116 Moon::Music* music = get_music (mrb, self);
103117 return mrb_bool_value (ga_handle_stopped (music->handle ));
104118}
@@ -107,7 +121,9 @@ static mrb_value music_is_stopped(mrb_state* mrb, mrb_value self) {
107121 *
108122 * @return [Boolean] Returns true if the playback is finished, else false.
109123 */
110- static mrb_value music_is_finished (mrb_state* mrb, mrb_value self) {
124+ static mrb_value
125+ music_is_finished (mrb_state* mrb, mrb_value self)
126+ {
111127 Moon::Music* music = get_music (mrb, self);
112128 return mrb_bool_value (ga_handle_finished (music->handle ));
113129}
@@ -117,7 +133,9 @@ static mrb_value music_is_finished(mrb_state* mrb, mrb_value self) {
117133 * @param [Integer] pos Offset from the start of the file, in seconds.
118134 * @return [Boolean] Returns true if the seek was successful, else false.
119135 */
120- static mrb_value music_seek (mrb_state* mrb, mrb_value self) {
136+ static mrb_value
137+ music_seek (mrb_state* mrb, mrb_value self)
138+ {
121139 mrb_int pos;
122140 Moon::Music* music = get_music (mrb, self);
123141 mrb_get_args (mrb, " i" , &pos);
@@ -128,7 +146,9 @@ static mrb_value music_seek(mrb_state* mrb, mrb_value self) {
128146 *
129147 * @return [Integer] Current position in the file (in seconds).
130148 */
131- static mrb_value music_pos (mrb_state* mrb, mrb_value self) {
149+ static mrb_value
150+ music_pos (mrb_state* mrb, mrb_value self)
151+ {
132152 Moon::Music* music = get_music (mrb, self);
133153 return mrb_fixnum_value (ga_handle_tell (music->handle , GA_TELL_PARAM_CURRENT ));
134154}
@@ -137,7 +157,9 @@ static mrb_value music_pos(mrb_state* mrb, mrb_value self) {
137157 *
138158 * @return [Integer] Total length (in seconds).
139159 */
140- static mrb_value music_length (mrb_state* mrb, mrb_value self) {
160+ static mrb_value
161+ music_length (mrb_state* mrb, mrb_value self)
162+ {
141163 Moon::Music* music = get_music (mrb, self);
142164 return mrb_fixnum_value (ga_handle_tell (music->handle , GA_TELL_PARAM_TOTAL ));
143165}
@@ -148,7 +170,9 @@ static mrb_value music_length(mrb_state* mrb, mrb_value self) {
148170 * @param [Integer] target position (in samples) where to jump to
149171 * @return [nil]
150172 */
151- static mrb_value music_loop (mrb_state* mrb, mrb_value self) {
173+ static mrb_value
174+ music_loop (mrb_state* mrb, mrb_value self)
175+ {
152176 mrb_int trigger = -1 ;
153177 mrb_int target = 0 ;
154178 Moon::Music* music = get_music (mrb, self);
@@ -161,20 +185,24 @@ static mrb_value music_loop(mrb_state* mrb, mrb_value self) {
161185 *
162186 * @return [Boolean] true
163187 */
164- static mrb_value music_clear_loop (mrb_state* mrb, mrb_value self) {
188+ static mrb_value
189+ music_clear_loop (mrb_state* mrb, mrb_value self)
190+ {
165191 Moon::Music* music = get_music (mrb, self);
166192 gau_sample_source_loop_clear (music->loopSrc );
167193 return mrb_bool_value (true );
168194}
169195
170- MOON_C_API void mmrb_music_init (mrb_state* mrb) {
196+ MOON_C_API void
197+ mmrb_music_init (mrb_state* mrb)
198+ {
171199 struct RClass * mod = mrb_define_module (mrb, " Moon" );
172200 /* Music used to playing audio streams (usually background music). The file is
173201 * buffered from disk instead of streamed from memory, because songs can be
174202 * rather large in file size.
175203 */
176204 struct RClass * music_class =
177- mrb_define_class_under (mrb, mod, " Music" , mrb->object_class );
205+ mrb_define_class_under (mrb, mod, " Music" , mrb->object_class );
178206 MRB_SET_INSTANCE_TT (music_class, MRB_TT_DATA );
179207
180208 mrb_define_method (mrb, music_class, " initialize" , music_initialize,
0 commit comments