Add a cdda_close that doesn't free the p_cdio pointer for those cases
where an application may want to keep that pointer open. All routines now are distinct from parnaoia routines with suitable #defines for compatibility.
This commit is contained in:
@@ -90,7 +90,8 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cdio_cddap_close(d);
|
cdio_cddap_close_no_free_cdio(d);
|
||||||
|
cdio_destroy( p_cdio );
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdda.h,v 1.10 2005/01/25 11:04:45 rocky Exp $
|
$Id: cdda.h,v 1.11 2005/01/26 01:03:16 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 2001 Xiph.org
|
Copyright (C) 2001 Xiph.org
|
||||||
@@ -175,56 +175,81 @@ extern cdrom_drive_t *cdio_cddap_identify_cooked(const char *ppsz_device,
|
|||||||
|
|
||||||
extern int cdio_cddap_speed_set(cdrom_drive_t *d, int speed);
|
extern int cdio_cddap_speed_set(cdrom_drive_t *d, int speed);
|
||||||
extern void cdio_cddap_verbose_set(cdrom_drive_t *d, int err_action,
|
extern void cdio_cddap_verbose_set(cdrom_drive_t *d, int err_action,
|
||||||
int mes_action);
|
int mes_action);
|
||||||
extern char *cdio_cddap_messages(cdrom_drive_t *d);
|
extern char *cdio_cddap_messages(cdrom_drive_t *d);
|
||||||
extern char *cdio_cddap_errors(cdrom_drive_t *d);
|
extern char *cdio_cddap_errors(cdrom_drive_t *d);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Closes d and releases all storage associated with it except
|
||||||
|
the internal p_cdio pointer.
|
||||||
|
|
||||||
|
@param d cdrom_drive_t object to be closed.
|
||||||
|
@return 0 if passed a null pointer and 1 if not in which case
|
||||||
|
some work was probably done.
|
||||||
|
|
||||||
|
@see cdio_cddap_close
|
||||||
|
*/
|
||||||
|
bool cdio_cddap_close_no_free_cdio(cdrom_drive_t *d);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Closes d and releases all storage associated with it.
|
||||||
|
Doubles as "cdrom_drive_free()".
|
||||||
|
|
||||||
|
@param d cdrom_drive_t object to be closed.
|
||||||
|
@return 0 if passed a null pointer and 1 if not in which case
|
||||||
|
some work was probably done.
|
||||||
|
|
||||||
|
@see cdio_cddap_close_no_free_cdio
|
||||||
|
*/
|
||||||
extern int cdio_cddap_close(cdrom_drive_t *d);
|
extern int cdio_cddap_close(cdrom_drive_t *d);
|
||||||
|
|
||||||
extern int cdio_cddap_open(cdrom_drive_t *d);
|
extern int cdio_cddap_open(cdrom_drive_t *d);
|
||||||
|
|
||||||
extern long cdio_cddap_read(cdrom_drive_t *d, void *p_buffer,
|
extern long cdio_cddap_read(cdrom_drive_t *d, void *p_buffer,
|
||||||
lsn_t beginsector, long sectors);
|
lsn_t beginsector, long sectors);
|
||||||
|
|
||||||
/*! Return the lsn for the start of track i_track */
|
/*! Return the lsn for the start of track i_track */
|
||||||
extern lsn_t cdda_track_firstsector(cdrom_drive_t *d, track_t i_track);
|
extern lsn_t cdio_cddap_track_firstsector(cdrom_drive_t *d,
|
||||||
|
track_t i_track);
|
||||||
|
|
||||||
/*! Get last lsn of the track. This generally one less than the start
|
/*! Get last lsn of the track. This generally one less than the start
|
||||||
of the next track. -1 is returned on error. */
|
of the next track. -1 is returned on error. */
|
||||||
extern lsn_t cdda_track_lastsector(cdrom_drive_t *d, track_t i_track);
|
extern lsn_t cdio_cddap_track_lastsector(cdrom_drive_t *d, track_t i_track);
|
||||||
|
|
||||||
/*! Return the number of tracks on the CD. */
|
/*! Return the number of tracks on the CD. */
|
||||||
extern track_t cdda_tracks(cdrom_drive_t *d);
|
extern track_t cdio_cddap_tracks(cdrom_drive_t *d);
|
||||||
|
|
||||||
/*! Return the track containing the given LSN. If the LSN is before
|
/*! Return the track containing the given LSN. If the LSN is before
|
||||||
the first track (in the pregap), 0 is returned. If there was an
|
the first track (in the pregap), 0 is returned. If there was an
|
||||||
error or the LSN after the LEADOUT (beyond the end of the CD), then
|
error or the LSN after the LEADOUT (beyond the end of the CD), then
|
||||||
CDIO_INVALID_TRACK is returned.
|
CDIO_INVALID_TRACK is returned.
|
||||||
*/
|
*/
|
||||||
extern int cdda_sector_gettrack(cdrom_drive_t *d, lsn_t lsn);
|
extern int cdio_cddap_sector_gettrack(cdrom_drive_t *d, lsn_t lsn);
|
||||||
|
|
||||||
/*! Return the number of channels in track: 2 or 4; -2 if not
|
/*! Return the number of channels in track: 2 or 4; -2 if not
|
||||||
implemented or -1 for error.
|
implemented or -1 for error.
|
||||||
Not meaningful if track is not an audio track.
|
Not meaningful if track is not an audio track.
|
||||||
*/
|
*/
|
||||||
extern int cdda_track_channels(cdrom_drive_t *d, track_t i_track);
|
extern int cdio_cddap_track_channels(cdrom_drive_t *d, track_t i_track);
|
||||||
|
|
||||||
/*! Return 1 is track is an audio track, 0 otherwise. */
|
/*! Return 1 is track is an audio track, 0 otherwise. */
|
||||||
extern int cdda_track_audiop(cdrom_drive_t *d, track_t i_track);
|
extern int cdio_cddap_track_audiop(cdrom_drive_t *d, track_t i_track);
|
||||||
|
|
||||||
/*! Return 1 is track has copy permit set, 0 otherwise. */
|
/*! Return 1 is track has copy permit set, 0 otherwise. */
|
||||||
extern int cdda_track_copyp(cdrom_drive_t *d, track_t i_track);
|
extern int cdio_cddap_track_copyp(cdrom_drive_t *d, track_t i_track);
|
||||||
|
|
||||||
/*! Return 1 is audio track has linear preemphasis set, 0 otherwise.
|
/*! Return 1 is audio track has linear preemphasis set, 0 otherwise.
|
||||||
Only makes sense for audio tracks.
|
Only makes sense for audio tracks.
|
||||||
*/
|
*/
|
||||||
extern int cdda_track_preemp(cdrom_drive_t *d, track_t i_track);
|
extern int cdio_cddap_track_preemp(cdrom_drive_t *d, track_t i_track);
|
||||||
|
|
||||||
/*! Get first lsn of the first audio track. -1 is returned on error. */
|
/*! Get first lsn of the first audio track. -1 is returned on error. */
|
||||||
extern lsn_t cdda_disc_firstsector(cdrom_drive_t *d);
|
extern lsn_t cdio_cddap_disc_firstsector(cdrom_drive_t *d);
|
||||||
|
|
||||||
/*! Get last lsn of the last audio track. The last lsn is generally one
|
/*! Get last lsn of the last audio track. The last lsn is generally one
|
||||||
less than the start of the next track after the audio track. -1 is
|
less than the start of the next track after the audio track. -1 is
|
||||||
returned on error. */
|
returned on error. */
|
||||||
extern lsn_t cdda_disc_lastsector(cdrom_drive_t *d);
|
extern lsn_t cdio_cddap_disc_lastsector(cdrom_drive_t *d);
|
||||||
|
|
||||||
/*! Determine Endian-ness of the CD-drive based on reading data from
|
/*! Determine Endian-ness of the CD-drive based on reading data from
|
||||||
it. Some drives return audio data Big Endian while some (most)
|
it. Some drives return audio data Big Endian while some (most)
|
||||||
@@ -302,7 +327,7 @@ const char *strerror_tr[]={
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** For compatibility with good ol' paranoia */
|
/** For compatibility with good ol' paranoia */
|
||||||
#define cdda_cddap_find_a_cdrom cdio_cddap_find_a_cdrom
|
#define cdda_find_a_cdrom cdio_cddap_find_a_cdrom
|
||||||
#define cdda_identify cdio_cddap_identify
|
#define cdda_identify cdio_cddap_identify
|
||||||
#define cdda_speed_set cdio_cddap_speed_set
|
#define cdda_speed_set cdio_cddap_speed_set
|
||||||
#define cdda_verbose_set cdio_cddap_verbose_set
|
#define cdda_verbose_set cdio_cddap_verbose_set
|
||||||
@@ -311,6 +336,16 @@ const char *strerror_tr[]={
|
|||||||
#define cdda_close cdio_cddap_close
|
#define cdda_close cdio_cddap_close
|
||||||
#define cdda_open cdio_cddap_open
|
#define cdda_open cdio_cddap_open
|
||||||
#define cdda_read cdio_cddap_read
|
#define cdda_read cdio_cddap_read
|
||||||
|
#define cdda_track_firstsector cdio_cddap_track_firstsector
|
||||||
|
#define cdda_track_lastsector cdio_cddap_track_lastsector
|
||||||
|
#define cdda_tracks cdio_cddap_tracks
|
||||||
|
#define cdda_sector_gettrack cdio_cddap_sector_gettrack
|
||||||
|
#define cdda_track_channels cdio_cddap_track_channels
|
||||||
|
#define cdda_track_audiop cdio_cddap_track_audiop
|
||||||
|
#define cdda_track_copyp cdio_cddap_track_copyp
|
||||||
|
#define cdda_track_preemp cdio_cddap_track_preemp
|
||||||
|
#define cdda_disc_firstsector cdio_cddap_disc_firstsector
|
||||||
|
#define cdda_disc_lastsector cdio_cddap_disc_lastsector
|
||||||
|
|
||||||
#endif /*_CDDA_INTERFACE_H_*/
|
#endif /*_CDDA_INTERFACE_H_*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: interface.c,v 1.16 2005/01/25 11:04:45 rocky Exp $
|
$Id: interface.c,v 1.17 2005/01/26 01:03:16 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 1998 Monty xiphmont@mit.edu
|
Copyright (C) 1998 Monty xiphmont@mit.edu
|
||||||
@@ -41,22 +41,53 @@ static void _clean_messages(cdrom_drive_t *d)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* doubles as "cdrom_drive_free()" */
|
/*!
|
||||||
int
|
Closes d and releases all storage associated with it except
|
||||||
cdio_cddap_close(cdrom_drive_t *d)
|
the internal p_cdio pointer.
|
||||||
|
|
||||||
|
@param d cdrom_drive_t object to be closed.
|
||||||
|
@return 0 if passed a null pointer and 1 if not in which case
|
||||||
|
some work was probably done.
|
||||||
|
|
||||||
|
@see cdio_cddap_close
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
cdio_cddap_close_no_free_cdio(cdrom_drive_t *d)
|
||||||
{
|
{
|
||||||
if(d){
|
if(d){
|
||||||
if(d->opened)
|
if(d->opened)
|
||||||
d->enable_cdda(d,0);
|
d->enable_cdda(d,0);
|
||||||
|
|
||||||
cdio_destroy (d->p_cdio);
|
|
||||||
_clean_messages(d);
|
_clean_messages(d);
|
||||||
if (d->cdda_device_name) free(d->cdda_device_name);
|
if (d->cdda_device_name) free(d->cdda_device_name);
|
||||||
if (d->drive_model) free(d->drive_model);
|
if (d->drive_model) free(d->drive_model);
|
||||||
|
d->cdda_device_name = d->drive_model = NULL;
|
||||||
free(d);
|
free(d);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return(0);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Closes d and releases all storage associated with it.
|
||||||
|
Doubles as "cdrom_drive_free()".
|
||||||
|
|
||||||
|
@param d cdrom_drive_t object to be closed.
|
||||||
|
@return 0 if passed a null pointer and 1 if not in which case
|
||||||
|
some work was probably done.
|
||||||
|
|
||||||
|
@see cdio_cddap_close_no_free_cdio
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
cdio_cddap_close(cdrom_drive_t *d)
|
||||||
|
{
|
||||||
|
if (d) {
|
||||||
|
CdIo_t *p_cdio = d->p_cdio;
|
||||||
|
cdio_cddap_close_no_free_cdio(d);
|
||||||
|
cdio_destroy (p_cdio);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* finish initializing the drive! */
|
/* finish initializing the drive! */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: _cdio_generic.c,v 1.11 2005/01/23 19:16:58 rocky Exp $
|
$Id: _cdio_generic.c,v 1.12 2005/01/26 01:03:16 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.11 2005/01/23 19:16:58 rocky Exp $";
|
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.12 2005/01/26 01:03:16 rocky Exp $";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -88,7 +88,7 @@ cdio_generic_free (void *p_user_data)
|
|||||||
track_t i_track;
|
track_t i_track;
|
||||||
|
|
||||||
if (NULL == p_env) return;
|
if (NULL == p_env) return;
|
||||||
free (p_env->source_name);
|
if (p_env->source_name) free (p_env->source_name);
|
||||||
|
|
||||||
for (i_track=0; i_track < p_env->i_tracks; i_track++) {
|
for (i_track=0; i_track < p_env->i_tracks; i_track++) {
|
||||||
cdtext_destroy(&(p_env->cdtext_track[i_track]));
|
cdtext_destroy(&(p_env->cdtext_track[i_track]));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: device.c,v 1.7 2005/01/20 00:36:38 rocky Exp $
|
$Id: device.c,v 1.8 2005/01/26 01:03:16 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -276,6 +276,7 @@ cdio_destroy (CdIo_t *p_cdio)
|
|||||||
|
|
||||||
if (p_cdio->op.free != NULL)
|
if (p_cdio->op.free != NULL)
|
||||||
p_cdio->op.free (p_cdio->env);
|
p_cdio->op.free (p_cdio->env);
|
||||||
|
p_cdio->env = NULL;
|
||||||
free (p_cdio);
|
free (p_cdio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user