Skip to content

Commit b615196

Browse files
committed
add support for Audacious 3.5-devel plugin API version 45
1 parent d661820 commit b615196

File tree

2 files changed

+56
-8
lines changed

2 files changed

+56
-8
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LD = gcc
77
LDFLAGS =
88
LIBS = `pkg-config --libs libxmp audacious glib-2.0`
99
INSTALL = /usr/bin/install -c
10-
PLUGIN_DIR = `pkg-config --variable input_plugin_dir audacious`
10+
PLUGIN_DIR = `pkg-config --variable plugin_dir audacious`/Input
1111
DESTDIR =
1212
SHELL = /bin/sh
1313
V = 0

audacious3.c

+55-7
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,22 @@
2222
#include <audacious/plugin.h>
2323
#include <audacious/misc.h>
2424
#include <audacious/preferences.h>
25+
#if _AUD_PLUGIN_VERSION >= 45
26+
#include <audacious/input.h>
27+
#endif
2528
#include <xmp.h>
2629

2730
#ifdef DEBUG
2831
#else
2932
#define _D(x...)
3033
#endif
3134

35+
#if _AUD_PLUGIN_VERSION < 45
3236
static GMutex *seek_mutex;
3337
static GCond *seek_cond;
3438
static gint jumpToTime = -1;
3539
static gboolean stop_flag = FALSE;
40+
#endif
3641
static GMutex *probe_mutex;
3742

3843
static xmp_context ctx;
@@ -112,6 +117,7 @@ static void strip_vfs(char *s) {
112117
}
113118

114119

120+
#if _AUD_PLUGIN_VERSION < 45
115121
static void stop(InputPlayback *playback)
116122
{
117123
_D("*** stop!");
@@ -139,12 +145,6 @@ static void mseek(InputPlayback *playback, gint msec)
139145
}
140146

141147

142-
static void seek_ctx(gint time)
143-
{
144-
xmp_seek_time(ctx, time);
145-
}
146-
147-
148148
static void mod_pause(InputPlayback *playback, gboolean p)
149149
{
150150
g_mutex_lock(seek_mutex);
@@ -153,6 +153,13 @@ static void mod_pause(InputPlayback *playback, gboolean p)
153153
}
154154
g_mutex_unlock(seek_mutex);
155155
}
156+
#endif /* AUD API < 45 */
157+
158+
159+
static void seek_ctx(gint time)
160+
{
161+
xmp_seek_time(ctx, time);
162+
}
156163

157164

158165
static gboolean init(void)
@@ -161,9 +168,11 @@ static gboolean init(void)
161168
ctx = xmp_create_context();
162169

163170
probe_mutex = g_mutex_new();
171+
#if _AUD_PLUGIN_VERSION < 45
164172
jumpToTime = -1;
165173
seek_mutex = g_mutex_new();
166174
seek_cond = g_cond_new();
175+
#endif
167176

168177
aud_config_set_defaults("XMP",plugin_defaults);
169178

@@ -189,8 +198,10 @@ static gboolean init(void)
189198

190199
static void cleanup()
191200
{
201+
#if _AUD_PLUGIN_VERSION < 45
192202
g_cond_free(seek_cond);
193203
g_mutex_free(seek_mutex);
204+
#endif
194205
g_mutex_free(probe_mutex);
195206
xmp_free_context(ctx);
196207
}
@@ -253,7 +264,11 @@ Tuple *probe_for_tuple(const gchar *_filename, VFSFile *fd)
253264
}
254265

255266

267+
#if _AUD_PLUGIN_VERSION < 45
256268
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
257272
{
258273
int channelcnt;
259274
FILE *f;
@@ -273,8 +288,10 @@ static gboolean play(InputPlayback *ipb, const gchar *_filename, VFSFile *file,
273288

274289
_D("play_file: %s", filename);
275290

291+
#if _AUD_PLUGIN_VERSION < 45
276292
jumpToTime = (start_time > 0) ? start_time : -1;
277293
stop_flag = FALSE;
294+
#endif
278295

279296
if ((f = fopen(filename, "rb")) == 0) {
280297
goto PLAY_ERROR_1;
@@ -322,7 +339,11 @@ static gboolean play(InputPlayback *ipb, const gchar *_filename, VFSFile *file,
322339

323340
fmt = resol == 16 ? FMT_S16_NE : FMT_U8;
324341

342+
#if _AUD_PLUGIN_VERSION < 45
325343
if (!ipb->output->open_audio(fmt, freq, channelcnt)) {
344+
#else
345+
if (!aud_input_open_audio(fmt, freq, channelcnt)) {
346+
#endif
326347
goto PLAY_ERROR_1;
327348
}
328349

@@ -345,14 +366,22 @@ static gboolean play(InputPlayback *ipb, const gchar *_filename, VFSFile *file,
345366
tuple_set_str(tuple, FIELD_TITLE, NULL, plugin_cfg.mod_info.mod->name);
346367
tuple_set_str(tuple, FIELD_CODEC, NULL, plugin_cfg.mod_info.mod->type);
347368
tuple_set_int(tuple, FIELD_LENGTH, NULL, lret);
369+
#if _AUD_PLUGIN_VERSION < 45
348370
ipb->set_tuple(ipb, tuple);
349371

350372
ipb->set_params(ipb, plugin_cfg.mod_info.mod->chn * 1000, freq, channelcnt);
351373
ipb->set_pb_ready(ipb);
352374

353375
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+
354382
xmp_start_player(ctx, freq, flags);
355383

384+
#if _AUD_PLUGIN_VERSION < 45
356385
while (!stop_flag) {
357386
if (stop_time >= 0 && ipb->output->written_time() >= stop_time) {
358387
goto DRAIN;
@@ -379,11 +408,28 @@ static gboolean play(InputPlayback *ipb, const gchar *_filename, VFSFile *file,
379408
break;
380409
}
381410
}
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);
382420

421+
if (xmp_play_frame(ctx) != 0) {
422+
break;
423+
}
424+
}
425+
#endif
426+
427+
#if _AUD_PLUGIN_VERSION < 45
383428
g_mutex_lock(seek_mutex);
384429
stop_flag = TRUE;
385430
g_cond_signal(seek_cond); /* wake up any waiting request */
386431
g_mutex_unlock(seek_mutex);
432+
#endif
387433

388434
xmp_end_player(ctx);
389435
xmp_release_module(ctx);
@@ -589,12 +635,14 @@ AUD_INPUT_PLUGIN (
589635
.about_text = plugin_aud_about,
590636
.prefs = &plugin_aud_preferences,
591637
.play = play,
638+
#if _AUD_PLUGIN_VERSION < 45
592639
.stop = stop,
593640
.pause = mod_pause,
641+
.mseek = mseek,
642+
#endif
594643
.probe_for_tuple = probe_for_tuple,
595644
.is_our_file_from_vfs = is_our_file_from_vfs,
596645
.cleanup = cleanup,
597-
.mseek = mseek,
598646
.extensions = fmts,
599647
)
600648

0 commit comments

Comments
 (0)