Browse Source

Cleanup

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2353 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 17 years ago
parent
commit
a6860540ea
4 changed files with 71 additions and 54 deletions
  1. +1
    -1
      doxyfile
  2. +16
    -16
      example-clients/metro.c
  3. +33
    -15
      example-clients/simple_client.c
  4. +21
    -22
      example-clients/transport.c

+ 1
- 1
doxyfile View File

@@ -23,7 +23,7 @@ PROJECT_NAME = "Jackdmp"
# This could be handy for archiving the generated documentation or # This could be handy for archiving the generated documentation or
# if some version control system is used. # if some version control system is used.


PROJECT_NUMBER = 0.72
PROJECT_NUMBER = 1.90


# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put. # base path where the generated documentation will be put.


+ 16
- 16
example-clients/metro.c View File

@@ -18,9 +18,9 @@


#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h>
#include <errno.h>
#ifndef WIN32 #ifndef WIN32
#include <unistd.h>
#include <unistd.h>
#endif #endif
#include <math.h> #include <math.h>
#include <signal.h> #include <signal.h>
@@ -269,24 +269,24 @@ main (int argc, char *argv[])
return 1; return 1;
} }
/* install a signal handler to properly quits jack client */
/* install a signal handler to properly quits jack client */
#ifdef WIN32 #ifdef WIN32
signal(SIGINT, signal_handler);
signal(SIGABRT, signal_handler);
signal(SIGTERM, signal_handler);
#else
signal(SIGQUIT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGHUP, signal_handler);
signal(SIGINT, signal_handler);
signal(SIGINT, signal_handler);
signal(SIGABRT, signal_handler);
signal(SIGTERM, signal_handler);
#else
signal(SIGQUIT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGHUP, signal_handler);
signal(SIGINT, signal_handler);
#endif #endif


/* run until interrupted */ /* run until interrupted */
while (1) {
#ifdef WIN32
Sleep(1000);
#else
sleep(1);
while (1) {
#ifdef WIN32
Sleep(1000);
#else
sleep(1);
#endif #endif
}; };


+ 33
- 15
example-clients/simple_client.c View File

@@ -9,7 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include <signal.h>
#include <jack/jack.h> #include <jack/jack.h>


jack_port_t *input_port; jack_port_t *input_port;
@@ -27,15 +27,21 @@ typedef struct
int left_phase; int left_phase;
int right_phase; int right_phase;
} }
paTestData;
static int Jack_Graph_Order_Callback(void *arg)
{
static int reorder = 0;
printf("Jack_Graph_Order_Callback count = %ld\n", reorder++);
return 0;
paTestData;
static void signal_handler(int sig)
{
jack_client_close(client);
fprintf(stderr, "signal received, exiting ...\n");
exit(0);
} }


static int Jack_Graph_Order_Callback(void *arg)
{
static int reorder = 0;
printf("Jack_Graph_Order_Callback count = %ld\n", reorder++);
return 0;
}


