#include "uade_tnplug.h"

uint32 TNPlug_DoNotify (struct TNPlugIFace *Self, struct TuneNet *inTuneNet, uint32 item,
	uint32 value)
{
	struct TNDecHandle *handle = inTuneNet->handle;
	uint32 res = FALSE;
	switch (item) {
		case TNDN_SubSong:
			if (!handle->player_proc) {
				break;
			}
			if (value >= 1 && value <= handle->num_subsongs) {
				handle->main_port->mp_SigTask = IExec->FindTask(NULL);
				handle->jump_subsong = value;
				IExec->Signal((struct Task *)handle->player_proc, handle->subsong_sig);
				IExec->Wait(1 << handle->main_port->mp_SigBit);
				if (IExec->GetMsg(handle->main_port) == (struct Message *)handle->death_msg) {
					handle->player_proc = NULL;
				} else {
					inTuneNet->current_subsong = value;
					res = TRUE;
				}
			}
			break;
	}
	return res;
}

