static gboolean prepare_params (ThreadBurnIsoParams *params, struct burn_drive *drive, gchar **failure_msg) { struct burn_write_opts * burn_options; burn_options = burn_write_opts_new (drive); burn_write_opts_set_perform_opc (burn_options, 0); burn_write_opts_set_multi (burn_options, 0); burn_write_opts_set_simulate(burn_options, params->dummy ? 1 : 0); burn_write_opts_set_underrun_proof (burn_options, params->burnfree ? 1 : 0); /* * 32 is the number of blocks to skip. This will increase reliability with BD disks that * are used for multisessions. xfburn doesn't support this, but other programs may be using * the disc that way, so we respect that here. */ burn_write_opts_set_stream_recording (burn_options, params->stream_recording ? 32 : 0); if (!xfburn_set_write_mode (burn_options, params->write_mode, params->disc, WRITE_MODE_TAO)) { burn_write_opts_free (burn_options); *failure_msg = _("Burn mode is not currently implemented."); return FALSE; } params->burn_options = burn_options; params->disc = burn_disc_create (); params->session = burn_session_create (); params->track = burn_track_create (); if (!create_disc (params, failure_msg)) { return FALSE; } return TRUE; }
static DB_playItem_t * insert_disc (ddb_playlist_t *plt, DB_playItem_t *after, const char *path, const track_t single_track, CdIo_t* cdio) { struct cddb_thread_params *p = calloc(1, sizeof(struct cddb_thread_params)); if (!p) { return NULL; } p->disc = create_disc(cdio); if (!p->disc) { cleanup_thread_params(p); return NULL; } const track_t tracks = single_track ? 1 : cddb_disc_get_track_count(p->disc); p->items = calloc(tracks+1, sizeof(*p->items)); if (!p->items) { cleanup_thread_params(p); return NULL; } const unsigned long discid = cddb_disc_get_discid(p->disc); DB_playItem_t *inserted = NULL; const track_t first_track = single_track ? single_track : cdio_get_first_track_num(cdio); track_t item_count = 0; for (track_t i = 0; i < tracks; i++) { if (cdio_get_track_format(cdio, first_track+i) == TRACK_FORMAT_AUDIO) { trace("inserting track %d from %s\n", first_track+i, path); inserted = insert_track(plt, after, path, first_track+i, cdio, discid); p->items[item_count++] = inserted; after = inserted; } } intptr_t tid = 0; if (item_count) { const int got_cdtext = read_disc_cdtext(cdio, p->items, tracks); const int prefer_cdtext = deadbeef->conf_get_int("cdda.prefer_cdtext", DEFAULT_PREFER_CDTEXT); const int enable_cddb = deadbeef->conf_get_int("cdda.freedb.enable", DEFAULT_USE_CDDB); if (!(got_cdtext && prefer_cdtext) && enable_cddb) { trace("cdda: querying freedb...\n"); tid = deadbeef->thread_start(cddb_thread, p); if (tid) { deadbeef->thread_detach(tid); } } } if (!tid) { cleanup_thread_params(p); } return inserted; }
static int cda_init (DB_fileinfo_t *_info, DB_playItem_t *it) { deadbeef->pl_lock(); const char *uri = deadbeef->pl_find_meta(it, ":URI"); const char *nr = uri ? strchr(uri, '#') : NULL; if (!nr || nr == uri) { deadbeef->pl_unlock(); trace ("cdda: bad name: %s\n", uri); return -1; } trace ("cdda: init %s\n", uri); const int track_nr = atoi(nr+1); const size_t device_length = nr - uri; char device[device_length+1]; strncpy(device, uri, device_length); device[device_length] = '\0'; deadbeef->pl_unlock(); cdda_info_t *info = (cdda_info_t *)_info; info->cdio = cdio_open(device, DRIVER_UNKNOWN); if (!info->cdio) { trace ("cdda: Could not open CD device\n"); return -1; } const int need_bitrate = info->hints & DDB_DECODER_HINT_NEED_BITRATE; const int drive_speed = deadbeef->conf_get_int("cdda.drive_speed", 2); cdio_set_speed(info->cdio, need_bitrate && drive_speed < 5 ? 1<<drive_speed : -1); cddb_disc_t *disc = create_disc(info->cdio); if (!disc) { return -1; } const unsigned long discid = cddb_disc_get_discid(disc); cddb_disc_destroy(disc); deadbeef->pl_lock(); const char *discid_hex = deadbeef->pl_find_meta(it, CDDB_DISCID_TAG); const unsigned long trk_discid = discid_hex ? strtoul(discid_hex, NULL, 16) : 0; deadbeef->pl_unlock(); if (trk_discid != discid) { trace ("cdda: the track belongs to another disc (%x vs %x), skipped\n", trk_discid, discid); return -1; } if (cdio_get_track_format(info->cdio, track_nr) != TRACK_FORMAT_AUDIO) { trace ("cdda: Not an audio track (%d)\n", track_nr); return -1; } info->first_sector = cdio_get_track_lsn(info->cdio, track_nr); info->current_sector = info->first_sector; info->last_sector = info->first_sector + cdio_get_track_sec_count(info->cdio, track_nr) - 1; trace("cdio nchannels (should always be 2 for an audio track): %d\n", cdio_get_track_channels (info->cdio, track_nr)); if (info->first_sector == CDIO_INVALID_LSN || info->last_sector <= info->first_sector) { trace ("cdda: invalid track\n"); return -1; } #if USE_PARANOIA if (cdio_get_driver_id(info->cdio) != DRIVER_NRG) { info->cdrom = cdda_identify(device, CDDA_MESSAGE_FORGETIT, NULL); if (info->cdrom) { cdda_open(info->cdrom); info->paranoia = paranoia_init(info->cdrom); } if (!info->paranoia) { trace ("cdda: cannot re-open %s for paranoia\n", device); return -1; } const int no_paranoia = need_bitrate || !deadbeef->conf_get_int("cdda.paranoia", 0); if (no_paranoia) { paranoia_cachemodel_size(info->paranoia, 100); } paranoia_modeset(info->paranoia, no_paranoia ? PARANOIA_MODE_DISABLE : PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP); paranoia_seek(info->paranoia, info->first_sector, SEEK_SET); } #endif return 0; }
/* * create_match_state * * TODO: Fill this function block in once we tie down what this actually does. * * Returns: A pointer to the new object or NULL on failure. */ MATCH_STATE *create_match_state(unsigned int hard_cap, unsigned int game_length_s, char *disc_graphic_filename, char *grass_tile_filename, char *offensive_xml_file, char *defensive_xml_file, int (*state_callback)(AUTOMATON_STATE ***, int), int (*event_callback)(AUTOMATON_EVENT ***)) { MATCH_STATE *state; /* * Allocate the memory for the new object. */ state = (MATCH_STATE *) DT_MALLOC(sizeof(MATCH_STATE)); /* * Set the throw to null to start, this will be created when the user starts * a throw. */ state->match_throw = create_throw(); /* * Create a disc object for this game. */ state->disc = create_disc(disc_graphic_filename); /* * The disc path starts as null so that we know when the first one has * been created. */ state->disc_path = NULL; /* * Initialise the pitch objects associated with the match. */ state->pitch = create_pitch(grass_tile_filename); /* * Initialise the camera handler associated with the match. */ state->camera_handler = create_camera_handler(); /* * Initialise the input handlers for the mouse and the keyboard. */ state->key_input_state = create_key_input_state(); state->mouse_input_state = create_mouse_input_state(); /* * Initialise the animation handler. This does not load any animations as this * is done by the load_animation_data function. */ state->animation_handler = create_animation_handler(); /* * Create the timer objects for use in the game. */ state->match_stats = create_match_stats(game_length_s, hard_cap); /* * Create the automaton handler, passing in the location of the two xml files * means that this whole structure is constructed here. This will tell us * what the default states are for the two teams. */ state->automaton_handler = create_automaton_handler(offensive_xml_file, defensive_xml_file, state_callback, event_callback, state); if (NULL == state->automaton_handler) { destroy_match_state(state); state = NULL; goto EXIT_LABEL; } /* * Create the teams. */ state->teams[0] = create_team(); state->teams[1] = create_team(); state->players_per_team = PLAYERS_PER_TEAM; create_players(state->teams, state->players_per_team, state->automaton_handler); EXIT_LABEL: return(state); }