Click here to Skip to main content
11,718,289 members (87,121 online)
Click here to Skip to main content
Add your own
alternative version

Windows Media Audio compressor

, 8 Apr 2004 242.1K 4.5K 104
Managed C++ Windows Media Audio (WMA) compressor.
//  This material has been supplied as part of the Adapt-X Engine Development
//  Kit. Under copyright laws, this material may not be duplicated in whole
//  or in part, except for personal use, without the express written consent
//  of the author. Refer to the license agreement contained with this SDK
//  before using any part of this material.
//
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
//  PURPOSE.
//
//  Email:  adaptx@hotmail.com
//
//  Copyright (C) 1999-2002 Ianier Munoz. All Rights Reserved.

#pragma once

#define WAVE_FORMAT_IEEE_FLOAT 3

#define ReleaseComObject(x) if (x != NULL) { x->Release(); x = NULL; }


//#include "adaptx30.h"

using namespace System;
//using namespace System::IO;
//using namespace System::Collections;
using namespace System::Runtime::InteropServices;

/*
using namespace System::Drawing;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::Windows::Forms;

namespace AdaptX
{

	#define errCantCreateEngine S"Can't create the Adapt-X engine."
	#define errBadEngineVersion S"Bad Adapt-X engine version."
	#define errCantCreateEnumerator S"Can't create the system enumerator."
	#define errCantCreateEditor S"Can't create the engine editor."

	public __gc class AdaptXException : public Exception
	{
	public:
		AdaptXException(String* Message) : Exception(Message)
		{
		}
	};
}
*/
template<__nogc class Derived, __nogc class I, __gc class W>
class ManWrapper : public I
{
public:
	static void Create(W* wrapped, I** result)
	{
		Derived* c = new Derived();
		c->Init(wrapped);
        c->QueryInterface(__uuidof(I), (void**)result);
	}
public:
	ManWrapper() : 
	  m_RefCount(0), m_IntfHandle(NULL)
	{
	}
	virtual ~ManWrapper()
	{
		Done();
	}
public:
	void Init(W* wrapped)
	{
		if (wrapped != GetIntf())
		{
			Done();
			IntPtr IntfHandle = (IntPtr)GCHandle::Alloc(wrapped);
			m_IntfHandle = IntfHandle.ToPointer();
		}
	}
	void Done()
	{
		if (m_IntfHandle != NULL)
		{
			GCHandle h = GCHandle::op_Explicit(IntPtr(m_IntfHandle));
			if (h.IsAllocated)
				h.Free();
			m_IntfHandle = NULL;
		}
	}
	W* GetIntf()
	{
		if (m_IntfHandle != NULL)
		{
			GCHandle h = GCHandle::op_Explicit(IntPtr(m_IntfHandle));
			return static_cast<W*>(h.Target);
		}
		else
			return NULL;
	}
protected:
	void* m_IntfHandle;
public: // IUnknown
	virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) 
	{ 
		if (riid == IID_IUnknown || riid == __uuidof(I)) 
		{ 
			(*ppvObject) = (I*)this; 
			AddRef(); 
			return S_OK; 
		} 
		else return E_NOINTERFACE; 
	} 
	virtual ULONG STDMETHODCALLTYPE AddRef(void) 
	{ 
		return ++m_RefCount; 
	} 
	virtual ULONG STDMETHODCALLTYPE Release(void) 
	{ 
		m_RefCount--; 
		if (m_RefCount > 0) 
			return m_RefCount; 
		else 
		{ 
			delete this; 
			return 0; 
		} 
	} 
private: 
	ULONG m_RefCount; 
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Idael Cardoso
Web Developer
France France
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150901.1 | Last Updated 9 Apr 2004
Article Copyright 2004 by Idael Cardoso
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid