Source code of Windows XP (NT5)
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.

94 lines
2.2 KiB

  1. // Copyright (c) 1999 Microsoft Corporation. All rights reserved.
  2. //
  3. // Implementation of CAutDirectMusicAudioPath.
  4. //
  5. #include "stdinc.h"
  6. #include "autaudiopath.h"
  7. const WCHAR CAutDirectMusicAudioPath::ms_wszClassName[] = L"AudioPath";
  8. //////////////////////////////////////////////////////////////////////
  9. // Method Names/DispIDs
  10. const DISPID DMPDISP_SetVolume = 1;
  11. const DISPID DMPDISP_GetVolume = 2;
  12. const AutDispatchMethod CAutDirectMusicAudioPath::ms_Methods[] =
  13. {
  14. // dispid, name,
  15. // return: type, (opt), (iid),
  16. // parm 1: type, opt, iid,
  17. // parm 2: type, opt, iid,
  18. // ...
  19. // ADT_None
  20. { DMPDISP_SetVolume, L"SetVolume",
  21. ADPARAM_NORETURN,
  22. ADT_Long, false, &IID_NULL, // volume
  23. ADT_Long, true, &IID_NULL, // duration
  24. ADT_None },
  25. { DMPDISP_GetVolume, L"GetVolume",
  26. ADT_Long, true, &IID_NULL, // returned volume
  27. ADT_None },
  28. { DISPID_UNKNOWN }
  29. };
  30. const DispatchHandlerEntry<CAutDirectMusicAudioPath> CAutDirectMusicAudioPath::ms_Handlers[] =
  31. {
  32. { DMPDISP_SetVolume, SetVolume },
  33. { DMPDISP_GetVolume, GetVolume },
  34. { DISPID_UNKNOWN }
  35. };
  36. //////////////////////////////////////////////////////////////////////
  37. // Creation
  38. CAutDirectMusicAudioPath::CAutDirectMusicAudioPath(
  39. IUnknown* pUnknownOuter,
  40. const IID& iid,
  41. void** ppv,
  42. HRESULT *phr)
  43. : BaseImpAudioPath(pUnknownOuter, iid, ppv, phr),
  44. m_lVolume(0)
  45. {
  46. }
  47. HRESULT
  48. CAutDirectMusicAudioPath::CreateInstance(
  49. IUnknown* pUnknownOuter,
  50. const IID& iid,
  51. void** ppv)
  52. {
  53. HRESULT hr = S_OK;
  54. CAutDirectMusicAudioPath *pInst = new CAutDirectMusicAudioPath(pUnknownOuter, iid, ppv, &hr);
  55. if (FAILED(hr))
  56. {
  57. delete pInst;
  58. return hr;
  59. }
  60. if (pInst == NULL)
  61. return E_OUTOFMEMORY;
  62. return hr;
  63. }
  64. //////////////////////////////////////////////////////////////////////
  65. // Automation methods
  66. HRESULT
  67. CAutDirectMusicAudioPath::SetVolume(AutDispatchDecodedParams *paddp)
  68. {
  69. LONG lVol = paddp->params[0].lVal;
  70. LONG lDuration = paddp->params[1].lVal;
  71. m_lVolume = ClipLongRange(lVol, -9600, 0);
  72. return m_pITarget->SetVolume(m_lVolume, lDuration);
  73. }
  74. HRESULT
  75. CAutDirectMusicAudioPath::GetVolume(AutDispatchDecodedParams *paddp)
  76. {
  77. LONG *plRet = reinterpret_cast<LONG*>(paddp->pvReturn);
  78. if (plRet)
  79. *plRet = m_lVolume;
  80. return S_OK;
  81. }