Search
lxdream.org :: lxdream/src/gdrom/gdrom.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdrom.c
changeset 678:35eb00945316
prev644:ccae4bfa5f82
next691:ad3356543392
author nkeynes
date Thu May 29 11:00:26 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Split gdrom.h into public and private gddriver.h
Reorganize gdrom mount to use a disc change hook
file annotate diff log raw
1.1 --- a/src/gdrom/gdrom.c Sun Mar 02 11:38:08 2008 +0000
1.2 +++ b/src/gdrom/gdrom.c Thu May 29 11:00:26 2008 +0000
1.3 @@ -20,13 +20,22 @@
1.4 #include <stdio.h>
1.5 #include <fcntl.h>
1.6 #include <errno.h>
1.7 +#include <glib/gutils.h>
1.8 #include "gdrom/ide.h"
1.9 #include "gdrom/gdrom.h"
1.10 +#include "gdrom/gddriver.h"
1.11 #include "gdrom/packet.h"
1.12 #include "dream.h"
1.13
1.14 extern gdrom_disc_t gdrom_disc;
1.15
1.16 +DEFINE_HOOK( gdrom_disc_change_hook, gdrom_disc_change_hook_t )
1.17 +
1.18 +gdrom_fire_disc_changed( gdrom_disc_t disc )
1.19 +{
1.20 + CALL_HOOKS( gdrom_disc_change_hook, disc, disc == NULL ? NULL : disc->name );
1.21 +}
1.22 +
1.23 gdrom_image_class_t gdrom_image_classes[] = { &cdrom_device_class,
1.24 &nrg_image_class,
1.25 &cdi_image_class,
1.26 @@ -89,17 +98,20 @@
1.27
1.28 void gdrom_mount_disc( gdrom_disc_t disc )
1.29 {
1.30 - gdrom_unmount_disc();
1.31 - gdrom_disc = disc;
1.32 - gdrom_image_dump_info( disc );
1.33 + if( disc != gdrom_disc ) {
1.34 + gdrom_unmount_disc();
1.35 + gdrom_disc = disc;
1.36 + gdrom_image_dump_info( disc );
1.37 + gdrom_fire_disc_changed( disc );
1.38 + }
1.39 }
1.40
1.41 gboolean gdrom_mount_image( const gchar *filename )
1.42 {
1.43 gdrom_disc_t disc = gdrom_image_open(filename);
1.44 if( disc != NULL ) {
1.45 - gdrom_mount_disc( disc );
1.46 - return TRUE;
1.47 + gdrom_mount_disc( disc );
1.48 + return TRUE;
1.49 }
1.50 return FALSE;
1.51 }
1.52 @@ -107,7 +119,8 @@
1.53 void gdrom_unmount_disc( )
1.54 {
1.55 if( gdrom_disc != NULL ) {
1.56 - gdrom_disc->close(gdrom_disc);
1.57 + gdrom_disc->close(gdrom_disc);
1.58 + gdrom_fire_disc_changed(NULL);
1.59 }
1.60 gdrom_disc = NULL;
1.61
1.62 @@ -118,6 +131,15 @@
1.63 return gdrom_disc;
1.64 }
1.65
1.66 +const gchar *gdrom_get_current_disc_name()
1.67 +{
1.68 + if( gdrom_disc == NULL ) {
1.69 + return NULL;
1.70 + } else {
1.71 + return gdrom_disc->name;
1.72 + }
1.73 +}
1.74 +
1.75 gchar *gdrom_get_relative_filename( const gchar *base_name, const gchar *rel_name )
1.76 {
1.77 gchar *dirname = g_path_get_dirname(base_name);
.