22
22
#include <audacious/plugin.h>
23
23
#include <audacious/misc.h>
24
24
#include <audacious/preferences.h>
25
+ #if _AUD_PLUGIN_VERSION >= 45
26
+ #include <audacious/input.h>
27
+ #endif
25
28
#include <xmp.h>
26
29
27
30
#ifdef DEBUG
28
31
#else
29
32
#define _D (x ...)
30
33
#endif
31
34
35
+ #if _AUD_PLUGIN_VERSION < 45
32
36
static GMutex * seek_mutex ;
33
37
static GCond * seek_cond ;
34
38
static gint jumpToTime = -1 ;
35
39
static gboolean stop_flag = FALSE;
40
+ #endif
36
41
static GMutex * probe_mutex ;
37
42
38
43
static xmp_context ctx ;
@@ -112,6 +117,7 @@ static void strip_vfs(char *s) {
112
117
}
113
118
114
119
120
+ #if _AUD_PLUGIN_VERSION < 45
115
121
static void stop (InputPlayback * playback )
116
122
{
117
123
_D ("*** stop!" );
@@ -139,12 +145,6 @@ static void mseek(InputPlayback *playback, gint msec)
139
145
}
140
146
141
147
142
- static void seek_ctx (gint time )
143
- {
144
- xmp_seek_time (ctx , time );
145
- }
146
-
147
-
148
148
static void mod_pause (InputPlayback * playback , gboolean p )
149
149
{
150
150
g_mutex_lock (seek_mutex );
@@ -153,6 +153,13 @@ static void mod_pause(InputPlayback *playback, gboolean p)
153
153
}
154
154
g_mutex_unlock (seek_mutex );
155
155
}
156
+ #endif /* AUD API < 45 */
157
+
158
+
159
+ static void seek_ctx (gint time )
160
+ {
161
+ xmp_seek_time (ctx , time );
162
+ }
156
163
157
164
158
165
static gboolean init (void )
@@ -161,9 +168,11 @@ static gboolean init(void)
161
168
ctx = xmp_create_context ();
162
169
163
170
probe_mutex = g_mutex_new ();
171
+ #if _AUD_PLUGIN_VERSION < 45
164
172
jumpToTime = -1 ;
165
173
seek_mutex = g_mutex_new ();
166
174
seek_cond = g_cond_new ();
175
+ #endif
167
176
168
177
aud_config_set_defaults ("XMP" ,plugin_defaults );
169
178
@@ -189,8 +198,10 @@ static gboolean init(void)
189
198
190
199
static void cleanup ()
191
200
{
201
+ #if _AUD_PLUGIN_VERSION < 45
192
202
g_cond_free (seek_cond );
193
203
g_mutex_free (seek_mutex );
204
+ #endif
194
205
g_mutex_free (probe_mutex );
195
206
xmp_free_context (ctx );
196
207
}
@@ -253,7 +264,11 @@ Tuple *probe_for_tuple(const gchar *_filename, VFSFile *fd)
253
264
}
254
265
255
266
267
+ #if _AUD_PLUGIN_VERSION < 45
256
268
static gboolean play (InputPlayback * ipb , const gchar * _filename , VFSFile * file , gint start_time , gint stop_time , gboolean pause )
269
+ #else
270
+ static gboolean play (const gchar * _filename , VFSFile * file )
271
+ #endif
257
272
{
258
273
int channelcnt ;
259
274
FILE * f ;
@@ -273,8 +288,10 @@ static gboolean play(InputPlayback *ipb, const gchar *_filename, VFSFile *file,
273
288
274
289
_D ("play_file: %s" , filename );
275
290
291
+ #if _AUD_PLUGIN_VERSION < 45
276
292
jumpToTime = (start_time > 0 ) ? start_time : -1 ;
277
293
stop_flag = FALSE;
294
+ #endif
278
295
279
296
if ((f = fopen (filename , "rb" )) == 0 ) {
280
297
goto PLAY_ERROR_1 ;
@@ -322,7 +339,11 @@ static gboolean play(InputPlayback *ipb, const gchar *_filename, VFSFile *file,
322
339
323
340
fmt = resol == 16 ? FMT_S16_NE : FMT_U8 ;
324
341
342
+ #if _AUD_PLUGIN_VERSION < 45
325
343
if (!ipb -> output -> open_audio (fmt , freq , channelcnt )) {
344
+ #else
345
+ if (!aud_input_open_audio (fmt , freq , channelcnt )) {
346
+ #endif
326
347
goto PLAY_ERROR_1 ;
327
348
}
328
349
@@ -345,14 +366,22 @@ static gboolean play(InputPlayback *ipb, const gchar *_filename, VFSFile *file,
345
366
tuple_set_str (tuple , FIELD_TITLE , NULL , plugin_cfg .mod_info .mod -> name );
346
367
tuple_set_str (tuple , FIELD_CODEC , NULL , plugin_cfg .mod_info .mod -> type );
347
368
tuple_set_int (tuple , FIELD_LENGTH , NULL , lret );
369
+ #if _AUD_PLUGIN_VERSION < 45
348
370
ipb -> set_tuple (ipb , tuple );
349
371
350
372
ipb -> set_params (ipb , plugin_cfg .mod_info .mod -> chn * 1000 , freq , channelcnt );
351
373
ipb -> set_pb_ready (ipb );
352
374
353
375
stop_flag = FALSE;
376
+ #else
377
+ aud_input_set_tuple (tuple );
378
+ // TODO: displays '4 kbps' instead of '4 channels'
379
+ //aud_input_set_bitrate(plugin_cfg.mod_info.mod->chn*1000);
380
+ #endif
381
+
354
382
xmp_start_player (ctx , freq , flags );
355
383
384
+ #if _AUD_PLUGIN_VERSION < 45
356
385
while (!stop_flag ) {
357
386
if (stop_time >= 0 && ipb -> output -> written_time () >= stop_time ) {
358
387
goto DRAIN ;
@@ -379,11 +408,28 @@ static gboolean play(InputPlayback *ipb, const gchar *_filename, VFSFile *file,
379
408
break ;
380
409
}
381
410
}
411
+ #else
412
+ while ( !aud_input_check_stop () ) {
413
+ gint jumpToTime = aud_input_check_seek ();
414
+ if (jumpToTime != -1 ) {
415
+ seek_ctx (jumpToTime );
416
+ }
417
+
418
+ xmp_get_frame_info (ctx , & fi );
419
+ aud_input_write_audio (fi .buffer , fi .buffer_size );
382
420
421
+ if (xmp_play_frame (ctx ) != 0 ) {
422
+ break ;
423
+ }
424
+ }
425
+ #endif
426
+
427
+ #if _AUD_PLUGIN_VERSION < 45
383
428
g_mutex_lock (seek_mutex );
384
429
stop_flag = TRUE;
385
430
g_cond_signal (seek_cond ); /* wake up any waiting request */
386
431
g_mutex_unlock (seek_mutex );
432
+ #endif
387
433
388
434
xmp_end_player (ctx );
389
435
xmp_release_module (ctx );
@@ -589,12 +635,14 @@ AUD_INPUT_PLUGIN (
589
635
.about_text = plugin_aud_about ,
590
636
.prefs = & plugin_aud_preferences ,
591
637
.play = play ,
638
+ #if _AUD_PLUGIN_VERSION < 45
592
639
.stop = stop ,
593
640
.pause = mod_pause ,
641
+ .mseek = mseek ,
642
+ #endif
594
643
.probe_for_tuple = probe_for_tuple ,
595
644
.is_our_file_from_vfs = is_our_file_from_vfs ,
596
645
.cleanup = cleanup ,
597
- .mseek = mseek ,
598
646
.extensions = fmts ,
599
647
)
600
648
0 commit comments