audiobase.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /******************************************************************************
  2. |* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. |* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. |* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. |* PARTICULAR PURPOSE.
  6. |*
  7. |* Copyright 1995-2005 Nero AG. All Rights Reserved.
  8. |*-----------------------------------------------------------------------------
  9. |* NeroSDK / AudioPluginManager
  10. |*
  11. |* FILE: audiobase.cpp
  12. |*
  13. |* PURPOSE: Implementation of the CStatus helper class
  14. ******************************************************************************/
  15. #include "stdafx.h"
  16. #include "AudioBase.h"
  17. ///////////////////////////////////////////////////////////////////// CStatus //
  18. CStatus::CStatus(DWORD syserror)
  19. : m_lRef (1),
  20. m_dwErr (syserror),
  21. m_eAudioError (AE_Undefined),
  22. m_category (ESC_General)
  23. {}
  24. CStatus::CStatus(EAudioError audioerror)
  25. : m_lRef (1),
  26. m_dwErr (0),
  27. m_eAudioError (audioerror),
  28. m_category (ESC_General)
  29. {}
  30. CStatus::CStatus(const char *szError)
  31. : m_lRef (1),
  32. m_dwErr (0),
  33. m_eAudioError (AE_Undefined),
  34. m_csError (szError),
  35. m_category (ESC_General)
  36. {}
  37. // IUnknown
  38. STDMETHODIMP CStatus::QueryInterface(REFIID riid,
  39. void __RPC_FAR *__RPC_FAR *ppObj)
  40. {
  41. if(!ppObj)
  42. {
  43. ASSERT(FALSE);
  44. return E_INVALIDARG;
  45. }
  46. *ppObj = NULL;
  47. if(IsEqualIID(riid, IID_IUnknown))
  48. *ppObj = static_cast<IUnknown*>(static_cast<IStatus*>(this));
  49. else
  50. if(IsEqualIID(riid, IID_IStatus))
  51. *ppObj = static_cast<IStatus*>(this);
  52. else
  53. if(IsEqualIID(riid, IID_IStatusCategory))
  54. {
  55. if(ESC_General != m_category)
  56. *ppObj = static_cast<IStatusCategory*>(this);
  57. }
  58. if(*ppObj)
  59. AddRef();
  60. return *ppObj? S_OK: E_NOINTERFACE;
  61. }
  62. STDMETHODIMP_(ULONG) CStatus::AddRef()
  63. {
  64. InterlockedIncrement(&m_lRef);
  65. return m_lRef;
  66. }
  67. STDMETHODIMP_(ULONG) CStatus::Release()
  68. {
  69. InterlockedDecrement(&m_lRef);
  70. if(!m_lRef)
  71. {
  72. delete this;
  73. return 0;
  74. }
  75. return m_lRef;
  76. }
  77. // IStatus
  78. const char * CStatus::GetDescription()
  79. {
  80. return m_csError;
  81. }
  82. EAudioError CStatus::GetAudioError()
  83. {
  84. return m_eAudioError;
  85. }
  86. DWORD CStatus::GetSysError()
  87. {
  88. return m_dwErr;
  89. }
  90. void CStatus::SetCategory(EStatusCategory cat)
  91. {
  92. m_category = cat;
  93. }
  94. EStatusCategory CStatus::GetCategory()
  95. {
  96. return m_category;
  97. }