From cad15897261ed1c34edc60b401e54750768624c4 Mon Sep 17 00:00:00 2001 From: sletz Date: Sun, 13 Dec 2009 10:52:40 +0000 Subject: [PATCH 01/25] Mario Lang alsa_io time calculation overflow patch. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3858 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 6 +++++- example-clients/alsa_in.c | 4 ++-- example-clients/alsa_out.c | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b4f3608b..d33851ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,12 +21,16 @@ Torben Hohn Paul Davis Peter L Jones Devin Anderson -Josh Green +Josh Green +Mario Lang --------------------------- Jackdmp changes log --------------------------- +2009-12-13 Stephane Letz + + * Mario Lang alsa_io time calculation overflow patch. 2009-12-10 Stephane Letz diff --git a/example-clients/alsa_in.c b/example-clients/alsa_in.c index 2a8b78c3..a04271eb 100644 --- a/example-clients/alsa_in.c +++ b/example-clients/alsa_in.c @@ -184,7 +184,7 @@ static int set_hwparams(snd_pcm_t *handle, snd_pcm_hw_params_t *params, snd_pcm_ } /* set the buffer time */ - buffer_time = 1000000*period*nperiods/rate; + buffer_time = 1000000*(uint64_t)period*nperiods/rate; err = snd_pcm_hw_params_set_buffer_time_near(handle, params, &buffer_time, &dir); if (err < 0) { printf("Unable to set buffer time %i for playback: %s\n", 1000000*period*nperiods/rate, snd_strerror(err)); @@ -199,7 +199,7 @@ static int set_hwparams(snd_pcm_t *handle, snd_pcm_hw_params_t *params, snd_pcm_ printf( "WARNING: buffer size does not match: (requested %d, got %d)\n", nperiods * period, (int) real_buffer_size ); } /* set the period time */ - period_time = 1000000*period/rate; + period_time = 1000000*(uint64_t)period/rate; err = snd_pcm_hw_params_set_period_time_near(handle, params, &period_time, &dir); if (err < 0) { printf("Unable to set period time %i for playback: %s\n", 1000000*period/rate, snd_strerror(err)); diff --git a/example-clients/alsa_out.c b/example-clients/alsa_out.c index 2d34cd13..852e978c 100644 --- a/example-clients/alsa_out.c +++ b/example-clients/alsa_out.c @@ -183,7 +183,7 @@ static int set_hwparams(snd_pcm_t *handle, snd_pcm_hw_params_t *params, snd_pcm_ } /* set the buffer time */ - buffer_time = 1000000*period*nperiods/rate; + buffer_time = 1000000*(uint64_t)period*nperiods/rate; err = snd_pcm_hw_params_set_buffer_time_near(handle, params, &buffer_time, &dir); if (err < 0) { printf("Unable to set buffer time %i for playback: %s\n", 1000000*period*nperiods/rate, snd_strerror(err)); @@ -198,7 +198,7 @@ static int set_hwparams(snd_pcm_t *handle, snd_pcm_hw_params_t *params, snd_pcm_ printf( "WARNING: buffer size does not match: (requested %d, got %d)\n", nperiods * period, (int) real_buffer_size ); } /* set the period time */ - period_time = 1000000*period/rate; + period_time = 1000000*(uint64_t)period/rate; err = snd_pcm_hw_params_set_period_time_near(handle, params, &period_time, &dir); if (err < 0) { printf("Unable to set period time %i for playback: %s\n", 1000000*period/rate, snd_strerror(err)); From 6ec1cee8b1c6a3fa00db534dd63b464c31f61f30 Mon Sep 17 00:00:00 2001 From: sletz Date: Tue, 15 Dec 2009 09:37:32 +0000 Subject: [PATCH 02/25] Shared memory manager was calling abort in case of fatal error, now return an error in caller. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3859 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 4 ++ common/JackLibClient.cpp | 3 ++ common/shm.c | 112 ++++++++++++++++++++++++++------------- common/shm.h | 2 +- 4 files changed, 84 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index d33851ad..66aa7ae0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,10 @@ Mario Lang Jackdmp changes log --------------------------- +2009-12-15 Stephane Letz + + * Shared memory manager was calling abort in case of fatal error, now return an error in caller. + 2009-12-13 Stephane Letz * Mario Lang alsa_io time calculation overflow patch. diff --git a/common/JackLibClient.cpp b/common/JackLibClient.cpp index 4c92e9e3..effdfc6f 100644 --- a/common/JackLibClient.cpp +++ b/common/JackLibClient.cpp @@ -103,6 +103,9 @@ int JackLibClient::Open(const char* server_name, const char* name, jack_options_ } catch (int n) { jack_error("Map shared memory segments exception %d", n); goto error; + } catch (...) { + jack_error("Unknown error..."); + goto error; } SetupDriverSync(false); diff --git a/common/shm.c b/common/shm.c index fdd3b151..ce05bb41 100644 --- a/common/shm.c +++ b/common/shm.c @@ -18,23 +18,23 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ - -/* This module provides a set of abstract shared memory interfaces - * with support using both System V and POSIX shared memory - * implementations. The code is divided into three sections: - * - * - common (interface-independent) code - * - POSIX implementation - * - System V implementation - * - * The implementation used is determined by whether USE_POSIX_SHM was - * set in the ./configure step. - */ + +/* This module provides a set of abstract shared memory interfaces + * with support using both System V and POSIX shared memory + * implementations. The code is divided into three sections: + * + * - common (interface-independent) code + * - POSIX implementation + * - System V implementation + * + * The implementation used is determined by whether USE_POSIX_SHM was + * set in the ./configure step. + */ #include "JackConstants.h" #ifdef WIN32 -#include +#include #include #else @@ -156,12 +156,11 @@ semaphore_add (int value) {} static void semaphore_error (char *msg) { - jack_error ("Fatal JACK semaphore error: %s (%s)", + jack_error ("JACK semaphore error: %s (%s)", msg, strerror (errno)); - abort (); } -static void +static int semaphore_init () { key_t semkey = JACK_SEMAPHORE_KEY; @@ -180,21 +179,26 @@ semaphore_init () sbuf.sem_op = 1; sbuf.sem_flg = 0; if (semop(semid, &sbuf, 1) == -1) { - semaphore_error ("semop"); + semaphore_error ("semop"); + return -1; } } else if (errno == EEXIST) { if ((semid = semget(semkey, 0, 0)) == -1) { - semaphore_error ("semget"); + semaphore_error ("semget"); + return -1; } } else { - semaphore_error ("semget creation"); + semaphore_error ("semget creation"); + return -1; } } + + return 0; } -static inline void +static inline int semaphore_add (int value) { struct sembuf sbuf; @@ -202,23 +206,29 @@ semaphore_add (int value) sbuf.sem_num = 0; sbuf.sem_op = value; sbuf.sem_flg = SEM_UNDO; + if (semop(semid, &sbuf, 1) == -1) { semaphore_error ("semop"); + return -1; } + + return 0; } #endif -static void +static int jack_shm_lock_registry (void) { - if (semid == -1) - semaphore_init (); + if (semid == -1) { + if (semaphore_init () < 0) + return -1; + } - semaphore_add (-1); + return semaphore_add (-1); } -static void +static void jack_shm_unlock_registry (void) { semaphore_add (1); @@ -297,7 +307,10 @@ jack_server_initialize_shm (int new_registry) if (jack_shm_header) return 0; /* already initialized */ - jack_shm_lock_registry (); + if (jack_shm_lock_registry () < 0) { + jack_error ("jack_shm_lock_registry fails..."); + return -1; + } rc = jack_access_registry (®istry_info); @@ -353,7 +366,11 @@ jack_initialize_shm (const char *server_name) jack_set_server_prefix (server_name); - jack_shm_lock_registry (); + if (jack_shm_lock_registry () < 0) { + jack_error ("jack_shm_lock_registry fails..."); + return -1; + } + if ((rc = jack_access_registry (®istry_info)) == 0) { if ((rc = jack_shm_validate_registry ()) != 0) { jack_error ("Incompatible shm registry, " @@ -412,15 +429,20 @@ jack_release_shm_entry (jack_shm_registry_index_t index) sizeof (jack_shm_registry[index].id)); } -void +int jack_release_shm_info (jack_shm_registry_index_t index) { /* must NOT have the registry locked */ if (jack_shm_registry[index].allocator == GetPID()) { - jack_shm_lock_registry (); + if (jack_shm_lock_registry () < 0) { + jack_error ("jack_shm_lock_registry fails..."); + return -1; + } jack_release_shm_entry (index); jack_shm_unlock_registry (); } + + return 0; } /* Claim server_name for this process. @@ -440,7 +462,10 @@ jack_register_server (const char *server_name, int new_registry) if (jack_server_initialize_shm (new_registry)) return ENOMEM; - jack_shm_lock_registry (); + if (jack_shm_lock_registry () < 0) { + jack_error ("jack_shm_lock_registry fails..."); + return -1; + } /* See if server_name already registered. Since server names * are per-user, we register the unique server prefix string. @@ -497,7 +522,10 @@ void jack_unregister_server (const char *server_name /* unused */) { int i; - jack_shm_lock_registry (); + if (jack_shm_lock_registry () < 0) { + jack_error ("jack_shm_lock_registry fails..."); + return -1; + } for (i = 0; i < MAX_SERVERS; i++) { if (jack_shm_header->server[i].pid == GetPID()) { @@ -517,7 +545,10 @@ jack_cleanup_shm () int destroy; jack_shm_info_t copy; - jack_shm_lock_registry (); + if (jack_shm_lock_registry () < 0) { + jack_error ("jack_shm_lock_registry fails..."); + return -1; + } for (i = 0; i < MAX_SHM_ID; i++) { jack_shm_registry_t* r; @@ -741,7 +772,10 @@ jack_shmalloc (const char *shm_name, jack_shmsize_t size, jack_shm_info_t* si) int rc = -1; char name[SHM_NAME_MAX+1]; - jack_shm_lock_registry (); + if (jack_shm_lock_registry () < 0) { + jack_error ("jack_shm_lock_registry fails..."); + return -1; + } if ((registry = jack_get_free_shm_info ()) == NULL) { jack_error ("shm registry full"); @@ -780,7 +814,7 @@ jack_shmalloc (const char *shm_name, jack_shmsize_t size, jack_shm_info_t* si) close (shm_fd); registry->size = size; strncpy (registry->id, name, sizeof (registry->id)); - registry->allocator = getpid(); + registry->allocator = GetPID(); si->index = registry->index; si->ptr.attached_at = MAP_FAILED; /* not attached */ rc = 0; /* success */ @@ -936,7 +970,10 @@ jack_shmalloc (const char *shm_name, jack_shmsize_t size, jack_shm_info_t* si) int rc = -1; char name[SHM_NAME_MAX+1]; - jack_shm_lock_registry (); + if (jack_shm_lock_registry () < 0) { + jack_error ("jack_shm_lock_registry fails..."); + return -1; + } if ((registry = jack_get_free_shm_info ()) == NULL) { jack_error ("shm registry full"); @@ -1133,7 +1170,10 @@ jack_shmalloc (const char* name_not_used, jack_shmsize_t size, int rc = -1; jack_shm_registry_t* registry; - jack_shm_lock_registry (); + if (jack_shm_lock_registry () < 0) { + jack_error ("jack_shm_lock_registry fails..."); + return -1; + } if ((registry = jack_get_free_shm_info ())) { diff --git a/common/shm.h b/common/shm.h index 4a7d15c6..bff6a857 100644 --- a/common/shm.h +++ b/common/shm.h @@ -132,7 +132,7 @@ extern "C" jack_shm_registry_index_t); void jack_shm_copy_to_registry (jack_shm_info_t*, jack_shm_registry_index_t*); - void jack_release_shm_info (jack_shm_registry_index_t); + int jack_release_shm_info (jack_shm_registry_index_t); char* jack_shm_addr (jack_shm_info_t* si); // here begin the API From 400a51c51539efce052e4587364913056616eec1 Mon Sep 17 00:00:00 2001 From: sletz Date: Wed, 16 Dec 2009 10:26:34 +0000 Subject: [PATCH 03/25] Compiles on Windows again. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3860 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/shm.c | 25 +++++++++++++------------ common/shm.h | 20 ++++++++++---------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/common/shm.c b/common/shm.c index ce05bb41..e74a2134 100644 --- a/common/shm.c +++ b/common/shm.c @@ -145,11 +145,11 @@ static int semid = -1; #ifdef WIN32 -static void -semaphore_init () {} +static int +semaphore_init () {return 0;} -static void -semaphore_add (int value) {} +static int +semaphore_add (int value) {return 0;} #else /* all semaphore errors are fatal -- issue message, but do not return */ @@ -194,7 +194,7 @@ semaphore_init () return -1; } } - + return 0; } @@ -206,12 +206,12 @@ semaphore_add (int value) sbuf.sem_num = 0; sbuf.sem_op = value; sbuf.sem_flg = SEM_UNDO; - + if (semop(semid, &sbuf, 1) == -1) { semaphore_error ("semop"); return -1; } - + return 0; } @@ -228,7 +228,7 @@ jack_shm_lock_registry (void) return semaphore_add (-1); } -static void +static void jack_shm_unlock_registry (void) { semaphore_add (1); @@ -370,7 +370,7 @@ jack_initialize_shm (const char *server_name) jack_error ("jack_shm_lock_registry fails..."); return -1; } - + if ((rc = jack_access_registry (®istry_info)) == 0) { if ((rc = jack_shm_validate_registry ()) != 0) { jack_error ("Incompatible shm registry, " @@ -441,7 +441,7 @@ jack_release_shm_info (jack_shm_registry_index_t index) jack_release_shm_entry (index); jack_shm_unlock_registry (); } - + return 0; } @@ -518,7 +518,7 @@ jack_register_server (const char *server_name, int new_registry) } /* release server_name registration */ -void +int jack_unregister_server (const char *server_name /* unused */) { int i; @@ -534,7 +534,8 @@ jack_unregister_server (const char *server_name /* unused */) } } - jack_shm_unlock_registry (); + jack_shm_unlock_registry (); + return 0; } /* called for server startup and termination */ diff --git a/common/shm.h b/common/shm.h index bff6a857..ed5a953f 100644 --- a/common/shm.h +++ b/common/shm.h @@ -115,33 +115,33 @@ extern "C" * indicating where the shared memory has been * attached to the address space. */ - + typedef struct _jack_shm_info { jack_shm_registry_index_t index; /* offset into the registry */ uint32_t size; union { void *attached_at; /* address where attached */ - char ptr_size[8]; - } ptr; /* a "pointer" that has the same 8 bytes size when compling in 32 or 64 bits */ + char ptr_size[8]; + } ptr; /* a "pointer" that has the same 8 bytes size when compling in 32 or 64 bits */ } POST_PACKED_STRUCTURE jack_shm_info_t; /* utility functions used only within JACK */ - + void jack_shm_copy_from_registry (jack_shm_info_t*, jack_shm_registry_index_t); void jack_shm_copy_to_registry (jack_shm_info_t*, jack_shm_registry_index_t*); int jack_release_shm_info (jack_shm_registry_index_t); - char* jack_shm_addr (jack_shm_info_t* si); + char* jack_shm_addr (jack_shm_info_t* si); - // here begin the API + // here begin the API int jack_register_server (const char *server_name, int new_registry); - void jack_unregister_server (const char *server_name); + int jack_unregister_server (const char *server_name); int jack_initialize_shm (const char *server_name); - int jack_initialize_shm_server (void); - int jack_initialize_shm_client (void); + int jack_initialize_shm_server (void); + int jack_initialize_shm_client (void); int jack_cleanup_shm (void); int jack_shmalloc (const char *shm_name, jack_shmsize_t size, @@ -149,7 +149,7 @@ extern "C" void jack_release_shm (jack_shm_info_t*); void jack_destroy_shm (jack_shm_info_t*); int jack_attach_shm (jack_shm_info_t*); - int jack_attach_shm_read (jack_shm_info_t*); + int jack_attach_shm_read (jack_shm_info_t*); int jack_resize_shm (jack_shm_info_t*, jack_shmsize_t size); #ifdef __cplusplus From 0da294703d0607c72f19bfc129feacef60d6f8e6 Mon Sep 17 00:00:00 2001 From: sletz Date: Wed, 16 Dec 2009 11:09:39 +0000 Subject: [PATCH 04/25] Windows projects and installer corrected. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3861 0c269be4-1314-0410-8aa9-9f06e86f4224 --- windows/Setup/jack.ci | 2 +- windows/jack_netsource.cbp | 223 ++++++++++++++++++------------------- windows/jack_netsource.rc | 48 -------- 3 files changed, 111 insertions(+), 162 deletions(-) delete mode 100644 windows/jack_netsource.rc diff --git a/windows/Setup/jack.ci b/windows/Setup/jack.ci index 66ef7114..25233392 100644 --- a/windows/Setup/jack.ci +++ b/windows/Setup/jack.ci @@ -73,7 +73,7 @@ <_>..\Release\bin\portaudio_x86.dllinstovernewer0 <_>..\Release\bin\jack\jack_net.dllinstjackovernewer0 <_>..\Release\bin\jack\jack_netone.dllinstjackovernewer0 -<_>..\Release\bin\jack\jack_netsource.exeinstjackovernewer0 +<_>..\Release\bin\jack_netsource.exeinstovernewer0 <_>..\Release\bin\jack\jack_dummy.dllinstjackovernewer0 <_>..\Release\bin\jack\jack_loopback.dllinstjackovernewer0 <_>..\Release\bin\jack\jack_winmme.dllinstjackovernewer0 diff --git a/windows/jack_netsource.cbp b/windows/jack_netsource.cbp index dd5f99e7..ddfe02e8 100644 --- a/windows/jack_netsource.cbp +++ b/windows/jack_netsource.cbp @@ -1,113 +1,110 @@ - - - - - - + + + + + + diff --git a/windows/jack_netsource.rc b/windows/jack_netsource.rc deleted file mode 100644 index efc71b7e..00000000 --- a/windows/jack_netsource.rc +++ /dev/null @@ -1,48 +0,0 @@ -// Generated by ResEdit 1.4.3 -// Copyright (C) 2006-2008 -// http://www.resedit.net - -#include "resource.h" -#include "afxres.h" - - -// -// Version Information resources -// -LANGUAGE LANG_FRENCH, SUBLANG_DEFAULT -1 VERSIONINFO - FILEVERSION 1,9,5,0 - PRODUCTVERSION 1,9,5,0 - FILEOS VOS_UNKNOWN - FILETYPE VFT_APP -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040c04b0" - BEGIN - VALUE "Comments", "\0" - VALUE "CompanyName", "Grame\0" - VALUE "FileDescription", "JackNetOne netsource for Windows\0" - VALUE "FileVersion", "1, 9, 5, 0\0" - VALUE "InternalName", "netsource\0" - VALUE "LegalCopyright", "Copyright Grame © 2006-2009\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "jack_netsource.exe\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", "jack_netsource\0" - VALUE "ProductVersion", "1, 9, 5, 0\0" - VALUE "SpecialBuild", "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 1036, 1200 - END -END - - -// -// Icon resources -// -LANGUAGE LANG_FRENCH, SUBLANG_DEFAULT -IDI_ICON1 ICON ".\\Setup\\src\\jack.ico" From b51c2ebb594539dd17750bb9b3297573350c3a9a Mon Sep 17 00:00:00 2001 From: sletz Date: Wed, 16 Dec 2009 11:22:56 +0000 Subject: [PATCH 05/25] JackRouter.dll updated. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3862 0c269be4-1314-0410-8aa9-9f06e86f4224 --- windows/Setup/JackRouter.dll | Bin 32768 -> 32768 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/windows/Setup/JackRouter.dll b/windows/Setup/JackRouter.dll index 226ea66792539d9053c87ba8a9c2674ea0583940..f06fe1b66bbb999b6c6f7bacaef4a3ac95d26767 100644 GIT binary patch delta 159 zcmZo@U}|V!n(%>H>ww0_&p+*LZ!$16@G>$qTmaIKfcO;8JSStvAOr|WMvkZU$?_wh6a0NE-o?EnA( delta 159 zcmZo@U}|V!n(%?ST7Y%q=b!erR~Q%?I2aikP6O$?K>QSl1%UjcK>8mL^8wkMKzsqn k)&P&Az6ZodHfuTtvruTnPS@XTAlGc(?&E0;0QxI0M*si- From 19ffdb6f5a7ee9e9088e11f93cad547ff21c1d53 Mon Sep 17 00:00:00 2001 From: sletz Date: Thu, 17 Dec 2009 09:54:43 +0000 Subject: [PATCH 06/25] Windows JackRouter sources and project added. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3863 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/jack/jack.h | 3 +- windows/JackRouter/JackRouter.cpp | 840 ++++++++++++++++++++++++++++++ windows/JackRouter/JackRouter.def | 9 + windows/JackRouter/JackRouter.dsp | 163 ++++++ windows/JackRouter/JackRouter.dsw | 29 ++ windows/JackRouter/JackRouter.h | 174 +++++++ windows/JackRouter/Psapi.Lib | Bin 0 -> 7230 bytes windows/JackRouter/README | 3 + windows/JackRouter/profport.cpp | 315 +++++++++++ windows/JackRouter/profport.h | 37 ++ windows/JackRouter/psapi.dll | Bin 0 -> 23040 bytes windows/JackRouter/psapi.h | 95 ++++ windows/JackRouter/resource.h | 15 + windows/JackRouter/resource.rc | 109 ++++ 14 files changed, 1791 insertions(+), 1 deletion(-) create mode 100644 windows/JackRouter/JackRouter.cpp create mode 100644 windows/JackRouter/JackRouter.def create mode 100644 windows/JackRouter/JackRouter.dsp create mode 100644 windows/JackRouter/JackRouter.dsw create mode 100644 windows/JackRouter/JackRouter.h create mode 100644 windows/JackRouter/Psapi.Lib create mode 100644 windows/JackRouter/README create mode 100644 windows/JackRouter/profport.cpp create mode 100644 windows/JackRouter/profport.h create mode 100644 windows/JackRouter/psapi.dll create mode 100644 windows/JackRouter/psapi.h create mode 100644 windows/JackRouter/resource.h create mode 100644 windows/JackRouter/resource.rc diff --git a/common/jack/jack.h b/common/jack/jack.h index 35f2acc7..74c8b3cb 100644 --- a/common/jack/jack.h +++ b/common/jack/jack.h @@ -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 diff --git a/windows/JackRouter/JackRouter.cpp b/windows/JackRouter/JackRouter.cpp new file mode 100644 index 00000000..47727af7 --- /dev/null +++ b/windows/JackRouter/JackRouter.cpp @@ -0,0 +1,840 @@ +/* +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. + +*/ + +#ifdef WIN32 +#pragma warning (disable : 4786) +#endif + +#include +#include +#include +#include +#include "JackRouter.h" +#include "profport.h" + +/* + + 08/07/2007 SL : USe jack_client_open instead of jack_client_new (automatic client renaming). + 09/08/2007 SL : Add JackRouter.ini parameter file. + 09/20/2007 SL : Better error report in DllRegisterServer (for Vista). + 09/27/2007 SL : Add AUDO_CONNECT property in JackRouter.ini file. + 10/10/2007 SL : Use ASIOSTInt32LSB instead of ASIOSTInt16LSB. + + */ + +//------------------------------------------------------------------------------------------ +// extern +void getNanoSeconds(ASIOTimeStamp *time); + +// local +double AsioSamples2double (ASIOSamples* samples); + +static const double twoRaisedTo32 = 4294967296.; +static const double twoRaisedTo32Reciprocal = 1. / twoRaisedTo32; + +//------------------------------------------------------------------------------------------ +// on windows, we do the COM stuff. + +#if WINDOWS +#include "windows.h" +#include "mmsystem.h" +#include "psapi.h" + +using namespace std; + +// class id. +// {838FE50A-C1AB-4b77-B9B6-0A40788B53F3} +CLSID IID_ASIO_DRIVER = { 0x838fe50a, 0xc1ab, 0x4b77, { 0xb9, 0xb6, 0xa, 0x40, 0x78, 0x8b, 0x53, 0xf3 } }; + + +CFactoryTemplate g_Templates[1] = { + {L"ASIOJACK", &IID_ASIO_DRIVER, JackRouter::CreateInstance} +}; +int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]); + +CUnknown* JackRouter::CreateInstance(LPUNKNOWN pUnk, HRESULT *phr) +{ + return (CUnknown*)new JackRouter(pUnk,phr); +}; + +STDMETHODIMP JackRouter::NonDelegatingQueryInterface(REFIID riid, void ** ppv) +{ + if (riid == IID_ASIO_DRIVER) { + return GetInterface(this, ppv); + } + return CUnknown::NonDelegatingQueryInterface(riid, ppv); +} + +// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// Register ASIO Driver +// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +extern LONG RegisterAsioDriver(CLSID,char *,char *,char *,char *); +extern LONG UnregisterAsioDriver(CLSID,char *,char *); + +// +// Server registration, called on REGSVR32.EXE "the dllname.dll" +// +HRESULT _stdcall DllRegisterServer() +{ + LONG rc; + char errstr[128]; + + rc = RegisterAsioDriver (IID_ASIO_DRIVER,"JackRouter.dll","JackRouter","JackRouter","Apartment"); + + if (rc) { + memset(errstr,0,128); + sprintf(errstr,"Register Server failed ! (%d)",rc); + MessageBox(0,(LPCTSTR)errstr,(LPCTSTR)"JackRouter",MB_OK); + return -1; + } + + return S_OK; +} + +// +// Server unregistration +// +HRESULT _stdcall DllUnregisterServer() +{ + LONG rc; + char errstr[128]; + + rc = UnregisterAsioDriver (IID_ASIO_DRIVER,"JackRouter.dll","JackRouter"); + + if (rc) { + memset(errstr,0,128); + sprintf(errstr,"Unregister Server failed ! (%d)",rc); + MessageBox(0,(LPCTSTR)errstr,(LPCTSTR)"JackRouter",MB_OK); + return -1; + } + + return S_OK; +} + +// Globals + +list > JackRouter::fConnections; +bool JackRouter::fFirstActivate = true; + +//------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------ +JackRouter::JackRouter (LPUNKNOWN pUnk, HRESULT *phr) + : CUnknown("ASIOJACK", pUnk, phr) + +//------------------------------------------------------------------------------------------ + +#else + +// when not on windows, we derive from AsioDriver +JackRouter::JackRouter() : AsioDriver() + +#endif +{ + long i; + + fSamplePosition = 0; + fActive = false; + fStarted = false; + fTimeInfoMode = false; + fTcRead = false; + fClient = NULL; + fAutoConnectIn = true; + fAutoConnectOut = true; + + for (i = 0; i < kNumInputs; i++) { + fInputBuffers[i] = 0; + fInputPorts[i] = 0; + fInMap[i] = 0; + } + for (i = 0; i < kNumOutputs; i++) { + fOutputBuffers[i] = 0; + fOutputPorts[i] = 0; + fOutMap[i] = 0; + } + fCallbacks = 0; + fActiveInputs = fActiveOutputs = 0; + fToggle = 0; + fBufferSize = 512; + fSampleRate = 44100; + printf("Constructor\n"); + + // Use "jackrouter.ini" parameters if available + HMODULE handle = LoadLibrary("JackRouter.dll"); + + if (handle) { + + // Get JackRouter.dll path + char dllName[512]; + string confPath; + DWORD res = GetModuleFileName(handle, dllName, 512); + + // Compute .ini file path + string fullPath = dllName; + int lastPos = fullPath.find_last_of(PATH_SEP); + string dllFolder = fullPath.substr(0, lastPos); + confPath = dllFolder + PATH_SEP + "JackRouter.ini"; + + // Get parameters + kNumInputs = get_private_profile_int("IO", "input", 2, confPath.c_str()); + kNumOutputs = get_private_profile_int("IO", "output", 2, confPath.c_str()); + + fAutoConnectIn = get_private_profile_int("AUTO_CONNECT", "input", 1, confPath.c_str()); + fAutoConnectOut = get_private_profile_int("AUTO_CONNECT", "output", 1, confPath.c_str()); + + FreeLibrary(handle); + + } else { + printf("LoadLibrary error\n"); + } +} + +//------------------------------------------------------------------------------------------ +JackRouter::~JackRouter() +{ + stop (); + disposeBuffers (); + printf("Destructor\n"); + jack_client_close(fClient); +} + +//------------------------------------------------------------------------------------------ +#include +#include +#include +#include "psapi.h" + +static bool GetEXEName(DWORD dwProcessID, char* name) +{ + DWORD aProcesses [1024], cbNeeded, cProcesses; + unsigned int i; + + // Enumerate all processes + if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded)) + return false; + + // Calculate how many process identifiers were returned. + cProcesses = cbNeeded / sizeof(DWORD); + + TCHAR szEXEName[MAX_PATH]; + // Loop through all process to find the one that matches + // the one we are looking for + + for (i = 0; i < cProcesses; i++) { + if (aProcesses [i] == dwProcessID) { + // Get a handle to the process + HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | + PROCESS_VM_READ, FALSE, dwProcessID); + + // Get the process name + if (NULL != hProcess) { + HMODULE hMod; + DWORD cbNeeded; + + if(EnumProcessModules(hProcess, &hMod, + sizeof(hMod), &cbNeeded)) { + //Get the name of the exe file + GetModuleBaseName(hProcess, hMod, szEXEName, + sizeof(szEXEName)/sizeof(TCHAR)); + int len = strlen((char*)szEXEName) - 4; // remove ".exe" + strncpy(name, (char*)szEXEName, len); + name[len] = '\0'; + return true; + } + } + } + } + + return false; +} + + //------------------------------------------------------------------------------------------ +static inline float ClipFloat(float sample) +{ + return (sample < -1.0f) ? -1.0f : (sample > 1.0f) ? 1.0f : sample; +} + +//------------------------------------------------------------------------------------------ +void JackRouter::shutdown(void* arg) +{ + JackRouter* driver = (JackRouter*)arg; + /* + //exit(1); + char errstr[128]; + + memset(errstr,0,128); + sprintf(errstr,"JACK server has quitted"); + MessageBox(0,(LPCTSTR)errstr,(LPCTSTR)"JackRouter",MB_OK); + */ +} + +//------------------------------------------------------------------------------------------ +int JackRouter::process(jack_nframes_t nframes, void* arg) +{ + JackRouter* driver = (JackRouter*)arg; + int i,j; + int pos = (driver->fToggle) ? 0 : driver->fBufferSize ; + + for (i = 0; i < driver->fActiveInputs; i++) { + +#ifdef LONG_SAMPLE + float* buffer = (float*)jack_port_get_buffer(driver->fInputPorts[i], nframes); + long* in = driver->fInputBuffers[i] + pos; + for (j = 0; j < nframes; j++) { + in[j] = buffer[j] * float(0x7fffffff); + } +#else + memcpy(driver->fInputBuffers[i] + pos, + jack_port_get_buffer(driver->fInputPorts[i], nframes), + nframes * sizeof(float)); +#endif + + } + + driver->bufferSwitch(); + + for (i = 0; i < driver->fActiveOutputs; i++) { + +#ifdef LONG_SAMPLE + float* buffer = (float*)jack_port_get_buffer(driver->fOutputPorts[i], nframes); + long* out = driver->fOutputBuffers[i] + pos; + float gain = 1.f/float(0x7fffffff); + for (j = 0; j < nframes; j++) { + buffer[j] = out[j] * gain; + } +#else + memcpy(jack_port_get_buffer(driver->fOutputPorts[i], nframes), + driver->fOutputBuffers[i] + pos, + nframes * sizeof(float)); +#endif + } + + return 0; +} + +//------------------------------------------------------------------------------------------ +void JackRouter::getDriverName(char *name) +{ + strcpy (name, "JackRouter"); +} + +//------------------------------------------------------------------------------------------ +long JackRouter::getDriverVersion() +{ + return 0x00000001L; +} + +//------------------------------------------------------------------------------------------ +void JackRouter::getErrorMessage(char *string) +{ + strcpy (string, fErrorMessage); +} + +//------------------------------------------------------------------------------------------ +ASIOBool JackRouter::init(void* sysRef) +{ + char name[MAX_PATH]; + sysRef = sysRef; + + if (fActive) + return true; + + HANDLE win = (HANDLE)sysRef; + int my_pid = _getpid(); + + if (!GetEXEName(my_pid, name)) { // If getting the .exe name fails, takes a generic one. + _snprintf(name, sizeof(name) - 1, "JackRouter_%d", my_pid); + } + + if (fClient) { + printf("Error: jack client still present...\n"); + return true; + } + + fClient = jack_client_open(name, JackNullOption, NULL); + if (fClient == NULL) { + strcpy (fErrorMessage, "Open error: is jack server running?"); + printf("Open error: is jack server running?\n"); + return false; + } + + fBufferSize = jack_get_buffer_size(fClient); + fSampleRate = jack_get_sample_rate(fClient); + jack_set_process_callback(fClient, process, this); + jack_on_shutdown(fClient, shutdown, this); + + fInputLatency = fBufferSize; // typically + fOutputLatency = fBufferSize * 2; + fMilliSeconds = (long)((double)(fBufferSize * 1000) / fSampleRate); + + // Typically fBufferSize * 2; try to get 1 by offering direct buffer + // access, and using asioPostOutput for lower latency + + printf("Init ASIO Jack\n"); + fActive = true; + return true; +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::start() +{ + if (fCallbacks) { + fSamplePosition = 0; + fTheSystemTime.lo = fTheSystemTime.hi = 0; + fToggle = 0; + fStarted = true; + printf("Start ASIO Jack\n"); + + if (jack_activate(fClient) == 0) { + + if (fFirstActivate) { + AutoConnect(); + fFirstActivate = false; + } else { + RestoreConnections(); + } + + return ASE_OK; + + } else { + return ASE_NotPresent; + } + } + + return ASE_NotPresent; +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::stop() +{ + fStarted = false; + printf("Stop ASIO Jack\n"); + SaveConnections(); + jack_deactivate(fClient); + return ASE_OK; +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::getChannels(long *numInputChannels, long *numOutputChannels) +{ + *numInputChannels = kNumInputs; + *numOutputChannels = kNumOutputs; + return ASE_OK; +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::getLatencies(long *_inputLatency, long *_outputLatency) +{ + *_inputLatency = fInputLatency; + *_outputLatency = fOutputLatency; + return ASE_OK; +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::getBufferSize(long *minSize, long *maxSize, long *preferredSize, long *granularity) +{ + *minSize = *maxSize = *preferredSize = fBufferSize; // allow this size only + *granularity = 0; + return ASE_OK; +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::canSampleRate(ASIOSampleRate sampleRate) +{ + return (sampleRate == fSampleRate) ? ASE_OK : ASE_NoClock; +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::getSampleRate(ASIOSampleRate *sampleRate) +{ + *sampleRate = fSampleRate; + return ASE_OK; +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::setSampleRate(ASIOSampleRate sampleRate) +{ + return (sampleRate == fSampleRate) ? ASE_OK : ASE_NoClock; +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::getClockSources(ASIOClockSource *clocks, long *numSources) +{ + // Internal + if (clocks && numSources) { + clocks->index = 0; + clocks->associatedChannel = -1; + clocks->associatedGroup = -1; + clocks->isCurrentSource = ASIOTrue; + strcpy(clocks->name, "Internal"); + *numSources = 1; + return ASE_OK; + } else { + return ASE_InvalidParameter; + } +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::setClockSource(long index) +{ + if (!index) { + fAsioTime.timeInfo.flags |= kClockSourceChanged; + return ASE_OK; + } else { + return ASE_NotPresent; + } +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp) +{ + tStamp->lo = fTheSystemTime.lo; + tStamp->hi = fTheSystemTime.hi; + + if (fSamplePosition >= twoRaisedTo32) { + sPos->hi = (unsigned long)(fSamplePosition * twoRaisedTo32Reciprocal); + sPos->lo = (unsigned long)(fSamplePosition - (sPos->hi * twoRaisedTo32)); + } else { + sPos->hi = 0; + sPos->lo = (unsigned long)fSamplePosition; + } + return ASE_OK; +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::getChannelInfo(ASIOChannelInfo *info) +{ + if (info->channel < 0 || (info->isInput ? info->channel >= kNumInputs : info->channel >= kNumOutputs)) + return ASE_InvalidParameter; +#ifdef LONG_SAMPLE + info->type = ASIOSTInt32LSB; +#else + info->type = ASIOSTFloat32LSB; +#endif + + info->channelGroup = 0; + info->isActive = ASIOFalse; + long i; + char buf[32]; + + if (info->isInput) { + for (i = 0; i < fActiveInputs; i++) { + if (fInMap[i] == info->channel) { + info->isActive = ASIOTrue; + //_snprintf(buf, sizeof(buf) - 1, "Jack::In%d ", info->channel); + //strcpy(info->name, buf); + //strcpy(info->name, jack_port_name(fInputPorts[i])); + break; + } + } + _snprintf(buf, sizeof(buf) - 1, "In%d ", info->channel); + strcpy(info->name, buf); + } else { + for (i = 0; i < fActiveOutputs; i++) { + if (fOutMap[i] == info->channel) { //NOT USED !! + info->isActive = ASIOTrue; + //_snprintf(buf, sizeof(buf) - 1, "Jack::Out%d ", info->channel); + //strcpy(info->name, buf); + //strcpy(info->name, jack_port_name(fOutputPorts[i])); + break; + } + } + _snprintf(buf, sizeof(buf) - 1, "Out%d ", info->channel); + strcpy(info->name, buf); + } + return ASE_OK; +} + +//------------------------------------------------------------------------------------------ +ASIOError JackRouter::createBuffers(ASIOBufferInfo *bufferInfos, long numChannels, + long bufferSize, ASIOCallbacks *callbacks) +{ + ASIOBufferInfo *info = bufferInfos; + long i; + bool notEnoughMem = false; + char buf[256]; + fActiveInputs = 0; + fActiveOutputs = 0; + + for (i = 0; i < numChannels; i++, info++) { + if (info->isInput) { + if (info->channelNum < 0 || info->channelNum >= kNumInputs) + goto error; + fInMap[fActiveInputs] = info->channelNum; + #ifdef LONG_SAMPLE + fInputBuffers[fActiveInputs] = new long[fBufferSize * 2]; // double buffer + #else + fInputBuffers[fActiveInputs] = new float[fBufferSize * 2]; // double buffer + #endif + if (fInputBuffers[fActiveInputs]) { + info->buffers[0] = fInputBuffers[fActiveInputs]; + info->buffers[1] = fInputBuffers[fActiveInputs] + fBufferSize; + } else { + info->buffers[0] = info->buffers[1] = 0; + notEnoughMem = true; + } + + _snprintf(buf, sizeof(buf) - 1, "in%d", fActiveInputs + 1); + fInputPorts[fActiveInputs] + = jack_port_register(fClient, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput,0); + if (fInputPorts[fActiveInputs] == NULL) + goto error; + + fActiveInputs++; + if (fActiveInputs > kNumInputs) { +error: + disposeBuffers(); + return ASE_InvalidParameter; + } + } else { // output + if (info->channelNum < 0 || info->channelNum >= kNumOutputs) + goto error; + fOutMap[fActiveOutputs] = info->channelNum; + + #ifdef LONG_SAMPLE + fOutputBuffers[fActiveOutputs] = new long[fBufferSize * 2]; // double buffer + #else + fOutputBuffers[fActiveOutputs] = new float[fBufferSize * 2]; // double buffer + #endif + + if (fOutputBuffers[fActiveOutputs]) { + info->buffers[0] = fOutputBuffers[fActiveOutputs]; + info->buffers[1] = fOutputBuffers[fActiveOutputs] + fBufferSize; + } else { + info->buffers[0] = info->buffers[1] = 0; + notEnoughMem = true; + } + + _snprintf(buf, sizeof(buf) - 1, "out%d", fActiveOutputs + 1); + fOutputPorts[fActiveOutputs] + = jack_port_register(fClient, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput,0); + if (fOutputPorts[fActiveOutputs] == NULL) + goto error; + + fActiveOutputs++; + if (fActiveOutputs > kNumOutputs) { + fActiveOutputs--; + disposeBuffers(); + return ASE_InvalidParameter; + } + } + } + + if (notEnoughMem) { + disposeBuffers(); + return ASE_NoMemory; + } + + this->fCallbacks = callbacks; + if (callbacks->asioMessage (kAsioSupportsTimeInfo, 0, 0, 0)) { + fTimeInfoMode = true; + fAsioTime.timeInfo.speed = 1.; + fAsioTime.timeInfo.systemTime.hi = fAsioTime.timeInfo.systemTime.lo = 0; + fAsioTime.timeInfo.samplePosition.hi = fAsioTime.timeInfo.samplePosition.lo = 0; + fAsioTime.timeInfo.sampleRate = fSampleRate; + fAsioTime.timeInfo.flags = kSystemTimeValid | kSamplePositionValid | kSampleRateValid; + + fAsioTime.timeCode.speed = 1.; + fAsioTime.timeCode.timeCodeSamples.lo = fAsioTime.timeCode.timeCodeSamples.hi = 0; + fAsioTime.timeCode.flags = kTcValid | kTcRunning ; + } else { + fTimeInfoMode = false; + } + + return ASE_OK; +} + +//--------------------------------------------------------------------------------------------- +ASIOError JackRouter::disposeBuffers() +{ + long i; + + fCallbacks = 0; + stop(); + + for (i = 0; i < fActiveInputs; i++) { + delete[] fInputBuffers[i]; + jack_port_unregister(fClient, fInputPorts[i]); + } + fActiveInputs = 0; + + for (i = 0; i < fActiveOutputs; i++) { + delete[] fOutputBuffers[i]; + jack_port_unregister(fClient, fOutputPorts[i]); + } + fActiveOutputs = 0; + + return ASE_OK; +} + +//--------------------------------------------------------------------------------------------- +ASIOError JackRouter::controlPanel() +{ + return ASE_NotPresent; +} + +//--------------------------------------------------------------------------------------------- +ASIOError JackRouter::future(long selector, void* opt) // !!! check properties +{ + ASIOTransportParameters* tp = (ASIOTransportParameters*)opt; + switch (selector) + { + case kAsioEnableTimeCodeRead: fTcRead = true; return ASE_SUCCESS; + case kAsioDisableTimeCodeRead: fTcRead = false; return ASE_SUCCESS; + case kAsioSetInputMonitor: return ASE_SUCCESS; // for testing!!! + case kAsioCanInputMonitor: return ASE_SUCCESS; // for testing!!! + case kAsioCanTimeInfo: return ASE_SUCCESS; + case kAsioCanTimeCode: return ASE_SUCCESS; + } + return ASE_NotPresent; +} + +//-------------------------------------------------------------------------------------------------------- +// private methods +//-------------------------------------------------------------------------------------------------------- + +//--------------------------------------------------------------------------------------------- +void JackRouter::bufferSwitch() +{ + if (fStarted && fCallbacks) { + getNanoSeconds(&fTheSystemTime); // latch system time + fSamplePosition += fBufferSize; + if (fTimeInfoMode) { + bufferSwitchX (); + } else { + fCallbacks->bufferSwitch (fToggle, ASIOFalse); + } + fToggle = fToggle ? 0 : 1; + } +} + +//--------------------------------------------------------------------------------------------- +// asio2 buffer switch +void JackRouter::bufferSwitchX () +{ + getSamplePosition (&fAsioTime.timeInfo.samplePosition, &fAsioTime.timeInfo.systemTime); + long offset = fToggle ? fBufferSize : 0; + if (fTcRead) { + // Create a fake time code, which is 10 minutes ahead of the card's sample position + // Please note that for simplicity here time code will wrap after 32 bit are reached + fAsioTime.timeCode.timeCodeSamples.lo = fAsioTime.timeInfo.samplePosition.lo + 600.0 * fSampleRate; + fAsioTime.timeCode.timeCodeSamples.hi = 0; + } + fCallbacks->bufferSwitchTimeInfo (&fAsioTime, fToggle, ASIOFalse); + fAsioTime.timeInfo.flags &= ~(kSampleRateChanged | kClockSourceChanged); +} + +//--------------------------------------------------------------------------------------------- +ASIOError JackRouter::outputReady() +{ + return ASE_NotPresent; +} + +//--------------------------------------------------------------------------------------------- +double AsioSamples2double(ASIOSamples* samples) +{ + double a = (double)(samples->lo); + if (samples->hi) + a += (double)(samples->hi) * twoRaisedTo32; + return a; +} + +//--------------------------------------------------------------------------------------------- +void getNanoSeconds(ASIOTimeStamp* ts) +{ + double nanoSeconds = (double)((unsigned long)timeGetTime ()) * 1000000.; + ts->hi = (unsigned long)(nanoSeconds / twoRaisedTo32); + ts->lo = (unsigned long)(nanoSeconds - (ts->hi * twoRaisedTo32)); +} + +//------------------------------------------------------------------------ +void JackRouter::SaveConnections() +{ + const char** connections; + int i; + + for (i = 0; i < fActiveInputs; ++i) { + if (fInputPorts[i] && (connections = jack_port_get_connections(fInputPorts[i])) != 0) { + for (int j = 0; connections[j]; j++) { + fConnections.push_back(make_pair(connections[j], jack_port_name(fInputPorts[i]))); + } + jack_free(connections); + } + } + + for (i = 0; i < fActiveOutputs; ++i) { + if (fOutputPorts[i] && (connections = jack_port_get_connections(fOutputPorts[i])) != 0) { + for (int j = 0; connections[j]; j++) { + fConnections.push_back(make_pair(jack_port_name(fOutputPorts[i]), connections[j])); + } + jack_free(connections); + } + } +} + +//------------------------------------------------------------------------ +void JackRouter::RestoreConnections() +{ + list >::const_iterator it; + + for (it = fConnections.begin(); it != fConnections.end(); it++) { + pair connection = *it; + jack_connect(fClient, connection.first.c_str(), connection.second.c_str()); + } + + fConnections.clear(); +} + +//------------------------------------------------------------------------------------------ +void JackRouter::AutoConnect() +{ + const char** ports; + + if ((ports = jack_get_ports(fClient, NULL, NULL, JackPortIsPhysical | JackPortIsOutput)) == NULL) { + printf("Cannot find any physical capture ports\n"); + } else { + if (fAutoConnectIn) { + for (int i = 0; i < fActiveInputs; i++) { + if (!ports[i]) { + printf("source port is null i = %ld\n", i); + break; + } else if (jack_connect(fClient, ports[i], jack_port_name(fInputPorts[i])) != 0) { + printf("Cannot connect input ports\n"); + } + } + } + jack_free(ports); + } + + if ((ports = jack_get_ports(fClient, NULL, NULL, JackPortIsPhysical | JackPortIsInput)) == NULL) { + printf("Cannot find any physical playback ports"); + } else { + if (fAutoConnectOut) { + for (int i = 0; i < fActiveOutputs; i++) { + if (!ports[i]){ + printf("destination port is null i = %ld\n", i); + break; + } else if (jack_connect(fClient, jack_port_name(fOutputPorts[i]), ports[i]) != 0) { + printf("Cannot connect output ports\n"); + } + } + } + jack_free(ports); + } +} + diff --git a/windows/JackRouter/JackRouter.def b/windows/JackRouter/JackRouter.def new file mode 100644 index 00000000..1316d71f --- /dev/null +++ b/windows/JackRouter/JackRouter.def @@ -0,0 +1,9 @@ +LIBRARY JackRouter +DESCRIPTION 'ASIO Jack Driver' +PROTMODE +EXPORTS + DllMain + DllGetClassObject + DllCanUnloadNow + DllRegisterServer + DllUnregisterServer diff --git a/windows/JackRouter/JackRouter.dsp b/windows/JackRouter/JackRouter.dsp new file mode 100644 index 00000000..c92ddf99 --- /dev/null +++ b/windows/JackRouter/JackRouter.dsp @@ -0,0 +1,163 @@ +# 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 diff --git a/windows/JackRouter/JackRouter.dsw b/windows/JackRouter/JackRouter.dsw new file mode 100644 index 00000000..e26ab1ee --- /dev/null +++ b/windows/JackRouter/JackRouter.dsw @@ -0,0 +1,29 @@ +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> +{{{ +}}} + +############################################################################### + diff --git a/windows/JackRouter/JackRouter.h b/windows/JackRouter/JackRouter.h new file mode 100644 index 00000000..bf5d44c8 --- /dev/null +++ b/windows/JackRouter/JackRouter.h @@ -0,0 +1,174 @@ +/* +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 +#include "ole2.h" + +#endif + +#include "combase.h" +#include "iasiodrv.h" + +#define MAX_PORTS 32 + +#define LONG_SAMPLE 1 + +#define PATH_SEP "\\" + +#include +#include + +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 > 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 + diff --git a/windows/JackRouter/Psapi.Lib b/windows/JackRouter/Psapi.Lib new file mode 100644 index 0000000000000000000000000000000000000000..ae896911ef3f262e1df96418d91b910c8be19f6f GIT binary patch literal 7230 zcmcIp%}*Og6n{2J0Ed7vV7}VQQ6n|ExIot6N^NBlNU>rZ7f5_bWn6m$Re?yg1jyd#@L&Z7gD5soqB7O6@yR)-vjPXj3*?k}Ln~yi|y)jq6FE&cM zKZd@IIiLBth2&z=NX{pm{5k$PpI9>3>vjkLZUPJ)0}Oux2*&}&3{EexMT(+~(BvAY zSJ)y=p)REt*domwG8%mXKxpGj;bjjh7U>gMf@bZ+b3Mj^MkoJ&KYkiDPDxW(`% zl{4wq+WqX^!pid2G89&82i07oUNW1_^?LbW&upgV7qOd4b-&;xwAm2#1&uoA|75mU zueXX#Gh3{h%eLMJ*c3L#cPQgpp9@QJwVyjZG=|-uF z5l<|(S*bhx!E*o{t95zfyd}hTwtdz`^M&;0KsD9&?A&Q-8^C0PPzA7F<98NoXrlQ!}*2l}< zsp4VpgD>ovO1f5QRf>C+Ba^$#oq8kR%okgwU2Ff_DB&3L&D*=h+K%I(y4c9bnGNd7 zwUSA_GAUe4FQYM_xMPwrH}ff}?dCf;%O0APPmowBN>_Q;JZ9Ke+*`%NURiOSJyq#E z!z5*fnZ*=yJOuD*7$6=7Fvb90A{}EqUz-GYg%qCxc!6{{1Mp-N;4K<`oB$}J&IkOC zi~~GJ3L@_a=>f{$qi%E>;0@-Hhe*%x{R9cq84N)freO*$z(p8^2#mov48sUqf_@l) zK?uPl%)l&MhA2$H6$n7EW1BwA5bhA8Kg{lpc5tYZP>ws@*w|L)@IL*x(K;d9XhkRv z6~;C6A`hXo)Wt%yak5bxQzT*2jA@HZI<}%M#v?M6?8Xu(7P=(jKCIY}&a>sTbwW99 zE?jpeCG64}J=#PYU4C(wBJC;_QG2-E&MHdmyRT-FoQO(Zu||znZg;eR_`;~s(~fW3 zetVeGsj&5Cz2oBARmASI{qj{&dU5)uZ~A7AB|F!-uZK`;DaI^ZS+TXmT5HvU!>A;NS6|02EPj6Q5rF!!44Epj&I z63jbD?*s$e6vSTRbq2H0Amt9qNnMAra6j@$Z{+Dm`=g49F)q2nT> z1FeVPW!3T6JcJY&^dTPdH-8rm@sM8Z{AqUdOB{sfEjQHhsx67153F3*6-uv>0LqD4OopX#vW&Q=Ty+smJ>Q@knjWelW4u9}>ZeTjzk)=fWa2 z&DpUMH}&(niu1Z4v0QbM1=#V<`K{zd1(6kB7MOfH*Kv4j;kq>yP2sE;$m2>(vp3`9mqVQOL@#tojKA0mOn7y25*nz2Bk-C|uPo^B@nC^R* z1t{OnA?8K|p4VMYf}L;79rMBMItKap(YO=W`6Ejgb2XOqS)0^z6CBfVmF)s+abAyg e1F@n6%m04d1#&|CLr;kc section - the name of the section to search for +* entry - the name of the entry to find the value of +* def - the default value in the event of a failed read +* 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: section - the name of the section to search for +* entry - the name of the entry to find the value of +* def - default string in the event of a failed read +* buffer - a pointer to the buffer to copy into +* buffer_len - the max number of characters to copy +* 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: section - the name of the section to search for + * entry - the name of the entry to find the value of + * buffer - pointer to the buffer that holds the string + * 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; + int ret = 0; + + if (!fd) goto end; + if (!content) { + fprintf (fd, "[%s]\n%s = %s\n", section, entry, buffer); + ret = 1; + goto end; + } + sprintf(t_section,"[%s]",section); /* Format the section name */ + ptr = str_search (content, t_section, 0); /* look for the section start */ + if (!ptr) { + /* no such section: add the new section at end of file */ + fprintf (fd, "%s\n[%s]\n%s = %s\n", content, section, entry, buffer); + } + else { + char * eptr; + eptr = str_search (ptr, entry, '['); + if (!eptr) { + /* no such entry: looks for next section */ + eptr = str_search (++ptr, "[", 0); + if (!eptr) { + /* section is the last one */ + fprintf (fd, "%s\n%s = %s\n", content, entry, buffer); + } + else { + while (*ptr && (*ptr != '\n')) ptr++; + *ptr = 0; + fprintf (fd, "%s\n%s = %s", content, entry, buffer); + *ptr = '\n'; + fprintf (fd, "%s", ptr); + } + } + else { + *eptr++ = 0; + fprintf (fd, "%s%s = %s", content, entry, buffer); + while (*eptr && (*eptr != '\n')) eptr++; + if (eptr) fprintf (fd, "%s", eptr); + } + } + ret = 1; + +end: + if (content) free(content); + if (fd) fclose(fd); + return 0; +} + +/*************************************************************************** + * Function: write_private_profile_int() + * Arguments: section - the name of the section to search for + * entry - the name of the entry to find the value of + * buffer - the value to be written + * file_name - the name of the .ini file to read from + * Returns: TRUE if successful, otherwise FALSE + ***************************************************************************/ +int write_private_profile_int(char *section, + char *entry, int val, char *file_name) +{ + char buffer [64]; + sprintf(buffer, "%d", val); + return write_private_profile_string (section,entry, buffer, file_name); +} + +#endif // #ifndef WIN32 + + +/************************************************************************** +* Function: get_private_profile_float() +* Arguments: section - the name of the section to search for +* entry - the name of the entry to find the value of +* def - the default value in the event of a failed read +* file_name - the name of the .ini file to read from +* Returns: the value located at entry +* Warning: The float value to be read must not contain more than 100 digits. +* Author: CD, 15/11/2006. +***************************************************************************/ +#define maxFloatLen 100 +float get_private_profile_float (char * section, char * entry, float def, char * file_name) +{ + float result = def; + char buffer[ maxFloatLen ], *endptr; + + if ( get_private_profile_string(section, entry, "", buffer, maxFloatLen, file_name) > 0 ) + { + result = (float)strtod(buffer, &endptr); + if ((result==0) && (endptr==buffer)) + result = def; + } + return result; +} diff --git a/windows/JackRouter/profport.h b/windows/JackRouter/profport.h new file mode 100644 index 00000000..2f717177 --- /dev/null +++ b/windows/JackRouter/profport.h @@ -0,0 +1,37 @@ + +/****************************************************************************** + PORTABLE ROUTINES FOR WRITING PRIVATE PROFILE STRINGS -- by Joseph J. Graf + Header file containing prototypes and compile-time configuration. + + [09/05/02] D. Fober - Windows definitions added +******************************************************************************/ + +#ifndef __profport__ +#define __profport__ + +#define MAX_LINE_LENGTH 1024 + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef WIN32 +#include "Windows.h" +#define get_private_profile_int GetPrivateProfileInt +#define get_private_profile_string GetPrivateProfileString +#define write_private_profile_string WritePrivateProfileString +#define write_private_profile_int WritePrivateProfileInt +#else +int get_private_profile_int (char * section, char * entry, int def, char * file_name); +int get_private_profile_string (char * section, char * entry, char * def, char * buffer, int buffer_len, char * file_name); +int write_private_profile_string (char * section, char * entry, char * buffer, char * file_name); +int write_private_profile_int (char * section, char * entry, int val, char * file_name); +#endif + +float get_private_profile_float (char * section, char * entry, float def, char * file_name); + +#ifdef __cplusplus +} +#endif + +#endif //__profport__ diff --git a/windows/JackRouter/psapi.dll b/windows/JackRouter/psapi.dll new file mode 100644 index 0000000000000000000000000000000000000000..ff4c964c7b2b195b22d99328130f5b97b0c1b05c GIT binary patch literal 23040 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 UC+cVDm!+;xe+vK0^S|@^cV|9)-2eap literal 0 HcmV?d00001 diff --git a/windows/JackRouter/psapi.h b/windows/JackRouter/psapi.h new file mode 100644 index 00000000..af72931e --- /dev/null +++ b/windows/JackRouter/psapi.h @@ -0,0 +1,95 @@ +/* + psapi.h - Include file for PSAPI.DLL APIs + + Written by Mumit Khan + + This file is part of a free library for the Win32 API. + + NOTE: This strictly does not belong in the Win32 API since it's + really part of Platform SDK. However,GDB needs it and we might + as well provide it here. + + This library 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. + +*/ +#ifndef _PSAPI_H +#define _PSAPI_H +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef RC_INVOKED + +typedef struct _MODULEINFO { + LPVOID lpBaseOfDll; + DWORD SizeOfImage; + LPVOID EntryPoint; +} MODULEINFO,*LPMODULEINFO; + +typedef struct _PSAPI_WS_WATCH_INFORMATION { + LPVOID FaultingPc; + LPVOID FaultingVa; +} PSAPI_WS_WATCH_INFORMATION,*PPSAPI_WS_WATCH_INFORMATION; + +typedef struct _PROCESS_MEMORY_COUNTERS { + DWORD cb; + DWORD PageFaultCount; + DWORD PeakWorkingSetSize; + DWORD WorkingSetSize; + DWORD QuotaPeakPagedPoolUsage; + DWORD QuotaPagedPoolUsage; + DWORD QuotaPeakNonPagedPoolUsage; + DWORD QuotaNonPagedPoolUsage; + DWORD PagefileUsage; + DWORD PeakPagefileUsage; +} PROCESS_MEMORY_COUNTERS,*PPROCESS_MEMORY_COUNTERS; + +/* Grouped by application,not in alphabetical order. */ +BOOL WINAPI EnumProcesses(DWORD *,DWORD,DWORD *); +BOOL WINAPI EnumProcessModules(HANDLE,HMODULE *,DWORD,LPDWORD); +DWORD WINAPI GetModuleBaseNameA(HANDLE,HMODULE,LPSTR,DWORD); +DWORD WINAPI GetModuleBaseNameW(HANDLE,HMODULE,LPWSTR,DWORD); +DWORD WINAPI GetModuleFileNameExA(HANDLE,HMODULE,LPSTR,DWORD); +DWORD WINAPI GetModuleFileNameExW(HANDLE,HMODULE,LPWSTR,DWORD); +BOOL WINAPI GetModuleInformation(HANDLE,HMODULE,LPMODULEINFO,DWORD); +BOOL WINAPI EmptyWorkingSet(HANDLE); +BOOL WINAPI QueryWorkingSet(HANDLE,PVOID,DWORD); +BOOL WINAPI InitializeProcessForWsWatch(HANDLE); +BOOL WINAPI GetWsChanges(HANDLE,PPSAPI_WS_WATCH_INFORMATION,DWORD); +DWORD WINAPI GetMappedFileNameW(HANDLE,LPVOID,LPWSTR,DWORD); +DWORD WINAPI GetMappedFileNameA(HANDLE,LPVOID,LPSTR,DWORD); +BOOL WINAPI EnumDeviceDrivers(LPVOID *,DWORD,LPDWORD); +DWORD WINAPI GetDeviceDriverBaseNameA(LPVOID,LPSTR,DWORD); +DWORD WINAPI GetDeviceDriverBaseNameW(LPVOID,LPWSTR,DWORD); +DWORD WINAPI GetDeviceDriverFileNameA(LPVOID,LPSTR,DWORD); +DWORD WINAPI GetDeviceDriverFileNameW(LPVOID,LPWSTR,DWORD); +BOOL WINAPI GetProcessMemoryInfo(HANDLE,PPROCESS_MEMORY_COUNTERS,DWORD); + +#endif /* not RC_INVOKED */ + +#ifdef UNICODE +#define GetModuleBaseName GetModuleBaseNameW +#define GetModuleFileNameEx GetModuleFileNameExW +#define GetMappedFilenameEx GetMappedFilenameExW +#define GetDeviceDriverBaseName GetDeviceDriverBaseNameW +#define GetDeviceDriverFileName GetDeviceDriverFileNameW +#else +#define GetModuleBaseName GetModuleBaseNameA +#define GetModuleFileNameEx GetModuleFileNameExA +#define GetMappedFilenameEx GetMappedFilenameExA +#define GetDeviceDriverBaseName GetDeviceDriverBaseNameA +#define GetDeviceDriverFileName GetDeviceDriverFileNameA +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _PSAPI_H */ + diff --git a/windows/JackRouter/resource.h b/windows/JackRouter/resource.h new file mode 100644 index 00000000..673206e6 --- /dev/null +++ b/windows/JackRouter/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by resource.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/windows/JackRouter/resource.rc b/windows/JackRouter/resource.rc new file mode 100644 index 00000000..4289ddc2 --- /dev/null +++ b/windows/JackRouter/resource.rc @@ -0,0 +1,109 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// French (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 0,2,0,0 + PRODUCTVERSION 0,2,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040c04b0" + BEGIN + VALUE "Comments", "\0" + VALUE "CompanyName", "Grame\0" + VALUE "FileDescription", "JackRouter ASIO driver\0" + VALUE "FileVersion", "0, 2, 0, 0\0" + VALUE "InternalName", "JackRouter\0" + VALUE "LegalCopyright", "Copyright Grame © 2006-2009\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "JackRouter.dll\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "JackRouter\0" + VALUE "ProductVersion", "0, 2, 0, 0\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x40c, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // French (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + From 770360b273140ed7581fb4ea4aa038a74837151e Mon Sep 17 00:00:00 2001 From: nedko Date: Mon, 21 Dec 2009 19:03:47 +0000 Subject: [PATCH 07/25] improve the configure time warning for mixed jackdbus+jack scenario git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3864 0c269be4-1314-0410-8aa9-9f06e86f4224 --- wscript | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wscript b/wscript index f5c0d488..ecf7acaa 100644 --- a/wscript +++ b/wscript @@ -203,8 +203,9 @@ def configure(conf): display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS']) if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']: - print Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues!' + Logs.colors.NORMAL - + print Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL + print Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL + if conf.env['IS_LINUX']: display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True) display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True) From ddc96f38f04bc4c151a495cf175a0ad65eb88d3e Mon Sep 17 00:00:00 2001 From: nedko Date: Mon, 28 Dec 2009 13:23:14 +0000 Subject: [PATCH 08/25] Fix jackdbus dependencies handling git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3865 0c269be4-1314-0410-8aa9-9f06e86f4224 --- dbus/wscript | 16 +++++++++------- wscript | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dbus/wscript b/dbus/wscript index e23e67b0..a4066b57 100644 --- a/dbus/wscript +++ b/dbus/wscript @@ -10,11 +10,15 @@ def set_options(opt): opt.add_option('--enable-pkg-config-dbus-service-dir', action='store_true', default=False, help='force D-Bus service install dir to be one returned by pkg-config') def configure(conf): - if not conf.check_cfg(package='dbus-1', atleast_version='1.0.0', args='--cflags --libs'): + conf.env['BUILD_JACKDBUS'] = False + + if not conf.check_cfg(package='dbus-1', atleast_version='1.0.0', args='--cflags --libs') or not conf.is_defined('HAVE_DBUS_1'): + print Logs.colors.RED + 'WARNING !! jackdbus will not be built because libdbus-dev is missing' + Logs.colors.NORMAL return dbus_dir = conf.check_cfg(package='dbus-1', args='--variable=session_bus_services_dir') if not dbus_dir: + print Logs.colors.RED + 'WARNING !! jackdbus will not be built because service dir is unknown' + Logs.colors.NORMAL return dbus_dir = dbus_dir.strip() @@ -31,15 +35,13 @@ def configure(conf): if conf.is_defined('HAVE_EXPAT'): conf.env['LIB_EXPAT'] = ['expat'] + else: + print Logs.colors.RED + 'WARNING !! jackdbus will not be built because of expat is missing' + Logs.colors.NORMAL + return - conf.env['BUILD_JACKDBUS1'] = conf.is_defined('HAVE_EXPAT') and conf.is_defined('HAVE_DBUS_1') - + conf.env['BUILD_JACKDBUS'] = True def build(bld): - - if bld.env['BUILD_JACKDBUS1'] != True: - return - obj = bld.new_task_gen('cc', 'program') if bld.env['IS_LINUX']: sysdeps_dbus_include = ['../linux', '../posix'] diff --git a/wscript b/wscript index ecf7acaa..33469397 100644 --- a/wscript +++ b/wscript @@ -112,6 +112,8 @@ def configure(conf): conf.sub_config('linux') if Options.options.dbus: conf.sub_config('dbus') + if conf.env['BUILD_JACKDBUS'] != True: + conf.fatal('jackdbus was explicitly requested but cannot be built') conf.sub_config('example-clients') if conf.check_cfg(package='celt', atleast_version='0.7.0', args='--cflags --libs'): @@ -136,7 +138,6 @@ def configure(conf): conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen conf.env['BUILD_WITH_PROFILE'] = Options.options.profile conf.env['BUILD_WITH_32_64'] = Options.options.mixed - conf.env['BUILD_JACKDBUS'] = Options.options.dbus conf.env['BUILD_CLASSIC'] = Options.options.classic conf.env['BUILD_DEBUG'] = Options.options.debug From 4efeb5470c890d77f162ab1883ab9eaf268dbb4c Mon Sep 17 00:00:00 2001 From: sletz Date: Thu, 31 Dec 2009 12:15:30 +0000 Subject: [PATCH 09/25] Typo. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3866 0c269be4-1314-0410-8aa9-9f06e86f4224 --- example-clients/jack_control | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example-clients/jack_control b/example-clients/jack_control index c7b2dab5..1d06436b 100755 --- a/example-clients/jack_control +++ b/example-clients/jack_control @@ -106,9 +106,9 @@ def main(): print "Usage: %s [command] [command] ..." % os.path.basename(sys.argv[0]) print "Commands:" print " exit - exit jack dbus service (stops jack server if currently running)" - print " status - check whether jack server is started, return value is 0 if runing and 1 otherwise" + print " status - check whether jack server is started, return value is 0 if running and 1 otherwise" print " start - start jack server if not currently started" - print " stop - stop jack server if currenly started" + print " stop - stop jack server if currently started" print " sm - switch master to currently selected driver" print " dl - get list of available drivers" print " dg - get currently selected driver" From 5d67ec263e53e75ab35e24ed4d09c6d799f3cf2f Mon Sep 17 00:00:00 2001 From: nedko Date: Sun, 3 Jan 2010 22:15:48 +0000 Subject: [PATCH 10/25] fix jack_transport build git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3867 0c269be4-1314-0410-8aa9-9f06e86f4224 --- example-clients/wscript | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/example-clients/wscript b/example-clients/wscript index 04cc9c4f..4cf08d15 100644 --- a/example-clients/wscript +++ b/example-clients/wscript @@ -49,10 +49,11 @@ def configure(conf): e = conf.check_cc(lib='readline', define_name="HAVE_READLINE") - if conf.is_defined('HAVE_READLINE'): - conf.env['LIB_READLINE'] = ['readline'] + # define_name="HAVE_READLINE" has no effect, LIB_READLINE is defined if readline is available + #if conf.is_defined('HAVE_READLINE'): + # conf.env['LIB_READLINE'] = ['readline'] - conf.env['BUILD_EXAMPLE_CLIENT_TRANSPORT'] = conf.is_defined('HAVE_READLINE') and conf.is_defined('HAVE_NCURSES') + conf.env['BUILD_EXAMPLE_CLIENT_TRANSPORT'] = bool(conf.env['LIB_READLINE']) and bool(conf.env['LIB_NCURSES']) conf.env['BUILD_EXAMPLE_CLIENT_REC'] = conf.is_defined('HAVE_SNDFILE') From 85ae7ba5cb3110d98e187485bba89fa9983ed37d Mon Sep 17 00:00:00 2001 From: sletz Date: Wed, 6 Jan 2010 17:30:34 +0000 Subject: [PATCH 11/25] Fix for ticket #152. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3868 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackDriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/JackDriver.cpp b/common/JackDriver.cpp index bab5db0f..a485d810 100644 --- a/common/JackDriver.cpp +++ b/common/JackDriver.cpp @@ -167,7 +167,7 @@ int JackDriver::Open(jack_nframes_t buffer_size, int JackDriver::Close() { - if (fClientControl.fRefNum > 0) { + if (fClientControl.fRefNum >= 0) { jack_log("JackDriver::Close"); fGraphManager->DirectDisconnect(fClientControl.fRefNum, fClientControl.fRefNum); // Disconnect driver from itself for sync fClientControl.fActive = false; From f7cb14ec455c37447876c19a5820963e6ef6b048 Mon Sep 17 00:00:00 2001 From: sletz Date: Sat, 9 Jan 2010 21:25:51 +0000 Subject: [PATCH 12/25] Fix for ticket #154. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3869 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/ringbuffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/ringbuffer.c b/common/ringbuffer.c index b60000c7..45ee27b3 100644 --- a/common/ringbuffer.c +++ b/common/ringbuffer.c @@ -70,7 +70,7 @@ jack_ringbuffer_create (size_t sz) int power_of_two; jack_ringbuffer_t *rb; - if ((rb = malloc (sizeof (jack_ringbuffer_t))) == NULL) { + if ((rb = (jack_ringbuffer_t *) malloc (sizeof (jack_ringbuffer_t))) == NULL) { return NULL; } @@ -81,7 +81,7 @@ jack_ringbuffer_create (size_t sz) rb->size_mask -= 1; rb->write_ptr = 0; rb->read_ptr = 0; - if ((rb->buf = malloc (rb->size)) == NULL) { + if ((rb->buf = (char *) malloc (rb->size)) == NULL) { free (rb); return NULL; } From 724237589baa3fa41ef2c4e4b1dfa2ab23590be0 Mon Sep 17 00:00:00 2001 From: Torben Hohn Date: Thu, 19 Nov 2009 21:05:02 +0100 Subject: [PATCH 13/25] remove HAVE_CELT 1 define and include config.h --- common/JackNetOneDriver.cpp | 2 -- common/netjack.c | 2 +- common/netjack_packet.c | 2 +- example-clients/netsource.c | 2 ++ 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/JackNetOneDriver.cpp b/common/JackNetOneDriver.cpp index bc0160bc..4a75cc23 100644 --- a/common/JackNetOneDriver.cpp +++ b/common/JackNetOneDriver.cpp @@ -17,8 +17,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -//#define HAVE_CELT 1 - #ifdef WIN32 #include #endif diff --git a/common/netjack.c b/common/netjack.c index eb5f36b7..b150ac7f 100644 --- a/common/netjack.c +++ b/common/netjack.c @@ -49,7 +49,7 @@ $Id: net_driver.c,v 1.17 2006/04/16 20:16:10 torbenh Exp $ #include "netjack.h" -//#include "config.h" +#include "config.h" #if HAVE_SAMPLERATE #include diff --git a/common/netjack_packet.c b/common/netjack_packet.c index 17a9b92e..3c20445a 100644 --- a/common/netjack_packet.c +++ b/common/netjack_packet.c @@ -26,7 +26,7 @@ * */ -//#include "config.h" +#include "config.h" #ifdef __APPLE__ #define _DARWIN_C_SOURCE diff --git a/example-clients/netsource.c b/example-clients/netsource.c index 32b06fc2..e8271ebb 100644 --- a/example-clients/netsource.c +++ b/example-clients/netsource.c @@ -34,6 +34,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include #include +#include "config.h" + #ifdef WIN32 #include #define socklen_t int From 7ceef48f5e6b88ce2bcbf7e17889138cd4f66fd4 Mon Sep 17 00:00:00 2001 From: Torben Hohn Date: Tue, 12 Jan 2010 06:50:59 +0100 Subject: [PATCH 14/25] [netone] switch to old deadline algo again. --- common/netjack.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/common/netjack.c b/common/netjack.c index b150ac7f..f8685909 100644 --- a/common/netjack.c +++ b/common/netjack.c @@ -92,7 +92,7 @@ int netjack_wait( netjack_driver_state_t *netj ) jacknet_packet_header *pkthdr; if( !netj->next_deadline_valid ) { - netj->next_deadline = jack_get_time() + netj->deadline_offset; + netj->next_deadline = jack_get_time() + netj->period_usecs; netj->next_deadline_valid = 1; } @@ -174,23 +174,23 @@ int netjack_wait( netjack_driver_state_t *netj ) if( netj->deadline_goodness != MASTER_FREEWHEELS ) { if( netj->deadline_goodness < want_deadline ) { - netj->deadline_offset -= netj->period_usecs/100; + netj->next_deadline -= netj->period_usecs/100; //jack_log( "goodness: %d, Adjust deadline: --- %d\n", netj->deadline_goodness, (int) netj->period_usecs*netj->latency/100 ); } if( netj->deadline_goodness > want_deadline ) { - netj->deadline_offset += netj->period_usecs/100; + netj->next_deadline += netj->period_usecs/100; //jack_log( "goodness: %d, Adjust deadline: +++ %d\n", netj->deadline_goodness, (int) netj->period_usecs*netj->latency/100 ); } } - if( netj->deadline_offset < (netj->period_usecs*70/100) ) { - jack_error( "master is forcing deadline_offset to below 70%% of period_usecs... increase latency setting on master" ); - netj->deadline_offset = (netj->period_usecs*90/100); - } +// if( netj->next_deadline < (netj->period_usecs*70/100) ) { +// jack_error( "master is forcing deadline_offset to below 70%% of period_usecs... increase latency setting on master" ); +// netj->deadline_offset = (netj->period_usecs*90/100); +// } - netj->next_deadline = jack_get_time() + netj->deadline_offset; + netj->next_deadline += netj->period_usecs; } else { netj->time_to_deadline = 0; - netj->next_deadline = jack_get_time() + netj->deadline_offset; + netj->next_deadline += netj->period_usecs; // bah... the packet is not there. // either // - it got lost. From 2653c629be3f9940a9f0021c30081e79360c823b Mon Sep 17 00:00:00 2001 From: sletz Date: Tue, 12 Jan 2010 17:06:02 +0000 Subject: [PATCH 15/25] Correct JackCoreAudioDriver. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3871 0c269be4-1314-0410-8aa9-9f06e86f4224 --- macosx/coreaudio/JackCoreAudioDriver.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/macosx/coreaudio/JackCoreAudioDriver.cpp b/macosx/coreaudio/JackCoreAudioDriver.cpp index fc291ebd..2143170f 100644 --- a/macosx/coreaudio/JackCoreAudioDriver.cpp +++ b/macosx/coreaudio/JackCoreAudioDriver.cpp @@ -1268,9 +1268,9 @@ int JackCoreAudioDriver::OpenAUHAL(bool capturing, if (capturing && inchannels > 0) { size = sizeof(AudioStreamBasicDescription); - err1 = AudioUnitGetProperty(fAUHAL, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &srcFormat, &size); + err1 = AudioUnitGetProperty(fAUHAL, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &srcFormat, &size); if (err1 != noErr) { - jack_error("Error calling AudioUnitGetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Input"); + jack_error("Error calling AudioUnitGetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Output"); printError(err1); goto error; } @@ -1288,9 +1288,8 @@ int JackCoreAudioDriver::OpenAUHAL(bool capturing, PrintStreamDesc(&srcFormat); err1 = AudioUnitSetProperty(fAUHAL, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &srcFormat, sizeof(AudioStreamBasicDescription)); - if (err1 != noErr) { - jack_error("Error calling AudioUnitSetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Input"); + jack_error("Error calling AudioUnitSetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Output"); printError(err1); goto error; } @@ -1299,9 +1298,9 @@ int JackCoreAudioDriver::OpenAUHAL(bool capturing, if (playing && outchannels > 0) { size = sizeof(AudioStreamBasicDescription); - err1 = AudioUnitGetProperty(fAUHAL, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 1, &dstFormat, &size); + err1 = AudioUnitGetProperty(fAUHAL, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &dstFormat, &size); if (err1 != noErr) { - jack_error("Error calling AudioUnitGetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Output"); + jack_error("Error calling AudioUnitGetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Input"); printError(err1); goto error; } @@ -1319,9 +1318,8 @@ int JackCoreAudioDriver::OpenAUHAL(bool capturing, PrintStreamDesc(&dstFormat); err1 = AudioUnitSetProperty(fAUHAL, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &dstFormat, sizeof(AudioStreamBasicDescription)); - if (err1 != noErr) { - jack_error("Error calling AudioUnitSetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Output"); + jack_error("Error calling AudioUnitSetProperty - kAudioUnitProperty_StreamFormat kAudioUnitScope_Input"); printError(err1); goto error; } From 9070e96347c21a22c453582ad4d87160ae3df7c7 Mon Sep 17 00:00:00 2001 From: Torben Hohn Date: Wed, 13 Jan 2010 21:45:34 +0100 Subject: [PATCH 16/25] require alsa 1.0.18 --- linux/wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/wscript b/linux/wscript index 20695a96..869985d4 100644 --- a/linux/wscript +++ b/linux/wscript @@ -2,7 +2,7 @@ # encoding: utf-8 def configure(conf): - conf.check_cfg(package='alsa', atleast_version='1.0.0', args='--cflags --libs') + conf.check_cfg(package='alsa', atleast_version='1.0.18', args='--cflags --libs') conf.env['BUILD_DRIVER_ALSA'] = conf.is_defined('HAVE_ALSA') conf. check_cfg(package='libfreebob', atleast_version='1.0.0', args='--cflags --libs') From 70596093923943a00281b8177fa48eb0b526bd4f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Dec 2009 10:05:55 +0100 Subject: [PATCH 17/25] socklen_t fix --- common/netjack.c | 1 + common/netjack_packet.c | 1 + 2 files changed, 2 insertions(+) diff --git a/common/netjack.c b/common/netjack.c index f8685909..dd772e97 100644 --- a/common/netjack.c +++ b/common/netjack.c @@ -42,6 +42,7 @@ $Id: net_driver.c,v 1.17 2006/04/16 20:16:10 torbenh Exp $ #ifdef WIN32 #include #include +#define socklen_t int #else #include #include diff --git a/common/netjack_packet.c b/common/netjack_packet.c index 3c20445a..c20b8299 100644 --- a/common/netjack_packet.c +++ b/common/netjack_packet.c @@ -52,6 +52,7 @@ #include #define socklen_t int #include +#define socklen_t int #else #include #include From efd8eefc7bf9d2056bbafe6b2445e1ed71410720 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Dec 2009 10:07:22 +0100 Subject: [PATCH 18/25] use big socketbuffers on win32 --- common/netjack.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/netjack.c b/common/netjack.c index dd772e97..f7fde41a 100644 --- a/common/netjack.c +++ b/common/netjack.c @@ -582,7 +582,13 @@ netjack_startup( netjack_driver_state_t *netj ) struct sockaddr_in address; // Now open the socket, and wait for the first packet to arrive... netj->sockfd = socket (AF_INET, SOCK_DGRAM, 0); + #ifdef WIN32 + u_long parm = 1; + DWORD bufsize = 262144; + //ioctlsocket( netj->sockfd, FIONBIO, &parm ); + setsockopt( netj->sockfd, SOL_SOCKET, SO_RCVBUF, (char *)&bufsize, sizeof(bufsize) ); + setsockopt( netj->sockfd, SOL_SOCKET, SO_SNDBUF, (char *)&bufsize, sizeof(bufsize) ); if (netj->sockfd == INVALID_SOCKET) #else if (netj->sockfd == -1) From 910fd826cb12d9e669558b199c46be9e76b40034 Mon Sep 17 00:00:00 2001 From: sletz Date: Thu, 14 Jan 2010 09:46:18 +0000 Subject: [PATCH 19/25] Compiles in Windows again. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3873 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/netjack.c | 12 +++++++----- common/netjack_packet.c | 8 +++++--- example-clients/netsource.c | 8 +++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/common/netjack.c b/common/netjack.c index f7fde41a..fa3a706a 100644 --- a/common/netjack.c +++ b/common/netjack.c @@ -49,8 +49,10 @@ $Id: net_driver.c,v 1.17 2006/04/16 20:16:10 torbenh Exp $ #endif #include "netjack.h" - -#include "config.h" + +#ifndef WIN32 +#include "config.h" +#endif #if HAVE_SAMPLERATE #include @@ -166,7 +168,7 @@ int netjack_wait( netjack_driver_state_t *netj ) netj->packet_data_valid = 1; int want_deadline; - if( netj->jitter_val != 0 ) + if( netj->jitter_val != 0 ) want_deadline = netj->jitter_val; else if( netj->latency < 4 ) want_deadline = -netj->period_usecs/2; @@ -712,7 +714,7 @@ netjack_startup( netjack_driver_state_t *netj ) netj->period_usecs = (jack_time_t) floor ((((float) netj->period_size) / (float)netj->sample_rate) * 1000000.0f); - + if( netj->latency == 0 ) netj->deadline_offset = 50*netj->period_usecs; else @@ -723,7 +725,7 @@ netjack_startup( netjack_driver_state_t *netj ) // TODO: this is a hack. But i dont want to change the packet header. netj->resample_factor = (netj->resample_factor * netj->period_size * 1024 / netj->sample_rate / 8)&(~1); netj->resample_factor_up = (netj->resample_factor_up * netj->period_size * 1024 / netj->sample_rate / 8)&(~1); - + netj->net_period_down = netj->resample_factor; netj->net_period_up = netj->resample_factor_up; } else { diff --git a/common/netjack_packet.c b/common/netjack_packet.c index c20b8299..afd41550 100644 --- a/common/netjack_packet.c +++ b/common/netjack_packet.c @@ -25,8 +25,10 @@ * $Id: net_driver.c,v 1.16 2006/03/20 19:41:37 torbenh Exp $ * */ - -#include "config.h" + +#ifndef WIN32 +#include "config.h" +#endif #ifdef __APPLE__ #define _DARWIN_C_SOURCE @@ -128,7 +130,7 @@ int get_sample_size (int bitdepth) if (bitdepth == 16) return sizeof (int16_t); //JN: why? is this for buffer sizes before or after encoding? - //JN: if the former, why not int16_t, if the latter, shouldn't it depend on -c N? + //JN: if the former, why not int16_t, if the latter, shouldn't it depend on -c N? if( bitdepth == CELT_MODE ) return sizeof( unsigned char ); return sizeof (int32_t); diff --git a/example-clients/netsource.c b/example-clients/netsource.c index e8271ebb..48f1ee66 100644 --- a/example-clients/netsource.c +++ b/example-clients/netsource.c @@ -33,8 +33,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include #include #include - -#include "config.h" + +#ifndef WIN32 +#include "config.h" +#endif #ifdef WIN32 #include @@ -756,7 +758,7 @@ main (int argc, char *argv[]) if (statecopy_netxruns != state_netxruns) { statecopy_netxruns = state_netxruns; printf ("%s: at frame %06d -> total netxruns %d (%d%%) queue time= %d\n", - client_name, + client_name, state_currentframe, statecopy_netxruns, 100*statecopy_netxruns/state_currentframe, From d3c1703a8c4d2f7d513827886964f82336d84c4d Mon Sep 17 00:00:00 2001 From: sletz Date: Thu, 14 Jan 2010 10:06:13 +0000 Subject: [PATCH 20/25] Compiles on OSX. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3874 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/netjack.c | 6 +++--- common/netjack_packet.c | 6 +++--- example-clients/netsource.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/netjack.c b/common/netjack.c index fa3a706a..a073c2cf 100644 --- a/common/netjack.c +++ b/common/netjack.c @@ -49,9 +49,9 @@ $Id: net_driver.c,v 1.17 2006/04/16 20:16:10 torbenh Exp $ #endif #include "netjack.h" - -#ifndef WIN32 -#include "config.h" + +#ifdef __linux__ +#include "config.h" #endif #if HAVE_SAMPLERATE diff --git a/common/netjack_packet.c b/common/netjack_packet.c index afd41550..dfe3b9e2 100644 --- a/common/netjack_packet.c +++ b/common/netjack_packet.c @@ -25,9 +25,9 @@ * $Id: net_driver.c,v 1.16 2006/03/20 19:41:37 torbenh Exp $ * */ - -#ifndef WIN32 -#include "config.h" + +#ifdef __linux__ +#include "config.h" #endif #ifdef __APPLE__ diff --git a/example-clients/netsource.c b/example-clients/netsource.c index 48f1ee66..d6d252c2 100644 --- a/example-clients/netsource.c +++ b/example-clients/netsource.c @@ -33,9 +33,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include #include #include - -#ifndef WIN32 -#include "config.h" + +#ifdef __linux__ +#include "config.h" #endif #ifdef WIN32 From 6f9ee03099a450a79b51dfe7d2533e83131d83c7 Mon Sep 17 00:00:00 2001 From: sletz Date: Thu, 28 Jan 2010 13:03:07 +0000 Subject: [PATCH 21/25] weakjack.h stuff backported from jack1. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3882 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/jack/jack.h | 225 ++++++++++++++++++++++------------------- common/jack/weakjack.h | 52 ++++++++++ 2 files changed, 171 insertions(+), 106 deletions(-) create mode 100644 common/jack/weakjack.h diff --git a/common/jack/jack.h b/common/jack/jack.h index 74c8b3cb..f1fe4d7b 100644 --- a/common/jack/jack.h +++ b/common/jack/jack.h @@ -34,31 +34,44 @@ extern "C" * Note: More documentation can be found in jack/types.h. */ -/************************************************************* - * NOTE: JACK_WEAK_EXPORT ***MUST*** be used on every function - * added to the JACK API after the 0.116.2 release. - *************************************************************/ - + /************************************************************* + * NOTE: JACK_WEAK_EXPORT ***MUST*** be used on every function + * added to the JACK API after the 0.116.2 release. + * + * Functions that predate this release are marked with + * JACK_WEAK_OPTIONAL_EXPORT which can be defined at compile + * time in a variety of ways. The default definition is empty, + * so that these symbols get normal linkage. If you wish to + * use all JACK symbols with weak linkage, include + * before jack.h. + *************************************************************/ + #ifndef JACK_WEAK_EXPORT #ifdef __GNUC__ -/* JACK_WEAK_EXPORT needs to be a macro which - expands into a compiler directive. If non-null, the directive - must tell the compiler to arrange for weak linkage of - the symbol it used with. For this to work full may - require linker arguments in the client as well. -*/ + /* JACK_WEAK_EXPORT needs to be a macro which + expands into a compiler directive. If non-null, the directive + must tell the compiler to arrange for weak linkage of + the symbol it used with. For this to work full may + require linker arguments in the client as well. + */ #define JACK_WEAK_EXPORT __attribute__((weak)) -#else -#define JACK_WEAK_EXPORT -/* Add other things here for non-gcc platforms */ +#else + /* Add other things here for non-gcc platforms */ #endif #endif - -/** -* @defgroup ClientFunctions Creating & manipulating clients -* @{ -*/ - + +#ifndef JACK_OPTIONAL_WEAK_EXPORT +#define JACK_OPTIONAL_WEAK_EXPORT +#endif + +#ifndef JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT +#ifdef __GNUC__ +#define JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT __attribute__((__deprecated__)) +#else + /* Add other things here for non-gcc platforms */ +#endif /* __GNUC__ */ +#endif + /** * Call this function to get version of the JACK, in form of several numbers * @@ -76,7 +89,7 @@ jack_get_version( int *major_ptr, int *minor_ptr, int *micro_ptr, - int *proto_ptr); + int *proto_ptr) JACK_OPTIONAL_WEAK_EXPORT; /** * Call this function to get version of the JACK, in form of a string @@ -85,7 +98,7 @@ jack_get_version( * */ const char * -jack_get_version_string(); +jack_get_version_string() JACK_OPTIONAL_WEAK_EXPORT; /** * Open an external client session with a JACK server. This interface @@ -122,7 +135,7 @@ jack_get_version_string(); */ jack_client_t * jack_client_open (const char *client_name, jack_options_t options, - jack_status_t *status, ...); + jack_status_t *status, ...) JACK_OPTIONAL_WEAK_EXPORT; /** * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN @@ -130,20 +143,20 @@ jack_client_t * jack_client_open (const char *client_name, * * @deprecated Please use jack_client_open(). */ -jack_client_t * jack_client_new (const char *client_name); +jack_client_t * jack_client_new (const char *client_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT; /** * Disconnects an external client from a JACK server. * * @return 0 on success, otherwise a non-zero error code */ -int jack_client_close (jack_client_t *client); +int jack_client_close (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the maximum number of characters in a JACK client name * including the final NULL character. This value is a constant. */ -int jack_client_name_size (void); +int jack_client_name_size (void) JACK_OPTIONAL_WEAK_EXPORT; /** * @return pointer to actual client name. This is useful when @ref @@ -151,7 +164,7 @@ int jack_client_name_size (void); * JackNameNotUnique status was returned. In that case, the actual * name will differ from the @a client_name requested. */ -char * jack_get_client_name (jack_client_t *client); +char * jack_get_client_name (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; /** * Load an internal client into the Jack server. @@ -176,14 +189,14 @@ char * jack_get_client_name (jack_client_t *client); */ int jack_internal_client_new (const char *client_name, const char *load_name, - const char *load_init); + const char *load_init) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT; /** * Remove an internal client from a JACK server. * * @deprecated Please use jack_internal_client_load(). */ -void jack_internal_client_close (const char *client_name); +void jack_internal_client_close (const char *client_name) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT; /** * Tell the Jack server that the program is ready to start processing @@ -191,7 +204,7 @@ void jack_internal_client_close (const char *client_name); * * @return 0 on success, otherwise a non-zero error code */ -int jack_activate (jack_client_t *client); +int jack_activate (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell the Jack server to remove this @a client from the process @@ -200,18 +213,18 @@ int jack_activate (jack_client_t *client); * * @return 0 on success, otherwise a non-zero error code */ -int jack_deactivate (jack_client_t *client); +int jack_deactivate (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; /** * @return pid of client. If not available, 0 will be returned. */ -int jack_get_client_pid (const char *name); +int jack_get_client_pid (const char *name) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the pthread ID of the thread running the JACK client side * code. */ -pthread_t jack_client_thread_id (jack_client_t *); +pthread_t jack_client_thread_id (jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT; /*@}*/ @@ -222,7 +235,7 @@ pthread_t jack_client_thread_id (jack_client_t *); * * @return 1 if JACK is running realtime, 0 otherwise */ -int jack_is_realtime (jack_client_t *client); +int jack_is_realtime (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; /** * @defgroup NonCallbackAPI The non-callback API @@ -235,7 +248,7 @@ int jack_is_realtime (jack_client_t *client); * * @deprecated Please use jack_cycle_wait() and jack_cycle_signal() functions. */ -jack_nframes_t jack_thread_wait (jack_client_t*, int status); +jack_nframes_t jack_thread_wait (jack_client_t*, int status) JACK_OPTIONAL_WEAK_EXPORT; /** * Wait until this JACK client should process data. @@ -244,7 +257,7 @@ jack_nframes_t jack_thread_wait (jack_client_t*, int status); * * @return the number of frames of data to process */ -jack_nframes_t jack_cycle_wait (jack_client_t* client); + jack_nframes_t jack_cycle_wait (jack_client_t* client) JACK_OPTIONAL_WEAK_EXPORT; /** * Signal next clients in the graph. @@ -252,7 +265,7 @@ jack_nframes_t jack_cycle_wait (jack_client_t* client); * @param client - pointer to a JACK client structure * @param status - if non-zero, calling thread should exit */ -void jack_cycle_signal (jack_client_t* client, int status); +void jack_cycle_signal (jack_client_t* client, int status) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell the Jack server to call @a thread_callback in the RT thread. @@ -270,7 +283,7 @@ void jack_cycle_signal (jack_client_t* client, int status); * * @return 0 on success, otherwise a non-zero error code. */ -int jack_set_process_thread(jack_client_t* client, JackThreadCallback thread_callback, void *arg); +int jack_set_process_thread(jack_client_t* client, JackThreadCallback thread_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT; /*@}*/ @@ -295,7 +308,7 @@ int jack_set_process_thread(jack_client_t* client, JackThreadCallback thread_cal */ int jack_set_thread_init_callback (jack_client_t *client, JackThreadInitCallback thread_init_callback, - void *arg); + void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * @param client pointer to JACK client structure. @@ -347,7 +360,7 @@ void jack_on_shutdown (jack_client_t *client, * jack_on_info_shutdown() will. */ void jack_on_info_shutdown (jack_client_t *client, - JackInfoShutdownCallback shutdown_callback, void *arg); + JackInfoShutdownCallback shutdown_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell the Jack server to call @a process_callback whenever there is @@ -368,7 +381,7 @@ void jack_on_info_shutdown (jack_client_t *client, */ int jack_set_process_callback (jack_client_t *client, JackProcessCallback process_callback, - void *arg); + void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell the Jack server to call @a freewheel_callback @@ -388,7 +401,7 @@ int jack_set_process_callback (jack_client_t *client, */ int jack_set_freewheel_callback (jack_client_t *client, JackFreewheelCallback freewheel_callback, - void *arg); + void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell JACK to call @a bufsize_callback whenever the size of the the @@ -411,7 +424,7 @@ int jack_set_freewheel_callback (jack_client_t *client, */ int jack_set_buffer_size_callback (jack_client_t *client, JackBufferSizeCallback bufsize_callback, - void *arg); + void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell the Jack server to call @a srate_callback whenever the system @@ -428,7 +441,7 @@ int jack_set_buffer_size_callback (jack_client_t *client, */ int jack_set_sample_rate_callback (jack_client_t *client, JackSampleRateCallback srate_callback, - void *arg); + void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell the JACK server to call @a client_registration_callback whenever a @@ -445,7 +458,7 @@ int jack_set_sample_rate_callback (jack_client_t *client, */ int jack_set_client_registration_callback (jack_client_t *, JackClientRegistrationCallback - registration_callback, void *arg); + registration_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell the JACK server to call @a registration_callback whenever a @@ -461,8 +474,8 @@ int jack_set_client_registration_callback (jack_client_t *, * @return 0 on success, otherwise a non-zero error code */ int jack_set_port_registration_callback (jack_client_t *, - JackPortRegistrationCallback - registration_callback, void *arg); + JackPortRegistrationCallback + registration_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell the JACK server to call @a connect_callback whenever a @@ -478,8 +491,8 @@ int jack_set_client_registration_callback (jack_client_t *, * @return 0 on success, otherwise a non-zero error code */ int jack_set_port_connect_callback (jack_client_t *, - JackPortConnectCallback - connect_callback, void *arg); + JackPortConnectCallback + connect_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell the JACK server to call @a rename_callback whenever a @@ -495,8 +508,8 @@ int jack_set_port_connect_callback (jack_client_t *, * @return 0 on success, otherwise a non-zero error code */ int jack_set_port_rename_callback (jack_client_t *, - JackPortRenameCallback - rename_callback, void *arg); + JackPortRenameCallback + rename_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell the JACK server to call @a graph_callback whenever the @@ -513,7 +526,7 @@ int jack_set_port_rename_callback (jack_client_t *, */ int jack_set_graph_order_callback (jack_client_t *, JackGraphOrderCallback graph_callback, - void *); + void *) JACK_OPTIONAL_WEAK_EXPORT; /** * Tell the JACK server to call @a xrun_callback whenever there is a @@ -529,7 +542,7 @@ int jack_set_graph_order_callback (jack_client_t *, * @return 0 on success, otherwise a non-zero error code */ int jack_set_xrun_callback (jack_client_t *, - JackXRunCallback xrun_callback, void *arg); + JackXRunCallback xrun_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT; /*@}*/ @@ -562,7 +575,7 @@ int jack_set_xrun_callback (jack_client_t *, * * @return 0 on success, otherwise a non-zero error code. */ -int jack_set_freewheel(jack_client_t* client, int onoff); +int jack_set_freewheel(jack_client_t* client, int onoff) JACK_OPTIONAL_WEAK_EXPORT; /** * Change the buffer size passed to the @a process_callback. @@ -579,13 +592,13 @@ int jack_set_freewheel(jack_client_t* client, int onoff); * * @return 0 on success, otherwise a non-zero error code */ -int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes); +int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the sample rate of the jack system, as set by the user when * jackd was started. */ -jack_nframes_t jack_get_sample_rate (jack_client_t *); +jack_nframes_t jack_get_sample_rate (jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the current maximum size that will ever be passed to the @a @@ -596,7 +609,7 @@ jack_nframes_t jack_get_sample_rate (jack_client_t *); * * @see jack_set_buffer_size_callback() */ -jack_nframes_t jack_get_buffer_size (jack_client_t *); +jack_nframes_t jack_get_buffer_size (jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT; /** * Old-style interface to become the timebase for the entire JACK @@ -608,7 +621,7 @@ jack_nframes_t jack_get_buffer_size (jack_client_t *); * * @return ENOSYS, function not implemented. */ -int jack_engine_takeover_timebase (jack_client_t *); +int jack_engine_takeover_timebase (jack_client_t *) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT; /** * @return the current CPU load estimated by JACK. This is a running @@ -616,7 +629,7 @@ int jack_engine_takeover_timebase (jack_client_t *); * all clients as a percentage of the real time available per cycle * determined by the buffer size and sample rate. */ -float jack_cpu_load (jack_client_t *client); +float jack_cpu_load (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; /*@}*/ @@ -655,7 +668,7 @@ jack_port_t * jack_port_register (jack_client_t *client, const char *port_name, const char *port_type, unsigned long flags, - unsigned long buffer_size); + unsigned long buffer_size) JACK_OPTIONAL_WEAK_EXPORT; /** * Remove the port from the client, disconnecting any existing @@ -663,7 +676,7 @@ jack_port_t * jack_port_register (jack_client_t *client, * * @return 0 on success, otherwise a non-zero error code */ -int jack_port_unregister (jack_client_t *, jack_port_t *); +int jack_port_unregister (jack_client_t *, jack_port_t *) JACK_OPTIONAL_WEAK_EXPORT; /** * This returns a pointer to the memory area associated with the @@ -684,7 +697,7 @@ int jack_port_unregister (jack_client_t *, jack_port_t *); * Caching output ports is DEPRECATED in Jack 2.0, due to some new optimization (like "pipelining"). * Port buffers have to be retrieved in each callback for proper functionning. */ -void * jack_port_get_buffer (jack_port_t *, jack_nframes_t); +void * jack_port_get_buffer (jack_port_t *, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the full name of the jack_port_t (including the @a @@ -692,7 +705,7 @@ void * jack_port_get_buffer (jack_port_t *, jack_nframes_t); * * @see jack_port_name_size(). */ -const char * jack_port_name (const jack_port_t *port); +const char * jack_port_name (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the short name of the jack_port_t (not including the @a @@ -700,35 +713,35 @@ const char * jack_port_name (const jack_port_t *port); * * @see jack_port_name_size(). */ -const char * jack_port_short_name (const jack_port_t *port); +const char * jack_port_short_name (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the @ref JackPortFlags of the jack_port_t. */ -int jack_port_flags (const jack_port_t *port); +int jack_port_flags (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the @a port type, at most jack_port_type_size() characters * including a final NULL. */ -const char * jack_port_type (const jack_port_t *port); +const char * jack_port_type (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the @a port type id. */ -jack_port_type_id_t jack_port_type_id (const jack_port_t *port); +jack_port_type_id_t jack_port_type_id (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * @return TRUE if the jack_port_t belongs to the jack_client_t. */ -int jack_port_is_mine (const jack_client_t *, const jack_port_t *port); +int jack_port_is_mine (const jack_client_t *, const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * @return number of connections to or from @a port. * * @pre The calling client must own @a port. */ -int jack_port_connected (const jack_port_t *port); +int jack_port_connected (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * @return TRUE if the locally-owned @a port is @b directly connected @@ -737,7 +750,7 @@ int jack_port_connected (const jack_port_t *port); * @see jack_port_name_size() */ int jack_port_connected_to (const jack_port_t *port, - const char *port_name); + const char *port_name) JACK_OPTIONAL_WEAK_EXPORT; /** * @return a null-terminated array of full port names to which the @a @@ -750,7 +763,7 @@ int jack_port_connected_to (const jack_port_t *port, * * @see jack_port_name_size(), jack_port_get_all_connections() */ -const char ** jack_port_get_connections (const jack_port_t *port); +const char ** jack_port_get_connections (const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * @return a null-terminated array of full port names to which the @a @@ -772,7 +785,7 @@ const char ** jack_port_get_connections (const jack_port_t *port); * @see jack_port_name_size() */ const char ** jack_port_get_all_connections (const jack_client_t *client, - const jack_port_t *port); + const jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * @@ -781,7 +794,7 @@ const char ** jack_port_get_all_connections (const jack_client_t *client, * turned out to serve essentially no purpose in real-life * JACK clients. */ -int jack_port_tie (jack_port_t *src, jack_port_t *dst); +int jack_port_tie (jack_port_t *src, jack_port_t *dst) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT; /** * @@ -790,7 +803,7 @@ int jack_port_tie (jack_port_t *src, jack_port_t *dst); * turned out to serve essentially no purpose in real-life * JACK clients. */ -int jack_port_untie (jack_port_t *port); +int jack_port_untie (jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT; /** * @return the time (in frames) between data being available or @@ -802,7 +815,7 @@ int jack_port_untie (jack_port_t *port); * connector and the corresponding frames being readable from the * port. */ -jack_nframes_t jack_port_get_latency (jack_port_t *port); +jack_nframes_t jack_port_get_latency (jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * The maximum of the sum of the latencies in every @@ -810,7 +823,7 @@ jack_nframes_t jack_port_get_latency (jack_port_t *port); * ports with the @ref JackPortIsTerminal flag set. */ jack_nframes_t jack_port_get_total_latency (jack_client_t *, - jack_port_t *port); + jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * The port latency is zero by default. Clients that control @@ -822,7 +835,7 @@ jack_nframes_t jack_port_get_total_latency (jack_client_t *, * to an external digital converter, the latency setting should * include both buffering by the audio interface *and* the converter. */ -void jack_port_set_latency (jack_port_t *, jack_nframes_t); +void jack_port_set_latency (jack_port_t *, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT; /** * Request a complete recomputation of a port's total latency. This @@ -835,7 +848,7 @@ void jack_port_set_latency (jack_port_t *, jack_nframes_t); * @return zero for successful execution of the request. non-zero * otherwise. */ -int jack_recompute_total_latency (jack_client_t*, jack_port_t* port); +int jack_recompute_total_latency (jack_client_t*, jack_port_t* port) JACK_OPTIONAL_WEAK_EXPORT; /** * Request a complete recomputation of all port latencies. This @@ -850,7 +863,7 @@ int jack_recompute_total_latency (jack_client_t*, jack_port_t* port); * @return zero for successful execution of the request. non-zero * otherwise. */ -int jack_recompute_total_latencies (jack_client_t*); + int jack_recompute_total_latencies (jack_client_t*) JACK_OPTIONAL_WEAK_EXPORT; /** * Modify a port's short name. May be called at any time. If the @@ -859,7 +872,7 @@ int jack_recompute_total_latencies (jack_client_t*); * * @return 0 on success, otherwise a non-zero error code. */ -int jack_port_set_name (jack_port_t *port, const char *port_name); +int jack_port_set_name (jack_port_t *port, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT; /** * Set @a alias as an alias for @a port. May be called at any time. @@ -874,7 +887,7 @@ int jack_port_set_name (jack_port_t *port, const char *port_name); * * @return 0 on success, otherwise a non-zero error code. */ -int jack_port_set_alias (jack_port_t *port, const char *alias); +int jack_port_set_alias (jack_port_t *port, const char *alias) JACK_OPTIONAL_WEAK_EXPORT; /** * Remove @a alias as an alias for @a port. May be called at any time. @@ -884,20 +897,20 @@ int jack_port_set_alias (jack_port_t *port, const char *alias); * * @return 0 on success, otherwise a non-zero error code. */ -int jack_port_unset_alias (jack_port_t *port, const char *alias); +int jack_port_unset_alias (jack_port_t *port, const char *alias) JACK_OPTIONAL_WEAK_EXPORT; /** * Get any aliases known for @port. * * @return the number of aliases discovered for the port */ -int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]); +int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]) JACK_OPTIONAL_WEAK_EXPORT; /** * If @ref JackPortCanMonitor is set for this @a port, turn input * monitoring on or off. Otherwise, do nothing. */ -int jack_port_request_monitor (jack_port_t *port, int onoff); +int jack_port_request_monitor (jack_port_t *port, int onoff) JACK_OPTIONAL_WEAK_EXPORT; /** * If @ref JackPortCanMonitor is set for this @a port_name, turn input @@ -908,7 +921,7 @@ int jack_port_request_monitor (jack_port_t *port, int onoff); * @see jack_port_name_size() */ int jack_port_request_monitor_by_name (jack_client_t *client, - const char *port_name, int onoff); + const char *port_name, int onoff) JACK_OPTIONAL_WEAK_EXPORT; /** * If @ref JackPortCanMonitor is set for a port, this function turns @@ -917,12 +930,12 @@ int jack_port_request_monitor_by_name (jack_client_t *client, * * @return 0 on success, otherwise a non-zero error code */ -int jack_port_ensure_monitor (jack_port_t *port, int onoff); +int jack_port_ensure_monitor (jack_port_t *port, int onoff) JACK_OPTIONAL_WEAK_EXPORT; /** * @return TRUE if input monitoring has been requested for @a port. */ -int jack_port_monitoring_input (jack_port_t *port); +int jack_port_monitoring_input (jack_port_t *port) JACK_OPTIONAL_WEAK_EXPORT; /** * Establish a connection between two ports. @@ -943,7 +956,7 @@ int jack_port_monitoring_input (jack_port_t *port); */ int jack_connect (jack_client_t *, const char *source_port, - const char *destination_port); + const char *destination_port) JACK_OPTIONAL_WEAK_EXPORT; /** * Remove a connection between two ports. @@ -960,7 +973,7 @@ int jack_connect (jack_client_t *, */ int jack_disconnect (jack_client_t *, const char *source_port, - const char *destination_port); + const char *destination_port) JACK_OPTIONAL_WEAK_EXPORT; /** * Perform the same function as jack_disconnect() using port handles @@ -971,7 +984,7 @@ int jack_disconnect (jack_client_t *, * while generic connection clients (e.g. patchbays) would use * jack_disconnect(). */ -int jack_port_disconnect (jack_client_t *, jack_port_t *); +int jack_port_disconnect (jack_client_t *, jack_port_t *) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the maximum number of characters in a full JACK port name @@ -981,13 +994,13 @@ int jack_port_disconnect (jack_client_t *, jack_port_t *); * with a colon (:) followed by its short name and a NULL * character. */ -int jack_port_name_size(void); +int jack_port_name_size(void) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the maximum number of characters in a JACK port type name * including the final NULL character. This value is a constant. */ -int jack_port_type_size(void); +int jack_port_type_size(void) JACK_OPTIONAL_WEAK_EXPORT; /*@}*/ @@ -1015,20 +1028,20 @@ int jack_port_type_size(void); const char ** jack_get_ports (jack_client_t *, const char *port_name_pattern, const char *type_name_pattern, - unsigned long flags); + unsigned long flags) JACK_OPTIONAL_WEAK_EXPORT; /** * @return address of the jack_port_t named @a port_name. * * @see jack_port_name_size() */ -jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name); +jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name) JACK_OPTIONAL_WEAK_EXPORT; /** * @return address of the jack_port_t of a @a port_id. */ jack_port_t * jack_port_by_id (jack_client_t *client, - jack_port_id_t port_id); + jack_port_id_t port_id) JACK_OPTIONAL_WEAK_EXPORT; /*@}*/ @@ -1045,7 +1058,7 @@ jack_port_t * jack_port_by_id (jack_client_t *client, * @return the estimated time in frames that has passed since the JACK * server began the current process cycle. */ -jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *); +jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the estimated current time in frames. @@ -1053,7 +1066,7 @@ jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *); * callback). The return value can be compared with the value of * jack_last_frame_time to relate time in other threads to JACK time. */ -jack_nframes_t jack_frame_time (const jack_client_t *); +jack_nframes_t jack_frame_time (const jack_client_t *) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the precise time at the start of the current process cycle. @@ -1069,17 +1082,17 @@ jack_nframes_t jack_frame_time (const jack_client_t *); * If an xrun occurs, clients must check this value again, as time * may have advanced in a non-linear way (e.g. cycles may have been skipped). */ -jack_nframes_t jack_last_frame_time (const jack_client_t *client); +jack_nframes_t jack_last_frame_time (const jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the estimated time in microseconds of the specified frame time */ -jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t); +jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT; /** * @return the estimated time in frames for the specified system time. */ -jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t); +jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t) JACK_OPTIONAL_WEAK_EXPORT; /** * @return return JACK's current system time in microseconds, @@ -1087,7 +1100,7 @@ jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t); * * The value returned is guaranteed to be monotonic, but not linear. */ -jack_time_t jack_get_time(); +jack_time_t jack_get_time() JACK_OPTIONAL_WEAK_EXPORT; /*@}*/ @@ -1104,7 +1117,7 @@ jack_time_t jack_get_time(); * * @param msg error message text (no newline at end). */ -extern void (*jack_error_callback)(const char *msg); +extern void (*jack_error_callback)(const char *msg) JACK_OPTIONAL_WEAK_EXPORT; /** * Set the @ref jack_error_callback for error message display. @@ -1113,7 +1126,7 @@ extern void (*jack_error_callback)(const char *msg); * The JACK library provides two built-in callbacks for this purpose: * default_jack_error_callback() and silent_jack_error_callback(). */ -void jack_set_error_function (void (*func)(const char *)); +void jack_set_error_function (void (*func)(const char *)) JACK_OPTIONAL_WEAK_EXPORT; /** * Display JACK info message. @@ -1123,7 +1136,7 @@ void jack_set_error_function (void (*func)(const char *)); * * @param msg info message text (no newline at end). */ -extern void (*jack_info_callback)(const char *msg); +extern void (*jack_info_callback)(const char *msg) JACK_OPTIONAL_WEAK_EXPORT; /** * Set the @ref jack_info_callback for info message display. @@ -1132,7 +1145,7 @@ extern void (*jack_info_callback)(const char *msg); * The JACK library provides two built-in callbacks for this purpose: * default_jack_info_callback() and silent_jack_info_callback(). */ -void jack_set_info_function (void (*func)(const char *)); +void jack_set_info_function (void (*func)(const char *)) JACK_OPTIONAL_WEAK_EXPORT; /*@}*/ @@ -1143,7 +1156,7 @@ void jack_set_info_function (void (*func)(const char *)); * Developers are strongly encouraged to use this function instead of the standard "free" function in new code. * */ -void jack_free(void* ptr); +void jack_free(void* ptr) JACK_OPTIONAL_WEAK_EXPORT; #ifdef __cplusplus diff --git a/common/jack/weakjack.h b/common/jack/weakjack.h new file mode 100644 index 00000000..11d2acaa --- /dev/null +++ b/common/jack/weakjack.h @@ -0,0 +1,52 @@ +/* + Copyright (C) 2010 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifndef __weakjack_h__ +#define __weakjack_h__ + +#ifndef JACK_OPTIONAL_WEAK_EXPORT +/* JACK_OPTIONAL_WEAK_EXPORT needs to be a macro which + expands into a compiler directive. If non-null, the directive + must tell the compiler to arrange for weak linkage of + the symbol it used with. For this to work fully may + require linker arguments for the client as well. +*/ +#ifdef __GNUC__ +#define JACK_OPTIONAL_WEAK_EXPORT __attribute__((__weak__)) +#else +/* Add other things here for non-gcc platforms */ +#endif +#endif + +#ifndef JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT +/* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT needs to be a macro + which expands into a compiler directive. If non-null, the directive + must tell the compiler to arrange for weak linkage of the + symbol it is used with AND optionally to mark the symbol + as deprecated. For this to work fully may require + linker arguments for the client as well. +*/ +#ifdef __GNUC__ +#define JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT __attribute__((__weak__,__deprecated__)) +#else +/* Add other things here for non-gcc platforms */ +#endif +#endif + +#endif /* weakjack */ From 246becdeb2e9b889930a09545c9a9697cc1caa9a Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 29 Jan 2010 16:49:35 +0000 Subject: [PATCH 22/25] More weak stuff in public headers. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3895 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackDebugClient.cpp | 2 +- common/jack/jack.h | 26 +--------------- common/jack/midiport.h | 22 +++++++------- common/jack/thread.h | 17 ++++++----- common/jack/transport.h | 25 ++++++++-------- common/jack/weakmacros.h | 61 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 96 insertions(+), 57 deletions(-) create mode 100644 common/jack/weakmacros.h diff --git a/common/JackDebugClient.cpp b/common/JackDebugClient.cpp index df263779..6a90fcdc 100644 --- a/common/JackDebugClient.cpp +++ b/common/JackDebugClient.cpp @@ -121,7 +121,7 @@ void JackDebugClient::CheckClient(const char* function_name) const *fStream << "!!! ERROR !!! : Accessing a client '" << fClientName << "' already closed " << "from " << function_name << endl; *fStream << "This is likely to cause crash !'" << endl; #ifdef __APPLE__ - Debugger(); + // Debugger(); #endif } } diff --git a/common/jack/jack.h b/common/jack/jack.h index f1fe4d7b..96800dcd 100644 --- a/common/jack/jack.h +++ b/common/jack/jack.h @@ -46,31 +46,7 @@ extern "C" * before jack.h. *************************************************************/ -#ifndef JACK_WEAK_EXPORT -#ifdef __GNUC__ - /* JACK_WEAK_EXPORT needs to be a macro which - expands into a compiler directive. If non-null, the directive - must tell the compiler to arrange for weak linkage of - the symbol it used with. For this to work full may - require linker arguments in the client as well. - */ -#define JACK_WEAK_EXPORT __attribute__((weak)) -#else - /* Add other things here for non-gcc platforms */ -#endif -#endif - -#ifndef JACK_OPTIONAL_WEAK_EXPORT -#define JACK_OPTIONAL_WEAK_EXPORT -#endif - -#ifndef JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT -#ifdef __GNUC__ -#define JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT __attribute__((__deprecated__)) -#else - /* Add other things here for non-gcc platforms */ -#endif /* __GNUC__ */ -#endif +#include /** * Call this function to get version of the JACK, in form of several numbers diff --git a/common/jack/midiport.h b/common/jack/midiport.h index da0b940d..fd620b8d 100644 --- a/common/jack/midiport.h +++ b/common/jack/midiport.h @@ -27,7 +27,7 @@ extern "C" { #include #include - +#include /** Type for raw event data contained in @ref jack_midi_event_t. */ typedef unsigned char jack_midi_data_t; @@ -53,7 +53,7 @@ typedef struct _jack_midi_event * @return number of events inside @a port_buffer */ jack_nframes_t -jack_midi_get_event_count(void* port_buffer); +jack_midi_get_event_count(void* port_buffer) JACK_OPTIONAL_WEAK_EXPORT; /** Get a MIDI event from an event port buffer. @@ -70,7 +70,7 @@ jack_midi_get_event_count(void* port_buffer); int jack_midi_event_get(jack_midi_event_t *event, void *port_buffer, - jack_nframes_t event_index); + jack_nframes_t event_index) JACK_OPTIONAL_WEAK_EXPORT; /** Clear an event buffer. @@ -82,7 +82,7 @@ jack_midi_event_get(jack_midi_event_t *event, * @param port_buffer Port buffer to clear (must be an output port buffer). */ void -jack_midi_clear_buffer(void *port_buffer); +jack_midi_clear_buffer(void *port_buffer) JACK_OPTIONAL_WEAK_EXPORT; /** Get the size of the largest event that can be stored by the port. @@ -93,7 +93,7 @@ jack_midi_clear_buffer(void *port_buffer); * @param port_buffer Port buffer to check size of. */ size_t -jack_midi_max_event_size(void* port_buffer); +jack_midi_max_event_size(void* port_buffer) JACK_OPTIONAL_WEAK_EXPORT; /** Allocate space for an event to be written to an event port buffer. @@ -112,9 +112,9 @@ jack_midi_max_event_size(void* port_buffer); * NULL on error (ie not enough space). */ jack_midi_data_t* -jack_midi_event_reserve(void *port_buffer, +jack_midi_event_reserve(void *port_buffer, jack_nframes_t time, - size_t data_size); + size_t data_size) JACK_OPTIONAL_WEAK_EXPORT; /** Write an event into an event port buffer. @@ -130,10 +130,10 @@ jack_midi_event_reserve(void *port_buffer, * @return 0 on success, ENOBUFS if there's not enough space in buffer for event. */ int -jack_midi_event_write(void *port_buffer, - jack_nframes_t time, +jack_midi_event_write(void *port_buffer, + jack_nframes_t time, const jack_midi_data_t *data, - size_t data_size); + size_t data_size) JACK_OPTIONAL_WEAK_EXPORT; /** Get the number of events that could not be written to @a port_buffer. @@ -145,7 +145,7 @@ jack_midi_event_write(void *port_buffer, * @returns Number of events that could not be written to @a port_buffer. */ jack_nframes_t -jack_midi_get_lost_event_count(void *port_buffer); +jack_midi_get_lost_event_count(void *port_buffer) JACK_OPTIONAL_WEAK_EXPORT; /*@}*/ diff --git a/common/jack/thread.h b/common/jack/thread.h index 48adf084..5d002afa 100644 --- a/common/jack/thread.h +++ b/common/jack/thread.h @@ -26,6 +26,7 @@ extern "C" #endif #include +#include /** @file thread.h * @@ -45,7 +46,7 @@ extern "C" * Otherwise returns -1. */ -int jack_client_real_time_priority (jack_client_t*); +int jack_client_real_time_priority (jack_client_t*) JACK_OPTIONAL_WEAK_EXPORT; /** * @returns if JACK is running with realtime scheduling, this returns @@ -53,7 +54,7 @@ int jack_client_real_time_priority (jack_client_t*); * is subject to realtime scheduling. Otherwise returns -1. */ -int jack_client_max_real_time_priority (jack_client_t*); +int jack_client_max_real_time_priority (jack_client_t*) JACK_OPTIONAL_WEAK_EXPORT; /** * Attempt to enable realtime scheduling for a thread. On some @@ -65,7 +66,7 @@ int jack_client_max_real_time_priority (jack_client_t*); * @returns 0, if successful; EPERM, if the calling process lacks * required realtime privileges; otherwise some other error number. */ -int jack_acquire_real_time_scheduling (pthread_t thread, int priority); +int jack_acquire_real_time_scheduling (pthread_t thread, int priority) JACK_OPTIONAL_WEAK_EXPORT; /** * Create a thread for JACK or one of its clients. The thread is @@ -88,7 +89,7 @@ int jack_client_create_thread (jack_client_t* client, int priority, int realtime, /* boolean */ void *(*start_routine)(void*), - void *arg); + void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Drop realtime scheduling for a thread. @@ -97,7 +98,7 @@ int jack_client_create_thread (jack_client_t* client, * * @returns 0, if successful; otherwise an error number. */ -int jack_drop_real_time_scheduling (pthread_t thread); +int jack_drop_real_time_scheduling (pthread_t thread) JACK_OPTIONAL_WEAK_EXPORT; /** * Stop the thread, waiting for the thread handler to terminate. @@ -106,7 +107,7 @@ int jack_drop_real_time_scheduling (pthread_t thread); * * @returns 0, if successful; otherwise an error number. */ -int jack_client_stop_thread(jack_client_t* client, pthread_t thread); +int jack_client_stop_thread(jack_client_t* client, pthread_t thread) JACK_OPTIONAL_WEAK_EXPORT; /** * Cancel the thread then waits for the thread handler to terminate. @@ -115,7 +116,7 @@ int jack_client_stop_thread(jack_client_t* client, pthread_t thread); * * @returns 0, if successful; otherwise an error number. */ - int jack_client_kill_thread(jack_client_t* client, pthread_t thread); + int jack_client_kill_thread(jack_client_t* client, pthread_t thread) JACK_OPTIONAL_WEAK_EXPORT; #ifndef WIN32 @@ -142,7 +143,7 @@ int jack_client_stop_thread(jack_client_t* client, pthread_t thread); * @param creator a function that creates a new thread * */ -void jack_set_thread_creator (jack_thread_creator_t creator); +void jack_set_thread_creator (jack_thread_creator_t creator) JACK_OPTIONAL_WEAK_EXPORT; #endif diff --git a/common/jack/transport.h b/common/jack/transport.h index 67bcaa2a..e8ba8cbb 100644 --- a/common/jack/transport.h +++ b/common/jack/transport.h @@ -26,6 +26,7 @@ extern "C" { #endif #include +#include /** * @defgroup TransportControl Transport and Timebase control @@ -48,7 +49,7 @@ extern "C" { * * @return 0 on success, otherwise a non-zero error code. */ -int jack_release_timebase (jack_client_t *client); +int jack_release_timebase (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; /** * Register (or unregister) as a slow-sync client, one that cannot @@ -72,7 +73,7 @@ int jack_release_timebase (jack_client_t *client); */ int jack_set_sync_callback (jack_client_t *client, JackSyncCallback sync_callback, - void *arg); + void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Set the timeout value for slow-sync clients. @@ -92,7 +93,7 @@ int jack_set_sync_callback (jack_client_t *client, * @return 0 on success, otherwise a non-zero error code. */ int jack_set_sync_timeout (jack_client_t *client, - jack_time_t timeout); + jack_time_t timeout) JACK_OPTIONAL_WEAK_EXPORT; /** * Register as timebase master for the JACK subsystem. @@ -122,7 +123,7 @@ int jack_set_sync_timeout (jack_client_t *client, int jack_set_timebase_callback (jack_client_t *client, int conditional, JackTimebaseCallback timebase_callback, - void *arg); + void *arg) JACK_OPTIONAL_WEAK_EXPORT; /** * Reposition the transport to a new frame number. @@ -141,7 +142,7 @@ int jack_set_timebase_callback (jack_client_t *client, * @return 0 if valid request, non-zero otherwise. */ int jack_transport_locate (jack_client_t *client, - jack_nframes_t frame); + jack_nframes_t frame) JACK_OPTIONAL_WEAK_EXPORT; /** * Query the current transport state and position. @@ -159,7 +160,7 @@ int jack_transport_locate (jack_client_t *client, * @return Current transport state. */ jack_transport_state_t jack_transport_query (const jack_client_t *client, - jack_position_t *pos); + jack_position_t *pos) JACK_OPTIONAL_WEAK_EXPORT; /** * Return an estimate of the current transport frame, @@ -168,7 +169,7 @@ jack_transport_state_t jack_transport_query (const jack_client_t *client, * * @param client the JACK client structure */ -jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client); +jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; /** * Request a new transport position. @@ -187,7 +188,7 @@ jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client); * @return 0 if valid request, EINVAL if position structure rejected. */ int jack_transport_reposition (jack_client_t *client, - jack_position_t *pos); + jack_position_t *pos) JACK_OPTIONAL_WEAK_EXPORT; /** * Start the JACK transport rolling. @@ -200,7 +201,7 @@ int jack_transport_reposition (jack_client_t *client, * * @param client the JACK client structure. */ -void jack_transport_start (jack_client_t *client); +void jack_transport_start (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; /** * Stop the JACK transport. @@ -210,7 +211,7 @@ void jack_transport_start (jack_client_t *client); * * @param client the JACK client structure. */ -void jack_transport_stop (jack_client_t *client); +void jack_transport_stop (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT; /** * Gets the current transport info structure (deprecated). @@ -225,7 +226,7 @@ void jack_transport_stop (jack_client_t *client); * @pre Must be called from the process thread. */ void jack_get_transport_info (jack_client_t *client, - jack_transport_info_t *tinfo); + jack_transport_info_t *tinfo) JACK_OPTIONAL_WEAK_EXPORT; /** * Set the transport info structure (deprecated). @@ -235,7 +236,7 @@ void jack_get_transport_info (jack_client_t *client, * a ::JackTimebaseCallback. */ void jack_set_transport_info (jack_client_t *client, - jack_transport_info_t *tinfo); + jack_transport_info_t *tinfo) JACK_OPTIONAL_WEAK_EXPORT; /*@}*/ diff --git a/common/jack/weakmacros.h b/common/jack/weakmacros.h new file mode 100644 index 00000000..3db19d3f --- /dev/null +++ b/common/jack/weakmacros.h @@ -0,0 +1,61 @@ +/* + Copyright (C) 2010 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifndef __weakmacros_h__ +#define __weakmacros_h__ + +/************************************************************* + * NOTE: JACK_WEAK_EXPORT ***MUST*** be used on every function + * added to the JACK API after the 0.116.2 release. + * + * Functions that predate this release are marked with + * JACK_WEAK_OPTIONAL_EXPORT which can be defined at compile + * time in a variety of ways. The default definition is empty, + * so that these symbols get normal linkage. If you wish to + * use all JACK symbols with weak linkage, include + * before jack.h. + *************************************************************/ + +#ifndef JACK_WEAK_EXPORT +#ifdef __GNUC__ +/* JACK_WEAK_EXPORT needs to be a macro which + expands into a compiler directive. If non-null, the directive + must tell the compiler to arrange for weak linkage of + the symbol it used with. For this to work full may + require linker arguments in the client as well. +*/ +#define JACK_WEAK_EXPORT __attribute__((weak)) +#else +/* Add other things here for non-gcc platforms */ +#endif +#endif + +#ifndef JACK_OPTIONAL_WEAK_EXPORT +#define JACK_OPTIONAL_WEAK_EXPORT +#endif + +#ifndef JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT +#ifdef __GNUC__ +#define JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT __attribute__((__deprecated__)) +#else +/* Add other things here for non-gcc platforms */ +#endif /* __GNUC__ */ +#endif + +#endif /* __weakmacros_h__ */ From 12c67a271dfe528b268f59f35a3ce8ba9f09c341 Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 29 Jan 2010 19:31:55 +0000 Subject: [PATCH 23/25] Change JackEngineProfiling and JackAudioAdapterInterface gnuplot scripts to output SVG instead of PDF. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3896 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 5 +++++ common/JackAudioAdapterInterface.cpp | 24 +++++++++++++++--------- common/JackEngineProfiling.cpp | 28 ++++++++++++++++++---------- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66aa7ae0..91292e25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ --------------------------- Dmitry Baikov +Gabriel M. Beddingfield Steven Chamberlain Thom Johansen Thibault LeMeur @@ -28,6 +29,10 @@ Mario Lang Jackdmp changes log --------------------------- +2010-01-29 Gabriel M. Beddingfield + + * Change JackEngineProfiling and JackAudioAdapterInterface gnuplot scripts to output SVG instead of PDF. + 2009-12-15 Stephane Letz * Shared memory manager was calling abort in case of fatal error, now return an error in caller. diff --git a/common/JackAudioAdapterInterface.cpp b/common/JackAudioAdapterInterface.cpp index dff17818..738363b6 100644 --- a/common/JackAudioAdapterInterface.cpp +++ b/common/JackAudioAdapterInterface.cpp @@ -68,8 +68,8 @@ namespace Jack fprintf(file, buffer); fprintf(file, "\n unset multiplot\n"); - fprintf(file, "set output 'AdapterTiming1.pdf\n"); - fprintf(file, "set terminal pdf\n"); + fprintf(file, "set output 'AdapterTiming1.svg\n"); + fprintf(file, "set terminal svg\n"); fprintf(file, "set multiplot\n"); fprintf(file, "set grid\n"); @@ -80,8 +80,10 @@ namespace Jack fprintf(file, "plot "); sprintf(buffer, "\"JackAudioAdapter.log\" using 2 title \"Consumer interrupt period\" with lines,"); fprintf(file, buffer); - sprintf(buffer, "\"JackAudioAdapter.log\" using 3 title \"Producer interrupt period\" with lines"); + sprintf(buffer, "\"JackAudioAdapter.log\" using 3 title \"Producer interrupt period\" with lines\n"); fprintf(file, buffer); + fprintf(file, "unset multiplot\n"); + fprintf(file, "unset output\n"); fclose(file); @@ -100,8 +102,8 @@ namespace Jack fprintf(file, buffer); fprintf(file, "\n unset multiplot\n"); - fprintf(file, "set output 'AdapterTiming2.pdf\n"); - fprintf(file, "set terminal pdf\n"); + fprintf(file, "set output 'AdapterTiming2.svg\n"); + fprintf(file, "set terminal svg\n"); fprintf(file, "set multiplot\n"); fprintf(file, "set grid\n"); @@ -112,8 +114,10 @@ namespace Jack fprintf(file, "plot "); sprintf(buffer, "\"JackAudioAdapter.log\" using 4 title \"Ratio 1\" with lines,"); fprintf(file, buffer); - sprintf(buffer, "\"JackAudioAdapter.log\" using 5 title \"Ratio 2\" with lines"); + sprintf(buffer, "\"JackAudioAdapter.log\" using 5 title \"Ratio 2\" with lines\n"); fprintf(file, buffer); + fprintf(file, "unset multiplot\n"); + fprintf(file, "unset output\n"); fclose(file); @@ -132,8 +136,8 @@ namespace Jack fprintf(file, buffer); fprintf(file, "\n unset multiplot\n"); - fprintf(file, "set output 'AdapterTiming3.pdf\n"); - fprintf(file, "set terminal pdf\n"); + fprintf(file, "set output 'AdapterTiming3.svg\n"); + fprintf(file, "set terminal svg\n"); fprintf(file, "set multiplot\n"); fprintf(file, "set grid\n"); @@ -144,8 +148,10 @@ namespace Jack fprintf(file, "plot "); sprintf(buffer, "\"JackAudioAdapter.log\" using 6 title \"Frames position in consumer ringbuffer\" with lines,"); fprintf(file, buffer); - sprintf(buffer, "\"JackAudioAdapter.log\" using 7 title \"Frames position in producer ringbuffer\" with lines"); + sprintf(buffer, "\"JackAudioAdapter.log\" using 7 title \"Frames position in producer ringbuffer\" with lines\n"); fprintf(file, buffer); + fprintf(file, "unset multiplot\n"); + fprintf(file, "unset output\n"); fclose(file); } diff --git a/common/JackEngineProfiling.cpp b/common/JackEngineProfiling.cpp index cfe5d636..5e329c0c 100644 --- a/common/JackEngineProfiling.cpp +++ b/common/JackEngineProfiling.cpp @@ -104,14 +104,15 @@ JackEngineProfiling::~JackEngineProfiling() fStream1 << "set ylabel \"usec\"\n"; fStream1 << "plot \"JackEngineProfiling.log\" using 1 title \"Audio period\" with lines \n"; - fStream1 << "set output 'Timing1.pdf\n"; - fStream1 << "set terminal pdf\n"; + fStream1 << "set output 'Timing1.svg\n"; + fStream1 << "set terminal svg\n"; fStream1 << "set grid\n"; fStream1 << "set title \"Audio driver timing\"\n"; fStream1 << "set xlabel \"audio cycles\"\n"; fStream1 << "set ylabel \"usec\"\n"; fStream1 << "plot \"JackEngineProfiling.log\" using 1 title \"Audio period\" with lines \n"; + fStream1 << "unset output\n"; } // Driver end date @@ -127,14 +128,15 @@ JackEngineProfiling::~JackEngineProfiling() fStream2 << "set ylabel \"usec\"\n"; fStream2 << "plot \"JackEngineProfiling.log\" using 2 title \"Driver end date\" with lines \n"; - fStream2 << "set output 'Timing2.pdf\n"; - fStream2 << "set terminal pdf\n"; + fStream2 << "set output 'Timing2.svg\n"; + fStream2 << "set terminal svg\n"; fStream2 << "set grid\n"; fStream2 << "set title \"Driver end date\"\n"; fStream2 << "set xlabel \"audio cycles\"\n"; fStream2 << "set ylabel \"usec\"\n"; fStream2 << "plot \"JackEngineProfiling.log\" using 2 title \"Driver end date\" with lines \n"; + fStream2 << "unset output\n"; } // Clients end date @@ -170,8 +172,8 @@ JackEngineProfiling::~JackEngineProfiling() } fStream3 << "\n unset multiplot\n"; - fStream3 << "set output 'Timing3.pdf\n"; - fStream3 << "set terminal pdf\n"; + fStream3 << "set output 'Timing3.svg\n"; + fStream3 << "set terminal svg\n"; fStream3 << "set multiplot\n"; fStream3 << "set grid\n"; @@ -196,6 +198,8 @@ JackEngineProfiling::~JackEngineProfiling() fStream3 << "\"JackEngineProfiling.log\" using " << ((i + 1) * 7) - 1 << " title \"" << fIntervalTable[i].fName << "\" with lines,"; } } + fStream3 << "\nunset multiplot\n"; + fStream3 << "unset output\n"; } } @@ -222,8 +226,8 @@ JackEngineProfiling::~JackEngineProfiling() } fStream4 << "\n unset multiplot\n"; - fStream4 << "set output 'Timing4.pdf\n"; - fStream4 << "set terminal pdf\n"; + fStream4 << "set output 'Timing4.svg\n"; + fStream4 << "set terminal svg\n"; fStream4 << "set multiplot\n"; fStream4 << "set grid\n"; @@ -238,6 +242,8 @@ JackEngineProfiling::~JackEngineProfiling() fStream4 << "\"JackEngineProfiling.log\" using " << ((i + 1) * 7) << " title \"" << fIntervalTable[i].fName << "\" with lines,"; } } + fStream4 << "\nunset multiplot\n"; + fStream4 << "unset output\n"; } } @@ -264,8 +270,8 @@ JackEngineProfiling::~JackEngineProfiling() } fStream5 << "\n unset multiplot\n"; - fStream5 << "set output 'Timing5.pdf\n"; - fStream5 << "set terminal pdf\n"; + fStream5 << "set output 'Timing5.svg\n"; + fStream5 << "set terminal svg\n"; fStream5 << "set multiplot\n"; fStream5 << "set grid\n"; @@ -280,6 +286,8 @@ JackEngineProfiling::~JackEngineProfiling() fStream5 << "\"JackEngineProfiling.log\" using " << ((i + 1) * 7) + 1 << " title \"" << fIntervalTable[i].fName << "\" with lines,"; } } + fStream5 << "\nunset multiplot\n"; + fStream5 << "unset output\n"; } } } From dc5d01e63cb6a89b81a3feeba25285819ac17edb Mon Sep 17 00:00:00 2001 From: sletz Date: Sat, 30 Jan 2010 09:52:56 +0000 Subject: [PATCH 24/25] Profiling engine : generate script and html file. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3897 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackEngineProfiling.cpp | 36 +++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/common/JackEngineProfiling.cpp b/common/JackEngineProfiling.cpp index 5e329c0c..bf065970 100644 --- a/common/JackEngineProfiling.cpp +++ b/common/JackEngineProfiling.cpp @@ -95,7 +95,7 @@ JackEngineProfiling::~JackEngineProfiling() std::ofstream fStream1("Timing1.plot", std::ios_base::ate); if (!fStream1.is_open()) { - jack_error("JackEngineProfiling::Save cannot open Timing1.log file"); + jack_error("JackEngineProfiling::Save cannot open Timing1.plot file"); } else { fStream1 << "set grid\n"; @@ -119,7 +119,7 @@ JackEngineProfiling::~JackEngineProfiling() std::ofstream fStream2("Timing2.plot", std::ios_base::ate); if (!fStream2.is_open()) { - jack_error("JackEngineProfiling::Save cannot open Timing2.log file"); + jack_error("JackEngineProfiling::Save cannot open Timing2.plot file"); } else { fStream2 << "set grid\n"; @@ -144,7 +144,7 @@ JackEngineProfiling::~JackEngineProfiling() std::ofstream fStream3("Timing3.plot", std::ios_base::ate); if (!fStream3.is_open()) { - jack_error("JackEngineProfiling::Save cannot open Timing3.log file"); + jack_error("JackEngineProfiling::Save cannot open Timing3.plot file"); } else { fStream3 << "set multiplot\n"; @@ -208,7 +208,7 @@ JackEngineProfiling::~JackEngineProfiling() std::ofstream fStream4("Timing4.plot", std::ios_base::ate); if (!fStream4.is_open()) { - jack_error("JackEngineProfiling::Save cannot open Timing4.log file"); + jack_error("JackEngineProfiling::Save cannot open Timing4.plot file"); } else { fStream4 << "set multiplot\n"; @@ -252,7 +252,7 @@ JackEngineProfiling::~JackEngineProfiling() std::ofstream fStream5("Timing5.plot", std::ios_base::ate); if (!fStream5.is_open()) { - jack_error("JackEngineProfiling::Save cannot open Timing5.log file"); + jack_error("JackEngineProfiling::Save cannot open Timing5.plot file"); } else { fStream5 << "set multiplot\n"; @@ -290,6 +290,32 @@ JackEngineProfiling::~JackEngineProfiling() fStream5 << "unset output\n"; } } + + std::ofstream fStream6("Timings.html", std::ios_base::ate); + if (!fStream6.is_open()) { + jack_error("JackEngineProfiling::Save cannot open Timing6.html file"); + } else { + fStream6 << "\n"; + fStream6 << "

JACK engine profiling

\n"; + fStream6 << "

\n"; + fStream6 << "

\n"; + fStream6 << "
\n"; + fStream6 << "
\n"; + fStream6 << "
\n"; + fStream6 << "
\n"; + fStream6 << "\n"; + } + + std::ofstream fStream7("generate_timings", std::ios_base::ate); + if (!fStream7.is_open()) { + jack_error("JackEngineProfiling::Save cannot open generate_timings file"); + } else { + fStream7 << "gnuplot Timing1.plot\n"; + fStream7 << "gnuplot Timing2.plot\n"; + fStream7 << "gnuplot Timing3.plot\n"; + fStream7 << "gnuplot Timing4.plot\n"; + fStream7 << "gnuplot Timing5.plot\n"; + } } bool JackEngineProfiling::CheckClient(const char* name, int cur_point) From 107ffadab90ec0a8d5447d20c0fdd7bbe21be597 Mon Sep 17 00:00:00 2001 From: sletz Date: Sat, 30 Jan 2010 16:19:27 +0000 Subject: [PATCH 25/25] Improvements from Gabriel M. Beddingfield (HTML file output for profiling) + couple of fixes. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3898 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackEngineProfiling.cpp | 41 +++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/common/JackEngineProfiling.cpp b/common/JackEngineProfiling.cpp index bf065970..4557fec9 100644 --- a/common/JackEngineProfiling.cpp +++ b/common/JackEngineProfiling.cpp @@ -293,28 +293,39 @@ JackEngineProfiling::~JackEngineProfiling() std::ofstream fStream6("Timings.html", std::ios_base::ate); if (!fStream6.is_open()) { - jack_error("JackEngineProfiling::Save cannot open Timing6.html file"); + jack_error("JackEngineProfiling::Save cannot open Timings.html file"); } else { - fStream6 << "\n"; - fStream6 << "

JACK engine profiling

\n"; - fStream6 << "

\n"; - fStream6 << "

\n"; - fStream6 << "
\n"; - fStream6 << "
\n"; - fStream6 << "
\n"; - fStream6 << "
\n"; - fStream6 << "\n"; + fStream6 << "\n"; + fStream6 << "\n"; + fStream6 << "\n"; + fStream6 << " \n"; + fStream6 << " JACK engine profiling\n"; + fStream6 << " \n"; + fStream6 << " \n"; + fStream6 << " \n"; + fStream6 << " \n"; + fStream6 << "

JACK engine profiling

\n"; + fStream6 << "
Timing1
"; + fStream6 << "
Timing2
"; + fStream6 << "
Timing3
"; + fStream6 << "
Timing4
"; + fStream6 << "
Timing5
"; + fStream6 << " \n"; + fStream6 << "\n"; } std::ofstream fStream7("generate_timings", std::ios_base::ate); if (!fStream7.is_open()) { jack_error("JackEngineProfiling::Save cannot open generate_timings file"); } else { - fStream7 << "gnuplot Timing1.plot\n"; - fStream7 << "gnuplot Timing2.plot\n"; - fStream7 << "gnuplot Timing3.plot\n"; - fStream7 << "gnuplot Timing4.plot\n"; - fStream7 << "gnuplot Timing5.plot\n"; + fStream7 << "gnuplot -persist Timing1.plot \n"; + fStream7 << "gnuplot -persist Timing2.plot\n"; + fStream7 << "gnuplot -persist Timing3.plot\n"; + fStream7 << "gnuplot -persist Timing4.plot\n"; + fStream7 << "gnuplot -persist Timing5.plot\n"; } }