Click here to Skip to main content
11,639,861 members (60,774 online)
Click here to Skip to main content
Add your own
alternative version

Multidevice ASIO output plugin for WinAMP

, 13 Feb 2009 CDDL 26.7K 370 21
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)

Share

About the Author

Domagoj Šarić
Software Developer Little Endian Ltd.
Croatia Croatia
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150731.1 | Last Updated 13 Feb 2009
Article Copyright 2009 by Domagoj Šarić
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid