Move a set_speed and set_blocksize (via MMC)from driver-specific

places to generic.

Add _t to yet another type.
This commit is contained in:
rocky
2005-01-20 01:00:52 +00:00
parent f7ebed2287
commit bd333bc73f
13 changed files with 99 additions and 104 deletions

View File

@@ -1,7 +1,7 @@
/*
$Id: _cdio_stream.c,v 1.1 2004/12/18 17:29:32 rocky Exp $
$Id: _cdio_stream.c,v 1.2 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2000, 2004 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2000, 2004, 2005 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@
#include <cdio/util.h>
#include "_cdio_stream.h"
static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.1 2004/12/18 17:29:32 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.2 2005/01/20 01:00:52 rocky Exp $";
/*
* DataSource implementations
@@ -52,7 +52,7 @@ struct _CdioDataSource {
Return false if we hit an error. Errno should be set for that error.
*/
static bool
_cdio_stream_open_if_necessary(CdioDataSource *p_obj)
_cdio_stream_open_if_necessary(CdioDataSource_t *p_obj)
{
cdio_assert (p_obj != NULL);
@@ -87,7 +87,7 @@ _cdio_stream_open_if_necessary(CdioDataSource *p_obj)
cate the error.
*/
long
cdio_stream_seek(CdioDataSource* p_obj, long int offset, int whence)
cdio_stream_seek(CdioDataSource_t* p_obj, long int offset, int whence)
{
cdio_assert (p_obj != NULL);
@@ -106,12 +106,12 @@ cdio_stream_seek(CdioDataSource* p_obj, long int offset, int whence)
return 0;
}
CdioDataSource*
CdioDataSource_t *
cdio_stream_new(void *user_data, const cdio_stream_io_functions *funcs)
{
CdioDataSource *new_obj;
CdioDataSource_t *new_obj;
new_obj = _cdio_malloc (sizeof (CdioDataSource));
new_obj = _cdio_malloc (sizeof (CdioDataSource_t));
new_obj->user_data = user_data;
memcpy(&(new_obj->op), funcs, sizeof(cdio_stream_io_functions));
@@ -137,16 +137,16 @@ cdio_stream_new(void *user_data, const cdio_stream_io_functions *funcs)
must use feof(3) and ferror(3) to determine which occurred.
*/
long
cdio_stream_read(CdioDataSource* obj, void *ptr, long size, long nmemb)
cdio_stream_read(CdioDataSource_t* p_obj, void *ptr, long size, long nmemb)
{
long read_bytes;
cdio_assert (obj != NULL);
cdio_assert (p_obj != NULL);
if (!_cdio_stream_open_if_necessary(obj)) return 0;
if (!_cdio_stream_open_if_necessary(p_obj)) return 0;
read_bytes = obj->op.read(obj->user_data, ptr, size*nmemb);
obj->position += read_bytes;
read_bytes = p_obj->op.read(p_obj->user_data, ptr, size*nmemb);
p_obj->position += read_bytes;
return read_bytes;
}
@@ -156,38 +156,38 @@ cdio_stream_read(CdioDataSource* obj, void *ptr, long size, long nmemb)
On error return -1;
*/
long int
cdio_stream_stat(CdioDataSource* obj)
cdio_stream_stat(CdioDataSource_t *p_obj)
{
cdio_assert (obj != NULL);
cdio_assert (p_obj != NULL);
if (!_cdio_stream_open_if_necessary(obj)) return -1;
if (!_cdio_stream_open_if_necessary(p_obj)) return -1;
return obj->op.stat(obj->user_data);
return p_obj->op.stat(p_obj->user_data);
}
void
cdio_stream_close(CdioDataSource* obj)
cdio_stream_close(CdioDataSource_t *p_obj)
{
cdio_assert (obj != NULL);
cdio_assert (p_obj != NULL);
if (obj->is_open) {
if (p_obj->is_open) {
cdio_debug ("closed source...");
obj->op.close(obj->user_data);
obj->is_open = 0;
obj->position = 0;
p_obj->op.close(p_obj->user_data);
p_obj->is_open = 0;
p_obj->position = 0;
}
}
void
cdio_stream_destroy(CdioDataSource* obj)
cdio_stream_destroy(CdioDataSource_t *p_obj)
{
cdio_assert (obj != NULL);
cdio_assert (p_obj != NULL);
cdio_stream_close(obj);
cdio_stream_close(p_obj);
obj->op.free(obj->user_data);
p_obj->op.free(p_obj->user_data);
free(obj);
free(p_obj);
}