Thread: Winamp 5.55 SDK
View Single Post
Old 23rd August 2006, 23:34   #20
Benski
Ben Allison
Former Winamp Developer
 
Benski's Avatar
 
Join Date: Jan 2005
Location: Brooklyn, NY
Posts: 1,047
Example

Here's an example of how to use the Wasabi service manager and the new global configuration API.

code:

#include "../winamp/wa_ipc.h"
#include <api/service/waServiceFactory.h> // add the "Wasabi" folder to your include path!
#include "../Agave/api/config/api_config.h" // Agave is the code name for the Winamp 5 Wasabi services

// {B6CB4A7C-A8D0-4c55-8E60-9F7A7A23DA0F}
static const GUID playbackConfigGroupGUID =
{ 0xb6cb4a7c, 0xa8d0, 0x4c55, { 0x8e, 0x60, 0x9f, 0x7a, 0x7a, 0x23, 0xda, 0xf } };

static api_service *serviceApi=0;
static api_config *configApi=0;

api_config *GetConfigAPI()
{
if (!serviceApi)
{
serviceApi = (api_service *)SendMessage(mod.hMainWindow, WM_WA_IPC, 0, IPC_GET_API_SERVICE);
}

if (serviceApi && !configApi)
{
waServiceFactory *sf= (waServiceFactory *)serviceApi->service_getServiceByGuid(AgaveConfigGUID);
configApi = (api_config *)sf->getInterface();
}

return configApi;
}

int GetSampleSize()
{
api_config *config = GetConfigAPI();
int bits=16;
if (config)
bits = config->GetUnsigned(playbackConfigGroupGUID, L"bits", 16);

return bits;
}

int GetNumChannels()
{
api_config *config = GetConfigAPI();
bool mono=false;
if (config)
mono = config->GetBool(playbackConfigGroupGUID, L"mono", false);

if (mono)
return 1;
else
return 2;
}

bool AllowSurround()
{
api_config *config = GetConfigAPI();
bool surround=true;
if (config)
surround= config->GetBool(playbackConfigGroupGUID, L"surround", true);

return surround;
}

Benski is offline   Reply With Quote