12961N/A if test "x$msg_cdda" == "xyes"; then
12961N/A PKG_CHECK_MODULES(CDDA, libcdio_paranoia hal >= $HAL_REQUIRED)
12961N/A- AC_DEFINE(HAVE_CDDA, 1, [Define to 1 if CDDA is going to be built])
12961N/A+ AC_DEFINE(HAVE_CDIO, 1, [Define to 1 if CDDA is going to be built with libcdio])
12961N/A+ if test "x$msg_cdda" == "xno"; then
12961N/A+ AC_DEFINE(HAVE_CDDA, 1, [Define to 1 if CDDA is going to be built])
12961N/A #define DO_NOT_WANT_PARANOIA_COMPATIBILITY
12961N/A g_free (cdda_backend->device_path);
12961N/A cdda_backend->device_path = NULL;
12961N/A if (cdda_backend->drive != NULL)
12961N/A cdio_cddap_close (cdda_backend->drive);
12961N/A cdda_backend->device_path = g_strdup_printf ("/dev/%s", host);
12961N/A find_udi_for_device (cdda_backend);
12961N/A cdda_backend->drive = cdio_cddap_identify (cdda_backend->device_path, 0, NULL);
12961N/A if (cdda_backend->drive == NULL)
12961N/A /* Translator: %s is the device the disc is inserted into */
12961N/A fuse_name = g_strdup_printf (_("cdda mount on %s"), host);
12961N/A long size; /* size of file being read */
12961N/A long header_size; /* size of the header */
12961N/A * is to avoid seeking back if fewer bytes than whole sector is requested.
12961N/A long buf_at_sector_num; /* the sector that is cached */
12961N/A char buf_at_sector[CDIO_CD_FRAMESIZE_RAW]; /* the data of the sector */
12961N/A free_read_handle (ReadHandle *read_handle)
12961N/A if (read_handle->paranoia != NULL)
12961N/A cdio_paranoia_free (read_handle->paranoia);
12961N/A /* TODO: fill in from metadata */
12961N/A software = "gvfs-cdda using libcdio " CDIO_VERSION;
12961N/A+ software = "gvfs-cdda not using libcdio ";
12961N/A read_handle->first_sector = cdio_cddap_track_firstsector (cdda_backend->drive, track_num);
12961N/A read_handle->last_sector = cdio_cddap_track_lastsector (cdda_backend->drive, track_num);
12961N/A read_handle->sector_cursor = -1;
12961N/A read_handle->buf_at_sector_num = -1;
12961N/A read_handle->content_size = ((read_handle->last_sector - read_handle->first_sector) + 1) * CDIO_CD_FRAMESIZE_RAW;
12961N/A read_handle->header = create_header (cdda_backend, &(read_handle->header_size), read_handle->content_size);
12961N/A read_handle->size = read_handle->header_size + read_handle->content_size;
12961N/A read_handle->paranoia = cdio_paranoia_init (cdda_backend->drive);
12961N/A cdio_paranoia_modeset (read_handle->paranoia, PARANOIA_MODE_DISABLE);
12961N/A cdda_backend->num_open_files++;
12961N/A /* We have to pass in a callback to paranoia_read, even though we don't use it */
12961N/A paranoia_callback (long int inpos, paranoia_cb_mode_t function)
12961N/A cursor_in_stream = read_handle->cursor - read_handle->header_size;
12961N/A desired_sector = cursor_in_stream / CDIO_CD_FRAMESIZE_RAW + read_handle->first_sector;
12961N/A if (desired_sector == read_handle->buf_at_sector_num)
12961N/A skip_bytes = cursor_in_stream - (desired_sector - read_handle->first_sector) * CDIO_CD_FRAMESIZE_RAW;
12961N/A readbuf = read_handle->buf_at_sector + skip_bytes;
12961N/A bytes_read = CDIO_CD_FRAMESIZE_RAW - skip_bytes;
12961N/A //g_warning ("read from cache for cursor @ %ld", read_handle->buf_at_sector_num);
12961N/A /* first check that we're at the right sector */
12961N/A if (desired_sector != read_handle->sector_cursor)
12961N/A cdio_paranoia_seek (read_handle->paranoia, desired_sector, SEEK_SET);
12961N/A read_handle->sector_cursor = desired_sector;
12961N/A //g_warning ("seeking cursor to %ld", read_handle->sector_cursor);
12961N/A skip_bytes = cursor_in_stream - (read_handle->sector_cursor - read_handle->first_sector) * CDIO_CD_FRAMESIZE_RAW;
12961N/A //g_warning ("advanced cursor to %ld", read_handle->sector_cursor);
12961N/A readbuf = (char *) cdio_paranoia_read (read_handle->paranoia, paranoia_callback);
12961N/A read_handle->buf_at_sector_num = read_handle->sector_cursor;
12961N/A memcpy (read_handle->buf_at_sector, readbuf, CDIO_CD_FRAMESIZE_RAW);
12961N/A bytes_read = CDIO_CD_FRAMESIZE_RAW - skip_bytes;
12961N/A first = cdio_cddap_track_firstsector (cdda_backend->drive, track_num);
12961N/A last = cdio_cddap_track_lastsector (cdda_backend->drive, track_num);
12961N/A content_size = (last - first + 1) * CDIO_CD_FRAMESIZE_RAW;
12961N/A header = create_header (cdda_backend, &header_size, content_size);
12961N/A if (track_num > cdda_backend->drive->tracks)
12961N/A error = g_error_new (G_IO_ERROR, G_IO_ERROR_NOT_FOUND, _("File doesn't exist"));
12961N/A g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
12961N/A if (! cdio_cddap_track_audiop (cdda_backend->drive, track_num))
12961N/A error = g_error_new (G_IO_ERROR, G_IO_ERROR_NOT_FOUND, _("The file does not exist or isn't an audio track"));
12961N/A g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
12961N/A set_info_for_track (cdda_backend, info, track_num);
12961N/A //g_warning ("enumerate (%s)", filename);
12961N/A for (n = 1; n <= cdda_backend->drive->tracks; n++)
12961N/A g_vfs_job_succeeded (G_VFS_JOB (job));