Commit 19ffdb6f authored by sletz's avatar sletz
Browse files

Windows JackRouter sources and project added.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3863 0c269be4-1314-0410-8aa9-9f06e86f4224
parent b51c2ebb
......@@ -48,7 +48,8 @@ extern "C"
require linker arguments in the client as well.
*/
#define JACK_WEAK_EXPORT __attribute__((weak))
#else
#else
#define JACK_WEAK_EXPORT
/* Add other things here for non-gcc platforms */
#endif
#endif
......
This diff is collapsed.
LIBRARY JackRouter
DESCRIPTION 'ASIO Jack Driver'
PROTMODE
EXPORTS
DllMain
DllGetClassObject
DllCanUnloadNow
DllRegisterServer
DllUnregisterServer
# Microsoft Developer Studio Project File - Name="JackRouter" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=JackRouter - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "JackRouter.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "JackRouter.mak" CFG="JackRouter - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "JackRouter - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "JackRouter - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "JackRouter - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\..\..\ASIOSDK2\common" /I "..\..\common" /I "..\..\common\jack" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /dll /machine:I386
!ELSEIF "$(CFG)" == "JackRouter - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /G5 /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\ASIOSDK2\common" /I "..\..\common" /I "..\..\common\jack" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"Debug/JackRouter_debug.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "JackRouter - Win32 Release"
# Name "JackRouter - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\..\..\ASIOSDK2\common\combase.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\..\ASIOSDK2\common\dllentry.cpp
# End Source File
# Begin Source File
SOURCE=.\JackRouter.cpp
# End Source File
# Begin Source File
SOURCE=.\JackRouter.def
# End Source File
# Begin Source File
SOURCE=.\profport.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\..\..\ASIOSDK2\common\register.cpp
# End Source File
# Begin Source File
SOURCE=.\resource.rc
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\common\asio.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\Asiodrvr.h
# End Source File
# Begin Source File
SOURCE=..\asiosmpl.h
# End Source File
# Begin Source File
SOURCE=..\..\..\common\asiosys.h
# End Source File
# Begin Source File
SOURCE=..\..\..\common\combase.h
# End Source File
# Begin Source File
SOURCE=..\..\..\common\iasiodrv.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File
SOURCE=.\Psapi.Lib
# End Source File
# Begin Source File
SOURCE=..\Release\bin\libjack.lib
# End Source File
# End Target
# End Project
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "JackRouter"=".\JackRouter.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
/*
Copyright (C) 2006 Grame
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _asiosmpl_
#define _asiosmpl_
#include "asiosys.h"
// Globals
static int kBlockFrames = 256;
static int kNumInputs = 4;
static int kNumOutputs = 4;
#if WINDOWS
#include "jack.h"
#include "rpc.h"
#include "rpcndr.h"
#ifndef COM_NO_WINDOWS_H
#include <windows.h>
#include "ole2.h"
#endif
#include "combase.h"
#include "iasiodrv.h"
#define MAX_PORTS 32
#define LONG_SAMPLE 1
#define PATH_SEP "\\"
#include <list>
#include <string>
class JackRouter : public IASIO, public CUnknown
{
public:
JackRouter(LPUNKNOWN pUnk, HRESULT *phr);
~JackRouter();
DECLARE_IUNKNOWN
//STDMETHODIMP QueryInterface(REFIID riid, void **ppv) { \
// return GetOwner()->QueryInterface(riid,ppv); \
//}; \
//STDMETHODIMP_(ULONG) AddRef() { \
// return GetOwner()->AddRef(); \
//}; \
//STDMETHODIMP_(ULONG) Release() { \
// return GetOwner()->Release(); \
//};
// Factory method
static CUnknown *CreateInstance(LPUNKNOWN pUnk, HRESULT *phr);
// IUnknown
virtual HRESULT STDMETHODCALLTYPE NonDelegatingQueryInterface(REFIID riid,void **ppvObject);
#else
#include "asiodrvr.h"
//---------------------------------------------------------------------------------------------
class JackRouter : public AsioDriver
{
public:
JackRouter();
~JackRouter();
#endif
static int process(jack_nframes_t nframes, void* arg);
static void shutdown(void* arg);
ASIOBool init(void* sysRef);
void getDriverName(char *name); // max 32 bytes incl. terminating zero
long getDriverVersion();
void getErrorMessage(char *string); // max 128 bytes incl.
ASIOError start();
ASIOError stop();
ASIOError getChannels(long *numInputChannels, long *numOutputChannels);
ASIOError getLatencies(long *inputLatency, long *outputLatency);
ASIOError getBufferSize(long *minSize, long *maxSize,
long *preferredSize, long *granularity);
ASIOError canSampleRate(ASIOSampleRate sampleRate);
ASIOError getSampleRate(ASIOSampleRate *sampleRate);
ASIOError setSampleRate(ASIOSampleRate sampleRate);
ASIOError getClockSources(ASIOClockSource *clocks, long *numSources);
ASIOError setClockSource(long index);
ASIOError getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp);
ASIOError getChannelInfo(ASIOChannelInfo *info);
ASIOError createBuffers(ASIOBufferInfo *bufferInfos, long numChannels,
long bufferSize, ASIOCallbacks *callbacks);
ASIOError disposeBuffers();
ASIOError controlPanel();
ASIOError future(long selector, void *opt);
ASIOError outputReady();
void bufferSwitch();
long getMilliSeconds() {return fMilliSeconds;}
static bool fFirstActivate;
static std::list<std::pair<std::string, std::string> > fConnections; // Connections list
private:
void bufferSwitchX();
double fSamplePosition;
ASIOCallbacks* fCallbacks;
ASIOTime fAsioTime;
ASIOTimeStamp fTheSystemTime;
#ifdef LONG_SAMPLE
long* fInputBuffers[MAX_PORTS * 2];
long* fOutputBuffers[MAX_PORTS * 2];
#else
float* fInputBuffers[MAX_PORTS * 2];
float* fOutputBuffers[MAX_PORTS * 2];
#endif
long fInMap[MAX_PORTS];
long fOutMap[MAX_PORTS];
long fInputLatency;
long fOutputLatency;
long fActiveInputs;
long fActiveOutputs;
long fToggle;
long fMilliSeconds;
bool fActive, fStarted;
bool fTimeInfoMode, fTcRead;
char fErrorMessage[128];
bool fAutoConnectIn;
bool fAutoConnectOut;
// Jack part
jack_client_t* fClient;
jack_port_t* fInputPorts[MAX_PORTS];
jack_port_t* fOutputPorts[MAX_PORTS];
long fBufferSize;
ASIOSampleRate fSampleRate;
void AutoConnect();
void SaveConnections();
void RestoreConnections();
};
#endif
This folder contains the sources for ASIO/JACK bridge ASIO driver called "JackRouter". The included project is a Microsoft VC++ 6 one.
It requires some files (combase.cpp, dllentry.cpp, register.cpp) that are part on the ASIO driver SDK. The produced "JackRouter.dll" file
has to be registered in the system using the "regsvr32" tool.
\ No newline at end of file
/*
History :
01-28-02 : Change the location of temporary files created in write_private_profile_string
now done in TmpDirectory.
01-29-02 : Correct bug when the '=' character is not present.
06-18-02 : Return default value if file does not exist, new write_private_profile_int function.
*/
/***** Routines to read profile strings -- by Joseph J. Graf ******/
/***** corrections and improvements -- by D. Fober - Grame ******/
/*
corrections: buffer sizes control
improvements: behavior more similar to windows
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <string>
#include <ctype.h>
#include "profport.h" /* function prototypes in here */
#ifndef WIN32
static int read_line (FILE *fp, char *bp, int size);
static int read_section(FILE *fp, char *section);
static int read_entry (FILE *fp, char *entry, char *buff, int size);
static char * read_value (char *buff);
static int read_int_value (char *buff, int def);
static char * read_file (char *file);
static char * str_search (char * buff, char * str, int stopCond);
/*****************************************************************
* Function: read_line()
* Arguments: <FILE *> fp - a pointer to the file to be read from
* <char *> bp - a pointer to the copy buffer
* <int> size - size of the copy buffer
* Returns: the line length if successful -1 otherwise
******************************************************************/
static int read_line(FILE *fp, char *bp, int size)
{
char c = '\0';
int i = 0, limit = size-2;
/* Read one line from the source file */
while (((c = getc(fp)) != '\n') && (i < limit)) {
if (c == EOF) {
if (!i) return -1;
else break;
}
bp[i++] = c;
}
bp[i] = '\0';
return i;
}
static int read_section (FILE *fp, char *section)
{
char buff[MAX_LINE_LENGTH];
char t_section[MAX_LINE_LENGTH];
int n, slen;
sprintf(t_section,"[%s]", section); /* Format the section name */
slen = strlen (t_section);
/* Move through file 1 line at a time until a section is matched or EOF */
do {
n = read_line(fp, buff, MAX_LINE_LENGTH);
if (n == -1)
return 0;
} while (strncmp (buff,t_section, slen));
return 1;
}
static int read_entry (FILE *fp, char *entry, char *buff, int size)
{
int n, elen = strlen (entry);
do {
n = read_line(fp, buff, size);
if (n == -1)
return 0;
else if (*buff == '[')
return 0;
} while (strncmp (buff, entry, elen));
return 1;
}
#define isBlank(c) ((c == ' ') || (c == '\t'))
static char * read_value (char *buff)
{
char * eq = strrchr (buff,'='); /* Parse out the equal sign */
if (eq) {
eq++;
while (*eq && isBlank(*eq))
eq++;
// return *eq ? eq : 0;
return eq;
}
return eq;
}
#define isSignedDigit(c) (isdigit(c) || (c == '+') || (c == '-'))
static int read_int_value (char *buff, int def)
{
char * val = read_value (buff);
char value[20]; int i;
if (!*val) return def;
for (i = 0; isSignedDigit(*val) && (i <= 10); i++ )
value[i] = *val++;
value[i] = '\0';
return value[0] ? atoi(value) : def;
}
static char * read_file (char *file)
{
FILE *fd = fopen (file,"r");
int size; char * buff = 0;
if (!fd) return 0;
if (fseek (fd, 0, SEEK_END) == -1) goto err;
size = ftell (fd);
if (size < 0) goto err;
if (fseek (fd, 0, SEEK_SET) == -1) goto err;
buff = (char *) malloc (size+1);
if (buff) {
*buff = 0;
fread (buff, 1, size, fd);
buff[size] = 0;
}
err:
fclose (fd);
return buff;
}
static char * str_search (char * buff, char * str, int stopCond)
{
char *ptr = buff;
int len = strlen (str);
while (*ptr && strncmp (ptr, str, len)) {
while (*ptr && (*ptr++ != '\n'))
;
if (*ptr == stopCond)
return 0;
}
return *ptr ? ptr : 0;
}
/**************************************************************************
* Function: get_private_profile_int()
* Arguments: <char *> section - the name of the section to search for
* <char *> entry - the name of the entry to find the value of
* <int> def - the default value in the event of a failed read
* <char *> file_name - the name of the .ini file to read from
* Returns: the value located at entry
***************************************************************************/
int get_private_profile_int(char *section,
char *entry, int def, char *file_name)
{
FILE *fp = fopen(file_name,"r");
char buff[MAX_LINE_LENGTH];
if( !fp ) return def; /* Return default value if file does not exist */
if (!read_section (fp, section)) goto err;
if (!read_entry (fp, entry, buff, MAX_LINE_LENGTH)) goto err;
def = read_int_value (buff, def);
err:
fclose (fp);
return def;
}
/**************************************************************************
* Function: get_private_profile_string()
* Arguments: <char *> section - the name of the section to search for
* <char *> entry - the name of the entry to find the value of
* <char *> def - default string in the event of a failed read
* <char *> buffer - a pointer to the buffer to copy into
* <int> buffer_len - the max number of characters to copy
* <char *> file_name - the name of the .ini file to read from
* Returns: the number of characters copied into the supplied buffer
***************************************************************************/
int get_private_profile_string(char *section, char *entry, char *def,
char *buffer, int buffer_len, char *file_name)
{
FILE *fp = fopen (file_name,"r");
char buff[MAX_LINE_LENGTH];
char *val;
if( !fp ) goto err; /* Return default value if file does not exist */
if (!read_section (fp, section)) goto err;
if (!read_entry (fp, entry, buff, MAX_LINE_LENGTH)) goto err;
val = read_value (buff);
if(val) def = val;
err:
if (fp) fclose (fp);
if (def) {
strncpy (buffer, def, buffer_len - 1);
buffer[buffer_len] = '\0';
}
else buffer[buffer_len] = '\0';
return strlen (buffer);
}
/***************************************************************************
* Function: write_private_profile_string()
* Arguments: <char *> section - the name of the section to search for
* <char *> entry - the name of the entry to find the value of
* <char *> buffer - pointer to the buffer that holds the string
* <char *> file_name - the name of the .ini file to read from
* Returns: TRUE if successful, otherwise FALSE
***************************************************************************/
int write_private_profile_string(char *section,
char *entry, char *buffer, char *file_name)
{
char * content = read_file(file_name);
FILE * fd = fopen(file_name,"w");
char t_section[MAX_LINE_LENGTH], *ptr;