Commit e69d3141 authored by Rocky Bernstein's avatar Rocky Bernstein

cdda/info.c: changes for libcddb 1.1.0 API

rest: Add "Probe" for media function in Open Disc.
parent efc10b25
......@@ -3645,8 +3645,16 @@ then
if test "${ac_cv_cxx_fpermissive}" = "yes"; then
VLC_ADD_CXXFLAGS([wxwindows],-fpermissive)
fi
PKG_CHECK_MODULES(LIBCDIO, libcdio >= 0.71,
[
AC_DEFINE(HAVE_LIBCDIO, [], [Define for the CD-DA plugin using libcdio])
VLC_ADD_CXXFLAGS([wxwindows],[`${WX_CONFIG} --cxxflags` $LIBCDIO_CFLAGS])
VLC_ADD_LDFLAGS([wxwindows],[`${WX_CONFIG} --libs`] $LIBCDIO_LIBS)],
[AC_MSG_WARN(libcdio library not found - Probe disc disabled)
VLC_ADD_CXXFLAGS([wxwindows],[`${WX_CONFIG} --cxxflags`])
VLC_ADD_LDFLAGS([wxwindows],[`${WX_CONFIG} --libs`])
HAVE_LIBCDIO=no])
# now look for the wxprec.h header
CPPFLAGS="${CPPFLAGS_save} ${CXXFLAGS_wxwindows}"
ac_cv_wx_headers=yes
......
......@@ -116,13 +116,14 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
{
track_t i_track = p_cdda->i_first_track + i;
cddb_track_t *t = cddb_track_new();
t->frame_offset = cdio_get_track_lba(p_cdio, i_track);
cddb_track_set_frame_offset(t,
cdio_get_track_lba(p_cdio, i_track));
cddb_disc_add_track(p_cdda->cddb.disc, t);
}
p_cdda->cddb.disc->length =
cddb_disc_set_length(p_cdda->cddb.disc,
cdio_get_track_lba(p_cdio, CDIO_CDROM_LEADOUT_TRACK)
/ CDIO_CD_FRAMES_PER_SEC;
/ CDIO_CD_FRAMES_PER_SEC);
if (!cddb_disc_calc_discid(p_cdda->cddb.disc))
{
......
......@@ -30,6 +30,10 @@
#include <stdio.h>
#include <vlc/vlc.h>
#ifdef HAVE_LIBCDIO
#include <cdio/cdio.h>
#include <cdio/cd_types.h>
#endif /* HAVE_LIBCDIO */
#include <wx/combobox.h>
#include <wx/statline.h>
......@@ -60,6 +64,9 @@ enum
FileName_Event,
DiscType_Event,
#ifdef HAVE_LIBCDIO
DiscProbe_Event,
#endif
DiscDevice_Event,
DiscTitle_Event,
DiscChapter_Event,
......@@ -99,6 +106,9 @@ BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
/* Events generated by the disc panel */
EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
#ifdef HAVE_LIBCDIO
EVT_CHECKBOX(DiscProbe_Event, OpenDialog::OnDiscProbe)
#endif
EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
......@@ -653,7 +663,13 @@ wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
WXSIZEOF(disc_type_array), disc_type_array,
WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
#ifdef HAVE_LIBCDIO
disc_probe = new wxCheckBox( panel, DiscProbe_Event,
wxU(_("Probe Disc")) );
#endif
sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
sizer_row->Add( disc_probe, 0, wxEXPAND | wxALL );
wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
......@@ -1225,6 +1241,221 @@ void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
UpdateMRL( DISC_ACCESS );
}
#ifdef HAVE_LIBCDIO
/* Return a device that has a DVD in it. The caller needs to free
the returned string.
*/
static char * ProbeDVD()
{
char **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);
}
}
}
cdio_free_device_list(ppsz_cd_drives);
}
return NULL;
}
static char * ProbeDevice(char **search_devices, cdio_fs_anal_t mask,
bool b_any)
{
char **ppsz_devices;
/* Start out trying the device that has been entered so far. */
ppsz_devices = cdio_get_devices_with_cap(search_devices, mask, b_any);
if (ppsz_devices && *ppsz_devices)
{
char *psz_device = strdup(*ppsz_devices);
cdio_free_device_list(ppsz_devices);
return psz_device;
}
/* 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 (!search_devices[0]) return NULL;
ppsz_devices = cdio_get_devices_with_cap(NULL, mask, b_any);
if (ppsz_devices && *ppsz_devices)
{
char *psz_device = strdup(*ppsz_devices);
cdio_free_device_list(ppsz_devices);
return psz_device;
}
return NULL;
}
/* Return a device that has a CD-DA in it. The caller needs to free
the returned string.
*/
static char * ProbeCDDA(const wxChar *device)
{
char *ppsz_device[2];
const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(device);
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, false);
}
/* Return a device that has a VCD in it. The caller needs to free
the returned string.
*/
static char * ProbeVCD(const wxChar *device)
{
char *ppsz_device[2];
const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(device);
char *psz_device = (char *) tmp_buf;
ppsz_device[0] = (device && *device) ? psz_device : NULL;
ppsz_device[1] = NULL;
return ProbeDevice(ppsz_device,
(CDIO_FS_ANAL_SVCD|CDIO_FS_ANAL_CVD|CDIO_FS_ANAL_VIDEOCD
|CDIO_FS_UNKNOWN), true);
}
/*
Probe (find anywhere) a CD-DA, VCD, or a DVD.
First we try the device name that may have been entered for the media class
selected. If that doesn't work we try any device for the media class.
If that doesn't work the try looking for CD-ROMs or DVD drives and set the
media selection to whatever we find.
*/
void OpenDialog::OnDiscProbe( wxCommandEvent& WXUNUSED(event) )
{
wxCommandEvent dummy_event;
char *psz_device = NULL;
bool b_probed_DVD = false;
bool b_probed_VCD = false;
retry:
switch( disc_type->GetSelection() )
{
case 0: /* DVD with menus */
case 1: /* DVD without menus */
/* 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)
{
b_probed_DVD = true;
disc_type->SetSelection(2);
OnDiscTypeChange( dummy_event );
goto retry;
}
disc_device->SetValue( wxL2U(psz_device) );
free(psz_device);
break;
case 2: /* VCD probe of some sort */
if(!psz_device) psz_device = ProbeVCD(disc_device->GetValue());
if( psz_device )
{
CdIo_t *p_cdio = cdio_open (psz_device, DRIVER_UNKNOWN);
disc_device->SetValue( wxL2U(psz_device) );
/* Set track range accurately if possible. */
if (p_cdio)
{
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);
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()) )
{
disc_type->SetSelection(0);
OnDiscTypeChange( dummy_event );
goto retry;
}
b_probed_DVD = true;
/* Couldn't find a VCD or DVD. See if we can find a CD-DA. */
psz_device = ProbeCDDA(disc_device->GetValue());
if( psz_device )
{
disc_type->SetSelection(3);
OnDiscTypeChange( dummy_event );
goto retry;
}
break;
case 3: /* CD-DA Probe */
if(!psz_device) psz_device = ProbeCDDA(disc_device->GetValue());
if( psz_device )
{
CdIo_t *p_cdio = cdio_open (psz_device, DRIVER_UNKNOWN);
disc_device->SetValue( wxL2U(psz_device) );
if (p_cdio)
{
track_t i_last_track = cdio_get_last_track_num(p_cdio);
disc_title->SetRange( 0, i_last_track );
}
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()) )
{
disc_type->SetSelection(0);
OnDiscTypeChange( dummy_event );
goto retry;
}
/* Couldn't find a CD-DA or DVD. See if we can find a VCD, unless
we've tried that before. */
if (!b_probed_VCD) psz_device = ProbeVCD(disc_device->GetValue());
if( psz_device )
{
disc_type->SetSelection(2);
OnDiscTypeChange( dummy_event );
goto retry;
}
break;
default:
msg_Err( p_intf, "invalid Disc type selection (%d)",
disc_type->GetSelection() );
break;
}
disc_probe->SetValue(FALSE);
UpdateMRL( DISC_ACCESS );
}
#endif /* HAVE_LIBCDIO */
void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
{
char *psz_device = NULL;
......
......@@ -480,6 +480,9 @@ private:
void OnDiscPanelChangeSpin( wxSpinEvent& event );
void OnDiscPanelChange( wxCommandEvent& event );
void OnDiscTypeChange( wxCommandEvent& event );
#ifdef HAVE_LIBCDIO
void OnDiscProbe( wxCommandEvent& event );
#endif
void OnDiscDeviceChange( wxCommandEvent& event );
/* Event handlers for the net page */
......@@ -519,6 +522,7 @@ private:
/* Controls for the disc panel */
wxRadioBox *disc_type;
wxCheckBox *disc_probe;
wxTextCtrl *disc_device;
wxSpinCtrl *disc_title; int i_disc_title;
wxSpinCtrl *disc_chapter; int i_disc_chapter;
......
......@@ -32,7 +32,7 @@ mkinstalldirs = $(SHELL) `case "$(MKINSTALLDIRS)" in /*) echo "$(MKINSTALLDIRS)"
GMSGFMT = @GMSGFMT@
MSGFMT = @MSGFMT@
XGETTEXT = @XGETTEXT@
MSGMERGE = @MSGMERGE@
MSGMERGE = msgmerge
MSGMERGE_UPDATE = @MSGMERGE@ --update
MSGINIT = msginit
MSGCONV = msgconv
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment