Search
lxdream.org :: lxdream/src/gdrom/gdrom.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdrom.h
changeset 736:a02d1475ccfd
prev720:b5594d1ac80a
next782:1af8b5ce627c
author nkeynes
date Mon Jul 14 07:44:42 2008 +0000 (14 years ago)
permissions -rw-r--r--
last change Re-indent everything consistently
Fix include guards for consistency as well
file annotate diff log raw
nkeynes@125
     1
/**
nkeynes@561
     2
 * $Id$
nkeynes@125
     3
 *
nkeynes@678
     4
 * This file defines the public structures and functions exported by the 
nkeynes@678
     5
 * GD-Rom subsystem
nkeynes@125
     6
 *
nkeynes@125
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@125
     8
 *
nkeynes@125
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@125
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@125
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@125
    12
 * (at your option) any later version.
nkeynes@125
    13
 *
nkeynes@125
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@125
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@125
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@125
    17
 * GNU General Public License for more details.
nkeynes@125
    18
 */
nkeynes@125
    19
nkeynes@678
    20
#ifndef lxdream_gdrom_H
nkeynes@678
    21
#define lxdream_gdrom_H 1
nkeynes@125
    22
nkeynes@678
    23
#include "lxdream.h"
nkeynes@678
    24
#include "hook.h"
nkeynes@678
    25
#include <glib/glist.h>
nkeynes@342
    26
nkeynes@736
    27
#ifdef __cplusplus
nkeynes@736
    28
extern "C" {
nkeynes@736
    29
#endif
nkeynes@736
    30
nkeynes@149
    31
typedef uint16_t gdrom_error_t;
nkeynes@149
    32
nkeynes@709
    33
nkeynes@709
    34
struct gdrom_device {
nkeynes@709
    35
    char *name;  // internal name
nkeynes@709
    36
    char *device_name; // Human-readable device name
nkeynes@709
    37
};
nkeynes@709
    38
nkeynes@709
    39
typedef struct gdrom_device *gdrom_device_t;
nkeynes@709
    40
nkeynes@678
    41
typedef struct gdrom_disc *gdrom_disc_t;
nkeynes@138
    42
nkeynes@678
    43
typedef gboolean (*gdrom_disc_change_hook_t)( gdrom_disc_t new_disc, const gchar *new_disc_name, void *user_data );
nkeynes@720
    44
DECLARE_HOOK(gdrom_disc_change_hook, gdrom_disc_change_hook_t);
nkeynes@138
    45
nkeynes@720
    46
typedef gboolean (*gdrom_drive_list_change_hook_t)( GList *drive_list, void *user_data );
nkeynes@720
    47
DECLARE_HOOK(gdrom_drive_list_change_hook, gdrom_drive_list_change_hook_t);
nkeynes@125
    48
nkeynes@138
    49
/**
nkeynes@138
    50
 * Open an image file
nkeynes@138
    51
 */
nkeynes@138
    52
gdrom_disc_t gdrom_image_open( const gchar *filename );
nkeynes@138
    53
nkeynes@138
    54
/**
nkeynes@422
    55
 * Dump image info
nkeynes@422
    56
 */
nkeynes@422
    57
void gdrom_image_dump_info( gdrom_disc_t d );
nkeynes@422
    58
nkeynes@245
    59
nkeynes@138
    60
/**
nkeynes@138
    61
 * Shortcut to open and mount an image file
nkeynes@433
    62
 * @return true on success
nkeynes@138
    63
 */
nkeynes@433
    64
gboolean gdrom_mount_image( const gchar *filename );
nkeynes@138
    65
nkeynes@138
    66
void gdrom_mount_disc( gdrom_disc_t disc );
nkeynes@138
    67
nkeynes@138
    68
void gdrom_unmount_disc( void );
nkeynes@138
    69
nkeynes@138
    70
gboolean gdrom_is_mounted( void );
nkeynes@138
    71
nkeynes@464
    72
gdrom_disc_t gdrom_get_current_disc();
nkeynes@464
    73
nkeynes@678
    74
const gchar *gdrom_get_current_disc_name();
nkeynes@678
    75
nkeynes@138
    76
uint32_t gdrom_read_sectors( uint32_t sector, uint32_t sector_count,
nkeynes@736
    77
                             int mode, unsigned char *buf, uint32_t *length );
nkeynes@125
    78
nkeynes@678
    79
nkeynes@613
    80
/**
nkeynes@678
    81
 * Retrieve the disc table of contents, and write it into the buffer in the 
nkeynes@678
    82
 * format expected by the DC.
nkeynes@678
    83
 * @return 0 on success, error code on failure (eg no disc mounted)
nkeynes@613
    84
 */
nkeynes@678
    85
gdrom_error_t gdrom_get_toc( unsigned char *buf );
nkeynes@678
    86
nkeynes@678
    87
/**
nkeynes@678
    88
 * Retrieve the short (6-byte) session info, and write it into the buffer.
nkeynes@678
    89
 * @return 0 on success, error code on failure.
nkeynes@678
    90
 */
nkeynes@678
    91
gdrom_error_t gdrom_get_info( unsigned char *buf, int session );
nkeynes@678
    92
nkeynes@678
    93
uint8_t gdrom_get_track_no_by_lba( uint32_t lba );
nkeynes@613
    94
nkeynes@709
    95
nkeynes@709
    96
/**
nkeynes@709
    97
 * Native CD-ROM API - provided by drivers/cd_*.c
nkeynes@709
    98
 *
nkeynes@709
    99
 * A device name is either a system special file (most unixes) or a url of the
nkeynes@709
   100
 * form dvd://<identifier> or cd://<identifier>, where <identifier> is a system
nkeynes@709
   101
 * defined string that uniquely identifies a particular device.
nkeynes@709
   102
 */
nkeynes@709
   103
nkeynes@709
   104
/**
nkeynes@709
   105
 * Return a list of gdrom_device_t defining all CD/DVD drives in the host system.
nkeynes@709
   106
 */
nkeynes@709
   107
GList *cdrom_get_native_devices();
nkeynes@709
   108
nkeynes@709
   109
/**
nkeynes@709
   110
 * Open a native device given a device name and url method. Eg, for the url dvd://1
nkeynes@709
   111
 * this function will be invoked with method = "dvd" and name = "1"
nkeynes@709
   112
 * 
nkeynes@709
   113
 * @return NULL on failure, otherwise a valid gdrom_disc_t that can be mounted.
nkeynes@709
   114
 */
nkeynes@709
   115
gdrom_disc_t cdrom_open_device( const gchar *method, const gchar *name );
nkeynes@709
   116
nkeynes@736
   117
#ifdef __cplusplus
nkeynes@736
   118
}
nkeynes@125
   119
#endif
nkeynes@736
   120
nkeynes@736
   121
#endif /* !lxdream_gdrom_H */
.