Click here to Skip to main content
15,892,005 members
Articles / Desktop Programming / WTL

Multidevice ASIO output plugin for WinAMP

Rate me:
Please Sign up or sign in to vote.
4.80/5 (9 votes)
13 Feb 2009CDDL27 min read 48.2K   728   23  
A tiny WinAMP output DLL that uses a C++ replacement of the official ASIO SDK that supports multiple ASIO devices.
#include "WTL.h"


#ifdef TINY_ATL

#if _ATL_VER != 0x0900
    #error "TINY_ATL" tested only with ATL version 9.0
#endif

#include "atlstdthunk.h"

#pragma warning( disable: 4074 )  // initializers put in compiler reserved initialization area
#pragma init_seg( compiler )

namespace ATL
{
    ////////////////////////////////////////////////////////////////////////////
    //
    //  Tiny ATL's CAtlBaseModule minimum implementation.
    //  -------------------------------------------------
    //
    ////////////////////////////////////////////////////////////////////////////

    extern "C" __declspec( selectany ) GUID const GUID_ATLVer70 = { 0x394c3de0, 0x3c6f, 0x11d2, { 0x81, 0x7b, 0x0, 0xc0, 0x4f, 0x79, 0x7a, 0xb7 } };
    CAtlBaseModule::CAtlBaseModule()
    {
        cbSize = sizeof( _ATL_BASE_MODULE );

        m_hInst = m_hInstResource = reinterpret_cast<HINSTANCE>( &__ImageBase );

        dwAtlBuildVer = _ATL_VER;
        pguidVer = &GUID_ATLVer70;
    }

    CAtlBaseModule::~CAtlBaseModule() {}

    ////////////////////////////////////////////////////////////////////////////
    //
    //  Tiny ATL's _stdcallthunk custom allocator/operator new implementation.
    //  ----------------------------------------------------------------------
    //
    //  No special logic/optimized algorithm is used, like in the full version,
    // to minimize code size as this 'dumb' implementation should be sufficient
    // for the use that TINY_ATL is meant for (only a few windows/window impls
    // being created).
    //
    ////////////////////////////////////////////////////////////////////////////

    void * __stdcall __AllocStdCallThunk(                        ) { return ::new _stdcallthunk; }
    void   __stdcall __FreeStdCallThunk ( void * const pATLThunk ) { ::delete pATLThunk;         }

    __declspec( selectany ) CAtlBaseModule _AtlBaseModule;
    __declspec( selectany ) CAtlComModule  _AtlComModule ;
    __declspec( selectany ) CAtlWinModule  _AtlWinModule ;
};  // namespace ATL

#else   // TINY_ATL

__declspec( selectany ) WTL::CAppModule _Module;

#endif  // TINY_ATL


namespace WTL
{

#ifndef TINY_ATL
__declspec( selectany ) CMessageLoop defaultMessageLoop;
CMessageLoop & DefaultMessageLoop()
{
    return defaultMessageLoop;
}
#endif


//************************************
// Method:    Initialize
// FullName:  WTL::Initialize
// Access:    global
//************************************

bool Initialize( HINSTANCE const hInstance, DWORD const commonControlFlags, CMessageLoop * const pDefaultMessageLoop )
{
    if ( commonControlFlags && ( AtlInitCommonControls( commonControlFlags ) == false ) )
        return false;

#ifndef TINY_ATL
    return SUCCEEDED( _Module.Init( NULL, hInstance ) ) &&
          ( !pDefaultMessageLoop || _Module.AddMessageLoop( pDefaultMessageLoop ) );
#else
    assert( !pDefaultMessageLoop && "You cannot use CMessageLoops and TINY_ATL." );
    hInstance; pDefaultMessageLoop;
    return true;
#endif
}


//************************************
// Method:    Uninitialize
// FullName:  WTL::Uninitialize
// Access:    global
//************************************

void Uninitialize()
{
#ifndef TINY_ATL
    _Module.Term();
#endif  // TINY_ATL
}

} // WTL


//************************************
// Method:    InitializeCOM
// FullName:  InitializeCOM
// Access:    global
//************************************

bool InitializeCOM( DWORD const comInitializationFlags )
{
    return SUCCEEDED( ::CoInitializeEx( NULL, comInitializationFlags ) );
}

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, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)


Written By
Software Developer Little Endian Ltd.
Croatia Croatia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions