#ifndef TN_QSF_H
#define TN_QSF_H

#include <exec/exec.h>
#include <dos/dos.h>

#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/utility.h>

#include <libraries/tnplug.h>
#include <proto/tnplug.h>

#include "debug.h"

#define AUDIO_BUFFER_SIZE (735 << 2)

struct TNPlugBase {
	struct Library tnpb_LibNode;
	BPTR tnpb_SegList;
};

struct TNDecHandle;

typedef struct {
	int32 (*open)(struct TNDecHandle *handle, void *buf, uint32 len);
	void (*close)(struct TNDecHandle *handle);
	int32 (*process)(struct TNDecHandle *handle, void *buf, uint32 len);
} xsfiface_t;

struct TNDecHandle {
	BPTR xsf_bin;
	xsfiface_t *iface;
	struct Interface *newlib;
	struct DOSIFace *dos;
	uint32 pcm_size;
};

/* announceplayer.c */
struct audio_player *TNPlug_AnnouncePlayer (struct TNPlugIFace *Self, uint32 version);

/* initplayer.c */
BOOL TNPlug_InitPlayer (struct TNPlugIFace *Self, struct TuneNet *inTuneNet, uint32 playmode);
void TNPlug_ExitPlayer (struct TNPlugIFace *Self, struct audio_player *aplayer);

/* openplayer.c */
int32 TNPlug_TestPlayer (struct TNPlugIFace *Self, uint8 *testme, uint8 *testbuffer,
	uint32 totalsize, uint32 testsize);
BOOL TNPlug_OpenPlayer (struct TNPlugIFace *Self, uint8 *openme, struct TuneNet *inTuneNet);
void TNPlug_ClosePlayer (struct TNPlugIFace *Self, struct TuneNet *inTuneNet);

/* decodeframeplayer.c */
int32 TNPlug_DecodeFramePlayer (struct TNPlugIFace *Self, struct TuneNet *inTuneNet,
	int16 *outbuffer);
int32 TNPlug_SeekPlayer (struct TNPlugIFace *Self, struct TuneNet *inTuneNet, uint32 seconds);

/* donotify.c */
uint32 TNPlug_DoNotify (struct TNPlugIFace *Self, struct TuneNet *inTuneNet, uint32 item,
	uint32 value);

#endif
