📄 hxaudses.h
字号:
/* PlayAudio is called by Audio Player object.
*/
HX_RESULT PlayAudio (UINT16 uNumBlocks = 1);
/* Pause is called by Audio Player object.
*/
HX_RESULT Pause (CHXAudioPlayer* p);
/* Resume is called by Audio Player object.
*/
HX_RESULT Resume (CHXAudioPlayer* pPlayer = NULL);
/* Stop is called by Audio Player object.
*/
HX_RESULT Stop (CHXAudioPlayer* p, BOOL bFlush);
/* Seek is called by Audio Player object.
*/
HX_RESULT Seek (
CHXAudioPlayer* pPlayerToExclude,
const UINT32 ulSeekTime
);
/* Return the device volume interface */
inline IHXVolume* GetDeviceVolume()
{
#if defined(HELIX_FEATURE_VOLUME)
if( m_pDeviceVolume )
m_pDeviceVolume->AddRef();
return m_pDeviceVolume;
#else
return NULL;
#endif /* HELIX_FEATURE_VOLUME */
}
/* The player object sets the granularity; I think the RMA session
* object should do this after it resolves the granularity amongst
* all of its players.
*/
/* Granularity is always 100ms now...
* The core keeps track of the granularity requirements for each
* renderer and queries audio sesssion.
*/
ULONG32 SetGranularity(ULONG32 ulGranularity);
/* Reset audio session; flush buffers, etc.
*/
virtual void ResetSession(void);
virtual HX_RESULT ProcessAudioHook(PROCESS_ACTION action,
IHXAudioHook* pAudioHook);
virtual HX_RESULT ProcessAudioDevice(PROCESS_ACTION action,
IHXAudioDevice* pAudioDevice);
virtual HX_RESULT CreateAudioDevice();
void ReleaseAudioDevice();
void RestoreReplacedDevice();
ULONG32 GetCurrentPlayBackTime(void);
/* Get format that audio device was opened with. */
void GetFormat( HXAudioFormat* pAudioFmt );
/* Return the core scheduler interface.
*/
inline void GetScheduler(IHXScheduler** pScheduler)
{
*pScheduler = m_pScheduler;
};
void SetVolume(const UINT16 uVolume );
UINT16 GetVolume();
void SetMute(const BOOL bMute);
inline BOOL GetMute()
{
return m_bMute;
}
/* Return the current time in timeline. */
//ULONG32 GetCurrentPlaybackTime(void);
/* Returns true if any audio player is playing... */
BOOL IsPlaying(void);
/* Returns number of active players (which are not is a STOP state).*/
UINT16 NumberOfActivePlayers(void);
UINT16 NumberOfResumedPlayers(void);
inline void ToBeRewound() {m_bToBeRewound = TRUE;};
BOOL CheckDisableWrite(void);
ULONG32 GetInitialPushdown(BOOL bAtStart = FALSE);
HX_RESULT CheckToPlayMoreAudio();
HX_RESULT TryOpenAudio (void); // attempt to open audio
void StopAllOtherPlayers();
inline HX_RESULT CheckForBufferReuse();
void ConvertTo8BitAndOrMono(HXAudioData* pAudioData);
double ConvertMsToBytes(UINT32 ulCurrentTime);
inline double NumberOfBytesWritten() {return m_dNumBytesWritten;};
inline double GetNumBytesPlayed() {return m_dNumBytesPlayed;};
void SetCoreMutex(HXMutex* pMutex) {m_pCoreMutex = pMutex;};
void CheckIfLastNMilliSecsToBeStored();
void RewindSession(CHXAudioPlayer* pPlayerToExclude = NULL);
void RewindAllPlayers(UINT32 ulCurTime,
UINT32 ulTimeToRewind,
CHXAudioPlayer* pPlayerToExclude);
HX_RESULT ActualResume();
inline UINT32 GetLastRewindTimestamp(void) {return m_ulLastRewindTimestamp;};
BOOL ReallyNeedData();
inline void UseCoreThread() {m_bShouldOpenOnCoreThread = TRUE;};
inline void PostMixHooksUpdated(void) { m_bPostMixHooksUpdated = TRUE; };
BOOL GetDisableMultiPlayPauseSupport();
//IHXCallback stuff
STDMETHOD(Func) (THIS);
IUnknown* m_pContext;
class HXDeviceSetupCallback :
public IHXCallback,
public IHXInterruptSafe
{
private:
~HXDeviceSetupCallback();
PRIVATE_DESTRUCTORS_ARE_NOT_A_CRIME
CHXAudioSession* m_pAudioSessionObject;
ULONG32 m_ulCallbackID;
LONG32 m_lRefCount;
public:
HXDeviceSetupCallback(CHXAudioSession* it);
STDMETHOD(QueryInterface) (THIS_ REFIID riid, void** ppvObj);
STDMETHOD_(ULONG32,AddRef) (THIS);
STDMETHOD_(ULONG32,Release) (THIS);
STDMETHOD(Func) (THIS);
STDMETHOD_(BOOL,IsInterruptSafe) (THIS);
void PendingID(ULONG32 it )
{ m_ulCallbackID = it;}
ULONG32 PendingID()
{ return m_ulCallbackID; }
};
friend class CHXAudioSession::HXDeviceSetupCallback;
protected:
~CHXAudioSession(void);
PRIVATE_DESTRUCTORS_ARE_NOT_A_CRIME
void _ConstructIfNeeded();
private:
#ifdef _MACINTOSH
static BOOL zm_Locked;
#endif
LONG32 m_lRefCount;
IHXScheduler* m_pScheduler;
IHXPreferences* m_pPreferences;
IHXInterruptState* m_pInterruptState;
HXAudioFormat m_BeforeHookDeviceFmt; // Actual Audio device format.
HXAudioFormat m_ActualDeviceFmt; // Actual Audio device format.
HXAudioFormat m_DeviceFmt; // Audio device format used for all calculations.
IHXBuffer* m_pPlayerBuf;
IHXBuffer* m_pSessionBuf;
ULONG32 m_ulGranularity; // Amount of audio to push (ms).
double m_dGranularity;
ULONG32 m_ulMinimumPushdown;
ULONG32 m_ulIdealMinimumPushdown;
ULONG32 m_ulMinBlocksTobeQueued;
ULONG32 m_ulMinBlocksTobeQueuedAtStart;
ULONG32 m_ulBytesPerGran; // Number of bytes in gran
ULONG32 m_ulBlocksWritten; // Number of blocks written so far
ULONG32 m_ulCallbackID;
BOOL m_bFakeAudioTimeline;
BOOL m_bShouldOpenOnCoreThread;
BOOL m_bToBeReOpened;
HXDeviceSetupCallback* m_pDeviceCallback;
BOOL m_bHasStreams; // True if there are audio streams
/* We keep a track of the current time when we use Scheduler for
* genertaing time syncs.
*/
ULONG32 m_ulIncreasingTimer;
/* This is the actual time we report back to the player->renderers
* It gets set in the OnTimeSync
*/
ULONG32 m_ulCurrentTime;
ULONG32 m_ulLastAudioTime;
ULONG32 m_ulLastAudioReturnTime;
ULONG32 m_ulLastSystemTime;
BOOL m_bAtLeastOneTimeReceived;
ULONG32 m_ulStartTime;
BOOL m_bTimeSyncReceived;
BOOL m_bPaused;
BOOL m_bStoppedDuringPause;
ULONG32 m_ulLastFakeCallbackTime;
Timeval* m_pFakeAudioCBTime;
HXAudioData* m_pInDataPtr;
HXAudioData* m_pOutDataPtr;
/*
* Should be in a data structure with the player objects and stuffed
* on the list.
*/
IHXAudioPlayerResponse* m_pPlayerResponse; // Notification interface
BOOL m_bFirstPlayAudio;
UINT16 m_uVolume; // Default volume
BOOL m_bMute; // the mute state
BOOL m_bAudioDeviceSupportsVolume;
/*
* Continuous session play back time. This is the time written to the audio
* device object for each buffer. This is the time that each audio player
* retrieves as its start time.
*/
double m_dBufEndTime;
BOOL m_bDisableWrite;
BOOL m_bInPlayAudio;
BOOL m_bInActualResume;
double m_dNumBytesWritten;
double m_dNumBytesPlayed;
/* CheckAudioFormat Interface is called by audio player to
* check resample audio format with audio device format.
*/
HX_RESULT CheckAudioFormat(
HXAudioFormat* pAudioFormat );
/* Create the playback buffer.
*/
HX_RESULT CreatePlaybackBuffer(void);
void OnTimerCallback();
inline void CheckAudioVolume()
{}
/* Write audio data to post mix hooks. */
HX_RESULT ProcessPostMixHooks(
CHXAudioPlayer* pPlayer,
IHXBuffer*& pInBuffer,
BOOL* bDisableWrite,
UINT32 ulBufTime,
BOOL& bChanged);
void InitHooks();
void ProcessHooks(HXAudioData* pAudioData);
/* Convert 16-bit buffer to 8-bit */
void ConvertToEight(void);
BOOL IsAudioOnlyTrue(void);
UINT32 AnchorDeviceTime(UINT32 ulCurTime);
void AdjustInRealTime();
HX_RESULT Rewind();
void UpdateMinimumPushdown();
void ReopenDevice();
protected:
BOOL m_bInited; // is audio setup?
IHXAudioDevice* m_pAudioDev; // device layer
IHXAudioDevice* m_pCurrentAudioDev; // keep track of the current device layer
IHXAudioDevice* m_pReplacedAudioDev; // keep track of replaced audio device
BOOL m_bReplacedDev; // is audio device replaced?
CHXSimpleList* m_pPlayerList; // list of player audio sessions
CHXSimpleList* m_pHookList; // hook list
// Any audio buffers that we were not able to write to the audio
// device successfully
CHXSimpleList* m_pAuxiliaryAudioBuffers;
HXMutex* m_pMutex;
IHXAudioHook* m_pFinalHook;
BOOL m_bUseFinalHook;
HXMutex* m_pCoreMutex;
UINT16 m_uAskFromAudioDevice;
BOOL m_bDeferActualResume;
CHXAudioPlayer* m_pLastPausedPlayer;
BOOL m_bUsingReplacedDevice;
BOOL m_bToBeRewound;
UINT32 m_ulLastRewindTimestamp;
UINT16 m_uNumToBePushed;
BOOL m_bSessionBufferDirty;
BOOL m_bPostMixHooksUpdated;
IHXMultiPlayPauseSupport* m_pMPPSupport;
#if defined(HELIX_FEATURE_TIMELINE_WATCHER)
//IHXTimelineManager support.
CHXSimpleList* m_pTimeLineWatchers;
void _NotifyTimelineWatchers( const int nWhich, const UINT32 ulNow=0 );
#else
inline void _NotifyTimelineWatchers(const int nWhich, const UINT32 ulNow=0 ) {};
#endif
#ifdef HELIX_FEATURE_VOLUME
IHXVolume* m_pDeviceVolume;
#endif
};
#endif // _HXAUDSES_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -