Example #1
0
/*
 * allocate the device
 */
int
wav_init(struct wav *f)
{
	if (!dev_ref(f->dev)) {
		wav_exit(f);
		return 0;
	}
	if (!f->mmc)
		f->dev->autostart = 1;
	if (f->mode & MODE_MIDIMASK) {
		wav_midiattach(f);
		return 1;
	}
	f->slot = dev_slotnew(f->dev, "wav", &ctl_wavops, f, 1);
	f->pstate = WAV_INIT;
	if ((f->mode & f->dev->mode) != f->mode) {
#ifdef DEBUG
		if (debug_level >= 1) {
			wav_dbg(f);
			dbg_puts(": ");
			dbg_puts(": operation not supported by device\n");
		}
#endif
		wav_exit(f);
		return 0;
	}
	wav_allocbuf(f);
	return 1;
}
Example #2
0
/*
 * seek to f->mmcpos and prepare to start, close
 * the file on error.
 */
int
wav_seekmmc(struct wav *f)
{
	/*
	 * don't go beyond the end-of-file, if so
	 * put it in INIT state so it dosn't start
	 */
	if (f->mmcpos > f->endpos && !(f->mode & MODE_RECMASK)) {
		wav_reset(f);
		/*
		 * don't make other stream wait for us
		 */
		if (f->slot >= 0)
			dev_slotstart(f->dev, f->slot);
		return 0;
	}
	if (!pipe_seek(&f->pipe.file, f->mmcpos)) {
		wav_exit(f);
		return 0;
	}
	if ((f->mode & MODE_RECMASK) && f->mmcpos > f->endpos)
		f->endpos = f->mmcpos;
	if (f->hdr == HDR_WAV)
		f->wbytes = WAV_DATAMAX - f->mmcpos;
	f->rbytes = f->endpos - f->mmcpos;
	wav_reset(f);
	wav_allocbuf(f);
	return 1;
}
Example #3
0
/*
 * Callback invoked when slot is gone
 */
void
wav_quitreq(void *arg)
{
	struct wav *f = (struct wav *)arg;

#ifdef DEBUG
	if (debug_level >= 3) {
		wav_dbg(f);
		dbg_puts(": slot gone\n");
	}
#endif
	if (f->pstate != WAV_RUN)
		wav_exit(f);
}
Example #4
0
static int isowavInit()
{
	wav_exit();

	isowavTOC = (isowavCDROM_TOC*)malloc(sizeof(isowavCDROM_TOC));
	if (isowavTOC == NULL) {
		return 1;
	}
	memset(isowavTOC, 0, sizeof(isowavCDROM_TOC));

	TCHAR* filename = ExtractFilename(CDEmuImage);

	if (_tcslen(filename) < 4) {
		return 1;
	}

	if (_tcscmp(_T(".cue"), filename + _tcslen(filename) - 4) == 0) {
		if (isowavParseCueFile()) {
			dprintf(_T("*** Couldn't parse .cue file\n"));
			isowavExit();

			return 1;
		}
	} else {
		if (isowavTestISO()) {
			dprintf(_T("*** Couldn't find .iso / .bin file\n"));
			isowavExit();

			return 1;
		}
	}

	dprintf(_T("    CD image TOC read\n"));
	
	for (int i = isowavTOC->FirstTrack - 1; i < isowavTOC->LastTrack; i++) {
		dprintf(_T("    track %2i start %02i:%02i:%02i control 0x%02X %s\n"), isowavTOC->TrackData[i].TrackNumber, isowavTOC->TrackData[i].Address[1], isowavTOC->TrackData[i].Address[2], isowavTOC->TrackData[i].Address[3], isowavTOC->TrackData[i].Control, isowavTOC->TrackData[i].Filename);
	}
	dprintf(_T("    total running time %02i:%02i:%02i\n"), isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[1], isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[2], isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[3]);

	CDEmuStatus = idle;
	
	return 0;
}
Example #5
0
static int isowavExit()
{
	wav_exit();

	if (isowavFile) {
		fclose(isowavFile);
		isowavFile = NULL;
	}

	isowavTrack    = 0;
	isowavLBA      = 0;

	if (isowavTOC) {
		for (int i = 0; i < MAXIMUM_NUMBER_TRACKS; i++) {
			free(isowavTOC->TrackData[i].Filename);
		}

		free(isowavTOC);
		isowavTOC = NULL;
	}

	return 0;
}
Example #6
0
/*
 * callback to stop the stream, invoked by the MIDI control code
 */
void
wav_stopreq(void *arg)
{
	struct wav *f = (struct wav *)arg;

#ifdef DEBUG
	if (debug_level >= 2) {
		wav_dbg(f);
		dbg_puts(": stopping");
		if (f->pstate != WAV_INIT && (f->mode & MODE_RECMASK)) {
			dbg_puts(", ");
			dbg_putu(f->endpos);
			dbg_puts(" bytes recorded");
		}
		dbg_puts("\n");
	}
#endif
	if (!f->mmc) {
		wav_exit(f);
		return;
	}
	(void)wav_seekmmc(f);
}