Ejemplo n.º 1
0
void cdrom_image_device::device_stop()
{
	if (m_cdrom_handle)
		cdrom_close(m_cdrom_handle);
	if( m_self_chd.opened() )
		m_self_chd.close();
}
Ejemplo n.º 2
0
void device_unload_mess_cd(mess_image *image)
{
	struct mess_cd *cd = get_drive(image);
	assert(cd->cdrom_handle);
	cdrom_close(cd->cdrom_handle);
	cd->cdrom_handle = NULL;
}
Ejemplo n.º 3
0
void cdrom_image_device::call_unload()
{
	assert(m_cdrom_handle);
	cdrom_close(m_cdrom_handle);
	m_cdrom_handle = NULL;
	if( m_self_chd.opened() )
		m_self_chd.close();
}
Ejemplo n.º 4
0
Archivo: chd_cd.c Proyecto: bji/libmame
static DEVICE_IMAGE_UNLOAD(cdrom)
{
	dev_cdrom_t	*cdrom = get_safe_token( &image.device() );

	assert( cdrom->cdrom_handle );
	cdrom_close( cdrom->cdrom_handle );
	cdrom->cdrom_handle = NULL;
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
    int randomReps = RANDOM_ACCESS_MAX_REPS;

    srand(time(NULL));

    output = fopen("results.csv", "w");
    cdrom_init(&cd);

    cdrom_open(&cd, "/dev/sr0");

    if(strcmp(argv[1], "speed") == 0)
    {
        speedTest(NULL);
    }
    else if(strcmp(argv[1], "random") == 0)
    {
        randomReps = atoi(argv[2]);

        if(randomReps <= RANDOM_ACCESS_MAX_REPS)
        {
            if(randomReps > 20)
            {
                randomAccessTest(randomReps, FALSE);
            }
            else
            {
                randomAccessTest(randomReps, TRUE);
            }
        }
        else
        {
            g_print("Too Many Reps\n");
        }
    }
    else if(strcmp(argv[1], "seek") == 0)
    {
        seekTest();
    }
    else
    {
        g_print("Usage: eaa (speed|random count)\n");
    }

    fclose(output);
    cdrom_close(&cd);

    return 0;
}
Ejemplo n.º 6
0
// global functions
void stvcd_reset(void)
{
	state = STATE_UNK;
	hirqmask = 0xffff;
	hirqreg = 0;
	cr1 = 'C';
	cr2 = ('D'<<8) | 'B';
	cr3 = ('L'<<8) | 'O';
	cr4 = ('C'<<8) | 'K';
	cd_stat = 0;

	if (curdir != (direntryT *)NULL)
		free((void *)curdir);
	curdir = (direntryT *)NULL;		// no directory yet

	// reset flag vars
	buffull = sectorstore = 0;

	freeblocks = 200;

	// open device
	if (cdrom)
	{
		cdrom_close(cdrom);
		cdrom = (cdrom_file *)NULL;
	}

	#ifdef MESS
	cdrom = mess_cd_get_cdrom_file_by_number(0);
	#else
	cdrom = cdrom_open(get_disk_handle(0));
	#endif

	memset(databuf, 0, (512*1024));

	dbufptr = 0;
	dbuflen = 0;
	wordsread = 0;

	if (cdrom)
	{
		logerror("Opened CD-ROM successfully, reading root directory\n");
		read_new_dir(0xffffff);	// read root directory
	}
}
Ejemplo n.º 7
0
int
cdrom_open() {
	int	n;
	extern void update_title();

	if (cdrom_fd != -1)
		return(cdi.curtrack);

	if (app_data.device != NULL) {
		if ((cdrom_fd = open(app_data.device, O_RDONLY)) == -1) {
			perror(app_data.device);
			return(-1);
		}
	} else {
		if (   (cdrom_fd = open(cdrom, O_RDONLY)) == -1
		    && (cdrom_fd = open(cdrom1, O_RDONLY)) == -1
		   ) {
			perror("open: ");
			return(-1);
		}
	}

	if (cdrom_get_times() == -1) {
		cdrom_close();
		return(-1);
	}

	if ((n = cdrom_get_curtrack()) == -1)
		return(-1);

	get_stored_info();

	update_title();

	if (cdi.state & CDROM_STATE_PLAY)
		cdi.curtrack = n;

	if (cdi.state & CDROM_STATE_SHUFFLE)
		shuffle_setup();

	return(cdi.curtrack);
}
Ejemplo n.º 8
0
bool cdrom_image_device::call_load()
{
	chd_error   err = (chd_error)0;
	chd_file    *chd = NULL;
	astring tempstring;

	if (m_cdrom_handle)
		cdrom_close(m_cdrom_handle);

	if (software_entry() == NULL)
	{
		if (strstr(m_image_name,".chd") && is_loaded()) {
			err = m_self_chd.open( *image_core_file() );    /* CDs are never writeable */
			if ( err )
				goto error;
			chd = &m_self_chd;
		}
	} else {
		chd  = get_disk_handle(device().machine(), device().subtag(tempstring,"cdrom"));
	}

	/* open the CHD file */
	if (chd) {
		m_cdrom_handle = cdrom_open( chd );
	} else {
		m_cdrom_handle = cdrom_open( m_image_name );
	}
	if ( ! m_cdrom_handle )
		goto error;

	return IMAGE_INIT_PASS;

error:
	if ( chd && chd == &m_self_chd )
		m_self_chd.close( );
	if ( err )
		seterror( IMAGE_ERROR_UNSPECIFIED, chd_file::error_string( err ) );
	return IMAGE_INIT_FAIL;
}
Ejemplo n.º 9
0
image_init_result cdrom_image_device::call_load()
{
	chd_error   err = (chd_error)0;
	chd_file    *chd = nullptr;

	if (m_cdrom_handle)
		cdrom_close(m_cdrom_handle);

	if (software_entry() == nullptr)
	{
		if (is_filetype("chd") && is_loaded()) {
			err = m_self_chd.open( image_core_file() );    /* CDs are never writeable */
			if ( err )
				goto error;
			chd = &m_self_chd;
		}
	} else {
		chd = device().machine().rom_load().get_disk_handle(device().subtag("cdrom").c_str());
	}

	/* open the CHD file */
	if (chd) {
		m_cdrom_handle = cdrom_open( chd );
	} else {
		m_cdrom_handle = cdrom_open(m_image_name.c_str());
	}
	if ( ! m_cdrom_handle )
		goto error;

	return image_init_result::PASS;

error:
	if ( chd && chd == &m_self_chd )
		m_self_chd.close( );
	if ( err )
		seterror( IMAGE_ERROR_UNSPECIFIED, chd_file::error_string( err ) );
	return image_init_result::FAIL;
}
Ejemplo n.º 10
0
void SysMediaArrived(const char *path, int type)
{
	// Replace the "cdrom" entry (we are polling, it's unique)
	if (type == MEDIA_CD && !PrefsFindBool("nocdrom"))
		PrefsReplaceString("cdrom", path);

	// Wait for media to be available for reading
	if (open_su_file_handles) {
		const int MAX_WAIT = 5;
		for (int i = 0; i < MAX_WAIT; i++) {
			if (access(path, R_OK) == 0)
				break;
			switch (errno) {
			case ENOENT: // Unlikely
			case EACCES: // MacOS X is mounting the media
				sleep(1);
				continue;
			}
			printf("WARNING: Cannot access %s (%s)\n", path, strerror(errno));
			return;
		}
	}

	for (open_su_file_handle *p = open_su_file_handles; p != NULL; p = p->next) {
		su_file_handle * const fh = p->fh;

		// Re-open CD-ROM device
		if (fh->is_cdrom && type == MEDIA_CD) {
			cdrom_close(fh);
			if (cdrom_open(fh, path)) {
				fh->is_media_present = true;
				MountVolume(fh);
			}
		}
	}
}