Changeset 366

Show
Ignore:
Timestamp:
02/23/06 20:12:37 (3 years ago)
Author:
conrad
Message:

restructure jack.c a little; add a thread for rendering for remix (currently empty)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • beatfish/trunk/src/jack.c

    r365 r366  
    3434static RemixPCM * pcm = NULL; 
    3535 
     36static const size_t sample_size = sizeof(RemixPCM); 
     37 
     38static pthread_t remix_thread_id = 0; 
     39 
     40/* Synchronization between jack thread and remix thread */ 
     41#define DEFAULT_RB_SIZE 16384  /* ringbuffer size in frames */ 
     42pthread_mutex_t remix_thread_lock = PTHREAD_MUTEX_INITIALIZER; 
     43pthread_cond_t data_ready = PTHREAD_COND_INITIALIZER; 
     44long overruns = 0; 
     45 
     46static const char ** ports; 
     47 
     48void * 
     49remix_thread (void * arg) 
     50{ 
     51  return 0; 
     52} 
     53 
    3654static int 
    37 beatfish_process (jack_nframes_t nframes, void * arg) 
     55process (jack_nframes_t nframes, void * arg) 
    3856{ 
    3957  RemixCount length, offset; 
     
    6684 
    6785static void 
    68 beatfish_shutdown (void * arg) 
     86shutdown (void * arg) 
    6987{ 
    7088  printf ("Beatfish JACK client shut down!\n"); 
     
    7290} 
    7391 
     92static void 
     93setup_remix_thread (void) 
     94{ 
     95  pthread_create (&remix_thread_id, NULL, remix_thread, NULL); 
     96} 
     97 
     98static void 
     99run_remix_thread (void) 
     100{ 
     101  pthread_join (remix_thread_id, NULL); 
     102} 
     103 
    74104void 
    75 setup_jack (char * client_name
     105setup_ports (jack_client_t * client
    76106{ 
    77   jack_client_t * client; 
    78   const char ** ports; 
    79  
    80   if ((client = jack_client_new (client_name)) == 0) { 
    81     fprintf (stderr, "%s: Could not connect to Jack server\n", 
    82              progname); 
    83     exit (1); 
    84   } 
    85  
    86   jack_set_process_callback (client, beatfish_process, 0); 
    87  
    88   jack_on_shutdown (client, beatfish_shutdown, 0); 
    89  
    90   remix_set_samplerate (remix, jack_get_sample_rate(client)); 
    91  
    92   output_port = jack_port_register (client, "output", 
    93                                     JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 
    94                                     0); 
    95  
    96   jack_activate (client); 
    97  
    98107  if ((ports = jack_get_ports (client, NULL, NULL, 
    99108                               JackPortIsPhysical|JackPortIsInput)) == NULL) { 
     
    109118    fprintf (stderr, "Cannot connect output port 1\n"); 
    110119  } 
     120} 
     121 
     122void 
     123setup_jack (char * client_name) 
     124{ 
     125  jack_client_t * client; 
     126 
     127  if ((client = jack_client_new (client_name)) == 0) { 
     128    fprintf (stderr, "%s: Could not connect to Jack server\n", 
     129             progname); 
     130    exit (1); 
     131  } 
     132 
     133  setup_remix_thread (); 
     134 
     135  jack_set_process_callback (client, process, 0); 
     136 
     137  jack_on_shutdown (client, shutdown, 0); 
     138 
     139  remix_set_samplerate (remix, jack_get_sample_rate(client)); 
     140 
     141  output_port = jack_port_register (client, "output", 
     142                                    JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 
     143                                    0); 
     144 
     145  jack_activate (client); 
     146 
     147  setup_ports (client); 
     148 
     149  run_remix_thread (); 
    111150 
    112151  free (ports);