Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.8 KiB

  1. // helper function for implementing the Clone method on DMOs
  2. #pragma once
  3. #include "dsdmobse.h"
  4. template<class TypeOf_CDirectSoundDMO, class TypeOf_ParamsStruct>
  5. HRESULT StandardDMOClone(TypeOf_CDirectSoundDMO *pThis, IMediaObjectInPlace **ppCloned);
  6. // implementation...
  7. // The end of StandardDMOClone is the same for all types. Implement it outside the template
  8. // so that the code isn't duplicated. Copies the input and output types, does the QI for IMediaObjectInPlace,
  9. // and returns with the correct ref count.
  10. HRESULT StandardDMOClone_Ending(IMediaObject *pThis, IMediaObject *pCloned, IMediaObjectInPlace **ppCloned);
  11. template<class TypeOf_CDirectSoundDMO, class TypeOf_ParamsStruct>
  12. HRESULT StandardDMOClone(TypeOf_CDirectSoundDMO *pThis, IMediaObjectInPlace **ppCloned)
  13. {
  14. if (!ppCloned)
  15. return E_POINTER;
  16. HRESULT hr = S_OK;
  17. TypeOf_CDirectSoundDMO *pCloned = NULL;
  18. IUnknown *pUnk = NULL;
  19. IMediaObject * pClonedMediaObject = NULL;
  20. try
  21. {
  22. pCloned = new TypeOf_CDirectSoundDMO( NULL, &hr );
  23. if( SUCCEEDED( hr ) )
  24. {
  25. hr = pCloned->NDQueryInterface( IID_IUnknown, (void **) &pUnk );
  26. if( SUCCEEDED(hr ) )
  27. {
  28. hr = pUnk->QueryInterface( IID_IMediaObject, (void **) &pClonedMediaObject );
  29. pUnk->Release();
  30. }
  31. }
  32. } catch(...) {}
  33. if (pCloned == NULL)
  34. {
  35. return hr;
  36. }
  37. // Copy parameter control information
  38. if (SUCCEEDED(hr))
  39. hr = pCloned->CopyParamsFromSource(pThis);
  40. // Copy current parameter values
  41. TypeOf_ParamsStruct params;
  42. if (SUCCEEDED(hr))
  43. hr = pThis->GetAllParameters(&params);
  44. if (SUCCEEDED(hr))
  45. hr = pCloned->SetAllParameters(&params);
  46. if (SUCCEEDED(hr))
  47. hr = StandardDMOClone_Ending(pThis, pClonedMediaObject, ppCloned);
  48. return hr;
  49. }