audplin.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:9k
源码类别:

Symbian

开发平台:

Visual C++

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: RCSL 1.0/RPSL 1.0
  3.  *
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
  5.  *
  6.  * The contents of this file, and the files included with this file, are
  7.  * subject to the current version of the RealNetworks Public Source License
  8.  * Version 1.0 (the "RPSL") available at
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed
  10.  * the file under the RealNetworks Community Source License Version 1.0
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
  12.  * in which case the RCSL will apply. You may also obtain the license terms
  13.  * directly from RealNetworks.  You may not use this file except in
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or
  16.  * RCSL for the rights, obligations and limitations governing use of the
  17.  * contents of the file.
  18.  *
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the
  20.  * developer of the Original Code and owns the copyrights in the portions
  21.  * it created.
  22.  *
  23.  * This file, and the files included with this file, is distributed and made
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  28.  *
  29.  * Technology Compatibility Kit Test Suite(s) Location:
  30.  *    http://www.helixcommunity.org/content/tck
  31.  *
  32.  * Contributor(s):
  33.  *
  34.  * ***** END LICENSE BLOCK ***** */
  35. #define INITGUID
  36. #include "hxcom.h"
  37. #include <stdio.h>
  38. #ifndef _WINCE
  39. #include <signal.h>
  40. #endif
  41. #include "hxtypes.h"
  42. #include "hxcomm.h"
  43. #include "hxengin.h"
  44. #include "ihxpckts.h"
  45. #include "hxvalue.h"
  46. #include "hxfiles.h"
  47. #include "hxcore.h"
  48. #include "hxprefs.h"
  49. #include "hxrendr.h"
  50. #include "hxplugn.h"
  51. #include "hxupgrd.h"
  52. #include "hxausvc.h"
  53. #include "netbyte.h"
  54. #include "hxheap.h"
  55. #include "hxstrutl.h"
  56. #include "hxslist.h"
  57. #include "hxformt.h"
  58. #include "hxpends.h"
  59. #include "hxwin.h"
  60. #include "hxvalue.h"
  61. #include "baseobj.h"
  62. #if defined(HELIX_FEATURE_AUDIO_WAVE) || defined(HELIX_FEATURE_AUDIO_AU) || defined(HELIX_FEATURE_AUDIO_AIFF)
  63. #include "audrend.h"
  64. #include "pcmrend.h"
  65. #endif /* #if defined(HELIX_FEATURE_AUDIO_WAVE) || defined(HELIX_FEATURE_AUDIO_AU)
  66.               || defined(HELIX_FEATURE_AUDIO_AIFF)*/
  67. #if defined(HELIX_FEATURE_AUDIO_WAVE)
  68. #include "wvffplin.h"
  69. #endif /* #if defined(HELIX_FEATURE_AUDIO_WAVE) */
  70. #if defined(HELIX_FEATURE_AUDIO_AU)
  71. #include "auffplin.h"
  72. #endif /* #if defined(HELIX_FEATURE_AUDIO_AU) */
  73. #if defined(HELIX_FEATURE_AUDIO_AIFF)
  74. #include "aiffplin.h"
  75. #endif /* #if defined(HELIX_FEATURE_AUDIO_AIFF) */
  76. #if defined(HELIX_FEATURE_PLAYBACK_LOCAL)
  77. #if defined(HELIX_FEATURE_AUDIO_CODEC_AMRNB) || defined(HELIX_FEATURE_AUDIO_CODEC_AMRWB)
  78. #define INCLUDE_AMRFF
  79. #endif /* #if defined(HELIX_FEATURE_AUDIO_CODEC_AMRNB) || defined(HELIX_FEATURE_AUDIO_CODEC_AMRWB) */
  80. #endif /* #if defined(HELIX_FEATURE_PLAYBACK_LOCAL) */
  81. #if defined(INCLUDE_AMRFF)
  82. #include "amrff.h"
  83. #endif /* #if defined(INCLUDE_AMRFF) */
  84. #if defined(HELIX_FEATURE_AUDIO_MPEG4)
  85. #include "hxacodec.h"
  86. #include "mp4audio.h"
  87. #endif /* #if defined(HELIX_FEATURE_AUDIO_MPEG4) */
  88. #include "audplin.h"
  89. #if !defined(HELIX_FEATURE_DLLACCESS_CLIENT)
  90. #include "dllpath.h"
  91. ENABLE_DLLACCESS_PATHS(audplin);
  92. #endif // HELIX_FEATURE_DLLACCESS_CLIENT
  93. #ifdef _DEBUG
  94. #undef HX_THIS_FILE
  95. static char HX_THIS_FILE[] = __FILE__;
  96. #endif
  97. HX_RESULT (STDAPICALLTYPE  * const AudioPluginFactory::m_fpEntryArray[])(IUnknown**)=
  98. {
  99. #if defined(HELIX_FEATURE_AUDIO_WAVE) || defined(HELIX_FEATURE_AUDIO_AU) || defined(HELIX_FEATURE_AUDIO_AIFF)
  100.     CPCMAudioRenderer::HXCreateInstance,
  101. #endif /* #if defined(HELIX_FEATURE_AUDIO_WAVE) || defined(HELIX_FEATURE_AUDIO_AU)
  102.               || defined(HELIX_FEATURE_AUDIO_AIFF)*/
  103. #if defined(HELIX_FEATURE_AUDIO_WAVE)
  104.     CWaveFileFormat::HXCreateInstance,
  105. #endif /* #if defined(HELIX_FEATURE_AUDIO_WAVE) */
  106. #if defined(HELIX_FEATURE_AUDIO_AU)
  107.     CAUFileFormat::HXCreateInstance,
  108. #endif /* #if defined(HELIX_FEATURE_AUDIO_AU) */
  109. #if defined(HELIX_FEATURE_AUDIO_AIFF)
  110.     AIFFFileFormat::HXCreateInstance,
  111. #endif /* #if defined(HELIX_FEATURE_AUDIO_AIFF) */
  112. #if defined(INCLUDE_AMRFF)
  113.     CAMRFileFormat::HXCreateInstance,
  114. #endif /* #if defined(INCLUDE_AMRFF) */
  115. #if defined(HELIX_FEATURE_AUDIO_MPEG4)
  116.     CMP4AudioRenderer::HXCreateInstance,
  117. #endif /* #if defined(HELIX_FEATURE_AUDIO_MPEG4) */
  118.     NULL
  119. };
  120. HX_RESULT (STDAPICALLTYPE* const AudioPluginFactory::m_fpUnloadArray[])()={
  121. #if defined(HELIX_FEATURE_AUDIO_WAVE) || defined(HELIX_FEATURE_AUDIO_AU) || defined(HELIX_FEATURE_AUDIO_AIFF)
  122.     CPCMAudioRenderer::CanUnload2,
  123. #endif /* #if defined(HELIX_FEATURE_AUDIO_WAVE) || defined(HELIX_FEATURE_AUDIO_AU)
  124.               || defined(HELIX_FEATURE_AUDIO_AIFF)*/
  125. #if defined(HELIX_FEATURE_AUDIO_WAVE)
  126.     CWaveFileFormat::CanUnload2,
  127. #endif /* #if defined(HELIX_FEATURE_AUDIO_WAVE) */
  128. #if defined(HELIX_FEATURE_AUDIO_AU)
  129.     CAUFileFormat::CanUnload2,
  130. #endif /* #if defined(HELIX_FEATURE_AUDIO_AU) */
  131. #if defined(HELIX_FEATURE_AUDIO_AIFF)
  132.     AIFFFileFormat::CanUnload2,
  133. #endif /* #if defined(HELIX_FEATURE_AUDIO_AIFF) */
  134. #if defined(INCLUDE_AMRFF)
  135.     CAMRFileFormat::CanUnload2,
  136. #endif /* #if defined(INCLUDE_AMRFF) */
  137. #if defined(HELIX_FEATURE_AUDIO_MPEG4)
  138.     CMP4AudioRenderer::CanUnload2,
  139. #endif /* #if defined(HELIX_FEATURE_AUDIO_MPEG4) */
  140.     NULL
  141. };
  142. STDAPI ENTRYPOINT(HXCREATEINSTANCE)(IUnknown** ppIUnknown)
  143. {
  144.     *ppIUnknown = (IUnknown*)(IHXPlugin*)new AudioPluginFactory();
  145.     if (*ppIUnknown)
  146.     {
  147. (*ppIUnknown)->AddRef();
  148. return HXR_OK;
  149.     }
  150.     return HXR_OUTOFMEMORY;
  151. }
  152. STDAPI ENTRYPOINT(CanUnload2)(void)
  153. {
  154.     for( int i=0; AudioPluginFactory::m_fpUnloadArray[i]; i++ )
  155.     {
  156.         if( (AudioPluginFactory::m_fpUnloadArray[i])() != HXR_OK )
  157.         {
  158.             return HXR_FAIL;
  159.         }
  160.     }
  161.     return HXR_OK;
  162. }
  163. /////////////////////////////////////////////////////////////////////////
  164. //  Method:
  165. //      AudioPluginFactory
  166. //  Purpose:
  167. //      Constructor. Counts the number of functions within the
  168. //      Entry Array. Would have liked to use:
  169. //      return (sizeof(m_fpEntryArray)/sizeof(m_fpEntryArray[0]))-1;
  170. //      But for some strange reason the complier spits at it...
  171. //
  172. AudioPluginFactory::AudioPluginFactory() :
  173. m_lRefCount(0)
  174. {
  175.     for(m_usNumOfPlugins=0;m_fpEntryArray[m_usNumOfPlugins];m_usNumOfPlugins++) ;
  176. }
  177. /////////////////////////////////////////////////////////////////////////
  178. //  Method:
  179. // IUnknown::QueryInterface
  180. //  Purpose:
  181. // Implement this to export the interfaces supported by your
  182. // object.
  183. //
  184. STDMETHODIMP AudioPluginFactory::QueryInterface(REFIID riid, void** ppvObj)
  185. {
  186.     if (IsEqualIID(riid, IID_IUnknown))
  187.     {
  188. AddRef();
  189. *ppvObj = (IUnknown *)this;
  190. return HXR_OK;
  191.     }
  192.     else if (IsEqualIID(riid, IID_IHXPluginFactory))
  193.     {
  194. AddRef();
  195. *ppvObj = (IHXPluginFactory *)this;
  196. return HXR_OK;
  197.     }
  198.     *ppvObj = NULL;
  199.     return HXR_NOINTERFACE;
  200. }
  201. /////////////////////////////////////////////////////////////////////////
  202. //  Method:
  203. //      AudioPluginFactory::AddRef
  204. //  Purpose:
  205. //      Everyone usually implements this the same... feel free to use
  206. //      this implementation.
  207. //
  208. STDMETHODIMP_(ULONG32) AudioPluginFactory::AddRef()
  209. {
  210.     return InterlockedIncrement(&m_lRefCount);
  211. }
  212. /////////////////////////////////////////////////////////////////////////
  213. //  Method:
  214. //      AudioPluginFactory::Release
  215. //  Purpose:
  216. //      Everyone usually implements this the same... feel free to use
  217. //      this implementation.
  218. //
  219. STDMETHODIMP_(ULONG32) AudioPluginFactory::Release()
  220. {
  221.     if (InterlockedDecrement(&m_lRefCount) > 0)
  222.     {
  223.         return m_lRefCount;
  224.     }
  225.     delete this;
  226.     return 0;
  227. }
  228. /////////////////////////////////////////////////////////////////////////
  229. //  Method:
  230. //      AudioPluginFactory::GetNumPlugins
  231. //  Purpose:
  232. //      Returns an int, the number of plugins in this DLL.
  233. //
  234. //
  235. STDMETHODIMP_(UINT16) AudioPluginFactory::GetNumPlugins()
  236. {
  237.     return m_usNumOfPlugins;
  238. }
  239. /////////////////////////////////////////////////////////////////////////
  240. //  Method:
  241. //      AudioPluginFactory::GetPlugin
  242. //  Purpose:
  243. //      Returns an IUnknown Reference to the specified Interface
  244. //
  245. //
  246. STDMETHODIMP AudioPluginFactory::GetPlugin(UINT16 uindex, IUnknown** pPlugin)
  247. {
  248.     if (uindex<m_usNumOfPlugins)
  249. return m_fpEntryArray[uindex](pPlugin);
  250.     *pPlugin=0;
  251.     return HXR_NOINTERFACE;
  252. }