/* a simple state machine for this client */ /* a simple state machine for this client */
volatile enum { volatile enum {
@@ -167,11 +173,11 @@ main (int argc, char *argv[])
if ((input_port == NULL) || (output_port1 == NULL) || (output_port2 == NULL)) { if ((input_port == NULL) || (output_port1 == NULL) || (output_port2 == NULL)) {
fprintf(stderr, "no more JACK ports available\n"); fprintf(stderr, "no more JACK ports available\n");
exit (1); exit (1);
}
if (jack_set_graph_order_callback(client, Jack_Graph_Order_Callback, 0) != 0) {
printf("Error when calling Jack_Graph_Order_Callback() !\n");
}
}
if (jack_set_graph_order_callback(client, Jack_Graph_Order_Callback, 0) != 0) {
printf("Error when calling Jack_Graph_Order_Callback() !\n");
}




/* Tell the JACK server that we are ready to roll. Our /* Tell the JACK server that we are ready to roll. Our
@@ -218,8 +224,20 @@ main (int argc, char *argv[])
fprintf (stderr, "cannot connect output ports\n"); fprintf (stderr, "cannot connect output ports\n");
} }


free (ports);
free (ports);
/* install a signal handler to properly quits jack client */
#ifdef WIN32
signal(SIGINT, signal_handler);
signal(SIGABRT, signal_handler);
signal(SIGTERM, signal_handler);
#else
signal(SIGQUIT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGHUP, signal_handler);
signal(SIGINT, signal_handler);
#endif

/* keep running until the transport stops */ /* keep running until the transport stops */


while (client_state != Exit) { while (client_state != Exit) {


+ 21
- 22
example-clients/transport.c View File

@@ -48,7 +48,7 @@ volatile int time_reset = 1; /* true when time values change */
* *
* Runs in the process thread. Realtime, must not wait. * Runs in the process thread. Realtime, must not wait.
*/ */
void timebase(jack_transport_state_t state, jack_nframes_t nframes,
static void timebase(jack_transport_state_t state, jack_nframes_t nframes,
jack_position_t *pos, int new_pos, void *arg) jack_position_t *pos, int new_pos, void *arg)
{ {
double min; /* minutes since frame 0 */ double min; /* minutes since frame 0 */
@@ -108,7 +108,7 @@ void timebase(jack_transport_state_t state, jack_nframes_t nframes,
} }
} }


void jack_shutdown(void *arg)
static void jack_shutdown(void *arg)
{ {
#if defined(RL_READLINE_VERSION) && RL_READLINE_VERSION >= 0x0400 #if defined(RL_READLINE_VERSION) && RL_READLINE_VERSION >= 0x0400
rl_cleanup_after_signal(); rl_cleanup_after_signal();
@@ -117,38 +117,37 @@ void jack_shutdown(void *arg)
exit(1); exit(1);
} }


void signal_handler(int sig)
static void signal_handler(int sig)
{ {
jack_client_close(client); jack_client_close(client);
fprintf(stderr, "signal received, exiting ...\n"); fprintf(stderr, "signal received, exiting ...\n");
exit(0); exit(0);
} }



/* Command functions: see commands[] table following. */ /* Command functions: see commands[] table following. */


void com_activate(char *arg)
static void com_activate(char *arg)
{ {
if (jack_activate(client)) { if (jack_activate(client)) {
fprintf(stderr, "cannot activate client"); fprintf(stderr, "cannot activate client");
} }
} }


void com_deactivate(char *arg)
static void com_deactivate(char *arg)
{ {
if (jack_deactivate(client)) { if (jack_deactivate(client)) {
fprintf(stderr, "cannot deactivate client"); fprintf(stderr, "cannot deactivate client");
} }
} }


void com_exit(char *arg)
static void com_exit(char *arg)
{ {
done = 1; done = 1;
} }


void com_help(char *); /* forward declaration */
static void com_help(char *); /* forward declaration */


void com_locate(char *arg)
static void com_locate(char *arg)
{ {
jack_nframes_t frame = 0; jack_nframes_t frame = 0;


@@ -158,31 +157,31 @@ void com_locate(char *arg)
jack_transport_locate(client, frame); jack_transport_locate(client, frame);
} }


void com_master(char *arg)
static void com_master(char *arg)
{ {
int cond = (*arg != '\0'); int cond = (*arg != '\0');
if (jack_set_timebase_callback(client, cond, timebase, NULL) != 0) if (jack_set_timebase_callback(client, cond, timebase, NULL) != 0)
fprintf(stderr, "Unable to take over timebase.\n"); fprintf(stderr, "Unable to take over timebase.\n");
} }


void com_play(char *arg)
static void com_play(char *arg)
{ {
jack_transport_start(client); jack_transport_start(client);
} }


void com_release(char *arg)
static void com_release(char *arg)
{ {
jack_release_timebase(client); jack_release_timebase(client);
} }


void com_stop(char *arg)
static void com_stop(char *arg)
{ {
jack_transport_stop(client); jack_transport_stop(client);
} }


/* Change the tempo for the entire timeline, not just from the current /* Change the tempo for the entire timeline, not just from the current
* location. */ * location. */
void com_tempo(char *arg)
static void com_tempo(char *arg)
{ {
float tempo = 120.0; float tempo = 120.0;


@@ -194,7 +193,7 @@ void com_tempo(char *arg)
} }


/* Set sync timeout in seconds. */ /* Set sync timeout in seconds. */
void com_timeout(char *arg)
static void com_timeout(char *arg)
{ {
double timeout = 2.0; double timeout = 2.0;


@@ -235,7 +234,7 @@ command_t commands[] = {
{(char *)NULL, (cmd_function_t *)NULL, (char *)NULL } {(char *)NULL, (cmd_function_t *)NULL, (char *)NULL }
}; };
command_t *find_command(char *name)
static command_t *find_command(char *name)
{ {
register int i; register int i;
size_t namelen; size_t namelen;
@@ -258,7 +257,7 @@ command_t *find_command(char *name)
return ((command_t *)NULL); return ((command_t *)NULL);
} }


void com_help(char *arg)
static void com_help(char *arg)
{ {
register int i; register int i;
command_t *cmd; command_t *cmd;
@@ -293,7 +292,7 @@ void com_help(char *arg)
} }
} }


void execute_command(char *line)
static void execute_command(char *line)
{ {
register int i; register int i;
command_t *command; command_t *command;
@@ -331,7 +330,7 @@ void execute_command(char *line)




/* Strip whitespace from the start and end of string. */ /* Strip whitespace from the start and end of string. */
char *stripwhite(char *string)
static char *stripwhite(char *string)
{ {
register char *s, *t; register char *s, *t;


@@ -350,7 +349,7 @@ char *stripwhite(char *string)
return s; return s;
} }
char *dupstr(char *s)
static char *dupstr(char *s)
{ {
char *r = malloc(strlen(s) + 1); char *r = malloc(strlen(s) + 1);
strcpy(r, s); strcpy(r, s);
@@ -358,7 +357,7 @@ char *dupstr(char *s)
} }
/* Readline generator function for command completion. */ /* Readline generator function for command completion. */
char *command_generator (const char *text, int state)
static char *command_generator (const char *text, int state)
{ {
static int list_index, len; static int list_index, len;
char *name; char *name;
@@ -383,7 +382,7 @@ char *command_generator (const char *text, int state)
return (char *) NULL; /* No names matched. */ return (char *) NULL; /* No names matched. */
} }


void command_loop()
static void command_loop()
{ {
char *line, *cmd; char *line, *cmd;
char prompt[32]; char prompt[32];


Loading…
Cancel
Save