aboutsummaryrefslogtreecommitdiff
path: root/pd/src/s_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'pd/src/s_main.c')
-rw-r--r--pd/src/s_main.c77
1 files changed, 48 insertions, 29 deletions
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index a1e5af2a..24b5860e 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -25,7 +25,11 @@
#define snprintf sprintf_s
#endif
-char *pd_version;
+
+#define stringify(s) str(s)
+#define str(s) #s
+
+char *pd_version = "Pd-" stringify(PD_MAJOR_VERSION) "." stringify(PD_MINOR_VERSION) "." stringify(PD_BUGFIX_VERSION) " (" stringify(PD_TEST_VERSION) ")";
char pd_compiletime[] = __TIME__;
char pd_compiledate[] = __DATE__;
@@ -61,16 +65,17 @@ int sys_nmidiin = -1;
int sys_midiindevlist[MAXMIDIINDEV] = {1};
int sys_midioutdevlist[MAXMIDIOUTDEV] = {1};
-char sys_font[100] =
#ifdef __APPLE__
- "Monaco";
+char sys_font[100] = "Monaco";
+char sys_fontweight[10] = "normal";
#else
- "Courier";
+char sys_font[100] = "Courier";
+char sys_fontweight[10] = "bold";
#endif
-char sys_fontweight[] = "bold ";
static int sys_main_srate;
static int sys_main_advance;
static int sys_main_callback;
+static int sys_main_blocksize;
static int sys_listplease;
int sys_externalschedlib;
@@ -258,15 +263,6 @@ void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv)
static void sys_afterargparse(void);
-static void pd_makeversion(void)
-{
- char foo[100];
- sprintf(foo, "Pd version %d.%d-%d%s\n",PD_MAJOR_VERSION,
- PD_MINOR_VERSION,PD_BUGFIX_VERSION,PD_TEST_VERSION);
- pd_version = malloc(strlen(foo)+1);
- strcpy(pd_version, foo);
-}
-
/* this is called from main() in s_entry.c */
int sys_main(int argc, char **argv)
{
@@ -290,9 +286,7 @@ int sys_main(int argc, char **argv)
if (sys_argparse(argc-1, argv+1)) /* parse cmd line */
return (1);
sys_afterargparse(); /* post-argparse settings */
- /* build version string from defines in m_pd.h */
- pd_makeversion();
- if (sys_verbose || sys_version) fprintf(stderr, "%scompiled %s %s\n",
+ if (sys_verbose || sys_version) fprintf(stderr, "%s compiled %s %s\n",
pd_version, pd_compiletime, pd_compiledate);
if (sys_version) /* if we were just asked our version, exit here. */
return (0);
@@ -356,6 +350,15 @@ static char *(usagemessage[]) = {
#ifdef USEAPI_MMIO
"-mmio -- use MMIO audio API (default for Windows)\n",
#endif
+
+#ifdef USEAPI_AUDIOUNIT
+"-audiounit -- use Apple AudioUnit API\n",
+#endif
+
+#ifdef USEAPI_ESD
+"-esd -- use Enlightenment Sound Daemon (ESD) API\n",
+#endif
+
" (default audio API for this platform: ", API_DEFSTRING, ")\n\n",
"\nMIDI configuration flags:\n",
@@ -440,20 +443,19 @@ void sys_findprogdir(char *progname)
{
char sbuf[MAXPDSTRING], sbuf2[MAXPDSTRING], *sp;
char *lastslash;
-#ifdef HAVE_UNISTD_H
+#ifndef _WIN32
struct stat statbuf;
-#endif
+#endif /* NOT _WIN32 */
/* find out by what string Pd was invoked; put answer in "sbuf". */
-#ifdef MSW
+#ifdef _WIN32
GetModuleFileName(NULL, sbuf2, sizeof(sbuf2));
sbuf2[MAXPDSTRING-1] = 0;
sys_unbashfilename(sbuf2, sbuf);
-#endif /* MSW */
-#ifdef HAVE_UNISTD_H
+#else
strncpy(sbuf, progname, MAXPDSTRING);
sbuf[MAXPDSTRING-1] = 0;
-#endif
+#endif /* _WIN32 */
lastslash = strrchr(sbuf, '/');
if (lastslash)
{
@@ -483,12 +485,12 @@ void sys_findprogdir(char *progname)
"gui" directory. In "simple" unix installations, the layout is
.../bin/pd
.../bin/pd-watchdog (etc)
- .../tcl/pd-gui.tcl
+ .../bin/pd-gui.tcl
.../doc
and in "complicated" unix installations, it's:
.../bin/pd
.../lib/pd/bin/pd-watchdog
- .../lib/tcl/pd-gui.tcl
+ .../lib/pd/bin/pd-gui.tcl
.../lib/pd/doc
To decide which, we stat .../lib/pd; if that exists, we assume it's
the complicated layout. In MSW, it's the "simple" layout, but
@@ -578,7 +580,7 @@ int sys_argparse(int argc, char **argv)
}
else if (!strcmp(*argv, "-blocksize"))
{
- sys_setblocksize(atoi(argv[1]));
+ sys_main_blocksize = atoi(argv[1]);
argc -= 2; argv += 2;
}
else if (!strcmp(*argv, "-sleepgrain") && (argc > 1))
@@ -657,6 +659,20 @@ int sys_argparse(int argc, char **argv)
argc--; argv++;
}
#endif
+#ifdef USEAPI_AUDIOUNIT
+ else if (!strcmp(*argv, "-audiounit"))
+ {
+ sys_set_audio_api(API_AUDIOUNIT);
+ argc--; argv++;
+ }
+#endif
+#ifdef USEAPI_ESD
+ else if (!strcmp(*argv, "-esd"))
+ {
+ sys_set_audio_api(API_ESD);
+ argc--; argv++;
+ }
+#endif
else if (!strcmp(*argv, "-nomidiin"))
{
sys_nmidiin = 0;
@@ -909,7 +925,7 @@ static void sys_afterargparse(void)
int i;
int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
- int nchindev, nchoutdev, rate, advance, callback;
+ int nchindev, nchoutdev, rate, advance, callback, blocksize;
int nmidiindev = 0, midiindev[MAXMIDIINDEV];
int nmidioutdev = 0, midioutdev[MAXMIDIOUTDEV];
/* add "extra" library to path */
@@ -945,7 +961,8 @@ static void sys_afterargparse(void)
else are the default. Overwrite them with any results
of argument parsing, and store them again. */
sys_get_audio_params(&naudioindev, audioindev, chindev,
- &naudiooutdev, audiooutdev, choutdev, &rate, &advance, &callback);
+ &naudiooutdev, audiooutdev, choutdev, &rate, &advance,
+ &callback, &blocksize);
if (sys_nchin >= 0)
{
nchindev = sys_nchin;
@@ -993,9 +1010,11 @@ static void sys_afterargparse(void)
rate = sys_main_srate;
if (sys_main_callback)
callback = sys_main_callback;
+ if (sys_main_blocksize)
+ blocksize = sys_main_blocksize;
sys_set_audio_settings(naudioindev, audioindev, nchindev, chindev,
naudiooutdev, audiooutdev, nchoutdev, choutdev, rate, advance,
- callback);
+ callback, blocksize);
sys_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev, 0);
}