[Player-cvs] hxclientkit/src CHXClientPlayer.cpp, 1.31, 1.32 CHXClientPlayer.h, 1.18, 1.19 CHXClientSink.cpp, 1.23, 1.24 CHXClientSink.h, 1.16, 1.17 CHXEQProcessor.cpp, 1.3, 1.4 CHXEQProcessor.h, 1.3, 1.4 CHXStatisticTracker.cpp, 1.10, 1.11 CHXStatisticTracker.h, 1.7, 1.8 HXClientCFuncs.cpp, 1.18, 1.19 IHXClientPlayer.h, 1.13, 1.14
sehancher at helixcommunity.org sehancher at helixcommunity.orgUpdate of /cvsroot/player/hxclientkit/src
In directory cvs-new:/tmp/cvs-serv28978
Modified Files:
CHXClientPlayer.cpp CHXClientPlayer.h CHXClientSink.cpp
CHXClientSink.h CHXEQProcessor.cpp CHXEQProcessor.h
CHXStatisticTracker.cpp CHXStatisticTracker.h
HXClientCFuncs.cpp IHXClientPlayer.h
Log Message:
Merge 122 branch to Head.
Index: CHXClientSink.h
===================================================================
RCS file: /cvsroot/player/hxclientkit/src/CHXClientSink.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- CHXClientSink.h 9 Jul 2004 18:25:22 -0000 1.16
+++ CHXClientSink.h 1 Sep 2004 18:50:23 -0000 1.17
@@ -55,7 +55,7 @@
#include "enter_hx_headers.h"
#include "hxclsnk.h"
#include "hxgroup.h"
-#include "hxausvc.h" // IHXVolumeAdviseSink
+#include "hxausvc.h" // IHXVolumeAdviseSink, IHXAudioHook
#include "hxerror.h"
#include "hxengin.h" // IHXCallback
@@ -74,6 +74,14 @@
typedef int HXBOOL;
_INTERFACE IHXPlayer;
+class CHXFlatArray;
+
+struct SHXAudioHookData
+{
+ const HXAudioHookCallbacks* m_pAudioHookCallbacks;
+ void* m_HookInfo;
+};
+
class CHXClientSink
: public CHXClientUnknown
, public IHXClientAdviseSink
@@ -84,6 +92,7 @@
#endif
, public IHXErrorSink
, public IHXCallback
+ , public IHXAudioHook
{
DECLARE_UNKNOWN_NOCREATE( CHXClientSink )
@@ -93,6 +102,7 @@
const HXClientCallbacks* m_pClientCallbacks;
IHXPlayer* m_pIHXCorePlayer;
CallbackHandle m_hScheduler;
+ CHXFlatArray* m_pAudioHooks; // <SHXAudioHookData>
#ifdef HELIX_FEATURE_REGISTRY
SPIHXPropWatch m_spPropWatch;
@@ -117,7 +127,11 @@
bool m_IsLive;
bool m_IsGroupsListDirty;
bool m_HasContentBegun;
+ bool m_HasHookedAudio;
+ void HookAudio( void );
+ void UnhookAudio( void );
+
void SetUpPropWatcher( void );
void DestroyPropWatcher( void );
@@ -166,6 +180,8 @@
{
return m_HasContentBegun;
}
+ bool AddAudioHook( const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo );
+ void RemoveAudioHook( const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo );
// IHXClientAdviseSink
STDMETHOD ( OnPosLength ) ( THIS_ UINT32 ulPosition, UINT32 ulLength );
@@ -210,6 +226,10 @@
// IHXCallback
STDMETHOD ( Func ) ( THIS );
+
+ // IHXAudioHook
+ STDMETHOD ( OnInit ) ( THIS_ HXAudioFormat* pFormat );
+ STDMETHOD ( OnBuffer ) ( THIS_ HXAudioData* pAudioInData, HXAudioData* pAudioOutData );
};
#endif
Index: CHXEQProcessor.cpp
===================================================================
RCS file: /cvsroot/player/hxclientkit/src/CHXEQProcessor.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CHXEQProcessor.cpp 9 Jul 2004 18:25:22 -0000 1.3
+++ CHXEQProcessor.cpp 1 Sep 2004 18:50:23 -0000 1.4
@@ -48,95 +48,26 @@
* ***** END LICENSE BLOCK ***** */
#include "CHXEQProcessor.h"
-
-#include "enter_hx_headers.h"
-#include "hxcore.h"
-#include "ihxpckts.h"
-
-#include "hxsmartptr.h"
-HX_SMART_POINTER_INLINE( SPIHXAudioPlayer, IHXAudioPlayer );
-HX_SMART_POINTER_INLINE( SPIHXAudioHookManager, IHXAudioHookManager );
-HX_SMART_POINTER_INLINE( SPIHXAudioDeviceManager, IHXAudioDeviceManager );
-#include "exit_hx_headers.h"
+#include "CHXClientDebug.h"
+#include "IHXClientPlayer.h"
CHXEQProcessor::~CHXEQProcessor( void )
{
DestroyEQData();
- m_pAudioPlayer->Release();
}
-CHXEQProcessor::CHXEQProcessor( IHXPlayer* pIHXPlayer )
- : m_lCount( 0 )
- , m_pAudioPlayer( NULL )
- , m_pEQData( NULL )
- , m_HasHookedAudio( false )
+CHXEQProcessor::CHXEQProcessor( void )
+ : m_pEQData( NULL )
, m_IsEnabled( false )
, m_IsAutoPreGainEnabled( false )
, m_PreGain( 0 )
, m_RoomSize( 0 )
, m_Reverb( 0 )
{
- SPIHXAudioPlayer( pIHXPlayer ).AsPtr( &m_pAudioPlayer );
memset( &m_AudioFormat, 0, sizeof( m_AudioFormat ) );
memset( m_Gains, 0, sizeof( m_Gains ) );
}
-DEFINE_SINGLE_INTERFACE_COMPONENT( CHXEQProcessor, IHXAudioHook, m_lCount )
-
-void
-CHXEQProcessor::HookAudio( void )
-{
- if ( !m_HasHookedAudio )
- {
- // XXXSEH: This method should allow for independent EQ settings per Player instance.
- // However, CHXAudioPlayer::ActualAddPostMixHook() fails since m_pPMixHookList is NULL and is never actually created in this file.
- //static const HXBOOL kEnableWrite = FALSE;
- //static const HXBOOL kIsFinal = TRUE; // XXXSEH: What does this mean?
- //m_HasHookedAudio = ( 0 != SUCCEEDED( m_pAudioPlayer->AddPostMixHook( this, kEnableWrite, kIsFinal ) ) );
-
- SPIHXAudioHookManager spAudioHookManager = m_pAudioPlayer;
- if ( spAudioHookManager.IsValid() )
- {
- m_HasHookedAudio = ( 0 != SUCCEEDED( spAudioHookManager->AddHook( this ) ) );
- return;
- }
- SPIHXAudioDeviceManager spAudioDeviceManager = m_pAudioPlayer;
- if ( spAudioDeviceManager.IsValid() )
- {
- m_HasHookedAudio = ( 0 != SUCCEEDED( spAudioDeviceManager->SetFinalHook( this ) ) );
- return;
- }
- }
-}
-
-void
-CHXEQProcessor::UnhookAudio( void )
-{
- if ( m_HasHookedAudio )
- {
- //( void ) m_pAudioPlayer->RemovePostMixHook( this );
-
- SPIHXAudioHookManager spAudioHookManager = m_pAudioPlayer;
- if ( spAudioHookManager.IsValid() )
- {
- spAudioHookManager->RemoveHook( this );
- }
- else
- {
- SPIHXAudioDeviceManager spAudioDeviceManager = m_pAudioPlayer;
- if ( spAudioDeviceManager.IsValid() )
- {
- spAudioDeviceManager->RemoveFinalHook( this );
- }
- }
- m_HasHookedAudio = false;
-
- // Clear EQ Data and audio format. Since we're no longer hooked, we have no way of knowing whether the format will subsequently change.
- DestroyEQData();
- memset( &m_AudioFormat, 0, sizeof( m_AudioFormat ) );
- }
-}
-
void
CHXEQProcessor::DestroyEQData( void )
{
@@ -170,36 +101,26 @@
return false;
}
-STDMETHODIMP
-CHXEQProcessor::OnInit( HXAudioFormat* pFormat )
+void
+CHXEQProcessor::InitAudioData( const SHXAudioFormat* pAudioFormat )
{
- if ( !pFormat ) return HXR_INVALID_PARAMETER;
-
- m_AudioFormat = *pFormat;
+ m_AudioFormat = *pAudioFormat;
if ( m_IsEnabled )
{
SetupEQData();
}
- return HXR_OK; // XXXSEH: When would we return a different value?
}
-STDMETHODIMP
-CHXEQProcessor::OnBuffer( HXAudioData* pAudioInData, HXAudioData* pAudioOutData )
+void
+CHXEQProcessor::OnAudioBuffer( unsigned char* pAudioBuffer, UInt32 bufferLength, UInt32 audioStartTime, int audioStreamType )
{
- if ( pAudioInData && pAudioInData->pData && pAudioOutData )
+ if ( m_IsEnabled && m_pEQData )
{
- if ( m_IsEnabled && m_pEQData )
- {
- short* inPCMData = ( short* ) pAudioInData->pData->GetBuffer();
- short* outPCMData = inPCMData; // XXXSEH: Modify this inline. Don't know why Windows doesn't do this.
- int numOfSamples = pAudioInData->pData->GetSize() / sizeof( short );
- ( void ) ::EQProcess( m_pEQData, inPCMData, outPCMData, numOfSamples );
- }
- HX_RELEASE( pAudioOutData->pData );
- pAudioOutData->pData = pAudioInData->pData;
- HX_ADDREF( pAudioOutData->pData ); // Caller assumes this had been AddRef'd, so let's oblige
+ short* inPCMData = ( short* ) pAudioBuffer; // XXXSEH: Will the data always be of short size? Why not check with uBitsPerSample?
+ short* outPCMData = inPCMData;
+ int numOfSamples = bufferLength / sizeof( short );
+ ( void ) ::EQProcess( m_pEQData, inPCMData, outPCMData, numOfSamples );
}
- return HXR_OK; // XXXSEH: When would we return a different value?
}
void
@@ -311,4 +232,50 @@
// XXXSEH: Jukebox returns ::EQGetReverb(...). If these values differ from the data members, sync. them up on setting them.
if ( pRoomSize ) *pRoomSize = m_RoomSize;
if ( pReverb ) *pReverb = m_Reverb;
+}
+
+#pragma mark -
+
+static void InitAudioData( const SHXAudioFormat* pAudioFormat, void/*CHXEQProcessor*/* eqProcessor )
+{
+ ( ( CHXEQProcessor* ) eqProcessor )->InitAudioData( pAudioFormat );
+}
+
+static void OnAudioBuffer( unsigned char* pAudioBuffer, UInt32 bufferLength, UInt32 audioStartTime, int audioStreamType, void/*CHXEQProcessor*/* eqProcessor )
+{
+ ( ( CHXEQProcessor* ) eqProcessor )->OnAudioBuffer( pAudioBuffer, bufferLength, audioStartTime, audioStreamType );
+}
+
+HXAudioHookCallbacks gEQProcessorAudioHookCallbacks =
+{
+ InitAudioData,
+ OnAudioBuffer,
+};
+
+CHXEQProcessor*
+CHXEQProcessor::CreateEQProcessor( IHXClientPlayer* pClientPlayer )
+{
+ CHXASSERT( pClientPlayer );
+
+ CHXEQProcessor* pEQProcessor = new CHXEQProcessor;
+ if ( !pEQProcessor ) return NULL;
+
+ if ( !pClientPlayer->AddAudioHook( &gEQProcessorAudioHookCallbacks, pEQProcessor ) )
+ {
+ delete pEQProcessor;
+ pEQProcessor = NULL;
+ }
+ return pEQProcessor;
+}
+
+void
+CHXEQProcessor::DestroyEQProcessor( IHXClientPlayer* pClientPlayer, CHXEQProcessor* pEQProcessor )
+{
+ CHXASSERT( pClientPlayer );
+
+ if ( !pEQProcessor ) return;
+
+ pClientPlayer->RemoveAudioHook( &gEQProcessorAudioHookCallbacks, pEQProcessor );
+
+ delete pEQProcessor;
}
Index: HXClientCFuncs.cpp
===================================================================
RCS file: /cvsroot/player/hxclientkit/src/HXClientCFuncs.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- HXClientCFuncs.cpp 9 Jul 2004 18:25:22 -0000 1.18
+++ HXClientCFuncs.cpp 1 Sep 2004 18:50:23 -0000 1.19
@@ -694,6 +694,21 @@
}
}
+bool ClientPlayerAddAudioHook( HXClientPlayerToken clientPlayerToken, const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo )
+{
+ IHXClientPlayer* pIClientPlayer = ( IHXClientPlayer* ) clientPlayerToken;
+ return pIClientPlayer ? pIClientPlayer->AddAudioHook( pAudioHookCallbacks, hookInfo ) : false;
+}
+
+void ClientPlayerRemoveAudioHook( HXClientPlayerToken clientPlayerToken, const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo )
+{
+ IHXClientPlayer* pIClientPlayer = ( IHXClientPlayer* ) clientPlayerToken;
+ if ( pIClientPlayer )
+ {
+ pIClientPlayer->RemoveAudioHook( pAudioHookCallbacks, hookInfo );
+ }
+}
+
/*!
@function ClientPlayerGetVideoAttribute
@param clientPlayerToken
@@ -769,4 +784,16 @@
{
pIClientPlayer->RemoveStatisticObserver( pStatisticKey, pStatisticsCallbacks, observerInfo );
}
+}
+
+bool ClientPlayerGetRegistryData( HXClientPlayerToken clientPlayerToken, const char* pDataKey, unsigned char* pValueBuffer, UInt32 bufferLength, int* pValueType, UInt32* pUsedBufferLength )
+{
+ IHXClientPlayer* pIClientPlayer = ( IHXClientPlayer* ) clientPlayerToken;
+ return pIClientPlayer ? pIClientPlayer->GetRegistryData( pDataKey, pValueBuffer, bufferLength, pValueType, pUsedBufferLength ) : false;
+}
+
+bool ClientPlayerSetRegistryData( HXClientPlayerToken clientPlayerToken, const char* pDataKey, const unsigned char* pValueBuffer, UInt32 bufferLength, int valueType )
+{
+ IHXClientPlayer* pIClientPlayer = ( IHXClientPlayer* ) clientPlayerToken;
+ return pIClientPlayer ? pIClientPlayer->SetRegistryData( pDataKey, pValueBuffer, bufferLength, valueType ) : false;
}
Index: CHXStatisticTracker.h
===================================================================
RCS file: /cvsroot/player/hxclientkit/src/CHXStatisticTracker.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CHXStatisticTracker.h 9 Jul 2004 18:25:22 -0000 1.7
+++ CHXStatisticTracker.h 1 Sep 2004 18:50:23 -0000 1.8
@@ -63,6 +63,32 @@
typedef int HXBOOL;
+class CHXStatisticProcessor
+{
+public:
+ CHXStatisticProcessor( void ) {}
+ virtual ~CHXStatisticProcessor( void ) {}
+ virtual bool operator() ( int valueType, const unsigned char* pValue ) = 0;
+};
+
+class CHXCopyStatisticProcessor : public CHXStatisticProcessor
+{
+private:
+ unsigned char* m_pValueBuffer;
+ UINT32 m_BufferLength;
+ int* m_pValueType;
+ UINT32* m_pUsedBufferLength;
+public:
+ CHXCopyStatisticProcessor( unsigned char* pValueBuffer, UINT32 bufferLength, int* pValueType, UINT32* pUsedBufferLength )
+ : m_pValueBuffer( pValueBuffer )
+ , m_BufferLength( bufferLength )
+ , m_pValueType( pValueType )
+ , m_pUsedBufferLength( pUsedBufferLength )
+ {}
+ virtual ~CHXCopyStatisticProcessor( void ) {}
+ virtual bool operator() ( int valueType, const unsigned char* pValue );
+};
+
class CHXFlatArray;
class CHXStatisticTracker;
class CHXStatisticTrackerNode
Index: CHXClientSink.cpp
===================================================================
RCS file: /cvsroot/player/hxclientkit/src/CHXClientSink.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- CHXClientSink.cpp 9 Jul 2004 18:25:22 -0000 1.23
+++ CHXClientSink.cpp 1 Sep 2004 18:50:23 -0000 1.24
@@ -48,6 +48,7 @@
* ***** END LICENSE BLOCK ***** */
#include "CHXClientSink.h"
+#include "CHXFlatArray.h"
#include "CHXClientDebug.h"
#include "enter_hx_headers.h"
@@ -61,6 +62,8 @@
HX_SMART_POINTER_INLINE( SPIHXPersistentComponentManager, IHXPersistentComponentManager );
HX_SMART_POINTER_INLINE( SPIHXPersistentComponent, IHXPersistentComponent );
HX_SMART_POINTER_INLINE( SPIHXAudioPlayer, IHXAudioPlayer );
+HX_SMART_POINTER_INLINE( SPIHXAudioHookManager, IHXAudioHookManager );
+HX_SMART_POINTER_INLINE( SPIHXAudioDeviceManager, IHXAudioDeviceManager );
HX_SMART_POINTER_INLINE( SPIHXErrorSinkControl, IHXErrorSinkControl );
HX_SMART_POINTER_INLINE( SPIHXErrorMessages, IHXErrorMessages );
HX_SMART_POINTER_INLINE( SPIHXScheduler, IHXScheduler );
@@ -132,6 +135,8 @@
CHXClientSink::~CHXClientSink( void )
{
+ delete m_pAudioHooks;
+
delete [] m_pRPURLTarget;
delete [] m_pRPURL;
delete [] m_pContextURL;
@@ -145,6 +150,7 @@
, m_pClientCallbacks( pClientCallbacks )
, m_pIHXCorePlayer( pIHXPlayer )
, m_hScheduler( 0 )
+ , m_pAudioHooks( NULL )
#ifdef HELIX_FEATURE_REGISTRY
, m_TitlePropID( 0 )
, m_ClipBandwidthPropID( 0 )
@@ -157,7 +163,7 @@
, m_pRPURL( NULL )
, m_pRPURLTarget( NULL )
, m_ClipBandwidth( 0 )
- , m_ContentState( kContentStateStopped ) // If this object is loaded, kContentStateNotLoaded is not applicable
+ , m_ContentState( kContentStateNotLoaded )
, m_BufferPercent( 100 )
, m_Position( 0 )
, m_Length( 0 )
@@ -166,6 +172,7 @@
, m_IsLive( false )
, m_IsGroupsListDirty( false )
, m_HasContentBegun( false )
+ , m_HasHookedAudio( false )
{
CHXASSERT( m_pClientCallbacks ); // What's the point in observing if we cannot tell anyone about it.
CHXASSERT( m_pIHXCorePlayer ); // Need a valid core player.
@@ -180,6 +187,7 @@
#endif
INTERFACE_LIST_ENTRY_SIMPLE( IHXErrorSink )
INTERFACE_LIST_ENTRY_SIMPLE( IHXCallback )
+ INTERFACE_LIST_ENTRY_SIMPLE( IHXAudioHook )
END_INTERFACE_LIST
void
@@ -202,6 +210,7 @@
{
spErrorSinkControl->AddErrorSink( this, HXLOG_EMERG, HXLOG_INFO );
}
+ HookAudio();
}
void
@@ -215,6 +224,8 @@
m_hScheduler = spScheduler->Remove( m_hScheduler );
}
}
+ UnhookAudio();
+
SPIHXErrorSinkControl spErrorSinkControl = m_pIHXCorePlayer;
if ( spErrorSinkControl.IsValid() )
{
@@ -236,6 +247,160 @@
#pragma mark -
void
+CHXClientSink::HookAudio( void )
+{
+ if ( !m_HasHookedAudio )
+ {
+ SPIHXAudioPlayer spAudioPlayer = m_pIHXCorePlayer;
+ if ( !spAudioPlayer.IsValid() ) return;
+
+ // XXXSEH: This method should allow for independent EQ settings per Player instance.
+ // However, CHXAudioPlayer::ActualAddPostMixHook() fails since m_pPMixHookList is NULL and is never actually created in this file.
+ //static const HXBOOL kEnableWrite = FALSE;
+ //static const HXBOOL kIsFinal = TRUE; // XXXSEH: What does this mean?
+ //m_HasHookedAudio = ( 0 != SUCCEEDED( spAudioPlayer->AddPostMixHook( this, kEnableWrite, kIsFinal ) ) );
+
+ SPIHXAudioHookManager spAudioHookManager = spAudioPlayer.Ptr();
+ if ( spAudioHookManager.IsValid() )
+ {
+ m_HasHookedAudio = ( 0 != SUCCEEDED( spAudioHookManager->AddHook( this ) ) );
+ return;
+ }
+ SPIHXAudioDeviceManager spAudioDeviceManager = spAudioPlayer.Ptr();
+ if ( spAudioDeviceManager.IsValid() )
+ {
+ m_HasHookedAudio = ( 0 != SUCCEEDED( spAudioDeviceManager->SetFinalHook( this ) ) );
+ return;
+ }
+ }
+}
+
+void
+CHXClientSink::UnhookAudio( void )
+{
+ if ( m_HasHookedAudio )
+ {
+ SPIHXAudioPlayer spAudioPlayer = m_pIHXCorePlayer;
+ CHXASSERT( spAudioPlayer.IsValid() );
+
+ //( void ) spAudioPlayer->RemovePostMixHook( this );
+
+ SPIHXAudioHookManager spAudioHookManager = spAudioPlayer.Ptr();
+ if ( spAudioHookManager.IsValid() )
+ {
+ spAudioHookManager->RemoveHook( this );
+ }
+ else
+ {
+ SPIHXAudioDeviceManager spAudioDeviceManager = spAudioPlayer.Ptr();
+ if ( spAudioDeviceManager.IsValid() )
+ {
+ spAudioDeviceManager->RemoveFinalHook( this );
+ }
+ }
+ m_HasHookedAudio = false;
+ }
+}
+
+static bool
+AreHookDataElementsEqual( const void* item1Ptr, const void* item2Ptr )
+{
+ const SHXAudioHookData* data1 = ( const SHXAudioHookData* ) item1Ptr;
+ const SHXAudioHookData* data2 = ( const SHXAudioHookData* ) item2Ptr;
+ return( ( data1->m_pAudioHookCallbacks == data2->m_pAudioHookCallbacks ) &&
+ ( data1->m_HookInfo == data2->m_HookInfo ) );
+}
+
+bool
+CHXClientSink::AddAudioHook( const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo )
+{
+ CHXASSERT( pAudioHookCallbacks );
+ if ( !pAudioHookCallbacks ) return false;
+
+ if ( !m_pAudioHooks )
+ {
+ m_pAudioHooks = new CHXFlatArray( sizeof( SHXAudioHookData ) );
+ }
+ if ( m_pAudioHooks )
+ {
+ SHXAudioHookData hookData = { pAudioHookCallbacks, hookInfo };
+ if ( m_pAudioHooks->HasRecord( &hookData, AreHookDataElementsEqual ) ) return true;
+
+ m_pAudioHooks->Push( &hookData );
+
+ return true;
+ }
+ return false;
+}
+
+void
+CHXClientSink::RemoveAudioHook( const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo )
+{
+ if ( m_pAudioHooks )
+ {
+ UINT32 recordNumToRemove;
+ SHXAudioHookData hookData = { pAudioHookCallbacks, hookInfo };
+ if ( m_pAudioHooks->FindRecord( &hookData, AreHookDataElementsEqual, 0, &recordNumToRemove, &hookData ) )
+ {
+ m_pAudioHooks->Remove( recordNumToRemove );
+ }
+ }
+}
+
+STDMETHODIMP
+CHXClientSink::OnInit( HXAudioFormat* pFormat )
+{
+ if ( !pFormat ) return HXR_INVALID_PARAMETER;
+
+ if ( m_pAudioHooks )
+ {
+ UINT32 numOfHooks = m_pAudioHooks->GetCount();
+ for ( UINT32 index = 0; index < numOfHooks; ++index )
+ {
+ SHXAudioHookData hookData;
+ m_pAudioHooks->GetAt( index, &hookData );
+ HXInitAudioDataProcPtr InitAudioData = hookData.m_pAudioHookCallbacks->InitAudioData;
+ if ( InitAudioData )
+ {
+ InitAudioData( ( const SHXAudioFormat* ) pFormat, hookData.m_HookInfo );
+ }
+ }
+ }
+ return HXR_OK; // XXXSEH: When would we return a different value?
+}
+
+STDMETHODIMP
+CHXClientSink::OnBuffer( HXAudioData* pAudioInData, HXAudioData* pAudioOutData )
+{
+ if ( pAudioInData && pAudioInData->pData && pAudioOutData )
+ {
+ if ( m_pAudioHooks )
+ {
+ unsigned char* pAudioBuffer = pAudioInData->pData->GetBuffer();
+ UINT32 bufferLength = pAudioInData->pData->GetSize();
+
+ UINT32 numOfHooks = m_pAudioHooks->GetCount();
+ for ( UINT32 index = 0; index < numOfHooks; ++index )
+ {
+ SHXAudioHookData hookData;
+ m_pAudioHooks->GetAt( index, &hookData );
+ HXOnAudioBufferProcPtr OnAudioBuffer = hookData.m_pAudioHookCallbacks->OnAudioBuffer;
+ if ( OnAudioBuffer )
+ {
+ OnAudioBuffer( pAudioBuffer, bufferLength, pAudioInData->ulAudioTime, pAudioInData->uAudioStreamType, hookData.m_HookInfo );
+ }
+ }
+ }
+ HX_RELEASE( pAudioOutData->pData );
+ pAudioOutData->pData = pAudioInData->pData; // XXXSEH: Data modified inline. Don't know why Windows doesn't do this.
+ HX_ADDREF( pAudioOutData->pData ); // Caller assumes this had been AddRef'd, so let's oblige
+ }
+ return HXR_OK; // XXXSEH: When would we return a different value?
+}
+
+#pragma mark -
+
+void
CHXClientSink::SetBeginPosition( UINT32 beginPosition )
{
if ( m_ContentState == kContentStateStopped )
@@ -290,6 +455,7 @@
STDMETHODIMP
CHXClientSink::OnPresentationOpened( void )
{
+ UpdateContentState( kContentStateStopped ); // Just in case we aren't already in this state, ie first content opened.
return HXR_OK;
}
@@ -493,6 +659,7 @@
if ( m_pTrackURL )
{
memcpy( m_pTrackURL, spTrackURLBuffer->GetBuffer(), bufferSize );
+// printf( "CHXClientSink::GetURLsFromTrackProperties(), track URL = %s\n", m_pTrackURL );
}
}
ULONG32 persistentComponentID = 0;
@@ -522,6 +689,7 @@
if ( m_pMetafileURL )
{
memcpy( m_pMetafileURL, spMetafileURLBuffer->GetBuffer(), bufferSize );
+// printf( "CHXClientSink::GetURLsFromTrackProperties(), metafile URL = %s\n", m_pMetafileURL );
}
}
}
@@ -570,17 +738,19 @@
( m_pMetafileURL && ( NULL != ( pContextURL = strstr( m_pMetafileURL, kContextURLName ) ) ) ) ? m_pMetafileURL : NULL;
if ( pURLToParse )
{
+// printf( "CHXClientSink::UpdateContextURL(), pURLToParse = %s\n", pURLToParse );
const char* pArgumentDelim;
UINT32 urlToParseLength = strlen( pURLToParse );
const char* pEndOfURLToParse = pURLToParse + urlToParseLength;
pContextURL += strlen( kContextURLName );
- // If the context URL has its own arguments, denoted by a '?', then we assume the context URL runs the remainder of the URL,
- // since we have no way of knowing when it actually stops.
- bool doesContextURLHaveArguments = ( NULL != strchr( pContextURL, '?' ) );
- pArgumentDelim = doesContextURLHaveArguments ? NULL : strchr( pContextURL, '&' );
- UINT32 contextURLLength = pArgumentDelim ? ( pArgumentDelim - pContextURL ) : ( pEndOfURLToParse - pContextURL );
+ // If the context URL has its own arguments, denoted by a '?' that doesn't follow a '&' (we assume this means there's another URL in the argument list),
+ // then we assume the context URL runs the remainder of the URL, since we have no way of knowing when it actually stops.
+ const char* pArgumentListDelim = strchr( pContextURL, '?' );
+ pArgumentDelim = strchr( pContextURL, '&' );
+ bool doesContextURLHaveArguments = ( NULL != pArgumentListDelim ) && ( ( NULL == pArgumentDelim ) || ( pArgumentDelim > pArgumentListDelim ) );
+ UINT32 contextURLLength = ( ( NULL != pArgumentDelim ) && !doesContextURLHaveArguments ) ? ( pArgumentDelim - pContextURL ) : ( pEndOfURLToParse - pContextURL );
UINT32 contextParamsLength = 0;
const char* pContextParams = strstr( pURLToParse, kContextParamsName );
@@ -677,9 +847,10 @@
// If the RPURL has its own arguments, denoted by a '?', then we assume the RPURL runs the remainder of the URL,
// since we have no way of knowing when it actually stops.
- bool doesRPURLHaveArguments = ( NULL != strchr( pRPURL, '?' ) );
- pArgumentDelim = doesRPURLHaveArguments ? NULL : strchr( pRPURL, '&' );
- UINT32 rpURLLength = pArgumentDelim ? ( pArgumentDelim - pRPURL ) : ( pEndOfURLToParse - pRPURL );
+ const char* pArgumentListDelim = strchr( pRPURL, '?' );
+ pArgumentDelim = strchr( pRPURL, '&' );
+ bool doesRPURLHaveArguments = ( NULL != pArgumentListDelim ) && ( ( NULL == pArgumentDelim ) || ( pArgumentDelim > pArgumentListDelim ) );
+ UINT32 rpURLLength = ( ( NULL != pArgumentDelim ) && !doesRPURLHaveArguments ) ? ( pArgumentDelim - pRPURL ) : ( pEndOfURLToParse - pRPURL );
pNewRPURL = new char[ rpURLLength + 1 ];
if ( pNewRPURL )
@@ -714,6 +885,39 @@
STDMETHODIMP
CHXClientSink::TrackStarted( UINT16 uGroupIndex, UINT16 uTrackIndex, IHXValues* pTrack )
{
+/*
+printf( "CHXClientSink::TrackStarted - group = %u, track = %u\n", uGroupIndex, uTrackIndex );
+if ( pTrack )
+{
+ const char* pPropertyName = NULL;
+ SPIHXBuffer spPropertyValueBuffer;
+ ULONG32 propertyValue;
+ if ( SUCCEEDED( pTrack->GetFirstPropertyCString( pPropertyName, *spPropertyValueBuffer.AsInOutParam() ) ) )
+ {
+ printf( "CHXClientSink::TrackStarted(), CString property: key = %s, value = %s\n", pPropertyName, ( const char* ) spPropertyValueBuffer->GetBuffer() );
+ while( SUCCEEDED( pTrack->GetNextPropertyCString( pPropertyName, *spPropertyValueBuffer.AsInOutParam() ) ) )
+ {
+ printf( "CHXClientSink::TrackStarted(), CString property: key = %s, value = %s\n", pPropertyName, ( const char* ) spPropertyValueBuffer->GetBuffer() );
+ }
+ }
+ if ( SUCCEEDED( pTrack->GetFirstPropertyBuffer( pPropertyName, *spPropertyValueBuffer.AsInOutParam() ) ) )
+ {
+ printf( "CHXClientSink::TrackStarted(), Buffer property: key = %s, value = %s\n", pPropertyName, ( const char* ) spPropertyValueBuffer->GetBuffer() );
+ while( SUCCEEDED( pTrack->GetNextPropertyBuffer( pPropertyName, *spPropertyValueBuffer.AsInOutParam() ) ) )
+ {
+ printf( "CHXClientSink::TrackStarted(), Buffer property: key = %s, value = %s\n", pPropertyName, ( const char* ) spPropertyValueBuffer->GetBuffer() );
+ }
+ }
+ if ( SUCCEEDED( pTrack->GetFirstPropertyULONG32( pPropertyName, propertyValue ) ) )
+ {
+ printf( "CHXClientSink::TrackStarted(), ULONG32 property: key = %s, value = %lu\n", pPropertyName, propertyValue );
+ while( SUCCEEDED( pTrack->GetNextPropertyULONG32( pPropertyName, propertyValue ) ) )
+ {
+ printf( "CHXClientSink::TrackStarted(), ULONG32 property: key = %s, value = %lu\n", pPropertyName, propertyValue );
+ }
+ }
+}
+ */
GetURLsFromTrackProperties( pTrack );
UpdateContextURL();
UpdateRPURLAndTarget();
Index: CHXClientPlayer.cpp
===================================================================
RCS file: /cvsroot/player/hxclientkit/src/CHXClientPlayer.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- CHXClientPlayer.cpp 14 Jul 2004 20:55:08 -0000 1.31
+++ CHXClientPlayer.cpp 1 Sep 2004 18:50:23 -0000 1.32
@@ -65,11 +65,14 @@
#endif
#include "enter_hx_headers.h"
-#include "hxfiles.h" /* IHXRequest */
+#include "hxfiles.h" // IHXRequest
#include "ihxpckts.h"
#include "hxcore.h"
#include "hxgroup.h"
#include "hxvsrc.h"
+#if defined(HELIX_FEATURE_REGISTRY)
+#include "hxmon.h" // IHXRegistry
+#endif
#include "hxsmartptr.h"
HX_SMART_POINTER_INLINE( SPIHXBuffer, IHXBuffer );
@@ -81,6 +84,9 @@
HX_SMART_POINTER_INLINE( SPIHXGroupManager, IHXGroupManager );
HX_SMART_POINTER_INLINE( SPIHXViewSourceCommand, IHXViewSourceCommand );
HX_SMART_POINTER_INLINE( SPIHXClientViewRights, IHXClientViewRights );
+#if defined(HELIX_FEATURE_REGISTRY)
+HX_SMART_POINTER_INLINE( SPIHXRegistry, IHXRegistry );
+#endif
#include "exit_hx_headers.h"
#include "HXClientConstants.h"
@@ -115,12 +121,9 @@
m_pStatisticTracker = NULL;
}
#endif
- if ( m_pEQProcessor )
- {
- m_pEQProcessor->UnhookAudio();
- m_pEQProcessor->Release();
- m_pEQProcessor = NULL;
- }
+ CHXEQProcessor::DestroyEQProcessor( this, m_pEQProcessor );
+ m_pEQProcessor = NULL;
+
HX_RELEASE( m_pIClientVolume );
// XXXSEH: There is no way to clear the client context from the Player.
@@ -201,10 +204,8 @@
//m_pIClientVolume = spAudioPlayer->GetAudioVolume();
m_pIClientVolume = spAudioPlayer->GetDeviceVolume();
}
- m_pEQProcessor = new CHXEQProcessor( m_pIHXCorePlayer );
- m_pEQProcessor->AddRef();
- m_pEQProcessor->HookAudio();
-
+ m_pEQProcessor = CHXEQProcessor::CreateEQProcessor( this );
+
#if defined(HELIX_FEATURE_REGISTRY) && defined(HELIX_FEATURE_STATS)
m_pStatisticTracker = CHXStatisticTracker::CreatePlayerStatisticTracker( m_pIHXCorePlayer );
#endif
@@ -1206,6 +1207,21 @@
}
bool
+CHXClientPlayer::AddAudioHook( const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo )
+{
+ return m_pClipSink ? m_pClipSink->AddAudioHook( pAudioHookCallbacks, hookInfo ) : false;
+}
+
+void
+CHXClientPlayer::RemoveAudioHook( const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo )
+{
+ if ( m_pClipSink )
+ {
+ m_pClipSink->RemoveAudioHook( pAudioHookCallbacks, hookInfo );
+ }
+}
+
+bool
CHXClientPlayer::GetVideoAttribute( int attributeKey, float* pAttributeValue ) const
{
CHXASSERT( pAttributeValue );
@@ -1322,4 +1338,84 @@
m_pStatisticTracker->RemoveObserver( pStatisticKey, pStatisticsCallbacks, observerInfo );
}
#endif
+}
+
+bool
+CHXClientPlayer::GetRegistryData( const char* pDataKey, unsigned char* pValueBuffer, UINT32 bufferLength, int* pValueType, UINT32* pUsedBufferLength )
+{
+#if defined(HELIX_FEATURE_REGISTRY)
+ SPIHXRegistry spRegistry = m_pIHXCorePlayer;
+ CHXASSERT( spRegistry.IsValid() ); // Client player must support IHXRegistry.
+
+ HXPropType propType = spRegistry->GetTypeByName( pDataKey );
+ CHXCopyStatisticProcessor Processor( pValueBuffer, bufferLength, pValueType, pUsedBufferLength );
+ switch ( propType )
+ {
+ case PT_INTEGER:
+ {
+ SInt32 intValue;
+ if ( SUCCEEDED( spRegistry->GetIntByName( pDataKey, intValue ) ) )
+ {
+ return Processor( kValueType32BitSignedInt, ( const unsigned char* ) &intValue );
+ }
+ }
+ break;
+
+ case PT_STRING:
+ {
+ SPIHXBuffer spValueBuffer;
+ if ( SUCCEEDED( spRegistry->GetStrByName( pDataKey, *spValueBuffer.AsInOutParam() ) ) && spValueBuffer.IsValid() )
+ {
+ return Processor( kValueTypeString, spValueBuffer->GetBuffer() );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+#endif
+ return false;
+}
+
+bool
+CHXClientPlayer::SetRegistryData( const char* pDataKey, const unsigned char* pValueBuffer, UINT32 bufferLength, int valueType )
+{
+#if defined(HELIX_FEATURE_REGISTRY)
+ SPIHXRegistry spRegistry = m_pIHXCorePlayer;
+ CHXASSERT( spRegistry.IsValid() ); // Client player must support IHXRegistry.
+
+ switch ( valueType )
+ {
+ case kValueType32BitSignedInt:
+ {
+ if ( sizeof( SInt32 ) == bufferLength )
+ {
+ SInt32 intValue = *( SInt32* ) pValueBuffer;
+ if ( SUCCEEDED( spRegistry->SetIntByName( pDataKey, intValue ) ) )
+ {
+ return true;
+ }
+ }
+ }
+ break;
+
+ case kValueTypeString:
+ {
+ SPIHXBuffer spValueBuffer = new CHXClientBuffer;
+ if ( SUCCEEDED( spValueBuffer->Set( pValueBuffer, bufferLength ) ) )
+ {
+ if ( SUCCEEDED( spRegistry->SetStrByName( pDataKey, spValueBuffer.Ptr() ) ) )
+ {
+ return true;
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+#endif
+ return false;
}
Index: IHXClientPlayer.h
===================================================================
RCS file: /cvsroot/player/hxclientkit/src/IHXClientPlayer.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- IHXClientPlayer.h 9 Jul 2004 18:25:23 -0000 1.13
+++ IHXClientPlayer.h 1 Sep 2004 18:50:23 -0000 1.14
@@ -140,11 +140,15 @@
virtual bool IsEQAutoPreGainEnabled( void ) const = 0;
virtual void SetEQReverb( INT32 roomSize, INT32 reverb ) = 0;
virtual void GetEQReverb( INT32* pRoomSize, INT32* pReverb ) const = 0;
+ virtual bool AddAudioHook( const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo ) = 0;
+ virtual void RemoveAudioHook( const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo ) = 0;
virtual bool GetVideoAttribute( int attributeKey, float* pAttributeValue ) const = 0;
virtual bool SetVideoAttribute( int attributeKey, float attributeValue ) = 0;
virtual bool GetStatistic( const char* pStatisticKey, unsigned char* pValueBuffer, UINT32 bufferLength, int* pValueType, UINT32* pUsedBufferLength ) = 0;
virtual bool AddStatisticObserver( const char* pStatisticKey, const HXStatisticsCallbacks* pStatisticsCallbacks, void* observerInfo ) = 0;
virtual void RemoveStatisticObserver( const char* pStatisticKey, const HXStatisticsCallbacks* pStatisticsCallbacks, void* observerInfo ) = 0;
+ virtual bool GetRegistryData( const char* pDataKey, unsigned char* pValueBuffer, UINT32 bufferLength, int* pValueType, UINT32* pUsedBufferLength ) = 0;
+ virtual bool SetRegistryData( const char* pDataKey, const unsigned char* pValueBuffer, UINT32 bufferLength, int valueType ) = 0;
};
#endif
Index: CHXEQProcessor.h
===================================================================
RCS file: /cvsroot/player/hxclientkit/src/CHXEQProcessor.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CHXEQProcessor.h 9 Jul 2004 18:25:22 -0000 1.3
+++ CHXEQProcessor.h 1 Sep 2004 18:50:23 -0000 1.4
@@ -50,28 +50,18 @@
#ifndef _CHXEQ_PROCESSOR_H_
#define _CHXEQ_PROCESSOR_H_
-#include "CHXClientUnknown.h"
-
-#include "enter_hx_headers.h"
-#include "hxausvc.h" // IHXAudioHook, IHXAudioPlayer, IHXAudioHookManager, IHXAudioDeviceManager, HXAudioFormat
-#include "exit_hx_headers.h"
-
#include "HXEQEngine.h"
+#include "HXClientTypes.h"
-_INTERFACE IHXPlayer;
+class IHXClientPlayer;
-class CHXEQProcessor : public IHXAudioHook
+class CHXEQProcessor
// , public IHXSecureStatus // XXXSEH: Add support. Found in common_rn/include/rmadrm.h
{
- DECLARE_UNKNOWN_NOCREATE( CHXEQProcessor )
-
private:
- LONG32 m_lCount;
- IHXAudioPlayer* m_pAudioPlayer;
EQPTR m_pEQData;
- HXAudioFormat m_AudioFormat;
- bool m_HasHookedAudio;
+ SHXAudioFormat m_AudioFormat;
bool m_IsEnabled;
bool m_IsAutoPreGainEnabled;
int m_PreGain;
@@ -85,15 +75,14 @@
public:
virtual ~CHXEQProcessor( void );
- CHXEQProcessor( IHXPlayer* pIHXPlayer );
-
- void HookAudio( void );
- void UnhookAudio( void );
+ CHXEQProcessor( void );
+
+ static CHXEQProcessor* CreateEQProcessor( IHXClientPlayer* pClientPlayer );
+ static void DestroyEQProcessor( IHXClientPlayer* pClientPlayer, CHXEQProcessor* pEQProcessor );
+
+ void InitAudioData( const SHXAudioFormat* pAudioFormat );
+ void OnAudioBuffer( unsigned char* pAudioBuffer, UInt32 bufferLength, UInt32 audioStartTime, int audioStreamType );
- // IHXAudioHook
- STDMETHOD ( OnInit ) ( THIS_ HXAudioFormat* pFormat );
- STDMETHOD ( OnBuffer ) ( THIS_ HXAudioData* pAudioInData, HXAudioData* pAudioOutData );
-
void Enable( bool enable );
bool IsEnabled( void ) const
{
Index: CHXClientPlayer.h
===================================================================
RCS file: /cvsroot/player/hxclientkit/src/CHXClientPlayer.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- CHXClientPlayer.h 9 Jul 2004 18:25:22 -0000 1.18
+++ CHXClientPlayer.h 1 Sep 2004 18:50:23 -0000 1.19
@@ -97,7 +97,7 @@
#endif
UINT32 m_PendingSeekPosition;
- CHXFlatArray* m_pDataStreams;
+ CHXFlatArray* m_pDataStreams; // <CHXClientDataStream*>
IHXRequest* m_pIOpenedRequest;
bool m_IsActivelySeeking;
bool m_ShouldPlayOnStopSeeking;
@@ -178,11 +178,15 @@
virtual bool IsEQAutoPreGainEnabled( void ) const;
virtual void SetEQReverb( INT32 roomSize, INT32 reverb );
virtual void GetEQReverb( INT32* pRoomSize, INT32* pReverb ) const;
+ virtual bool AddAudioHook( const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo );
+ virtual void RemoveAudioHook( const HXAudioHookCallbacks* pAudioHookCallbacks, void* hookInfo );
virtual bool GetVideoAttribute( int attributeKey, float* pAttributeValue ) const;
virtual bool SetVideoAttribute( int attributeKey, float attributeValue );
virtual bool GetStatistic( const char* pStatisticKey, unsigned char* pValueBuffer, UINT32 bufferLength, int* pValueType, UINT32* pUsedBufferLength );
virtual bool AddStatisticObserver( const char* pStatisticKey, const HXStatisticsCallbacks* pStatisticsCallbacks, void* observerInfo );
virtual void RemoveStatisticObserver( const char* pStatisticKey, const HXStatisticsCallbacks* pStatisticsCallbacks, void* observerInfo );
+ virtual bool GetRegistryData( const char* pDataKey, unsigned char* pValueBuffer, UINT32 bufferLength, int* pValueType, UINT32* pUsedBufferLength );
+ virtual bool SetRegistryData( const char* pDataKey, const unsigned char* pValueBuffer, UINT32 bufferLength, int valueType );
};
#endif
Index: CHXStatisticTracker.cpp
===================================================================
RCS file: /cvsroot/player/hxclientkit/src/CHXStatisticTracker.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- CHXStatisticTracker.cpp 9 Jul 2004 18:25:22 -0000 1.10
+++ CHXStatisticTracker.cpp 1 Sep 2004 18:50:23 -0000 1.11
@@ -87,14 +87,6 @@
}
#endif
-class CHXStatisticProcessor
-{
-public:
- CHXStatisticProcessor( void ) {}
- virtual ~CHXStatisticProcessor( void ) {}
- virtual bool operator() ( int valueType, const unsigned char* pValue ) = 0;
-};
-
static bool
ProcessStatistic( IHXRegistry* pIRegistry, UINT32 statisticPropID, CHXStatisticProcessor& Processor )
{
@@ -282,74 +274,59 @@
m_pPropWatch = NULL;
}
-class CopyStatisticProcessor : public CHXStatisticProcessor
+bool
+CHXCopyStatisticProcessor::operator() ( int valueType, const unsigned char* pValue )
{
-private:
- unsigned char* m_pValueBuffer;
- UINT32 m_BufferLength;
- int* m_pValueType;
- UINT32* m_pUsedBufferLength;
-public:
- CopyStatisticProcessor( unsigned char* pValueBuffer, UINT32 bufferLength, int* pValueType, UINT32* pUsedBufferLength )
- : m_pValueBuffer( pValueBuffer )
- , m_BufferLength( bufferLength )
- , m_pValueType( pValueType )
- , m_pUsedBufferLength( pUsedBufferLength )
- {}
- virtual ~CopyStatisticProcessor( void ) {}
- virtual bool operator() ( int valueType, const unsigned char* pValue )
+ *m_pValueType = valueType;
+ UINT32 desiredBufferLength = 0;
+ switch ( valueType )
+ {
+ case kValueType32BitSignedInt:
+ desiredBufferLength = sizeof( INT32 );
+ break;
+ case kValueTypeString:
+ desiredBufferLength = strlen( ( const char* ) pValue ) + 1;
+ break;
+ }
+ if ( !m_pValueBuffer || ( m_BufferLength == 0 ) )
+ {
+ if ( m_pUsedBufferLength )
+ {
+ *m_pUsedBufferLength = desiredBufferLength;
+ }
+ return false;
+ }
+ bool outCopied = false;
+ UINT32 usedBufferLength = 0;
+ if ( desiredBufferLength <= m_BufferLength )
+ {
+ usedBufferLength = desiredBufferLength;
+ memcpy( m_pValueBuffer, pValue, usedBufferLength );
+ outCopied = true;
+ }
+ else
{
- *m_pValueType = valueType;
- UINT32 desiredBufferLength = 0;
switch ( valueType )
{
case kValueType32BitSignedInt:
- desiredBufferLength = sizeof( INT32 );
break;
+
case kValueTypeString:
- desiredBufferLength = strlen( ( const char* ) pValue ) + 1;
- break;
- }
- if ( !m_pValueBuffer || ( m_BufferLength == 0 ) )
- {
- if ( m_pUsedBufferLength )
{
- *m_pUsedBufferLength = desiredBufferLength;
- }
- return false;
- }
- bool outCopied = false;
- UINT32 usedBufferLength = 0;
- if ( desiredBufferLength <= m_BufferLength )
- {
- usedBufferLength = desiredBufferLength;
- memcpy( m_pValueBuffer, pValue, usedBufferLength );
- outCopied = true;
- }
- else
- {
- switch ( valueType )
- {
- case kValueType32BitSignedInt:
- break;
-
- case kValueTypeString:
- {
- usedBufferLength = m_BufferLength;
- memcpy( m_pValueBuffer, pValue, usedBufferLength );
- m_pValueBuffer[ usedBufferLength - 1 ] = '\0';
- outCopied = true;
- }
- break;
+ usedBufferLength = m_BufferLength;
+ memcpy( m_pValueBuffer, pValue, usedBufferLength );
+ m_pValueBuffer[ usedBufferLength - 1 ] = '\0';
+ outCopied = true;
}
+ break;
}
- if ( m_pUsedBufferLength )
- {
- *m_pUsedBufferLength = usedBufferLength;
- }
- return outCopied;
}
-};
+ if ( m_pUsedBufferLength )
+ {
+ *m_pUsedBufferLength = usedBufferLength;
+ }
+ return outCopied;
+}
bool
CHXStatisticTrackerNode::GetStatisticsFor( const char* pStatisticKey, unsigned char* pValueBuffer, UINT32 bufferLength, int* pValueType, UINT32* pUsedBufferLength )
@@ -377,7 +354,7 @@
UINT32 propID = m_pRegistry->GetId( pFullPropName );
if ( propID != kInvalidRegistryPropID )
{
- CopyStatisticProcessor Processor( pValueBuffer, bufferLength, pValueType, pUsedBufferLength );
+ CHXCopyStatisticProcessor Processor( pValueBuffer, bufferLength, pValueType, pUsedBufferLength );
outGotStatistic = ProcessStatistic( m_pRegistry, propID, Processor );
}
delete [] pFullPropName;
@@ -744,13 +721,15 @@
CHXStatisticTracker::AddObserver( const char* pStatisticKey, const HXStatisticsCallbacks* pStatisticsCallbacks, void* observerInfo )
{
CHXASSERT( pStatisticsCallbacks );
+ if ( !pStatisticsCallbacks ) return false;
+
CHXASSERT( pStatisticKey && *pStatisticKey );
if ( ShouldObserveProperty( pStatisticKey, GetPropName(), false ) )
{
if ( !m_pObservers )
{
- m_pObservers = new CHXFlatArray(sizeof(SHXTrackerObserverData));
+ m_pObservers = new CHXFlatArray( sizeof( SHXTrackerObserverData ) );
}
if ( m_pObservers )
{
@@ -874,6 +853,7 @@
CHXStatisticTrackerEntry::AddObserver( const char* pStatisticKey, const HXStatisticsCallbacks* pStatisticsCallbacks, void* observerInfo )
{
CHXASSERT( pStatisticsCallbacks );
+ if ( !pStatisticsCallbacks ) return false;
if ( ShouldObserveProperty( pStatisticKey, GetPropName(), true ) )
{