2003-11-07 12:47:01 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2001-12-23 16:13:33 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "gstmikmod.h"
|
|
|
|
|
|
|
|
static int buffer_size;
|
|
|
|
static SBYTE *audiobuffer = NULL;
|
|
|
|
extern int need_sync;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static BOOL
|
|
|
|
mikmod_IsThere (void)
|
2001-12-23 16:13:33 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static BOOL
|
|
|
|
mikmod_Init (void)
|
2001-12-23 16:13:33 +00:00
|
|
|
{
|
|
|
|
buffer_size = 32768;
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!(audiobuffer = (SBYTE *) g_malloc (buffer_size)))
|
2001-12-23 16:13:33 +00:00
|
|
|
return 1;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
return VC_Init ();
|
2001-12-23 16:13:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
mikmod_Exit (void)
|
2001-12-23 16:13:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
VC_Exit ();
|
2001-12-23 16:13:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (audiobuffer) {
|
|
|
|
g_free (audiobuffer);
|
2001-12-23 16:13:33 +00:00
|
|
|
audiobuffer = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2001-12-23 16:13:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
mikmod_Update (void)
|
2001-12-23 16:13:33 +00:00
|
|
|
{
|
2002-02-02 14:03:45 +00:00
|
|
|
gint length;
|
|
|
|
GstBuffer *outdata;
|
2001-12-23 16:13:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
length = VC_WriteBytes ((SBYTE *) audiobuffer, buffer_size);
|
|
|
|
|
|
|
|
outdata = gst_buffer_new ();
|
2002-06-22 16:20:25 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_BUFFER_DATA (outdata) = g_memdup (audiobuffer, length);
|
|
|
|
GST_BUFFER_SIZE (outdata) = length;
|
2001-12-23 16:13:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outdata) = timestamp;
|
2002-06-22 16:20:25 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (need_sync == 1) {
|
2001-12-28 20:24:41 +00:00
|
|
|
/* FIXME, send a flush event or something */
|
2004-03-14 22:34:33 +00:00
|
|
|
need_sync = 0;
|
2001-12-23 16:13:33 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_push (srcpad, GST_DATA (outdata));
|
|
|
|
|
2001-12-23 16:13:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static BOOL
|
|
|
|
mikmod_Reset (void)
|
2001-12-23 16:13:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
VC_Exit ();
|
|
|
|
return VC_Init ();
|
2001-12-23 16:13:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
MDRIVER drv_gst = {
|
|
|
|
NULL,
|
|
|
|
"mikmod",
|
|
|
|
"mikmod output driver v1.0",
|
|
|
|
0, 255,
|
2001-12-23 16:13:33 +00:00
|
|
|
#if (LIBMIKMOD_VERSION > 0x030106)
|
2004-03-14 22:34:33 +00:00
|
|
|
"mikmod",
|
|
|
|
NULL,
|
2001-12-23 16:13:33 +00:00
|
|
|
#endif
|
2004-03-14 22:34:33 +00:00
|
|
|
mikmod_IsThere,
|
|
|
|
VC_SampleLoad,
|
|
|
|
VC_SampleUnload,
|
|
|
|
VC_SampleSpace,
|
|
|
|
VC_SampleLength,
|
|
|
|
mikmod_Init,
|
|
|
|
mikmod_Exit,
|
|
|
|
mikmod_Reset,
|
|
|
|
VC_SetNumVoices,
|
|
|
|
VC_PlayStart,
|
|
|
|
VC_PlayStop,
|
|
|
|
mikmod_Update,
|
|
|
|
NULL,
|
|
|
|
VC_VoiceSetVolume,
|
|
|
|
VC_VoiceGetVolume,
|
|
|
|
VC_VoiceSetFrequency,
|
|
|
|
VC_VoiceGetFrequency,
|
|
|
|
VC_VoiceSetPanning,
|
|
|
|
VC_VoiceGetPanning,
|
|
|
|
VC_VoicePlay,
|
|
|
|
VC_VoiceStop,
|
|
|
|
VC_VoiceStopped,
|
|
|
|
VC_VoiceGetPosition,
|
|
|
|
VC_VoiceRealVolume
|
2001-12-23 16:13:33 +00:00
|
|
|
};
|