Version

menu_open

include/AK/SoundEngine/Common/IAkStreamMgr.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
00003 released in source code form as part of the SDK installer package.
00004 
00005 Commercial License Usage
00006 
00007 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
00008 may use this file in accordance with the end user license agreement provided 
00009 with the software or, alternatively, in accordance with the terms contained in a
00010 written agreement between you and Audiokinetic Inc.
00011 
00012 Apache License Usage
00013 
00014 Alternatively, this file may be used under the Apache License, Version 2.0 (the 
00015 "Apache License"); you may not use this file except in compliance with the 
00016 Apache License. You may obtain a copy of the Apache License at 
00017 http://www.apache.org/licenses/LICENSE-2.0.
00018 
00019 Unless required by applicable law or agreed to in writing, software distributed
00020 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
00021 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
00022 the specific language governing permissions and limitations under the License.
00023 
00024   Version: <VERSION>  Build: <BUILDNUMBER>
00025   Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
00026 *******************************************************************************/
00027 
00030 
00031 #ifndef _IAK_STREAM_MGR_H_
00032 #define _IAK_STREAM_MGR_H_
00033 
00034 #include <AK/SoundEngine/Common/AkMemoryMgr.h>
00035 
00036 //-----------------------------------------------------------------------------
00037 // Defines. 
00038 //-----------------------------------------------------------------------------
00039 
00041 
00042 #define AK_MONITOR_STREAMNAME_MAXLENGTH    (64)
00043 #define AK_MONITOR_DEVICENAME_MAXLENGTH    (16)
00044 
00045  
00046 //-----------------------------------------------------------------------------
00047 // Enums.
00048 //-----------------------------------------------------------------------------
00049 
00051 enum AkStmStatus
00052 {
00053     AK_StmStatusIdle            = 0,        
00054     AK_StmStatusCompleted       = 1,        
00055     AK_StmStatusPending         = 2,        
00056     AK_StmStatusCancelled       = 3,        
00057     AK_StmStatusError           = 4         
00058 };
00059 
00064 enum AkMoveMethod
00065 {
00066     AK_MoveBegin                = 0,        
00067     AK_MoveCurrent              = 1,        
00068     AK_MoveEnd                  = 2         
00069 };
00070 
00072 enum AkOpenMode
00073 {
00074     AK_OpenModeRead             = 0,        
00075     AK_OpenModeWrite            = 1,        
00076     AK_OpenModeWriteOvrwr       = 2,        
00077     AK_OpenModeReadWrite        = 3         
00078 };
00079 
00081 struct AkFileSystemFlags
00082 {
00083     AkFileSystemFlags()
00084         : uCacheID( AK_INVALID_FILE_ID ) {}
00085 
00086     AkFileSystemFlags( AkUInt32 in_uCompanyID, AkUInt32 in_uCodecID, AkUInt32 in_uCustomParamSize, void * in_pCustomParam, bool in_bIsLanguageSpecific, bool in_bIsFromRSX, AkFileID in_uCacheID )
00087         : uCompanyID( in_uCompanyID )
00088         , uCodecID( in_uCodecID )
00089         , uCustomParamSize( in_uCustomParamSize )
00090         , pCustomParam( in_pCustomParam )
00091         , bIsLanguageSpecific( in_bIsLanguageSpecific )
00092         , bIsFromRSX( in_bIsFromRSX )
00093         , uCacheID( in_uCacheID ) 
00094         , uNumBytesPrefetch( 0 ) {}
00095 
00096     AkUInt32            uCompanyID;         
00097     AkUInt32            uCodecID;           
00098     AkUInt32            uCustomParamSize;   
00099     void *              pCustomParam;       
00100     bool                bIsLanguageSpecific;
00101     bool                bIsFromRSX;         
00102     bool                bIsAutomaticStream; 
00103 
00104     AkFileID            uCacheID;           
00105 
00106     AkUInt32            uNumBytesPrefetch;  
00107 
00108 
00109 };
00110 
00115 struct AkStreamInfo
00116 {
00117     AkDeviceID          deviceID;           
00118     const AkOSChar *    pszName;            
00119     AkUInt64            uSize;              
00120     bool                bIsOpen;            
00121 };
00122 
00124 struct AkAutoStmHeuristics
00125 {
00126     AkReal32            fThroughput;        
00127     AkUInt32            uLoopStart;         
00128     AkUInt32            uLoopEnd;           
00129     AkUInt8             uMinNumBuffers;     
00130 
00131 
00132 
00133     AkPriority          priority;           
00134 };
00135 
00137 struct AkAutoStmBufSettings
00138 {
00139     AkUInt32            uBufferSize;        
00140 
00141 
00142     AkUInt32            uMinBufferSize;     
00143 
00144     AkUInt32            uBlockSize;         
00145 };
00146 
00148 
00149 
00151 struct AkDeviceDesc
00152 {
00153     AkDeviceID          deviceID;           
00154     bool                bCanWrite;          
00155     bool                bCanRead;           
00156     AkUtf16             szDeviceName[AK_MONITOR_DEVICENAME_MAXLENGTH];      
00157     AkUInt32            uStringSize;        
00158 };
00159 
00161 struct AkDeviceData
00162 {
00163     AkDeviceID          deviceID;           
00164     AkUInt32            uMemSize;           
00165     AkUInt32            uMemUsed;           
00166     AkUInt32            uAllocs;            
00167     AkUInt32            uFrees;             
00168     AkUInt32            uPeakRefdMemUsed;           
00169     AkUInt32            uUnreferencedCachedBytes;   
00170     AkUInt32            uGranularity;       
00171     AkUInt32            uNumActiveStreams;  
00172     AkUInt32            uTotalBytesTransferred;         
00173     AkUInt32            uLowLevelBytesTransferred;      
00174     AkReal32            fAvgCacheEfficiency;            
00175     AkUInt32            uNumLowLevelRequestsCompleted;  
00176     AkUInt32            uNumLowLevelRequestsCancelled;  
00177     AkUInt32            uNumLowLevelRequestsPending;    
00178     AkUInt32            uCustomParam;       
00179     AkUInt32            uCachePinnedBytes;  
00180 };
00181 
00183 struct AkStreamRecord
00184 {
00185     AkUInt32            uStreamID;          
00186     AkDeviceID          deviceID;           
00187     AkUtf16             szStreamName[AK_MONITOR_STREAMNAME_MAXLENGTH];       
00188     AkUInt32            uStringSize;        
00189     AkUInt64            uFileSize;          
00190     AkUInt32            uCustomParamSize;   
00191     AkUInt32            uCustomParam;       
00192     bool                bIsAutoStream;      
00193     bool                bIsCachingStream;   
00194 };
00195 
00197 struct AkStreamData
00198 {
00199     AkUInt32            uStreamID;          
00200     // Status (replace)
00201     AkUInt32            uPriority;          
00202     AkUInt64            uFilePosition;      
00203     AkUInt32            uTargetBufferingSize;       
00204     AkUInt32            uVirtualBufferingSize;      
00205     AkUInt32            uBufferedSize;              
00206     AkUInt32            uNumBytesTransfered;        
00207     AkUInt32            uNumBytesTransferedLowLevel;
00208     AkUInt32            uMemoryReferenced;          
00209     AkReal32            fEstimatedThroughput;       
00210     bool                bActive;            
00211 };
00213 
00214 namespace AK
00215 {
00217 
00218     
00221     class IAkStreamProfile
00222     {
00223     protected:
00225         virtual ~IAkStreamProfile(){}
00226 
00227     public:
00231         virtual void    GetStreamRecord( 
00232             AkStreamRecord & out_streamRecord   
00233             ) = 0;
00234 
00238         virtual void    GetStreamData(
00239             AkStreamData &   out_streamData     
00240             ) = 0;
00241 
00246         virtual bool    IsNew() = 0;
00247 
00251         virtual void    ClearNew() = 0;
00252     };
00253 
00254 
00257     class IAkDeviceProfile
00258     {
00259     protected:
00261         virtual ~IAkDeviceProfile(){}
00262 
00263     public:
00264 
00266         virtual void    OnProfileStart() = 0;
00267 
00269         virtual void    OnProfileEnd() = 0;
00270 
00274         virtual void    GetDesc(
00275             AkDeviceDesc &  out_deviceDesc      
00276             ) = 0;
00277 
00281         virtual void    GetData(
00282             AkDeviceData &  out_deviceData      
00283             ) = 0;
00284 
00289         virtual bool    IsNew() = 0;
00290 
00294         virtual void    ClearNew() = 0;
00295 
00300         virtual AkUInt32 GetNumStreams() = 0;
00301 
00306         virtual IAkStreamProfile * GetStreamProfile( 
00307             AkUInt32    in_uStreamIndex     
00308             ) = 0;
00309     };
00310 
00313     class IAkStreamMgrProfile
00314     {
00315     protected:
00317         virtual ~IAkStreamMgrProfile(){}
00318         
00319     public:
00324         virtual AKRESULT StartMonitoring() = 0;
00325 
00329         virtual void     StopMonitoring() = 0;
00330         
00335         virtual AkUInt32 GetNumDevices() = 0;
00336 
00342         virtual IAkDeviceProfile * GetDeviceProfile( 
00343             AkUInt32    in_uDeviceIndex     
00344             ) = 0;
00345     };
00347 
00349 
00350 
00354     class IAkStdStream
00355     {
00356     protected:
00358         virtual ~IAkStdStream(){}
00359 
00360     public:
00362 
00363 
00364 
00365 
00366         virtual void      Destroy() = 0;
00367 
00371         virtual void      GetInfo(
00372             AkStreamInfo &  out_info            
00373             ) = 0;
00374 
00377         virtual void * GetFileDescriptor() = 0;
00378 
00382         virtual AKRESULT  SetStreamName(
00383             const AkOSChar *    in_pszStreamName    
00384             ) = 0;
00385 
00392         virtual AkUInt32  GetBlockSize() = 0;   
00394 
00396 
00397         
00404         virtual AKRESULT Read(
00405             void *          in_pBuffer,         
00406             AkUInt32        in_uReqSize,        
00407             bool            in_bWait,           
00408             AkPriority      in_priority,        
00409             AkReal32        in_fDeadline,       
00410             AkUInt32 &      out_uSize           
00411             ) = 0;
00412 
00419         virtual AKRESULT Write(
00420             void *          in_pBuffer,         
00421             AkUInt32        in_uReqSize,        
00422             bool            in_bWait,           
00423             AkPriority      in_priority,        
00424             AkReal32        in_fDeadline,       
00425             AkUInt32 &      out_uSize           
00426             ) = 0;
00427 
00433         virtual AkUInt64 GetPosition( 
00434             bool *          out_pbEndOfStream   
00435             ) = 0;
00436 
00443         virtual AKRESULT SetPosition(
00444             AkInt64         in_iMoveOffset,     
00445             AkMoveMethod    in_eMoveMethod,     
00446             AkInt64 *       out_piRealOffset    
00447 
00448             ) = 0;
00449 
00455         virtual void Cancel() = 0;
00456 
00458 
00460 
00461 
00462 
00463 
00464 
00465         virtual void *   GetData( 
00466             AkUInt32 &      out_uSize           
00467             ) = 0;
00468 
00473         virtual AkStmStatus GetStatus() = 0;  
00474 
00476     };
00477 
00478 
00485     class IAkAutoStream 
00486     {
00487     protected:
00489         virtual ~IAkAutoStream(){}
00490 
00491     public:
00493 
00494 
00495 
00496 
00497         virtual void      Destroy() = 0;
00498 
00502         virtual void      GetInfo(
00503             AkStreamInfo &      out_info        
00504             ) = 0;
00505 
00508         virtual void * GetFileDescriptor() = 0;
00509 
00513         virtual void      GetHeuristics(
00514             AkAutoStmHeuristics & out_heuristics
00515             ) = 0;
00516 
00520         virtual AKRESULT  SetHeuristics(
00521             const AkAutoStmHeuristics & in_heuristics   
00522             ) = 0;
00523 
00530         virtual AKRESULT  SetMinimalBufferSize(
00531             AkUInt32        in_uMinBufferSize   
00532             ) = 0;
00533 
00537         virtual AKRESULT  SetStreamName(
00538             const AkOSChar *    in_pszStreamName    
00539             ) = 0;
00540 
00547         virtual AkUInt32  GetBlockSize() = 0;
00548 
00559         virtual AKRESULT QueryBufferingStatus( 
00560             AkUInt32 & out_uNumBytesAvailable   
00561             ) = 0;
00562 
00566         virtual AkUInt32 GetNominalBuffering() = 0;
00567 
00569 
00571 
00572         
00577         virtual AKRESULT Start() = 0;
00578 
00583         virtual AKRESULT Stop() = 0;
00584 
00594         virtual AkUInt64 GetPosition( 
00595             bool *          out_pbEndOfStream   
00596             ) = 0;  
00597 
00605         virtual AKRESULT SetPosition(
00606             AkInt64         in_iMoveOffset,     
00607             AkMoveMethod    in_eMoveMethod,     
00608             AkInt64 *       out_piRealOffset    
00609 
00610             ) = 0;
00611 
00613 
00614 
00616 
00617 
00630         virtual AKRESULT GetBuffer(
00631             void *&         out_pBuffer,        
00632             AkUInt32 &      out_uSize,          
00633             bool            in_bWait            
00634             ) = 0;
00635 
00642         virtual AKRESULT ReleaseBuffer() = 0;
00644     };
00645 
00647 
00648 
00651     class IAkStreamMgr
00652     {
00653     protected:
00655         virtual ~IAkStreamMgr(){}
00656         
00657     public:
00662         inline static IAkStreamMgr * Get()
00663         {
00664             return m_pStreamMgr;
00665         }
00666 
00670         virtual void     Destroy() = 0;
00671 
00672 
00674 
00675 
00676 
00677         virtual IAkStreamMgrProfile * GetStreamMgrProfile() = 0;
00679 
00680 
00682 
00683         
00684         // Standard stream creation methods.
00685 
00691         virtual AKRESULT CreateStd(
00692             const AkOSChar*     in_pszFileName,     
00693             AkFileSystemFlags * in_pFSFlags,        
00694             AkOpenMode          in_eOpenMode,       
00695             IAkStdStream *&     out_pStream,        
00696             bool                in_bSyncOpen        
00697             ) = 0;
00698 
00704         virtual AKRESULT CreateStd(
00705             AkFileID            in_fileID,          
00706             AkFileSystemFlags * in_pFSFlags,        
00707             AkOpenMode          in_eOpenMode,       
00708             IAkStdStream *&     out_pStream,        
00709             bool                in_bSyncOpen        
00710             ) = 0;
00711 
00712         
00713         // Automatic stream create methods.
00714 
00721         virtual AKRESULT CreateAuto(
00722             const AkOSChar*             in_pszFileName,     
00723             AkFileSystemFlags *         in_pFSFlags,        
00724             const AkAutoStmHeuristics & in_heuristics,      
00725             AkAutoStmBufSettings *      in_pBufferSettings, 
00726             IAkAutoStream *&            out_pStream,        
00727             bool                        in_bSyncOpen        
00728             ) = 0;
00729 
00736         virtual AKRESULT CreateAuto(
00737             AkFileID                    in_fileID,          
00738             AkFileSystemFlags *         in_pFSFlags,        
00739             const AkAutoStmHeuristics & in_heuristics,      
00740             AkAutoStmBufSettings *      in_pBufferSettings, 
00741             IAkAutoStream *&            out_pStream,        
00742             bool                        in_bSyncOpen        
00743             ) = 0;
00744 
00756         virtual AKRESULT PinFileInCache(
00757             AkFileID                    in_fileID,          
00758             AkFileSystemFlags *         in_pFSFlags,        
00759             AkPriority                  in_uPriority        
00760             ) = 0;
00761 
00771         virtual AKRESULT UnpinFileInCache(
00772             AkFileID                    in_fileID,              
00773             AkPriority                  in_uPriority        
00774             ) = 0;
00775         
00784         virtual AKRESULT UpdateCachingPriority(
00785             AkFileID                    in_fileID,          
00786             AkPriority                  in_uPriority,       
00787             AkPriority                  in_uOldPriority         
00788             ) = 0;
00789         
00793         virtual AKRESULT GetBufferStatusForPinnedFile( 
00794             AkFileID in_fileID,                             
00795             AkReal32& out_fPercentBuffered,                 
00796             bool& out_bCacheFull                            
00797             ) = 0;
00798 
00800 
00801     protected:
00805         static AKSOUNDENGINE_API IAkStreamMgr * m_pStreamMgr;
00806     };
00807 
00808 }
00809 #endif //_IAK_STREAM_MGR_H_

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise