Changeset 366
- Timestamp:
- 02/23/06 20:12:37 (6 years ago)
- Files:
-
- beatfish/trunk/src/jack.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
beatfish/trunk/src/jack.c
r365 r366 34 34 static RemixPCM * pcm = NULL; 35 35 36 static const size_t sample_size = sizeof(RemixPCM); 37 38 static 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 */ 42 pthread_mutex_t remix_thread_lock = PTHREAD_MUTEX_INITIALIZER; 43 pthread_cond_t data_ready = PTHREAD_COND_INITIALIZER; 44 long overruns = 0; 45 46 static const char ** ports; 47 48 void * 49 remix_thread (void * arg) 50 { 51 return 0; 52 } 53 36 54 static int 37 beatfish_process (jack_nframes_t nframes, void * arg)55 process (jack_nframes_t nframes, void * arg) 38 56 { 39 57 RemixCount length, offset; … … 66 84 67 85 static void 68 beatfish_shutdown (void * arg)86 shutdown (void * arg) 69 87 { 70 88 printf ("Beatfish JACK client shut down!\n"); … … 72 90 } 73 91 92 static void 93 setup_remix_thread (void) 94 { 95 pthread_create (&remix_thread_id, NULL, remix_thread, NULL); 96 } 97 98 static void 99 run_remix_thread (void) 100 { 101 pthread_join (remix_thread_id, NULL); 102 } 103 74 104 void 75 setup_ jack (char * client_name)105 setup_ports (jack_client_t * client) 76 106 { 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 98 107 if ((ports = jack_get_ports (client, NULL, NULL, 99 108 JackPortIsPhysical|JackPortIsInput)) == NULL) { … … 109 118 fprintf (stderr, "Cannot connect output port 1\n"); 110 119 } 120 } 121 122 void 123 setup_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 (); 111 150 112 151 free (ports);
