목차

include/AK/SoundEngine/Common/IAkStreamMgr.h

Go to the documentation of this file.
00001 
00002 //
00003 // Copyright (c) 2006 Audiokinetic Inc. / All Rights Reserved
00004 //
00006 
00009 
00010 #ifndef _IAK_STREAM_MGR_H_
00011 #define _IAK_STREAM_MGR_H_
00012 
00013 #include <AK/SoundEngine/Common/AkMemoryMgr.h>
00014 
00015 //-----------------------------------------------------------------------------
00016 // Defines. 
00017 //-----------------------------------------------------------------------------
00018 
00020 
00021 #define AK_MONITOR_STREAMNAME_MAXLENGTH    (64)
00022 #define AK_MONITOR_DEVICENAME_MAXLENGTH    (16)
00023 
00024  
00025 //-----------------------------------------------------------------------------
00026 // Enums.
00027 //-----------------------------------------------------------------------------
00028 
00030 enum AkStmStatus
00031 {
00032     AK_StmStatusIdle            = 0,        
00033     AK_StmStatusCompleted       = 1,        
00034     AK_StmStatusPending         = 2,        
00035     AK_StmStatusCancelled       = 3,        
00036     AK_StmStatusError           = 4         
00037 };
00038 
00043 enum AkMoveMethod
00044 {
00045     AK_MoveBegin                = 0,        
00046     AK_MoveCurrent              = 1,        
00047     AK_MoveEnd                  = 2         
00048 };
00049 
00051 enum AkOpenMode
00052 {
00053     AK_OpenModeRead             = 0,        
00054     AK_OpenModeWrite            = 1,        
00055     AK_OpenModeWriteOvrwr       = 2,        
00056     AK_OpenModeReadWrite        = 3         
00057 };
00058 
00060 struct AkFileSystemFlags
00061 {
00062     AkFileSystemFlags()
00063         : uCacheID( AK_INVALID_FILE_ID ) {}
00064 
00065     AkFileSystemFlags( AkUInt32 in_uCompanyID, AkUInt32 in_uCodecID, AkUInt32 in_uCustomParamSize, void * in_pCustomParam, bool in_bIsLanguageSpecific, bool in_bIsFromRSX, AkFileID in_uCacheID )
00066         : uCompanyID( in_uCompanyID )
00067         , uCodecID( in_uCodecID )
00068         , uCustomParamSize( in_uCustomParamSize )
00069         , pCustomParam( in_pCustomParam )
00070         , bIsLanguageSpecific( in_bIsLanguageSpecific )
00071         , bIsFromRSX( in_bIsFromRSX )
00072         , uCacheID( in_uCacheID ) 
00073         , uNumBytesPrefetch( 0 ) {}
00074 
00075     AkUInt32            uCompanyID;         
00076     AkUInt32            uCodecID;           
00077     AkUInt32            uCustomParamSize;   
00078     void *              pCustomParam;       
00079     bool                bIsLanguageSpecific;
00080     bool                bIsFromRSX;         
00081     bool                bIsAutomaticStream; 
00082 
00083     AkFileID            uCacheID;           
00084 
00085     AkUInt32            uNumBytesPrefetch;  
00086 };
00087 
00092 struct AkStreamInfo
00093 {
00094     AkDeviceID          deviceID;           
00095     const AkOSChar *    pszName;            
00096     AkUInt64            uSize;              
00097     bool                bIsOpen;            
00098 };
00099 
00101 struct AkAutoStmHeuristics
00102 {
00103     AkReal32            fThroughput;        
00104     AkUInt32            uLoopStart;         
00105     AkUInt32            uLoopEnd;           
00106     AkUInt8             uMinNumBuffers;     
00107 
00108 
00109 
00110     AkPriority          priority;           
00111 };
00112 
00114 struct AkAutoStmBufSettings
00115 {
00116     AkUInt32            uBufferSize;        
00117 
00118 
00119     AkUInt32            uMinBufferSize;     
00120 
00121     AkUInt32            uBlockSize;         
00122 };
00123 
00125 
00126 
00128 struct AkDeviceDesc
00129 {
00130     AkDeviceID          deviceID;           
00131     bool                bCanWrite;          
00132     bool                bCanRead;           
00133     AkUtf16             szDeviceName[AK_MONITOR_DEVICENAME_MAXLENGTH];      
00134     AkUInt32            uStringSize;        
00135 };
00136 
00138 struct AkDeviceData
00139 {
00140     AkDeviceID          deviceID;           
00141     AkUInt32            uMemSize;           
00142     AkUInt32            uMemUsed;           
00143     AkUInt32            uAllocs;            
00144     AkUInt32            uFrees;             
00145     AkUInt32            uPeakRefdMemUsed;           
00146     AkUInt32            uUnreferencedCachedBytes;   
00147     AkUInt32            uGranularity;       
00148     AkUInt32            uNumActiveStreams;  
00149     AkUInt32            uTotalBytesTransferred;         
00150     AkUInt32            uLowLevelBytesTransferred;      
00151     AkReal32            fAvgCacheEfficiency;            
00152     AkUInt32            uNumLowLevelRequestsCompleted;  
00153     AkUInt32            uNumLowLevelRequestsCancelled;  
00154     AkUInt32            uNumLowLevelRequestsPending;    
00155     AkUInt32            uCustomParam;       
00156     AkUInt32            uCachePinnedBytes;  
00157 };
00158 
00160 struct AkStreamRecord
00161 {
00162     AkUInt32            uStreamID;          
00163     AkDeviceID          deviceID;           
00164     AkUtf16             szStreamName[AK_MONITOR_STREAMNAME_MAXLENGTH];       
00165     AkUInt32            uStringSize;        
00166     AkUInt64            uFileSize;          
00167     AkUInt32            uCustomParamSize;   
00168     AkUInt32            uCustomParam;       
00169     bool                bIsAutoStream;      
00170     bool                bIsCachingStream;   
00171 };
00172 
00174 struct AkStreamData
00175 {
00176     AkUInt32            uStreamID;          
00177     // Status (replace)
00178     AkUInt32            uPriority;          
00179     AkUInt64            uFilePosition;      
00180     AkUInt32            uTargetBufferingSize;       
00181     AkUInt32            uVirtualBufferingSize;      
00182     AkUInt32            uBufferedSize;              
00183     AkUInt32            uNumBytesTransfered;        
00184     AkUInt32            uNumBytesTransferedLowLevel;
00185     AkUInt32            uMemoryReferenced;          
00186     AkReal32            fEstimatedThroughput;       
00187     bool                bActive;            
00188 };
00190 
00191 namespace AK
00192 {
00194 
00195     
00198     class IAkStreamProfile
00199     {
00200     protected:
00202         virtual ~IAkStreamProfile(){}
00203 
00204     public:
00208         virtual void    GetStreamRecord( 
00209             AkStreamRecord & out_streamRecord   
00210             ) = 0;
00211 
00215         virtual void    GetStreamData(
00216             AkStreamData &   out_streamData     
00217             ) = 0;
00218 
00223         virtual bool    IsNew() = 0;
00224 
00228         virtual void    ClearNew() = 0;
00229     };
00230 
00231 
00234     class IAkDeviceProfile
00235     {
00236     protected:
00238         virtual ~IAkDeviceProfile(){}
00239 
00240     public:
00241 
00243         virtual void    OnProfileStart() = 0;
00244 
00246         virtual void    OnProfileEnd() = 0;
00247 
00251         virtual void    GetDesc(
00252             AkDeviceDesc &  out_deviceDesc      
00253             ) = 0;
00254 
00258         virtual void    GetData(
00259             AkDeviceData &  out_deviceData      
00260             ) = 0;
00261 
00266         virtual bool    IsNew() = 0;
00267 
00271         virtual void    ClearNew() = 0;
00272 
00277         virtual AkUInt32 GetNumStreams() = 0;
00278 
00283         virtual IAkStreamProfile * GetStreamProfile( 
00284             AkUInt32    in_uStreamIndex     
00285             ) = 0;
00286     };
00287 
00290     class IAkStreamMgrProfile
00291     {
00292     protected:
00294         virtual ~IAkStreamMgrProfile(){}
00295         
00296     public:
00301         virtual AKRESULT StartMonitoring() = 0;
00302 
00306         virtual void     StopMonitoring() = 0;
00307         
00312         virtual AkUInt32 GetNumDevices() = 0;
00313 
00319         virtual IAkDeviceProfile * GetDeviceProfile( 
00320             AkUInt32    in_uDeviceIndex     
00321             ) = 0;
00322     };
00324 
00326 
00327 
00331     class IAkStdStream
00332     {
00333     protected:
00335         virtual ~IAkStdStream(){}
00336 
00337     public:
00339 
00340 
00341 
00342 
00343         virtual void      Destroy() = 0;
00344 
00348         virtual void      GetInfo(
00349             AkStreamInfo &  out_info            
00350             ) = 0;
00351 
00354         virtual void * GetFileDescriptor() = 0;
00355 
00359         virtual AKRESULT  SetStreamName(
00360             const AkOSChar *    in_pszStreamName    
00361             ) = 0;
00362 
00369         virtual AkUInt32  GetBlockSize() = 0;   
00371 
00373 
00374         
00381         virtual AKRESULT Read(
00382             void *          in_pBuffer,         
00383             AkUInt32        in_uReqSize,        
00384             bool            in_bWait,           
00385             AkPriority      in_priority,        
00386             AkReal32        in_fDeadline,       
00387             AkUInt32 &      out_uSize           
00388             ) = 0;
00389 
00396         virtual AKRESULT Write(
00397             void *          in_pBuffer,         
00398             AkUInt32        in_uReqSize,        
00399             bool            in_bWait,           
00400             AkPriority      in_priority,        
00401             AkReal32        in_fDeadline,       
00402             AkUInt32 &      out_uSize           
00403             ) = 0;
00404 
00410         virtual AkUInt64 GetPosition( 
00411             bool *          out_pbEndOfStream   
00412             ) = 0;
00413 
00420         virtual AKRESULT SetPosition(
00421             AkInt64         in_iMoveOffset,     
00422             AkMoveMethod    in_eMoveMethod,     
00423             AkInt64 *       out_piRealOffset    
00424 
00425             ) = 0;
00426 
00432         virtual void Cancel() = 0;
00433 
00435 
00437 
00438 
00439 
00440 
00441 
00442         virtual void *   GetData( 
00443             AkUInt32 &      out_uSize           
00444             ) = 0;
00445 
00450         virtual AkStmStatus GetStatus() = 0;  
00451 
00453     };
00454 
00455 
00462     class IAkAutoStream 
00463     {
00464     protected:
00466         virtual ~IAkAutoStream(){}
00467 
00468     public:
00470 
00471 
00472 
00473 
00474         virtual void      Destroy() = 0;
00475 
00479         virtual void      GetInfo(
00480             AkStreamInfo &      out_info        
00481             ) = 0;
00482 
00485         virtual void * GetFileDescriptor() = 0;
00486 
00490         virtual void      GetHeuristics(
00491             AkAutoStmHeuristics & out_heuristics
00492             ) = 0;
00493 
00497         virtual AKRESULT  SetHeuristics(
00498             const AkAutoStmHeuristics & in_heuristics   
00499             ) = 0;
00500 
00507         virtual AKRESULT  SetMinimalBufferSize(
00508             AkUInt32        in_uMinBufferSize   
00509             ) = 0;
00510 
00514         virtual AKRESULT  SetStreamName(
00515             const AkOSChar *    in_pszStreamName    
00516             ) = 0;
00517 
00524         virtual AkUInt32  GetBlockSize() = 0;
00525 
00536         virtual AKRESULT QueryBufferingStatus( 
00537             AkUInt32 & out_uNumBytesAvailable   
00538             ) = 0;
00539 
00543         virtual AkUInt32 GetNominalBuffering() = 0;
00544 
00546 
00548 
00549         
00554         virtual AKRESULT Start() = 0;
00555 
00560         virtual AKRESULT Stop() = 0;
00561 
00571         virtual AkUInt64 GetPosition( 
00572             bool *          out_pbEndOfStream   
00573             ) = 0;  
00574 
00582         virtual AKRESULT SetPosition(
00583             AkInt64         in_iMoveOffset,     
00584             AkMoveMethod    in_eMoveMethod,     
00585             AkInt64 *       out_piRealOffset    
00586 
00587             ) = 0;
00588 
00590 
00591 
00593 
00594 
00607         virtual AKRESULT GetBuffer(
00608             void *&         out_pBuffer,        
00609             AkUInt32 &      out_uSize,          
00610             bool            in_bWait            
00611             ) = 0;
00612 
00619         virtual AKRESULT ReleaseBuffer() = 0;
00621     };
00622 
00624 
00625 
00628     class IAkStreamMgr
00629     {
00630     protected:
00632         virtual ~IAkStreamMgr(){}
00633         
00634     public:
00639         inline static IAkStreamMgr * Get()
00640         {
00641             return m_pStreamMgr;
00642         }
00643 
00647         virtual void     Destroy() = 0;
00648 
00649 
00651 
00652 
00653 
00654         virtual IAkStreamMgrProfile * GetStreamMgrProfile() = 0;
00656 
00657 
00659 
00660         
00661         // Standard stream creation methods.
00662 
00668         virtual AKRESULT CreateStd(
00669             const AkOSChar*     in_pszFileName,     
00670             AkFileSystemFlags * in_pFSFlags,        
00671             AkOpenMode          in_eOpenMode,       
00672             IAkStdStream *&     out_pStream,        
00673             bool                in_bSyncOpen        
00674             ) = 0;
00675 
00681         virtual AKRESULT CreateStd(
00682             AkFileID            in_fileID,          
00683             AkFileSystemFlags * in_pFSFlags,        
00684             AkOpenMode          in_eOpenMode,       
00685             IAkStdStream *&     out_pStream,        
00686             bool                in_bSyncOpen        
00687             ) = 0;
00688 
00689         
00690         // Automatic stream create methods.
00691 
00698         virtual AKRESULT CreateAuto(
00699             const AkOSChar*             in_pszFileName,     
00700             AkFileSystemFlags *         in_pFSFlags,        
00701             const AkAutoStmHeuristics & in_heuristics,      
00702             AkAutoStmBufSettings *      in_pBufferSettings, 
00703             IAkAutoStream *&            out_pStream,        
00704             bool                        in_bSyncOpen        
00705             ) = 0;
00706 
00713         virtual AKRESULT CreateAuto(
00714             AkFileID                    in_fileID,          
00715             AkFileSystemFlags *         in_pFSFlags,        
00716             const AkAutoStmHeuristics & in_heuristics,      
00717             AkAutoStmBufSettings *      in_pBufferSettings, 
00718             IAkAutoStream *&            out_pStream,        
00719             bool                        in_bSyncOpen        
00720             ) = 0;
00721 
00727         virtual AKRESULT PinFileInCache(
00728             AkFileID                    in_fileID,          
00729             AkFileSystemFlags *         in_pFSFlags,        
00730             AkPriority                  in_uPriority        
00731             ) = 0;
00732 
00738         virtual AKRESULT UnpinFileInCache(
00739             AkFileID                    in_fileID,              
00740             AkPriority                  in_uPriority        
00741             ) = 0;
00742         
00747         virtual AKRESULT UpdateCachingPriority(
00748             AkFileID                    in_fileID,          
00749             AkPriority                  in_uPriority,       
00750             AkPriority                  in_uOldPriority         
00751             ) = 0;
00752         
00756         virtual AKRESULT GetBufferStatusForPinnedFile( 
00757             AkFileID in_fileID,                             
00758             AkReal32& out_fPercentBuffered,                 
00759             bool& out_bCacheFull                            
00760             ) = 0;
00761 
00763 
00764     protected:
00768         static AKSOUNDENGINE_API IAkStreamMgr * m_pStreamMgr;
00769     };
00770 
00771 }
00772 #endif //_IAK_STREAM_MGR_H_