Browse Source

[alsa-io] fix signal termination

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@3414 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.117.0
torben 17 years ago
parent
commit
8d20c36965
2 changed files with 26 additions and 10 deletions
  1. +13
    -5
      tools/alsa_in.c
  2. +13
    -5
      tools/alsa_out.c

+ 13
- 5
tools/alsa_in.c View File

@@ -36,6 +36,7 @@ snd_pcm_t *alsa_handle;
int jack_sample_rate;
int jack_buffer_size;

int quit = 0;
double resample_mean = 1.0;
double static_resample_factor = 1.0;

@@ -557,8 +558,7 @@ fprintf(stderr, "usage: alsa_out [options]\n"
void
sigterm_handler( int signal )
{
jack_deactivate( client );
jack_client_close( client );
quit = 1;
}


@@ -721,9 +721,10 @@ int main (int argc, char *argv[]) {
}

signal( SIGTERM, sigterm_handler );
signal( SIGINT, sigterm_handler );

if( verbose ) {
while(1) {
while(!quit) {
usleep(500000);
if( output_new_delay ) {
printf( "delay = %d\n", output_new_delay );
@@ -734,12 +735,19 @@ int main (int argc, char *argv[]) {
} else if( instrument ) {
printf( "# n\tresamp\tdiff\toffseti\tintegral\n");
int n=0;
while(1) {
while(!quit) {
usleep(1000);
printf( "%d\t%f\t%f\t%f\t%f\n", n++, output_resampling_factor, output_diff, output_offset, output_integral );
}
} else {
while(1) sleep(10);
while(!quit)
{
usleep(500000);
if( output_new_delay ) {
printf( "delay = %d\n", output_new_delay );
output_new_delay = 0;
}
}
}

jack_deactivate( client );


+ 13
- 5
tools/alsa_out.c View File

@@ -44,6 +44,7 @@ double *window_array;
int offset_differential_index = 0;

double offset_integral = 0;
int quit = 0;

// ------------------------------------------------------ commandline parameters

@@ -555,8 +556,7 @@ fprintf(stderr, "usage: alsa_out [options]\n"
void
sigterm_handler( int signal )
{
jack_deactivate( client );
jack_client_close( client );
quit = 1;
}


@@ -719,9 +719,10 @@ int main (int argc, char *argv[]) {
}

signal( SIGTERM, sigterm_handler );
signal( SIGINT, sigterm_handler );

if( verbose ) {
while(1) {
while(!quit) {
usleep(500000);
if( output_new_delay ) {
printf( "delay = %d\n", output_new_delay );
@@ -732,12 +733,19 @@ int main (int argc, char *argv[]) {
} else if( instrument ) {
printf( "# n\tresamp\tdiff\toffseti\tintegral\n");
int n=0;
while(1) {
while(!quit) {
usleep(1000);
printf( "%d\t%f\t%f\t%f\t%f\n", n++, output_resampling_factor, output_diff, output_offset, output_integral );
}
} else {
while(1) sleep(10);
while(!quit)
{
usleep(500000);
if( output_new_delay ) {
printf( "delay = %d\n", output_new_delay );
output_new_delay = 0;
}
}
}

jack_deactivate( client );


Loading…
Cancel
Save