Click here to Skip to main content
15,888,527 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.
#pragma once


//  Generic utility namespace for WinAMP modules.

namespace WinAMP
{
#pragma warning( push )
#pragma warning( disable : 4100 )   // unreferenced formal wParam
    #include "WA SDK/Winamp/WA_IPC.h"
#pragma warning( pop )

//  Must be implemented by the specific WinAMP module that receives the handles
// from WinAMP upon startup.
HWND      WinAMPWindowHandle();
HINSTANCE DLLInstanceHandle ();


//  Helpers for controlling WinAMP via Windows messages.
inline LRESULT WAMessage( UINT message, WPARAM wParam = 0, LPARAM lParam = 0 ) { return ::SendMessage( WinAMPWindowHandle(), message, wParam, lParam ); }

struct WAMessages
{
    // (todo) Fill as needed.
    enum
    {
        StopPlayback = 40047
    };
};

inline LRESULT    WACommand( LPARAM command, WPARAM parameter = 0 ) { return WAMessage( WM_WA_IPC, parameter, command ); }
template<typename ReturnType>
inline ReturnType WACommand( LPARAM command, WPARAM parameter = 0 ) { return reinterpret_cast<ReturnType>( WACommand( command, parameter ) ); }

inline char const * GetWinAMPIniPath  () { return WACommand<char const *>( IPC_GETINIFILE         ); }
inline char const * GetIniDirectory   () { return WACommand<char const *>( IPC_GETINIDIRECTORY    ); }
inline char const * GetPluginDirectory() { return WACommand<char const *>( IPC_GETPLUGINDIRECTORY ); }

static char const pluginIniFileName[] = "plugin.ini";

char const * GetPluginIniPath();


template<class Config>
inline bool ReadConfig( Config & config, char const * const iniSection, char const * const iniFile = GetPluginIniPath() )
{
    return ( ::GetPrivateProfileStructA( iniSection, "binaryConfigData", (LPVOID)&config, sizeof( config ), iniFile ) != 0 );
}

template<class Config>
inline bool SaveConfig( Config const & config, char const * const iniSection, char const * const iniFile = GetPluginIniPath() )
{
    return ( ::WritePrivateProfileStructA( iniSection, "binaryConfigData", (LPVOID)&config, sizeof( config ), iniFile ) != 0 );
}

}   // namespace WinAMP

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