summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhb/dvd.c23
-rw-r--r--libhb/hb.h2
-rw-r--r--macosx/DriveDetector.h14
-rw-r--r--macosx/DriveDetector.m22
-rw-r--r--macosx/ExpressController.h1
-rw-r--r--macosx/ExpressController.m32
-rw-r--r--macosx/ScanController.mm2
7 files changed, 78 insertions, 18 deletions
diff --git a/libhb/dvd.c b/libhb/dvd.c
index f0cc521bc..7d19fae11 100644
--- a/libhb/dvd.c
+++ b/libhb/dvd.c
@@ -41,6 +41,29 @@ struct hb_dvd_s
static void FindNextCell( hb_dvd_t * );
static int dvdtime2msec( dvd_time_t * );
+char * hb_dvd_name( char * path )
+{
+ static char name[1024];
+ unsigned char unused[1024];
+ dvd_reader_t * reader;
+
+ reader = DVDOpen( path );
+ if( !reader )
+ {
+ return NULL;
+ }
+
+ if( DVDUDFVolumeInfo( reader, name, sizeof( name ),
+ unused, sizeof( unused ) ) )
+ {
+ DVDClose( reader );
+ return NULL;
+ }
+
+ DVDClose( reader );
+ return name;
+}
+
/***********************************************************************
* hb_dvd_init
***********************************************************************
diff --git a/libhb/hb.h b/libhb/hb.h
index 5feef6c94..e989a6bc0 100644
--- a/libhb/hb.h
+++ b/libhb/hb.h
@@ -66,6 +66,8 @@ int hb_check_update( hb_handle_t * h, char ** version );
ports.h) */
void hb_set_cpu_count( hb_handle_t *, int );
+char * hb_dvd_name( char * path );
+
/* hb_scan()
Scan the specified path. Can be a DVD device, a VIDEO_TS folder or
a VOB file. If title_index is 0, scan all titles. */
diff --git a/macosx/DriveDetector.h b/macosx/DriveDetector.h
index 09d589adb..2018309b1 100644
--- a/macosx/DriveDetector.h
+++ b/macosx/DriveDetector.h
@@ -8,14 +8,16 @@
@interface DriveDetector : NSObject
{
- id fTarget;
- SEL fSelector;
+ id fTarget;
+ SEL fSelector;
- int fCount;
- NSMutableArray * fDrives;
- NSTimer * fTimer;
+ int fCount;
+ NSMutableDictionary * fDrives;
+ NSTimer * fTimer;
}
-- (id) initWithCallback: (id) target selector: (SEL) selector;
+- (id) initWithCallback: (id) target selector: (SEL) selector;
+- (void) run;
+- (void) stop;
@end
diff --git a/macosx/DriveDetector.m b/macosx/DriveDetector.m
index 26958a964..61f722960 100644
--- a/macosx/DriveDetector.m
+++ b/macosx/DriveDetector.m
@@ -11,6 +11,7 @@
#include <IOKit/storage/IODVDMedia.h>
#include "DriveDetector.h"
+#include "hb.h"
@interface DriveDetector (Private)
@@ -22,7 +23,7 @@
- (void) dealloc
{
- [fTimer invalidate];
+ [fDrives release];
[super dealloc];
}
@@ -32,8 +33,13 @@
fSelector = selector;
fCount = -1;
- fDrives = [[NSMutableArray alloc] initWithCapacity: 1];
+ fDrives = [[NSMutableDictionary alloc] initWithCapacity: 1];
+ return self;
+}
+
+- (void) run
+{
/* Set up a timer to check devices every second */
fTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self
selector: @selector( detectTimer: ) userInfo: nil repeats: YES];
@@ -42,8 +48,11 @@
/* Do a first update right away */
[fTimer fire];
+}
- return self;
+- (void) stop
+{
+ [fTimer invalidate];
}
- (void) detectTimer: (NSTimer *) timer
@@ -82,6 +91,7 @@
next_media = IOIteratorNext( media_iterator );
if( next_media )
{
+ char * name;
char psz_buf[0x32];
size_t dev_path_length;
CFTypeRef str_bsd_path;
@@ -106,7 +116,11 @@
sizeof(psz_buf) - dev_path_length,
kCFStringEncodingASCII ) )
{
- [fDrives addObject: [NSString stringWithCString: psz_buf]];
+ if( ( name = hb_dvd_name( psz_buf ) ) )
+ {
+ [fDrives setObject: [NSString stringWithCString: psz_buf]
+ forKey: [NSString stringWithCString: name]];
+ }
}
CFRelease( str_bsd_path );
diff --git a/macosx/ExpressController.h b/macosx/ExpressController.h
index 03ce5eb49..3cbe0b4de 100644
--- a/macosx/ExpressController.h
+++ b/macosx/ExpressController.h
@@ -39,6 +39,7 @@
NSString * fConvertFolderString;
DriveDetector * fDriveDetector;
+ NSDictionary * fDrives;
}
- (void) openShow: (id) sender;
diff --git a/macosx/ExpressController.m b/macosx/ExpressController.m
index 285b5a8f6..5121f9173 100644
--- a/macosx/ExpressController.m
+++ b/macosx/ExpressController.m
@@ -5,7 +5,7 @@
@interface ExpressController (Private)
-- (void) openUpdateDrives: (NSArray *) drives;
+- (void) openUpdateDrives: (NSDictionary *) drives;
- (void) openBrowseDidEnd: (NSOpenPanel *) sheet returnCode: (int)
returnCode contextInfo: (void *) contextInfo;
- (void) openEnable: (BOOL) b;
@@ -29,6 +29,7 @@
/* Show the "Open DVD" interface */
fDriveDetector = [[DriveDetector alloc] initWithCallback: self
selector: @selector( openUpdateDrives: )];
+ [fDriveDetector run];
[self openEnable: YES];
[fWindow setContentSize: [fOpenView frame].size];
[fWindow setContentView: fOpenView];
@@ -141,8 +142,7 @@
[fWindow setFrame: frame display: YES animate: YES];
[fWindow setContentView: fOpenView];
- fDriveDetector = [[DriveDetector alloc] initWithCallback: self
- selector: @selector( openUpdateDrives: )];
+ [fDriveDetector run];
}
- (void) openMatrixChanged: (id) sender
@@ -172,6 +172,7 @@
[fOpenIndicator setIndeterminate: YES];
[fOpenIndicator startAnimation: nil];
[fOpenProgressField setStringValue: @"Opening..."];
+ [fDriveDetector stop];
if( [fOpenMatrix selectedRow] )
{
@@ -179,8 +180,8 @@
}
else
{
- hb_scan( fHandle, [[fOpenPopUp titleOfSelectedItem]
- UTF8String], 0 );
+ hb_scan( fHandle, [[fDrives objectForKey: [fOpenPopUp
+ titleOfSelectedItem]] UTF8String], 0 );
}
NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval: 0.5
@@ -311,10 +312,22 @@
@implementation ExpressController (Private)
-- (void) openUpdateDrives: (NSArray *) drives
+- (void) openUpdateDrives: (NSDictionary *) drives
{
+ if( fDrives )
+ {
+ [fDrives release];
+ }
+ fDrives = [[NSDictionary alloc] initWithDictionary: drives];
+
+ NSString * device;
+ NSEnumerator * enumerator = [fDrives keyEnumerator];
[fOpenPopUp removeAllItems];
- [fOpenPopUp addItemsWithTitles: drives];
+ while( ( device = [enumerator nextObject] ) )
+ {
+ [fOpenPopUp addItemWithTitle: device];
+ }
+
if( ![fOpenPopUp numberOfItems] )
{
[fOpenPopUp addItemWithTitle: INSERT_STRING];
@@ -392,9 +405,12 @@
if( hb_list_count( fList ) )
{
- [fDriveDetector release];
[self convertShow];
}
+ else
+ {
+ [fDriveDetector run];
+ }
break;
default:
diff --git a/macosx/ScanController.mm b/macosx/ScanController.mm
index a956ea83b..e5fe2e70a 100644
--- a/macosx/ScanController.mm
+++ b/macosx/ScanController.mm
@@ -41,6 +41,7 @@
DriveDetector * driveDetector;
driveDetector = [[DriveDetector alloc] initWithCallback: self
selector: @selector( UpdatePopup: )];
+ [driveDetector run];
[NSApp beginSheet: fPanel modalForWindow: fWindow
modalDelegate: nil didEndSelector: nil contextInfo: nil];
@@ -48,6 +49,7 @@
[NSApp endSheet: fPanel];
[fPanel orderOut: self];
+ [driveDetector stop];
[driveDetector release];
}