BltCddaDevice.h

00001 /*****************************************************************
00002 |
00003 |      Cdda: BltCddaDevice.h
00004 |
00005 |      Cdda Device Module
00006 |
00007 |      (c) 2002-2003 Gilles Boccon-Gibod
00008 |      Author: Gilles Boccon-Gibod (bok@bok.net)
00009 |
00010  ****************************************************************/
00011 
00012 #ifndef _BLT_CDDA_DEVICE_H_
00013 #define _BLT_CDDA_DEVICE_H_
00014 
00015 /*----------------------------------------------------------------------
00016 |       includes
00017 +---------------------------------------------------------------------*/
00018 #include "Atomix.h"
00019 #include "BltTypes.h"
00020 
00021 /*----------------------------------------------------------------------
00022 |       types
00023 +---------------------------------------------------------------------*/
00024 typedef enum {
00025     BLT_CDDA_TRACK_TYPE_AUDIO,
00026     BLT_CDDA_TRACK_TYPE_DATA
00027 } BLT_CddaTrackType;
00028 
00029 typedef unsigned long BLT_CddaLba;
00030 typedef struct {
00031     unsigned int m;
00032     unsigned int s;
00033     unsigned int f;
00034 } BLT_CddaMsf;
00035 
00036 typedef struct {
00037     unsigned short left;
00038     unsigned short right;
00039 } BLT_CddaSample;
00040 
00041 typedef struct {
00042     BLT_Ordinal       index;
00043     BLT_CddaTrackType type;
00044     BLT_CddaLba       address;
00045     struct {
00046         BLT_CddaLba frames;
00047         BLT_CddaMsf msf;
00048     }                 duration;
00049 } BLT_CddaTrackInfo;
00050 
00051 typedef struct {
00052     BLT_Cardinal       track_count;
00053     BLT_Ordinal        first_track_index;
00054     BLT_Ordinal        last_track_index;
00055     BLT_CddaTrackInfo* tracks;
00056 } BLT_CddaTableOfContents;
00057 
00058 typedef struct BLT_CddaTrack BLT_CddaTrack;
00059 
00060 /*----------------------------------------------------------------------
00061 |       constants
00062 +---------------------------------------------------------------------*/
00063 #define BLT_CDDA_FRAME_SIZE        2352
00064 #define BLT_CDDA_FRAMES_PER_SECOND 75
00065 #define BLT_CDDA_MSF_FRAME_OFFSET  150
00066 
00067 /*----------------------------------------------------------------------
00068 |       BLT_CddaDevice interface
00069 +---------------------------------------------------------------------*/
00070 ATX_DECLARE_INTERFACE(BLT_CddaDevice)
00071 ATX_BEGIN_INTERFACE_DEFINITION(BLT_CddaDevice)
00072     BLT_Result (*GetTrackInfo)(BLT_CddaDevice*    self, 
00073                                BLT_Ordinal        index,
00074                                BLT_CddaTrackInfo* info);
00075     BLT_Result (*GetTableOfContents)(BLT_CddaDevice*           self,
00076                                      BLT_CddaTableOfContents** toc);
00077     BLT_Result (*ReadFrames)(BLT_CddaDevice* self,
00078                              BLT_CddaLba     addr,
00079                              BLT_Cardinal    count,
00080                              BLT_Any         buffer);
00081 ATX_END_INTERFACE_DEFINITION
00082 
00083 /*----------------------------------------------------------------------
00084 |       convenience macros
00085 +---------------------------------------------------------------------*/
00086 #define BLT_CddaDevice_GetTrackInfo(self, index, info) \
00087 ATX_INTERFACE(self)->GetTrackInfo(self, index, info)
00088 
00089 #define BLT_CddaDevice_GetTableOfContents(self, toc) \
00090 ATX_INTERFACE(self)->GetTableOfContents(self, toc)
00091 
00092 #define BLT_CddaDevice_ReadFrames(self, addr, count, samples) \
00093 ATX_INTERFACE(self)->ReadFrames(self, addr, count, samples)
00094 
00095 
00096 /*----------------------------------------------------------------------
00097 |       prototypes
00098 +---------------------------------------------------------------------*/
00099 void       BLT_Cdda_FramesToMsf(BLT_CddaLba frames, BLT_CddaMsf* msf);
00100 BLT_Result BLT_CddaDevice_Create(BLT_CString name, BLT_CddaDevice** device);
00101 BLT_Result BLT_CddaTrack_Create(BLT_CddaDevice*   device,
00102                                 BLT_Ordinal       index,
00103                                 ATX_InputStream** track);
00104 
00105 #endif /* _BLT_CDDA_DEVICE_H_ */