Commit bca56756 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

Removed unnecessary debugging hooks. Added -unique flag that enables spawning...

Removed unnecessary debugging hooks. Added -unique flag that enables spawning of multiple instances of pd-l2ork (disabled by default which means all new file opens will be forwarded to the existing instace). Made ALSA default driver
parent 6314db73
...@@ -4733,7 +4733,7 @@ void canvas_menuclose(t_canvas *x, t_floatarg fforce) ...@@ -4733,7 +4733,7 @@ void canvas_menuclose(t_canvas *x, t_floatarg fforce)
int force = fforce; int force = fforce;
t_glist *g; t_glist *g;
if (x->gl_owner && (force == 0 || force == 1)) { if (x->gl_owner && (force == 0 || force == 1)) {
fprintf(stderr," invis\n"); //fprintf(stderr," invis\n");
canvas_vis(x, 0); /* if subpatch, just invis it */ canvas_vis(x, 0); /* if subpatch, just invis it */
} }
else if (force == 0) else if (force == 0)
......
...@@ -24,6 +24,10 @@ fconfigure stderr -encoding utf-8 ...@@ -24,6 +24,10 @@ fconfigure stderr -encoding utf-8
fconfigure stdout -encoding utf-8 fconfigure stdout -encoding utf-8
##--/moo ##--/moo
set appname [tk appname]
tk appname $appname-startup
#puts stderr "APPNAME [tk appname]"
if { [info tclversion] >= 8.5 } { if { [info tclversion] >= 8.5 } {
# EDIT THIS PART TO CUSTOMIZE LINUX THEME # EDIT THIS PART TO CUSTOMIZE LINUX THEME
...@@ -8854,3 +8858,30 @@ proc pdtk_gettip { w item xletno name helpname dir } { ...@@ -8854,3 +8858,30 @@ proc pdtk_gettip { w item xletno name helpname dir } {
pdtk_tip $w 0 1 $msg pdtk_tip $w 0 1 $msg
} }
# ---------------- allow for unique instance ---------------------
proc pdtk_open_files_via_unique {filenames} {
#puts stderr "pdtk_open_files_via_unique $filenames"
if { $filenames != 0 } {
foreach file $filenames {
#puts stderr "open_file $file"
open_file $file
}
}
}
proc pdtk_check_unique {unique filenames} {
#puts stderr "pdtk_check_unique $unique $filenames"
global appname
if { $unique == 0 } {
#puts stderr "send pd-l2ork pdtk_open_files_via_unique $filenames"
set outcome [catch {send pd-l2ork pdtk_open_files_via_unique $filenames}]
#puts stderr "outcome = $outcome"
if { $outcome == 0 } {
menu_really_quit
exit
}
}
tk appname $appname
#puts stderr "this is unique instance [tk appname]"
}
\ No newline at end of file
...@@ -50,6 +50,7 @@ int sys_guisetportnumber; /* if started from the GUI, this is the port # */ ...@@ -50,6 +50,7 @@ int sys_guisetportnumber; /* if started from the GUI, this is the port # */
int sys_nosleep = 0; /* skip all "sleep" calls and spin instead */ int sys_nosleep = 0; /* skip all "sleep" calls and spin instead */
int sys_console = 0; /* default settings for the console is off */ int sys_console = 0; /* default settings for the console is off */
int sys_k12_mode = 0; /* by default k12 mode is off */ int sys_k12_mode = 0; /* by default k12 mode is off */
int sys_unique = 0; /* by default off, prevents multiple instances of pd-l2ork */
char *sys_guicmd; char *sys_guicmd;
t_symbol *sys_libdir; t_symbol *sys_libdir;
...@@ -247,7 +248,7 @@ static void pd_makeversion(void) ...@@ -247,7 +248,7 @@ static void pd_makeversion(void)
//snprintf(foo, sizeof(foo), "Pd-l2ork version %d.%d-%d%s\n", PD_MAJOR_VERSION, //snprintf(foo, sizeof(foo), "Pd-l2ork version %d.%d-%d%s\n", PD_MAJOR_VERSION,
// PD_MINOR_VERSION, PD_BUGFIX_VERSION, PD_TEST_VERSION); // PD_MINOR_VERSION, PD_BUGFIX_VERSION, PD_TEST_VERSION);
snprintf(foo, sizeof(foo), "Pd-l2ork version %s\n", PD_TEST_VERSION); snprintf(foo, sizeof(foo), "Pd-L2Ork version %s\n", PD_TEST_VERSION);
pd_version = strdup(foo); pd_version = strdup(foo);
} }
...@@ -258,8 +259,9 @@ int sys_main(int argc, char **argv) ...@@ -258,8 +259,9 @@ int sys_main(int argc, char **argv)
int i, noprefs; int i, noprefs;
sys_externalschedlib = 0; sys_externalschedlib = 0;
sys_extraflags = 0; sys_extraflags = 0;
char * filenames;
#ifdef PD_DEBUG #ifdef PD_DEBUG
fprintf(stderr, "Pd: COMPILED FOR DEBUGGING\n"); fprintf(stderr, "Pd-L2Ork: COMPILED FOR DEBUGGING\n");
#endif #endif
pd_init(); /* start the message system */ pd_init(); /* start the message system */
sys_findprogdir(argv[0]); /* set sys_progname, guipath */ sys_findprogdir(argv[0]); /* set sys_progname, guipath */
...@@ -283,6 +285,30 @@ int sys_main(int argc, char **argv) ...@@ -283,6 +285,30 @@ int sys_main(int argc, char **argv)
return (0); return (0);
if (sys_startgui(sys_guidir->s_name)) /* start the gui */ if (sys_startgui(sys_guidir->s_name)) /* start the gui */
return(1); return(1);
/* check if we are unique, otherwise, just focus existing
instance, and if necessary open file inside it */\
if (sys_openlist) {
// let's create one continuous string from all files
int length = 0;
t_namelist *nl;
for (nl = sys_openlist; nl; nl = nl->nl_next)
length = length + strlen(nl->nl_string) + 1;
if((filenames = malloc(length)) != NULL) {
filenames[0] = '\0'; // ensures the memory is an empty string
if (sys_openlist) {
for (nl = sys_openlist; nl; nl = nl->nl_next) {
strcat(filenames,nl->nl_string);
if (nl->nl_next)
strcat(filenames," ");
}
}
//fprintf(stderr,"final list: <%s>\n", filenames);
} else {
error("filelist malloc failed!\n");
return(1);
}
}
sys_vgui("pdtk_check_unique %d %s\n", sys_unique, (filenames ? filenames : "0"));
if (sys_externalschedlib) if (sys_externalschedlib)
return (sys_run_scheduler(sys_externalschedlibname, return (sys_run_scheduler(sys_externalschedlibname,
sys_extraflagsstring)); sys_extraflagsstring));
...@@ -308,8 +334,8 @@ int sys_main(int argc, char **argv) ...@@ -308,8 +334,8 @@ int sys_main(int argc, char **argv)
} }
static char *(usagemessage[]) = { static char *(usagemessage[]) = {
"usage: pd [-flags] [file]...\n", "Usage: pd-l2ork [-flags <value>] [file1 file2 ... filen]\n",
"\naudio configuration flags:\n", "\nAudio configuration flags:\n",
"-r <n> -- specify sample rate\n", "-r <n> -- specify sample rate\n",
"-audioindev ... -- audio in devices; e.g., \"1,3\" for first and third\n", "-audioindev ... -- audio in devices; e.g., \"1,3\" for first and third\n",
"-audiooutdev ... -- audio out devices (same)\n", "-audiooutdev ... -- audio out devices (same)\n",
...@@ -350,7 +376,7 @@ static char *(usagemessage[]) = { ...@@ -350,7 +376,7 @@ static char *(usagemessage[]) = {
#ifdef USEAPI_MMIO #ifdef USEAPI_MMIO
"-mmio -- use MMIO audio API (default for Windows)\n", "-mmio -- use MMIO audio API (default for Windows)\n",
#endif #endif
" (default audio API for this platform: ", API_DEFSTRING, ")\n\n", " (default audio API for this platform: ", API_DEFSTRING, ")\n",
"\nMIDI configuration flags:\n", "\nMIDI configuration flags:\n",
"-midiindev ... -- midi in device list; e.g., \"1,3\" for first and third\n", "-midiindev ... -- midi in device list; e.g., \"1,3\" for first and third\n",
...@@ -364,7 +390,7 @@ static char *(usagemessage[]) = { ...@@ -364,7 +390,7 @@ static char *(usagemessage[]) = {
#endif #endif
"\nother flags:\n", "\nOther flags:\n",
"-path <path> -- add to file search path\n", "-path <path> -- add to file search path\n",
"-nostdpath -- don't search standard (\"extra\") directory\n", "-nostdpath -- don't search standard (\"extra\") directory\n",
"-stdpath -- search standard directory (true by default)\n", "-stdpath -- search standard directory (true by default)\n",
...@@ -395,6 +421,8 @@ static char *(usagemessage[]) = { ...@@ -395,6 +421,8 @@ static char *(usagemessage[]) = {
"-batch -- run off-line as a batch process\n", "-batch -- run off-line as a batch process\n",
"-autopatch -- enable auto-patching new from selected objects\n", "-autopatch -- enable auto-patching new from selected objects\n",
"-k12 -- enable K-12 education mode (requires L2Ork K12 lib)\n", "-k12 -- enable K-12 education mode (requires L2Ork K12 lib)\n",
"-unique -- enable multiple instances (disabled by default)\n",
"\n",
}; };
static void sys_parsedevlist(int *np, int *vecp, int max, char *str) static void sys_parsedevlist(int *np, int *vecp, int max, char *str)
...@@ -788,6 +816,12 @@ int sys_argparse(int argc, char **argv) ...@@ -788,6 +816,12 @@ int sys_argparse(int argc, char **argv)
sys_k12_mode = 1; sys_k12_mode = 1;
argc--; argv++; argc--; argv++;
} }
else if (!strcmp(*argv, "-unique"))
{
sys_unique = 1;
argc -= 1;
argv += 1;
}
else if (!strcmp(*argv, "-guiport") && argc > 1 && else if (!strcmp(*argv, "-guiport") && argc > 1 &&
sscanf(argv[1], "%d", &sys_guisetportnumber) >= 1) sscanf(argv[1], "%d", &sys_guisetportnumber) >= 1)
{ {
......
...@@ -199,8 +199,8 @@ void sys_setvirtualalarm( void); ...@@ -199,8 +199,8 @@ void sys_setvirtualalarm( void);
#define API_SGI 6 #define API_SGI 6
#ifdef __linux__ #ifdef __linux__
#define API_DEFAULT API_OSS #define API_DEFAULT API_ALSA
#define API_DEFSTRING "OSS" #define API_DEFSTRING "ALSA"
#endif #endif
#ifdef MSW #ifdef MSW
#define API_DEFAULT API_MMIO #define API_DEFAULT API_MMIO
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment