Allow returned parameters to be NULL.

This commit is contained in:
rocky
2005-03-14 02:02:49 +00:00
parent 02ce555171
commit 0507f61921
4 changed files with 27 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
/* -*- c -*- /* -*- c -*-
$Id: audio.h,v 1.7 2005/03/06 15:59:20 rocky Exp $ $Id: audio.h,v 1.8 2005/03/14 02:02:49 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -66,6 +66,10 @@ extern "C" {
Get volume of an audio CD. Get volume of an audio CD.
@param p_cdio the CD object to be acted upon. @param p_cdio the CD object to be acted upon.
@param p_volume place to put the list of volume outputs levels
p_volume can be NULL in which case we return only whether the driver
has the ability to get the volume or not.
*/ */
driver_return_code_t cdio_audio_get_volume (CdIo_t *p_cdio, /*out*/ driver_return_code_t cdio_audio_get_volume (CdIo_t *p_cdio, /*out*/

View File

@@ -1,5 +1,5 @@
/* -*- c -*- /* -*- c -*-
$Id: device.h,v 1.21 2005/03/07 07:23:52 rocky Exp $ $Id: device.h,v 1.22 2005/03/14 02:02:49 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -221,10 +221,10 @@ extern "C" {
/*! /*!
Close media tray in CD drive if there is a routine to do so. Close media tray in CD drive if there is a routine to do so.
@param name of CD-ROM device to be acted upon. @param psz_drive the name of CD-ROM to be closed.
driver_id is the driver to use to perform the action. If DRIVER_UNKNOWN @param p_driver_id is the driver to be used or that got used if
or DRIVER_DEVICE we'll scan for a suitable driver and set it was DRIVER_UNKNOWN or DRIVER_DEVICE; If this is NULL, we won't
driver_id to that on return. report back the driver used.
*/ */
driver_return_code_t cdio_close_tray (const char *psz_device, driver_return_code_t cdio_close_tray (const char *psz_device,
/*in/out*/ driver_id_t *p_driver_id); /*in/out*/ driver_id_t *p_driver_id);

View File

@@ -1,5 +1,5 @@
/* /*
$Id: audio.c,v 1.7 2005/03/06 22:36:27 rocky Exp $ $Id: audio.c,v 1.8 2005/03/14 02:02:49 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -46,8 +46,11 @@ cdio_audio_get_msf_seconds(msf_t *p_msf)
driver_return_code_t driver_return_code_t
cdio_audio_get_volume (CdIo_t *p_cdio, /*out*/ cdio_audio_volume_t *p_volume) cdio_audio_get_volume (CdIo_t *p_cdio, /*out*/ cdio_audio_volume_t *p_volume)
{ {
cdio_audio_volume_t temp_audio_volume;
if (!p_cdio) return DRIVER_OP_UNINIT; if (!p_cdio) return DRIVER_OP_UNINIT;
if (!p_volume) p_volume = &temp_audio_volume;
if (p_cdio->op.audio_get_volume) { if (p_cdio->op.audio_get_volume) {
return p_cdio->op.audio_get_volume (p_cdio->env, p_volume); return p_cdio->op.audio_get_volume (p_cdio->env, p_volume);
} else { } else {

View File

@@ -1,5 +1,5 @@
/* /*
$Id: device.c,v 1.18 2005/03/09 02:19:54 rocky Exp $ $Id: device.c,v 1.19 2005/03/14 02:02:49 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -301,13 +301,19 @@ cdio_destroy (CdIo_t *p_cdio)
/*! /*!
Close media tray in CD drive if there is a routine to do so. Close media tray in CD drive if there is a routine to do so.
@param p_cdio the CD object to be acted upon. @param psz_drive the name of CD-ROM to be closed.
If the CD is ejected *p_cdio is free'd and p_cdio set to NULL. @param p_driver_id is the driver to be used or that got used if
it was DRIVER_UNKNOWN or DRIVER_DEVICE; If this is NULL, we won't
report back the driver used.
*/ */
driver_return_code_t driver_return_code_t
cdio_close_tray (const char *psz_device, /*in/out*/ driver_id_t cdio_close_tray (const char *psz_drive, /*in/out*/ driver_id_t
*p_driver_id) *p_driver_id)
{ {
const driver_id_t temp_driver_id = DRIVER_DEVICE;
if (!p_driver_id) p_driver_id = &temp_driver_id;
if (DRIVER_UNKNOWN == *p_driver_id || DRIVER_DEVICE == *p_driver_id) { if (DRIVER_UNKNOWN == *p_driver_id || DRIVER_DEVICE == *p_driver_id) {
*p_driver_id = CDIO_MIN_DEVICE_DRIVER; *p_driver_id = CDIO_MIN_DEVICE_DRIVER;
@@ -315,7 +321,7 @@ cdio_close_tray (const char *psz_device, /*in/out*/ driver_id_t
for ( ; *p_driver_id<=CDIO_MAX_DRIVER; (*p_driver_id)++) { for ( ; *p_driver_id<=CDIO_MAX_DRIVER; (*p_driver_id)++) {
if ( (*CdIo_all_drivers[*p_driver_id].have_driver)() && if ( (*CdIo_all_drivers[*p_driver_id].have_driver)() &&
*CdIo_all_drivers[*p_driver_id].close_tray ) { *CdIo_all_drivers[*p_driver_id].close_tray ) {
return (*CdIo_all_drivers[*p_driver_id].close_tray)(psz_device); return (*CdIo_all_drivers[*p_driver_id].close_tray)(psz_drive);
} }
} }
return DRIVER_OP_UNSUPPORTED; return DRIVER_OP_UNSUPPORTED;
@@ -324,7 +330,7 @@ cdio_close_tray (const char *psz_device, /*in/out*/ driver_id_t
/* The driver id was specified. Use that. */ /* The driver id was specified. Use that. */
if ( (*CdIo_all_drivers[*p_driver_id].have_driver)() && if ( (*CdIo_all_drivers[*p_driver_id].have_driver)() &&
*CdIo_all_drivers[*p_driver_id].close_tray ) { *CdIo_all_drivers[*p_driver_id].close_tray ) {
return (*CdIo_all_drivers[*p_driver_id].close_tray)(psz_device); return (*CdIo_all_drivers[*p_driver_id].close_tray)(psz_drive);
} }
return DRIVER_OP_UNSUPPORTED; return DRIVER_OP_UNSUPPORTED;
} }