Esempio n. 1
0
static void AMF_Cleanup(void)
{
	MikMod_free(mh);
	MikMod_free(track);
	mh=NULL;
	track=NULL;
}
Esempio n. 2
0
void S3M_Cleanup(void)
{
	MikMod_free(s3mbuf);
	MikMod_free(paraptr);
	MikMod_free(poslookup);
	MikMod_free(mh);
	MikMod_free(origpositions);
}
Esempio n. 3
0
static void IMF_Cleanup(void)
{
	FreeLinear();

	MikMod_free(imfpat);
	MikMod_free(mh);
	imfpat=NULL;
	mh=NULL;
}
Esempio n. 4
0
static void STX_Cleanup(void)
{
	MikMod_free(stxbuf);
	MikMod_free(paraptr);
	MikMod_free(poslookup);
	MikMod_free(mh);
	stxbuf=NULL;
	paraptr=NULL;
	poslookup=NULL;
	mh=NULL;
}
Esempio n. 5
0
void MikMod_Exit_internal(void)
{
	MikMod_DisableOutput_internal();
	md_driver->Exit();
	md_numchn = md_sfxchn = md_sngchn = 0;
	md_driver = &drv_nos;

	if(sfxinfo) MikMod_free(sfxinfo);
	if(md_sample) MikMod_free(md_sample);
	md_sample  = NULL;
	sfxinfo    = NULL;

	initialized = 0;
}
Esempio n. 6
0
static void pipe_Exit(void)
{
#if defined unix || (defined __APPLE__ && defined __MACH__)
	int pstat;
	pid_t pid2;
#endif

	VC_Exit();
	MikMod_free(audiobuffer);
	if(pipeout) {
		_mm_delete_file_writer(pipeout);
		pipeout=NULL;
	}
	if(pipefile) {
#if !defined unix && (!defined __APPLE__ || !defined __MACH__)
#ifdef __WATCOMC__
		_pclose(pipefile);
#else
		pclose(pipefile);
#endif
#ifdef __EMX__
		_fsetmode(stdout,"t");
#endif
#else
		fclose(pipefile);
		do {
			pid2=waitpid(pid,&pstat,0);
		} while (pid2==-1 && errno==EINTR);
#endif
		pipefile=NULL;
	}
}
Esempio n. 7
0
/* If either parameter is -1, the current set value will be retained. */
BOOL MikMod_SetNumVoices_internal(int music, int sfx)
{
	BOOL resume = 0;
	int t, oldchn = 0;

	if((!music)&&(!sfx)) return 1;
	_mm_critical = 1;
	if(isplaying) {
		MikMod_DisableOutput_internal();
		oldchn = md_numchn;
		resume = 1;
	}

	if(sfxinfo) MikMod_free(sfxinfo);
	if(md_sample) MikMod_free(md_sample);
	md_sample  = NULL;
	sfxinfo    = NULL;

	if(music!=-1) md_sngchn = music;
	if(sfx!=-1)   md_sfxchn = sfx;
	md_numchn = md_sngchn + md_sfxchn;

	LimitHardVoices(md_driver->HardVoiceLimit);
	LimitSoftVoices(md_driver->SoftVoiceLimit);

	if(md_driver->SetNumVoices()) {
		MikMod_Exit_internal();
		if(_mm_errno)
			if(_mm_errorhandler!=NULL) _mm_errorhandler();
		md_numchn = md_softchn = md_hardchn = md_sfxchn = md_sngchn = 0;
		return 1;
	}

	if(md_sngchn+md_sfxchn)
		md_sample=(SAMPLE**)MikMod_calloc(md_sngchn+md_sfxchn,sizeof(SAMPLE*));
	if(md_sfxchn)
		sfxinfo = (UBYTE *)MikMod_calloc(md_sfxchn,sizeof(UBYTE));

	/* make sure the player doesn't start with garbage */
	for(t=oldchn;t<md_numchn;t++)  Voice_Stop_internal(t);

	sfxpool = 0;
	if(resume) MikMod_EnableOutput_internal();
	_mm_critical = 0;

	return 0;
}
Esempio n. 8
0
static void stdout_Exit(void)
{
	VC_Exit();
#ifdef __EMX__
	_fsetmode(stdout,"t");
#endif
	MikMod_free(audiobuffer);
	audiobuffer=NULL;
}
Esempio n. 9
0
static void AIX_Exit(void)
{
	VC_Exit();
	if (fd>=0) {
		close(fd);
		fd=-1;
	}
	MikMod_free(audiobuffer);
}
Esempio n. 10
0
static void pipe_CommandLine(CHAR *cmdline)
{
	CHAR *ptr=MD_GetAtom("pipe",cmdline,0);

	if(ptr) {
		MikMod_free(target);
		target=ptr;
	}
}
Esempio n. 11
0
static void ESD_CommandLine(const CHAR *cmdline)
{
	CHAR *ptr=MD_GetAtom("machine",cmdline,0);

	if (ptr) {
		MikMod_free(espeaker);
		espeaker=ptr;
	}
}
Esempio n. 12
0
static void AF_CommandLine(CHAR *cmdline)
{
	CHAR *machine=MD_GetAtom("machine",cmdline,0);

	if(machine) {
		if(soundbox) MikMod_free(soundbox);
		soundbox=machine;
	}
}
Esempio n. 13
0
static void WAV_CommandLine(const CHAR *cmdline)
{
	CHAR *ptr=MD_GetAtom("file",cmdline,0);

	if(ptr) {
		MikMod_free(filename);
		filename=ptr;
	}
}
Esempio n. 14
0
static void commandLine(CHAR *cmdline)
{
	CHAR *ptr;

	if((ptr=MD_GetAtom("card", cmdline, 0))) {
		card=atoi(ptr);
		MikMod_free(ptr);
	}
}
Esempio n. 15
0
static void ALSA_Exit_internal(void)
{
	VC_Exit();
	if (pcm_h) {
		alsa_pcm_drain_playback(pcm_h);
		alsa_pcm_close(pcm_h);
		pcm_h=NULL;
	}
	MikMod_free(audiobuffer);
}
Esempio n. 16
0
static void DS_CommandLine(CHAR *cmdline)
{
	CHAR *ptr=MD_GetAtom("buffer",cmdline,0);

	if (ptr) {
		int buf=atoi(ptr);

		if ((buf<12)||(buf>19)) buf=FRAGSIZE;
		fragsize=1<<buf;

		MikMod_free(ptr);
	}
	
	if ((ptr=MD_GetAtom("globalfocus",cmdline,1))) {
		controlflags |= DSBCAPS_GLOBALFOCUS;
		MikMod_free(ptr);
	} else
		controlflags &= ~DSBCAPS_GLOBALFOCUS;
}
Esempio n. 17
0
BOOL ReadLinedComment(UWORD len,UWORD linelen)
{
	CHAR *tempcomment,*line,*storage;
	UWORD total=0,t,lines;
	int i;

	lines = (len + linelen - 1) / linelen;
	if (len) {
		if(!(tempcomment=(CHAR*)MikMod_malloc(len+1))) return 0;
		if(!(storage=(CHAR*)MikMod_malloc(linelen+1))) {
			MikMod_free(tempcomment);
			return 0;
		}
		memset(tempcomment, ' ', len);
		_mm_read_UBYTES(tempcomment,len,modreader);

		/* compute message length */
		for(line=tempcomment,total=t=0;t<lines;t++,line+=linelen) {
			for(i=linelen;(i>=0)&&(line[i]==' ');i--) line[i]=0;
			for(i=0;i<linelen;i++) if (!line[i]) break;
			total+=1+i;
		}

		if(total>lines) {
			if(!(of.comment=(CHAR*)MikMod_malloc(total+1))) {
				MikMod_free(storage);
				MikMod_free(tempcomment);
				return 0;
			}

			/* convert message */
			for(line=tempcomment,t=0;t<lines;t++,line+=linelen) {
				for(i=0;i<linelen;i++) if(!(storage[i]=line[i])) break;
				storage[i]=0; /* if (i==linelen) */
				strcat(of.comment,storage);strcat(of.comment,"\r");
			}
			MikMod_free(storage);
			MikMod_free(tempcomment);
		}
	}
	return 1;
}
Esempio n. 18
0
static void ALSA_CommandLine(CHAR *cmdline)
{
	CHAR *ptr;

	if((ptr=MD_GetAtom("card",cmdline,0))) {
		cardmin=atoi(ptr);cardmax=cardmin+1;
		MikMod_free(ptr);
	} else {
		cardmin=0;cardmax=SND_CARDS;
	}
	if((ptr=MD_GetAtom("pcm",cmdline,0))) {
		device=atoi(ptr);
		MikMod_free(ptr);
	} else device=-1;
	if((ptr=MD_GetAtom("buffer",cmdline,0))) {
		numfrags=atoi(ptr);
		if ((numfrags<2)||(numfrags>16)) numfrags=DEFAULT_NUMFRAGS;
		MikMod_free(ptr);
	} else numfrags=DEFAULT_NUMFRAGS;
}
Esempio n. 19
0
static void ALSA_Exit_internal(void)
{
	enabled = 0;
	VC_Exit();
	if (pcm_h) {
		alsa_pcm_drain(pcm_h);
		alsa_pcm_close(pcm_h);
		pcm_h = NULL;
	}
	MikMod_free(audiobuffer);
	audiobuffer = NULL;
}
Esempio n. 20
0
static void AIX_CommandLine(CHAR *cmdline)
{
	char *buffer=MD_GetAtom("buffer",cmdline,0);

	if(buffer) {
		int buf=atoi(buffer);

		if((buf<12)||(buf>19)) buf=BUFFERSIZE;
		buffersize=1<<buf;

		MikMod_free(buffer);
	}
}
Esempio n. 21
0
void IT_Cleanup(void)
{
	FreeLinear();

	MikMod_free(mh);
	MikMod_free(poslookup);
	MikMod_free(itpat);
	MikMod_free(mask);
	MikMod_free(last);
	MikMod_free(paraptr);
	MikMod_free(origpositions);
}
Esempio n. 22
0
static void ALSA_Exit_internal(void)
{
	VC_Exit();
	if (pcm_h) {
#ifdef OLD_ALSA
		alsa_pcm_drain_playback(pcm_h);
#else
		alsa_pcm_drain(pcm_h);
#endif
		alsa_pcm_close(pcm_h);
		pcm_h=NULL;
	}
	MikMod_free(audiobuffer);
}
Esempio n. 23
0
static void WAV_Exit(void)
{
	VC_Exit();

	/* write in the actual sizes now */
	if(wavout) {
		putheader();
		_mm_delete_file_writer(wavout);
		fclose(wavfile);
		wavfile=NULL;wavout=NULL;
	}
	MikMod_free(audiobuffer);
	audiobuffer=NULL;
}
Esempio n. 24
0
void dma_free(dma_buffer * buffer)
{
	__dpmi_meminfo buff_info;

	if (!buffer)
		return;

	buff_info.address = buffer->physical;
	buff_info.size = buffer->size;
	__dpmi_unlock_linear_region(&buff_info);

	__dpmi_free_dos_memory(buffer->selector);
	MikMod_free(buffer);

	if (--__buffer_count == 0)
		dma_finalize();
}
Esempio n. 25
0
static BOOL loadsmp5(void)
{
	int t,u;
	SAMPLE *q;
	INSTRUMENT *d;

	q=of.samples;s=wh;
	for(u=0;u<of.numsmp;u++,q++,s++) {
		q->samplename=s->samplename;

		q->length   =s->length;
		q->loopstart=s->loopstart;
		q->loopend  =s->loopend;
		q->volume   =s->volume;
		q->speed    =s->c2spd;
		q->panning  =s->panning;
		q->vibtype  =s->vibtype;
		q->vibsweep =s->vibsweep;
		q->vibdepth =s->vibdepth;
		q->vibrate  =s->vibrate;

		/* convert flags */
		q->flags=0;
		if(s->flags&128) q->flags|=SF_REVERSE;
		if(s->flags& 64) q->flags|=SF_SUSTAIN;
		if(s->flags& 32) q->flags|=SF_BIDI;
		if(s->flags& 16) q->flags|=SF_LOOP;
		if(s->flags&  8) q->flags|=SF_BIG_ENDIAN;
		if(s->flags&  4) q->flags|=SF_DELTA;
		if(s->flags&  2) q->flags|=SF_SIGNED;
		if(s->flags&  1) q->flags|=SF_16BITS;
	}

	d=of.instruments;s=wh;
	for(u=0;u<of.numins;u++,d++)
		for(t=0;t<INSTNOTES;t++)
			d->samplenote[t]=(d->samplenumber[t]>=of.numsmp)?
			  255:(t+s[d->samplenumber[t]].transpose);

	MikMod_free(wh);wh=NULL;

	return 1;
}
Esempio n. 26
0
BOOL ReadComment(UWORD len)
{
	if(len) {
		int i;

		if(!(of.comment=(CHAR*)MikMod_malloc(len+1))) return 0;
		_mm_read_UBYTES(of.comment,len,modreader);
		
		/* translate IT linefeeds */
		for(i=0;i<len;i++)
			if(of.comment[i]=='\r') of.comment[i]='\n';

		of.comment[len]=0;	/* just in case */
	}
	if(!of.comment[0]) {
		MikMod_free(of.comment);
		of.comment=NULL;
	}
	return 1;
}
Esempio n. 27
0
void *dlopen(const char *name, int flags)
{
	shl_t handle;
	char *library;

	if (name == NULL || *name == '\0')
		return NULL;

	/* By convention, libmikmod will look for "foo.so" while on HP-UX the
	   name would be "foo.sl". Change the last letter here. */
	library = strdup(name);
	library[strlen(library) - 1] = 'l';

	handle = shl_load(library,
		(flags & RTLD_LAZY ? BIND_DEFERRED : BIND_IMMEDIATE) | DYNAMIC_PATH,
	    0L);

	MikMod_free(library);

	return (void *)handle;
}
Esempio n. 28
0
SAMPLE *Load(const char *fn)
{
    char *file_data;
    long sysFileGetLength;
    FILE *fptr;

/*  return Sample_Load(fn);*/

    /* open the file */
    fptr = fopen(fn, "rb");
    if (fptr == NULL) {
        perror("fopen");
        return 0;
    }

    /* calculate the file size */
    fseek(fptr, 0, SEEK_END);
    sysFileGetLength = ftell(fptr);
    fseek(fptr, 0, SEEK_SET);

    /* allocate a buffer and load the file into it */
    file_data = (char *) MikMod_malloc(sysFileGetLength);
    if (file_data == NULL) {
        perror("MikMod_malloc");
        fclose(fptr);
        return 0;
    }
    if (fread(file_data, sysFileGetLength, 1, fptr) != 1) {
        perror("fread");
        fclose(fptr);
        MikMod_free(file_data);
        return 0;
    }
    fclose(fptr);

    return Sample_LoadMem(file_data, sysFileGetLength);
}
Esempio n. 29
0
static void freeChunk(GT_CHUNK *c)
{
	if (!memcmp(c, "GT2", 3)) {
		if (c->gt2.voice_pannings)
			MikMod_free(c->gt2.voice_pannings);
	}
	else if (!memcmp(c, "TVOL", 4)) {
		if (c->tvol.track_volumes)
			MikMod_free(c->tvol.track_volumes);
	}
	else if (!memcmp(c, "XCOM", 4)) {
		if (c->xcom.comment)
			MikMod_free(c->xcom.comment);
	}
	else if (!memcmp(c, "SONG", 4)) {
		if (c->song.patterns)
			MikMod_free(c->song.patterns);
	}
	else if (!memcmp(c, "PATD", 4)) {
		if (c->patd.notes)
			MikMod_free(c->patd.notes);
	}
	MikMod_free(c);
}
Esempio n. 30
0
static void ML_FreeEx(MODULE *mf)
{
	UWORD t;

	if(mf->songname) MikMod_free(mf->songname);
	if(mf->comment)  MikMod_free(mf->comment);

	if(mf->modtype)   MikMod_free(mf->modtype);
	if(mf->positions) MikMod_free(mf->positions);
	if(mf->patterns)  MikMod_free(mf->patterns);
	if(mf->pattrows)  MikMod_free(mf->pattrows);

	if(mf->tracks) {
		for(t=0;t<mf->numtrk;t++)
			if(mf->tracks[t]) MikMod_free(mf->tracks[t]);
		MikMod_free(mf->tracks);
	}
	if(mf->instruments) {
		for(t=0;t<mf->numins;t++)
			ML_XFreeInstrument(&mf->instruments[t]);
		MikMod_free(mf->instruments);
	}
	if(mf->samples) {
		for(t=0;t<mf->numsmp;t++)
			if(mf->samples[t].length) ML_XFreeSample(&mf->samples[t]);
		MikMod_free(mf->samples);
	}
	memset(mf,0,sizeof(MODULE));
	if(mf!=&of) MikMod_free(mf);
}