src/cdrom/macosx/AudioFilePlayer.h
changeset 1487 dc6b59e925a2
parent 1402 d910939febfa
child 1662 782fd950bd46
child 1895 c121d94672cb
child 4103 9df8136abec0
equal deleted inserted replaced
1486:9d77fc9d0ace 1487:dc6b59e925a2
    22     This file based on Apple sample code. We haven't changed the file name, 
    22     This file based on Apple sample code. We haven't changed the file name, 
    23     so if you want to see the original search for it on apple.com/developer
    23     so if you want to see the original search for it on apple.com/developer
    24 */
    24 */
    25 #include "SDL_config.h"
    25 #include "SDL_config.h"
    26 
    26 
    27 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    27 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    28 //  AudioFilePlayer.h
    28     AudioFilePlayer.h
    29 //
    29 */
    30 #ifndef __AudioFilePlayer_H__
    30 #ifndef __AudioFilePlayer_H__
    31 #define __AudioFilePlayer_H__
    31 #define __AudioFilePlayer_H__
    32 
    32 
    33 #include <CoreServices/CoreServices.h>
    33 #include <CoreServices/CoreServices.h>
    34 
    34 
    60 struct S_AudioFileManager;
    60 struct S_AudioFileManager;
    61 
    61 
    62 #pragma mark __________ AudioFilePlayer
    62 #pragma mark __________ AudioFilePlayer
    63 typedef struct S_AudioFilePlayer
    63 typedef struct S_AudioFilePlayer
    64 {
    64 {
    65 //public:
    65 /*public:*/
    66     int             (*SetDestination)(struct S_AudioFilePlayer *afp, AudioUnit *inDestUnit);
    66     int             (*SetDestination)(struct S_AudioFilePlayer *afp, AudioUnit *inDestUnit);
    67     void            (*SetNotifier)(struct S_AudioFilePlayer *afp, AudioFilePlayNotifier inNotifier, void *inRefCon);
    67     void            (*SetNotifier)(struct S_AudioFilePlayer *afp, AudioFilePlayNotifier inNotifier, void *inRefCon);
    68     void            (*SetStartFrame)(struct S_AudioFilePlayer *afp, int frame); // seek in the file
    68     void            (*SetStartFrame)(struct S_AudioFilePlayer *afp, int frame); /* seek in the file */
    69     int             (*GetCurrentFrame)(struct S_AudioFilePlayer *afp); // get the current frame position
    69     int             (*GetCurrentFrame)(struct S_AudioFilePlayer *afp); /* get the current frame position */
    70     void            (*SetStopFrame)(struct S_AudioFilePlayer *afp, int frame);   // set limit in the file
    70     void            (*SetStopFrame)(struct S_AudioFilePlayer *afp, int frame);   /* set limit in the file */
    71     int             (*Connect)(struct S_AudioFilePlayer *afp);
    71     int             (*Connect)(struct S_AudioFilePlayer *afp);
    72     void            (*Disconnect)(struct S_AudioFilePlayer *afp);
    72     void            (*Disconnect)(struct S_AudioFilePlayer *afp);
    73     void            (*DoNotification)(struct S_AudioFilePlayer *afp, OSStatus inError);
    73     void            (*DoNotification)(struct S_AudioFilePlayer *afp, OSStatus inError);
    74     int             (*IsConnected)(struct S_AudioFilePlayer *afp);
    74     int             (*IsConnected)(struct S_AudioFilePlayer *afp);
    75     AudioUnit       (*GetDestUnit)(struct S_AudioFilePlayer *afp);
    75     AudioUnit       (*GetDestUnit)(struct S_AudioFilePlayer *afp);
    76     void            (*Print)(struct S_AudioFilePlayer *afp);
    76     void            (*Print)(struct S_AudioFilePlayer *afp);
    77 
    77 
    78 //private:
    78 /*private:*/
    79     AudioUnit                       mPlayUnit;
    79     AudioUnit                       mPlayUnit;
    80     SInt16                          mForkRefNum;
    80     SInt16                          mForkRefNum;
    81     
    81     
    82     AudioUnitInputCallback          mInputCallback;
    82     AudioUnitInputCallback          mInputCallback;
    83 
    83 
   104 
   104 
   105 
   105 
   106 #pragma mark __________ AudioFileManager
   106 #pragma mark __________ AudioFileManager
   107 typedef struct S_AudioFileManager
   107 typedef struct S_AudioFileManager
   108 {
   108 {
   109 //public:
   109 /*public:*/
   110         // this method should NOT be called by an object of this class
   110         /* this method should NOT be called by an object of this class
   111         // as it is called by the parent's Disconnect() method
   111            as it is called by the parent's Disconnect() method */
   112     void                (*Disconnect)(struct S_AudioFileManager *afm);
   112     void                (*Disconnect)(struct S_AudioFileManager *afm);
   113     int                 (*DoConnect)(struct S_AudioFileManager *afm);
   113     int                 (*DoConnect)(struct S_AudioFileManager *afm);
   114     OSStatus            (*Read)(struct S_AudioFileManager *afm, char *buffer, UInt32 *len);
   114     OSStatus            (*Read)(struct S_AudioFileManager *afm, char *buffer, UInt32 *len);
   115     const char*         (*GetFileBuffer)(struct S_AudioFileManager *afm);
   115     const char*         (*GetFileBuffer)(struct S_AudioFileManager *afm);
   116     const AudioFilePlayer *(*GetParent)(struct S_AudioFileManager *afm);
   116     const AudioFilePlayer *(*GetParent)(struct S_AudioFileManager *afm);
   117     void                (*SetPosition)(struct S_AudioFileManager *afm, SInt64 pos);  // seek/rewind in the file
   117     void                (*SetPosition)(struct S_AudioFileManager *afm, SInt64 pos);  /* seek/rewind in the file */
   118     int                 (*GetByteCounter)(struct S_AudioFileManager *afm);  // return actual bytes streamed to audio hardware
   118     int                 (*GetByteCounter)(struct S_AudioFileManager *afm);  /* return actual bytes streamed to audio hardware */
   119     void                (*SetEndOfFile)(struct S_AudioFileManager *afm, SInt64 pos);  // set the "EOF" (will behave just like it reached eof)
   119     void                (*SetEndOfFile)(struct S_AudioFileManager *afm, SInt64 pos);  /* set the "EOF" (will behave just like it reached eof) */
   120    
   120    
   121 //protected:
   121 /*protected:*/
   122     AudioFilePlayer*    mParent;
   122     AudioFilePlayer*    mParent;
   123     SInt16              mForkRefNum;
   123     SInt16              mForkRefNum;
   124     SInt64              mAudioDataOffset;
   124     SInt64              mAudioDataOffset;
   125     
   125     
   126     char*               mFileBuffer;
   126     char*               mFileBuffer;
   135 
   135 
   136 
   136 
   137 	void*               mTmpBuffer;
   137 	void*               mTmpBuffer;
   138 	UInt32              mBufferSize;
   138 	UInt32              mBufferSize;
   139 	UInt32              mBufferOffset;
   139 	UInt32              mBufferOffset;
   140 //public:
   140 /*public:*/
   141     UInt32              mChunkSize;
   141     UInt32              mChunkSize;
   142     SInt64              mFileLength;
   142     SInt64              mFileLength;
   143     SInt64              mReadFilePosition;
   143     SInt64              mReadFilePosition;
   144     int                 mWriteToFirstBuffer;
   144     int                 mWriteToFirstBuffer;
   145     int                 mFinishedReadingData;
   145     int                 mFinishedReadingData;
   146 
   146 
   147 //protected:
   147 /*protected:*/
   148     OSStatus            (*Render)(struct S_AudioFileManager *afm, AudioBuffer *ioData);
   148     OSStatus            (*Render)(struct S_AudioFileManager *afm, AudioBuffer *ioData);
   149     OSStatus            (*GetFileData)(struct S_AudioFileManager *afm, void** inOutData, UInt32 *inOutDataSize);
   149     OSStatus            (*GetFileData)(struct S_AudioFileManager *afm, void** inOutData, UInt32 *inOutDataSize);
   150     void                (*AfterRender)(struct S_AudioFileManager *afm);
   150     void                (*AfterRender)(struct S_AudioFileManager *afm);
   151 
   151 
   152 //public:
   152 /*public:*/
   153     //static
   153     /*static*/
   154     OSStatus            (*FileInputProc)(void                             *inRefCon,
   154     OSStatus            (*FileInputProc)(void                             *inRefCon,
   155                                          AudioUnitRenderActionFlags      inActionFlags,
   155                                          AudioUnitRenderActionFlags      inActionFlags,
   156                                          const AudioTimeStamp            *inTimeStamp,
   156                                          const AudioTimeStamp            *inTimeStamp,
   157                                          UInt32                          inBusNumber,
   157                                          UInt32                          inBusNumber,
   158                                          AudioBuffer                     *ioData);
   158                                          AudioBuffer                     *ioData);