ref: bbd221a848a91ad4ff4768daf7939f155aa0a1e4
parent: 3ff0475329552066207a5b83ae014ddffc7b86a4
author: Sam Hocevar <sam@videolan.org>
date: Thu Jan 26 15:48:06 EST 2006
* src/device.c: reduced code duplication and fixed a pointer/integer confusion in the OS X drive detection.
--- a/src/device.c
+++ b/src/device.c
@@ -1,11 +1,11 @@
/*****************************************************************************
* device.h: DVD device access
*****************************************************************************
- * Copyright (C) 1998-2002 VideoLAN
+ * Copyright (C) 1998-2006 VideoLAN
* $Id$
*
* Authors: St�phane Borel <stef@via.ecp.fr>
- * Samuel Hocevar <sam@zoy.org>
+ * Sam Hocevar <sam@zoy.org>
* H�kan Hjort <d95hjort@dtek.chalmers.se>
*
* This program is free software; you can redistribute it and/or modify
@@ -225,46 +225,48 @@
}
next_media = IOIteratorNext( media_iterator );
- if( next_media != NULL )
+ for( ; ; )
{
char psz_buf[0x32];
size_t i_pathlen;
CFTypeRef psz_path;
- do
+ next_media = IOIteratorNext( media_iterator );
+ if( next_media == 0 )
{
- psz_path = IORegistryEntryCreateCFProperty( next_media,
- CFSTR( kIOBSDNameKey ),
- kCFAllocatorDefault,
- 0 );
- if( psz_path == NULL )
- {
- IOObjectRelease( next_media );
- continue;
- }
+ break;
+ }
- snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' );
- i_pathlen = strlen( psz_buf );
+ psz_path = IORegistryEntryCreateCFProperty( next_media,
+ CFSTR( kIOBSDNameKey ),
+ kCFAllocatorDefault,
+ 0 );
+ if( psz_path == NULL )
+ {
+ IOObjectRelease( next_media );
+ continue;
+ }
- if( CFStringGetCString( psz_path,
- (char*)&psz_buf + i_pathlen,
- sizeof(psz_buf) - i_pathlen,
- kCFStringEncodingASCII ) )
- {
- print_debug( dvdcss, "defaulting to drive `%s'", psz_buf );
- CFRelease( psz_path );
- IOObjectRelease( next_media );
- IOObjectRelease( media_iterator );
- free( dvdcss->psz_device );
- dvdcss->psz_device = strdup( psz_buf );
- return;
- }
+ snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' );
+ i_pathlen = strlen( psz_buf );
+ if( CFStringGetCString( psz_path,
+ (char*)&psz_buf + i_pathlen,
+ sizeof(psz_buf) - i_pathlen,
+ kCFStringEncodingASCII ) )
+ {
+ print_debug( dvdcss, "defaulting to drive `%s'", psz_buf );
CFRelease( psz_path );
-
IOObjectRelease( next_media );
+ IOObjectRelease( media_iterator );
+ free( dvdcss->psz_device );
+ dvdcss->psz_device = strdup( psz_buf );
+ return;
+ }
- } while( ( next_media = IOIteratorNext( media_iterator ) ) != NULL );
+ CFRelease( psz_path );
+
+ IOObjectRelease( next_media );
}
IOObjectRelease( media_iterator );