[gnome-disk-utility] Remove css bits for now
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Remove css bits for now
- Date: Wed, 1 Aug 2012 16:45:16 +0000 (UTC)
commit 0a94e46063277fb6c066ff9be9c283cb09e359ee
Author: David Zeuthen <zeuthen gmail com>
Date: Wed Aug 1 12:44:06 2012 -0400
Remove css bits for now
... to do it right, it's a bit more complicated and involves
title-specific keys etc. Don't bother for now.
Signed-off-by: David Zeuthen <zeuthen gmail com>
src/disks/gducreatediskimagedialog.c | 243 +---------------------------------
1 files changed, 7 insertions(+), 236 deletions(-)
---
diff --git a/src/disks/gducreatediskimagedialog.c b/src/disks/gducreatediskimagedialog.c
index 7282927..9395a0a 100644
--- a/src/disks/gducreatediskimagedialog.c
+++ b/src/disks/gducreatediskimagedialog.c
@@ -50,166 +50,6 @@
*/
/* ---------------------------------------------------------------------------------------------------- */
-/* libdvdcss support - see http://www.videolan.org/developers/libdvdcss.html */
-
-#define DVDCSS_BLOCK_SIZE 2048
-#define DVDCSS_READ_DECRYPT (1 << 0)
-
-struct dvdcss_s;
-typedef struct dvdcss_s * dvdcss_t;
-static dvdcss_t (*dvdcss_open) (const char *psz_target) = NULL;
-static int (*dvdcss_close) (dvdcss_t ctx) = NULL;
-static int (*dvdcss_seek) (dvdcss_t ctx,
- int i_blocks,
- int i_flags ) = NULL;
-static int (*dvdcss_read) (dvdcss_t ctx,
- void *p_buffer,
- int i_blocks,
- int i_flags ) = NULL;
-static int (*dvdcss_readv) (dvdcss_t ctx,
- void *p_iovec,
- int i_blocks,
- int i_flags ) = NULL;
-static char * (*dvdcss_error) (dvdcss_t ctx) = NULL;
-
-static gboolean
-have_dvdcss (void)
-{
- static gsize once = 0;
- static gboolean available = FALSE;
-
- if (g_once_init_enter (&once))
- {
- GModule *module = NULL;
-
- module = g_module_open ("libdvdcss.so.2", G_MODULE_BIND_LOCAL);
- if (module == NULL)
- goto out;
- if (!g_module_symbol (module, "dvdcss_open", (gpointer*) &dvdcss_open) || dvdcss_open == NULL)
- goto out;
- if (!g_module_symbol (module, "dvdcss_close", (gpointer*) &dvdcss_close) || dvdcss_close == NULL)
- goto out;
- if (!g_module_symbol (module, "dvdcss_seek", (gpointer*) &dvdcss_seek) || dvdcss_seek == NULL)
- goto out;
- if (!g_module_symbol (module, "dvdcss_read", (gpointer*) &dvdcss_read) || dvdcss_read == NULL)
- goto out;
- if (!g_module_symbol (module, "dvdcss_readv", (gpointer*) &dvdcss_readv) || dvdcss_readv == NULL)
- goto out;
- if (!g_module_symbol (module, "dvdcss_error", (gpointer*) &dvdcss_error) || dvdcss_error == NULL)
- goto out;
-
- available = TRUE;
-
- out:
- if (!available)
- {
- if (module != NULL)
- g_module_close (module);
- }
- g_once_init_leave (&once, (gsize) 1);
- }
- return available;
-}
-
-/* async dvdcss_read(): */
-
-typedef struct
-{
- dvdcss_t ctx;
- guchar *buffer;
- gsize num_bytes;
-} ReadDVDCSSData;
-
-static void
-read_dvdcss_data_free (ReadDVDCSSData *data)
-{
- g_slice_free (ReadDVDCSSData, data);
-}
-
-static void
-read_dvdcss_in_thread (GSimpleAsyncResult *simple,
- GObject *object,
- GCancellable *cancellable)
-{
- ReadDVDCSSData *data;
- int num_blocks_read;
-
- data = g_object_get_data (G_OBJECT (simple), "x-data");
- g_assert (data != NULL);
-
- num_blocks_read = dvdcss_read (data->ctx,
- data->buffer,
- data->num_bytes / DVDCSS_BLOCK_SIZE,
- DVDCSS_READ_DECRYPT);
- if (num_blocks_read < 0)
- {
- g_simple_async_result_set_error (simple,
- G_IO_ERROR,
- G_IO_ERROR_FAILED,
- "%s", dvdcss_error (data->ctx));
- }
- else
- {
- g_simple_async_result_set_op_res_gssize (simple, num_blocks_read * DVDCSS_BLOCK_SIZE);
- }
-}
-
-static void
-read_dvdcss_async (dvdcss_t ctx,
- guchar *buffer,
- gsize num_bytes,
- gint io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- ReadDVDCSSData *data;
-
- g_return_if_fail (buffer != NULL);
- g_return_if_fail ((num_bytes % DVDCSS_BLOCK_SIZE) == 0);
-
- simple = g_simple_async_result_new (NULL,
- callback,
- user_data,
- read_dvdcss_async);
-
- data = g_slice_new0 (ReadDVDCSSData);
- data->ctx = ctx;
- data->buffer = buffer;
- data->num_bytes = num_bytes;
- g_object_set_data_full (G_OBJECT (simple), "x-data", data, (GDestroyNotify) read_dvdcss_data_free);
-
- g_simple_async_result_set_check_cancellable (simple, cancellable);
- g_simple_async_result_run_in_thread (simple,
- read_dvdcss_in_thread,
- io_priority,
- cancellable);
- g_object_unref (simple);
-}
-
-static gssize
-read_dvdcss_finish (GAsyncResult *res,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- gssize ret = -1;
-
- g_return_val_if_fail (G_IS_ASYNC_RESULT (res), -1);
- g_return_val_if_fail (error == NULL || *error == NULL, -1);
-
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == read_dvdcss_async);
-
- if (g_simple_async_result_propagate_error (simple, error))
- goto out;
-
- ret = g_simple_async_result_get_op_res_gssize (simple);
-
- out:
- return ret;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
/* TODO: make dynamic? */
#define BUFFER_SIZE (1*1024*1024)
@@ -243,8 +83,6 @@ typedef struct
guint64 block_size;
gboolean delete_on_free;
- dvdcss_t dvdcss_ctx;
-
guchar *buffer;
guint64 total_bytes_read;
guint64 buffer_bytes_written;
@@ -302,10 +140,6 @@ create_disk_image_data_unref (CreateDiskImageData *data)
g_object_unref (data->builder);
g_free (data->buffer);
g_clear_object (&data->estimator);
- if (data->dvdcss_ctx != NULL)
- {
- dvdcss_close (data->dvdcss_ctx);
- }
g_free (data);
}
}
@@ -504,43 +338,6 @@ write_more (CreateDiskImageData *data)
/* ---------------------------------------------------------------------------------------------------- */
static void
-read_dvdcss_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- CreateDiskImageData *data = user_data;
- GError *error;
- gssize bytes_read;
-
- error = NULL;
- bytes_read = read_dvdcss_finish (res, &error);
- if (error != NULL)
- {
- gchar *s;
- s = g_strdup_printf (_("Error reading with libdvdcss from offset %" G_GUINT64_FORMAT " of device %s"),
- (guint64) data->total_bytes_read,
- udisks_block_get_preferred_device (data->block));
- if (!(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED))
- gdu_utils_show_error (GTK_WINDOW (data->dialog), s, error);
- g_free (s);
- g_error_free (error);
- create_disk_image_data_complete (data);
- goto out;
- }
-
- /* TODO: handle zero bytes being read */
-
- data->total_bytes_read += bytes_read;
-
- data->buffer_bytes_written = 0;
- data->buffer_bytes_to_write = bytes_read;
- write_more (data);
-
- out:
- create_disk_image_data_unref (data);
-}
-
-static void
read_cb (GInputStream *input_stream,
GAsyncResult *res,
gpointer user_data)
@@ -592,26 +389,13 @@ copy_more (CreateDiskImageData *data)
if (bytes_to_read > BUFFER_SIZE)
bytes_to_read = BUFFER_SIZE;
- if (data->dvdcss_ctx != NULL)
- {
- read_dvdcss_async (data->dvdcss_ctx,
- data->buffer,
- bytes_to_read,
- G_PRIORITY_DEFAULT,
- data->cancellable,
- (GAsyncReadyCallback) read_dvdcss_cb,
- create_disk_image_data_ref (data));
- }
- else
- {
- g_input_stream_read_async (data->block_stream,
- data->buffer,
- bytes_to_read,
- G_PRIORITY_DEFAULT,
- data->cancellable,
- (GAsyncReadyCallback) read_cb,
- create_disk_image_data_ref (data));
- }
+ g_input_stream_read_async (data->block_stream,
+ data->buffer,
+ bytes_to_read,
+ G_PRIORITY_DEFAULT,
+ data->cancellable,
+ (GAsyncReadyCallback) read_cb,
+ create_disk_image_data_ref (data));
out:
;
}
@@ -784,19 +568,6 @@ open_device (CreateDiskImageData *data)
if (g_str_has_prefix (udisks_block_get_device (data->block), "/dev/sr"))
{
data->fd = open (udisks_block_get_device (data->block), O_RDONLY);
- if (data->fd != -1)
- {
- /* Great, that worked! Also use libdvdcss (if available) */
- if (have_dvdcss ())
- {
- data->dvdcss_ctx = dvdcss_open (udisks_block_get_device (data->block));
- if (data->dvdcss_ctx == NULL)
- {
- g_printerr ("Error opening %s with dvdcss_open(). Falling back\n",
- udisks_block_get_device (data->block));
- }
- }
- }
}
if (data->fd != -1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]