#include <stdio.h>
#include <vlc/vlc.h>
+
#ifdef HAVE_LIBCDIO
#include <cdio/cdio.h>
#include <cdio/cd_types.h>
+#include <cdio/logging.h>
#endif /* HAVE_LIBCDIO */
#ifdef HAVE_VCDINFO
END_EVENT_TABLE()
+#if 0
+/* Perhaps someday we'll figure out how to add media information to
+ "Stream-and-Media info" when no input thread hasn't been initialized.
+*/
+extern void MediaInsertCDDA( intf_thread_t *_p_intf, CdIo_t *p_cdio,
+ track_t i_last_track );
+#endif
+
/*****************************************************************************
* AutoBuiltPanel.
*****************************************************************************/
#ifdef HAVE_LIBCDIO
disc_probe = new wxCheckBox( panel, DiscProbe_Event,
- wxU(_("Probe Disc")) );
+ wxU(_("Probe Disc(s)")) );
disc_probe->SetToolTip( wxU(_("Probe for a DVD, VCD or audio CD. "
"First try the Device name entered for the selected Disc type "
"(DVD, DVD Menu, VCD, audio CD). If that doesn't find media, try any device "
#ifdef HAVE_LIBCDIO
+/* Return true if *psz_drive is a drive with a DVD in it. A more complete
+ check would see if the media looks like a *playable* DVD. This should
+ go into libcdio.
+ */
+static bool IsDVD(const char *psz_drive)
+{
+ CdIo_t *p_cdio = cdio_open (psz_drive, DRIVER_UNKNOWN);
+ if (p_cdio)
+ {
+ discmode_t discmode = cdio_get_discmode(p_cdio);
+ cdio_destroy(p_cdio);
+ return cdio_is_discmode_dvd(discmode);
+ }
+ return false;
+}
+
+
/* Return a device that has a DVD in it. The caller needs to free
the returned string.
*/
-static char * ProbeDVD()
+static char * ProbeDVD(const wxChar *device)
{
- char **ppsz_cd_drives = cdio_get_devices(DRIVER_DEVICE);
- if (ppsz_cd_drives)
+ char **ppsz_cd_drives;
+ const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(device);
+ char *psz_device = (char *) tmp_buf;
+
+ if( IsDVD(psz_device) )
+ {
+ return strdup(psz_device);
+ }
+
+ ppsz_cd_drives = cdio_get_devices(DRIVER_DEVICE);
+ if( ppsz_cd_drives )
{
char **c;
for( c = ppsz_cd_drives; *c != NULL; c++ )
{
- CdIo_t *p_cdio = cdio_open (*c, DRIVER_UNKNOWN);
- if (p_cdio)
- {
- discmode_t discmode = cdio_get_discmode(p_cdio);
- cdio_destroy(p_cdio);
- if( cdio_is_discmode_dvd(discmode) )
- {
- char *psz_drive = strdup(*c);
- cdio_free_device_list(ppsz_cd_drives);
- return strdup(psz_drive);
- }
+ if( IsDVD(*c) )
+ {
+ char *psz_drive = strdup(*c);
+ cdio_free_device_list(ppsz_cd_drives);
+ return strdup(psz_drive);
}
-
}
cdio_free_device_list(ppsz_cd_drives);
}
}
-static char * ProbeDevice(char **ppsz_search_devices, cdio_fs_anal_t mask)
+static char * ProbeDevice(char **ppsz_search_devices, cdio_fs_anal_t mask,
+ bool b_any)
{
char **ppsz_devices;
+ if( ppsz_search_devices && !ppsz_search_devices[0] )
+ ppsz_search_devices = NULL;
+
/* Start out trying the device that has been entered so far. */
- ppsz_devices = cdio_get_devices_with_cap(ppsz_search_devices, mask, true);
+ ppsz_devices = cdio_get_devices_with_cap(ppsz_search_devices, mask,
+ b_any);
if (ppsz_devices && *ppsz_devices)
{
return psz_device;
}
- /* If there was no device specified on the first try then give up
+ /* If there was no device specified on the first try, then give up
now. Otherwise accept any CD-ROM in the class (e.g. VCD or DVD).
*/
- if (!ppsz_search_devices[0]) return NULL;
+ if( !ppsz_search_devices ) return NULL;
ppsz_devices = cdio_get_devices_with_cap(NULL, mask, true);
char *psz_device = (char *) tmp_buf;
ppsz_device[0] = (device && *device) ? psz_device : NULL;
ppsz_device[1] = NULL;
- return ProbeDevice(ppsz_device, CDIO_FS_AUDIO);
+ return ProbeDevice(ppsz_device, CDIO_FS_AUDIO, false);
}
/* Return a device that has a VCD in it. The caller needs to free
ppsz_device[1] = NULL;
return ProbeDevice(ppsz_device,
(CDIO_FS_ANAL_SVCD|CDIO_FS_ANAL_CVD|CDIO_FS_ANAL_VIDEOCD
- |CDIO_FS_UNKNOWN));
+ |CDIO_FS_UNKNOWN), true);
}
+#define SELECTION_DISC_TYPE_DVD_MENUS 0
+#define SELECTION_DISC_TYPE_DVD 1
+#define SELECTION_DISC_TYPE_VCD 2
+#define SELECTION_DISC_TYPE_CDDA 3
+
/*
Probe (find anywhere) a CD-DA, VCD, or a DVD.
First try the device name that may have been entered for the "disc type"
char *psz_device = NULL;
bool b_probed_DVD = false;
bool b_probed_VCD = false;
+ const int i_selection = disc_type->GetSelection();
+
+ /* Reduce verbosity of cdio errors. */
+ cdio_loglevel_default = CDIO_LOG_ERROR;
retry:
switch( disc_type->GetSelection() )
{
- case 0: /* DVD with menus */
- case 1: /* DVD without menus */
+ case SELECTION_DISC_TYPE_DVD_MENUS:
+ case SELECTION_DISC_TYPE_DVD:
/* If not a DVD then try for a VCD. If VCD fails it will
try for a CD-DA. */
- if (!psz_device) psz_device = ProbeDVD();
+ if (!psz_device) psz_device = ProbeDVD(disc_device->GetValue());
if (!psz_device)
{
b_probed_DVD = true;
- disc_type->SetSelection(2);
+ disc_type->SetSelection(SELECTION_DISC_TYPE_VCD);
OnDiscTypeChange( dummy_event );
goto retry;
}
disc_device->SetValue( wxL2U(psz_device) );
- free(psz_device);
break;
- case 2: /* VCD probe of some sort */
+ case SELECTION_DISC_TYPE_VCD: /* VCD probe of some sort */
if(!psz_device) psz_device = ProbeVCD(disc_device->GetValue());
if( psz_device )
{
track_t i_last_track = cdio_get_last_track_num(p_cdio);
disc_title->SetRange( 0, i_last_track-1 );
}
- free(psz_device);
cdio_destroy(p_cdio);
#endif
break;
b_probed_VCD = true;
/* Not a VCD. Try for a DVD unless we've been there before. */
- if( !b_probed_DVD && (psz_device = ProbeDVD()) )
+ if( !b_probed_DVD && (psz_device = ProbeDVD(disc_device->GetValue())) )
{
- disc_type->SetSelection(0);
+ disc_type->SetSelection(SELECTION_DISC_TYPE_DVD_MENUS);
OnDiscTypeChange( dummy_event );
goto retry;
}
psz_device = ProbeCDDA(disc_device->GetValue());
if( psz_device )
{
- disc_type->SetSelection(3);
+ disc_type->SetSelection(SELECTION_DISC_TYPE_CDDA);
OnDiscTypeChange( dummy_event );
goto retry;
}
+
+ /* Couldn't find a VCD, DVD or CD-DA. Null out the Device name and
+ set to original selection.
+ */
+ disc_device->SetValue( wxL2U("") );
+ disc_type->SetSelection(i_selection);
+ OnDiscTypeChange( dummy_event );
break;
- case 3: /* CD-DA Probe */
+ case SELECTION_DISC_TYPE_CDDA:
if(!psz_device) psz_device = ProbeCDDA(disc_device->GetValue());
if( psz_device )
{
{
track_t i_last_track = cdio_get_last_track_num(p_cdio);
disc_title->SetRange( 0, i_last_track );
+#if 0
+ MediaInsertCDDA( p_intf, p_cdio, i_last_track );
+#endif
}
- free(psz_device);
cdio_destroy(p_cdio);
break;
}
/* Not a CD-DA. Try for a DVD unless we've been there before. */
- if( !b_probed_DVD && (psz_device = ProbeDVD()) )
+ if( !b_probed_DVD && (psz_device = ProbeDVD(disc_device->GetValue())) )
{
- disc_type->SetSelection(0);
+ disc_type->SetSelection(SELECTION_DISC_TYPE_DVD_MENUS);
OnDiscTypeChange( dummy_event );
goto retry;
}
if (!b_probed_VCD) psz_device = ProbeVCD(disc_device->GetValue());
if( psz_device )
{
- disc_type->SetSelection(2);
+ disc_type->SetSelection(SELECTION_DISC_TYPE_VCD);
OnDiscTypeChange( dummy_event );
goto retry;
}
+ disc_device->SetValue( wxL2U("") );
break;
default:
break;
}
+ free(psz_device);
disc_probe->SetValue(FALSE);
UpdateMRL( DISC_ACCESS );
switch( disc_type->GetSelection() )
{
- case 0: /* DVD with menus */
- case 1: /* DVD without menus */
+ case SELECTION_DISC_TYPE_DVD_MENUS:
+ case SELECTION_DISC_TYPE_DVD:
disc_sub->Enable(); disc_sub_label->Enable();
disc_audio->Enable(); disc_audio_label->Enable();
disc_chapter->Enable(); disc_chapter_label->Enable();
)) );
break;
- case 2: /* VCD of some sort */
+ case SELECTION_DISC_TYPE_VCD:
disc_sub->Enable(); disc_sub_label->Enable();
disc_audio->Enable(); disc_audio_label->Enable();
disc_chapter->Disable(); disc_chapter_label->Disable();
)) );
break;
- case 3: /* CD-DA */
+ case SELECTION_DISC_TYPE_CDDA:
disc_sub->Disable(); disc_sub_label->Disable();
disc_chapter->Disable(); disc_chapter_label->Disable();
disc_audio->Disable(); disc_audio_label->Disable();