gvfs-02-enable-cdda-without-cdio.diff revision 12961
12961N/A--- /usr/tmp/clean/gvfs-0.2.2/configure.ac 2008-03-28 12:44:50.000000000 +0000
12961N/A+++ gvfs-0.2.2/configure.ac 2008-04-25 15:34:27.524495000 +0100
12961N/A@@ -239,8 +239,12 @@
12961N/A
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 fi
12961N/A+ if test "x$msg_cdda" == "xno"; then
12961N/A+ msg_cdda=yes
12961N/A+ fi
12961N/A+ AC_DEFINE(HAVE_CDDA, 1, [Define to 1 if CDDA is going to be built])
12961N/A fi
12961N/A
12961N/A AC_SUBST(CDDA_LIBS)
12961N/A--- /usr/tmp/clean/gvfs-0.2.3/daemon/gvfsbackendcdda.c 2008-04-08 02:27:43.000000000 +0100
12961N/A+++ gvfs-0.2.3/daemon/gvfsbackendcdda.c 2008-04-28 08:54:49.680400000 +0100
12961N/A@@ -52,8 +52,10 @@
12961N/A /* see this bug http://bugzilla.gnome.org/show_bug.cgi?id=518284 */
12961N/A #define _I18N_LATER(x) x
12961N/A
12961N/A+#ifdef HAVE_CDIO
12961N/A #define DO_NOT_WANT_PARANOIA_COMPATIBILITY
12961N/A #include <cdio/paranoia.h>
12961N/A+#endif
12961N/A
12961N/A /* TODO:
12961N/A *
12961N/A@@ -96,7 +98,9 @@
12961N/A guint64 size;
12961N/A
12961N/A char *device_path;
12961N/A+#ifdef HAVE_CDIO
12961N/A cdrom_drive_t *drive;
12961N/A+#endif
12961N/A int num_open_files;
12961N/A };
12961N/A
12961N/A@@ -108,11 +112,13 @@
12961N/A g_free (cdda_backend->device_path);
12961N/A cdda_backend->device_path = NULL;
12961N/A
12961N/A+#ifdef HAVE_CDIO
12961N/A if (cdda_backend->drive != NULL)
12961N/A {
12961N/A cdio_cddap_close (cdda_backend->drive);
12961N/A cdda_backend->drive = NULL;
12961N/A }
12961N/A+#endif
12961N/A }
12961N/A
12961N/A static void
12961N/A@@ -268,10 +274,15 @@
12961N/A return;
12961N/A }
12961N/A
12961N/A+#ifdef __sun
12961N/A+ cdda_backend->device_path = g_strdup_printf ("/dev/dsk/%s", host);
12961N/A+#else
12961N/A cdda_backend->device_path = g_strdup_printf ("/dev/%s", host);
12961N/A+#endif
12961N/A
12961N/A find_udi_for_device (cdda_backend);
12961N/A
12961N/A+#ifdef HAVE_CDIO
12961N/A cdda_backend->drive = cdio_cddap_identify (cdda_backend->device_path, 0, NULL);
12961N/A if (cdda_backend->drive == NULL)
12961N/A {
12961N/A@@ -292,6 +303,7 @@
12961N/A release_device (cdda_backend);
12961N/A return;
12961N/A }
12961N/A+#endif
12961N/A
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@@ -389,7 +401,9 @@
12961N/A }
12961N/A
12961N/A typedef struct {
12961N/A+#ifdef HAVE_CDIO
12961N/A cdrom_paranoia_t *paranoia;
12961N/A+#endif
12961N/A
12961N/A long size; /* size of file being read */
12961N/A long header_size; /* size of the header */
12961N/A@@ -407,15 +421,19 @@
12961N/A * is to avoid seeking back if fewer bytes than whole sector is requested.
12961N/A */
12961N/A long buf_at_sector_num; /* the sector that is cached */
12961N/A+#ifdef HAVE_CDIO
12961N/A char buf_at_sector[CDIO_CD_FRAMESIZE_RAW]; /* the data of the sector */
12961N/A+#endif
12961N/A
12961N/A } ReadHandle;
12961N/A
12961N/A static void
12961N/A free_read_handle (ReadHandle *read_handle)
12961N/A {
12961N/A+#ifdef HAVE_CDIO
12961N/A if (read_handle->paranoia != NULL)
12961N/A cdio_paranoia_free (read_handle->paranoia);
12961N/A+#endif
12961N/A g_free (read_handle->header);
12961N/A g_free (read_handle);
12961N/A }
12961N/A@@ -449,7 +467,11 @@
12961N/A /* TODO: fill in from metadata */
12961N/A artist = NULL;
12961N/A title = NULL;
12961N/A+#ifdef HAVE_CDIO
12961N/A software = "gvfs-cdda using libcdio " CDIO_VERSION;
12961N/A+#else
12961N/A+ software = "gvfs-cdda not using libcdio ";
12961N/A+#endif
12961N/A
12961N/A artist_len = 0;
12961N/A title_len = 0;
12961N/A@@ -552,20 +574,25 @@
12961N/A return;
12961N/A }
12961N/A
12961N/A-
12961N/A+#ifdef HAVE_CDIO
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+#endif
12961N/A read_handle->sector_cursor = -1;
12961N/A
12961N/A read_handle->cursor = 0;
12961N/A read_handle->buf_at_sector_num = -1;
12961N/A+#ifdef HAVE_CDIO
12961N/A read_handle->content_size = ((read_handle->last_sector - read_handle->first_sector) + 1) * CDIO_CD_FRAMESIZE_RAW;
12961N/A+#endif
12961N/A
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
12961N/A+#ifdef HAVE_CDIO
12961N/A read_handle->paranoia = cdio_paranoia_init (cdda_backend->drive);
12961N/A cdio_paranoia_modeset (read_handle->paranoia, PARANOIA_MODE_DISABLE);
12961N/A+#endif
12961N/A
12961N/A cdda_backend->num_open_files++;
12961N/A
12961N/A@@ -575,10 +602,12 @@
12961N/A }
12961N/A
12961N/A /* We have to pass in a callback to paranoia_read, even though we don't use it */
12961N/A+#ifdef HAVE_CDIO
12961N/A static void
12961N/A paranoia_callback (long int inpos, paranoia_cb_mode_t function)
12961N/A {
12961N/A }
12961N/A+#endif
12961N/A
12961N/A
12961N/A static void
12961N/A@@ -619,16 +648,20 @@
12961N/A
12961N/A cursor_in_stream = read_handle->cursor - read_handle->header_size;
12961N/A
12961N/A+#ifdef HAVE_CDIO
12961N/A desired_sector = cursor_in_stream / CDIO_CD_FRAMESIZE_RAW + read_handle->first_sector;
12961N/A+#endif
12961N/A
12961N/A if (desired_sector == read_handle->buf_at_sector_num)
12961N/A {
12961N/A /* got it cached */
12961N/A
12961N/A /* skip some bytes */
12961N/A+#ifdef HAVE_CDIO
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+#endif
12961N/A
12961N/A //g_warning ("read from cache for cursor @ %ld", read_handle->buf_at_sector_num);
12961N/A }
12961N/A@@ -637,16 +670,20 @@
12961N/A /* first check that we're at the right sector */
12961N/A if (desired_sector != read_handle->sector_cursor)
12961N/A {
12961N/A+#ifdef HAVE_CDIO
12961N/A cdio_paranoia_seek (read_handle->paranoia, desired_sector, SEEK_SET);
12961N/A+#endif
12961N/A read_handle->sector_cursor = desired_sector;
12961N/A //g_warning ("seeking cursor to %ld", read_handle->sector_cursor);
12961N/A }
12961N/A
12961N/A /* skip some bytes */
12961N/A+#ifdef HAVE_CDIO
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
12961N/A readbuf = (char *) cdio_paranoia_read (read_handle->paranoia, paranoia_callback);
12961N/A+#endif
12961N/A
12961N/A if (readbuf == NULL)
12961N/A {
12961N/A@@ -660,12 +697,14 @@
12961N/A }
12961N/A
12961N/A read_handle->buf_at_sector_num = read_handle->sector_cursor;
12961N/A+#ifdef HAVE_CDIO
12961N/A memcpy (read_handle->buf_at_sector, readbuf, CDIO_CD_FRAMESIZE_RAW);
12961N/A
12961N/A read_handle->sector_cursor++;
12961N/A
12961N/A readbuf += skip_bytes;
12961N/A bytes_read = CDIO_CD_FRAMESIZE_RAW - skip_bytes;
12961N/A+#endif
12961N/A
12961N/A
12961N/A }
12961N/A@@ -757,9 +796,11 @@
12961N/A long content_size;
12961N/A GIcon *icon;
12961N/A
12961N/A+#ifdef HAVE_CDIO
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+#endif
12961N/A
12961N/A header = create_header (cdda_backend, &header_size, content_size);
12961N/A g_free (header);
12961N/A@@ -820,19 +861,23 @@
12961N/A return;
12961N/A }
12961N/A
12961N/A+#ifdef HAVE_CDIO
12961N/A if (track_num > cdda_backend->drive->tracks)
12961N/A {
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 return;
12961N/A }
12961N/A+#endif
12961N/A
12961N/A+#ifdef HAVE_CDIO
12961N/A if (! cdio_cddap_track_audiop (cdda_backend->drive, track_num))
12961N/A {
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 return;
12961N/A }
12961N/A+#endif
12961N/A
12961N/A set_info_for_track (cdda_backend, info, track_num);
12961N/A }
12961N/A@@ -856,6 +901,7 @@
12961N/A //g_warning ("enumerate (%s)", filename);
12961N/A
12961N/A l = NULL;
12961N/A+#ifdef HAVE_CDIO
12961N/A for (n = 1; n <= cdda_backend->drive->tracks; n++)
12961N/A {
12961N/A char *name;
12961N/A@@ -875,6 +921,7 @@
12961N/A
12961N/A l = g_list_append (l, info);
12961N/A }
12961N/A+#endif
12961N/A
12961N/A g_vfs_job_succeeded (G_VFS_JOB (job));
12961N/A
12961N/A--- /usr/tmp/clean/gvfs-0.2.3/daemon/cdda.mount.in 2008-04-08 02:27:43.000000000 +0100
12961N/A+++ gvfs-0.2.3/daemon/cdda.mount.in 2008-04-28 08:56:52.278895000 +0100
12961N/A@@ -1,4 +1,4 @@
12961N/A [Mount]
12961N/A Type=cdda
12961N/A Exec=@libexecdir@/gvfsd-cdda
12961N/A-AutoMount=false
12961N/A+AutoMount=true