Changeset 363

Show
Ignore:
Timestamp:
02/23/06 19:31:01 (3 years ago)
Author:
conrad
Message:

split jack functionality out into separate jack.c

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • beatfish/trunk/src/Makefile.am

    r346 r363  
    77 
    88beatfish_SOURCES = \ 
    9         beatfish.h beatfish.c evas_software_x11_main.c 
     9        beatfish.h beatfish.c evas_software_x11_main.c jack.c 
    1010 
    1111beatfish_LDADD = @REMIX_LIBS@ @JACK_LIBS@ -lX11 @EVAS_LIBS@ 
    1212 
    1313beatfish_gtk_SOURCES = \ 
    14         beatfish.h beatfish.c evas_software_gtk2_main.c 
     14        beatfish.h beatfish.c evas_software_gtk2_main.c jack.c 
    1515 
    1616beatfish_gtk_LDADD = @REMIX_LIBS@ @JACK_LIBS@ @EVAS_LIBS@ @GTK2_LIBS@ 
  • beatfish/trunk/src/beatfish.c

    r347 r363  
    1919#include <pthread.h> 
    2020#include <remix/remix.h> 
    21 #include <jack/jack.h> 
    2221 
    2322/* for getpid() */ 
     
    5150#define FONT_SIZE 12 
    5251 
    53 static pthread_mutex_t render_lock = PTHREAD_MUTEX_INITIALIZER; 
     52pthread_mutex_t render_lock = PTHREAD_MUTEX_INITIALIZER; 
    5453 
    5554typedef void (*Evas_Event_Callback) (void *data, Evas *e, Evas_Object *obj, void *event_info); 
    5655 
    57 static char * progname = "Beatfish"; 
     56char * progname = "Beatfish"; 
    5857 
    5958Evas *evas = NULL; 
     
    984983} 
    985984 
    986 jack_port_t * output_port; 
    987 RemixStream * output_stream = NULL; 
    988 static jack_nframes_t last_nframes = 0; 
    989 static RemixPCM * last_pcm = NULL; 
    990 static RemixPCM * pcm = NULL; 
    991  
    992 int 
    993 beatfish_process (jack_nframes_t nframes, void * arg) 
    994 { 
    995   RemixCount length, offset; 
    996    
    997   pcm = (RemixPCM *) jack_port_get_buffer (output_port, nframes); 
    998  
    999   pthread_mutex_lock (&render_lock); 
    1000  
    1001   length = remix_length (remix, mix_deck); 
    1002   offset = remix_tell (remix, mix_deck); 
    1003  
    1004   if (offset > length) { 
    1005     remix_seek (remix, mix_deck, 0, SEEK_SET); 
    1006   } 
    1007  
    1008   if ((last_nframes != nframes) || (last_pcm != pcm)) { 
    1009     output_stream = remix_stream_new_from_buffers (remix, nframes, &pcm); 
    1010     last_nframes = nframes; 
    1011     last_pcm = pcm; 
    1012   } else { 
    1013     remix_seek (remix, output_stream, 0, SEEK_SET); 
    1014   } 
    1015  
    1016   remix_process (remix, mix_deck, nframes, RemixNone, output_stream); 
    1017  
    1018   pthread_mutex_unlock (&render_lock); 
    1019  
    1020   return 0; 
    1021 } 
    1022  
    1023 void 
    1024 beatfish_shutdown (void * arg) 
    1025 { 
    1026   printf ("Beatfish JACK client shut down!\n"); 
    1027   exit (1); 
    1028 } 
    1029  
    1030 void 
    1031 setup_jack (char * client_name) 
    1032 { 
    1033   jack_client_t * client; 
    1034   const char ** ports; 
    1035  
    1036   if ((client = jack_client_new (client_name)) == 0) { 
    1037     fprintf (stderr, "%s: Could not connect to Jack server\n", 
    1038              progname); 
    1039     exit (1); 
    1040   } 
    1041  
    1042   jack_set_process_callback (client, beatfish_process, 0); 
    1043  
    1044   jack_on_shutdown (client, beatfish_shutdown, 0); 
    1045  
    1046   remix_set_samplerate (remix, jack_get_sample_rate(client)); 
    1047  
    1048   output_port = jack_port_register (client, "output", 
    1049                                     JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 
    1050                                     0); 
    1051  
    1052   jack_activate (client); 
    1053  
    1054   if ((ports = jack_get_ports (client, NULL, NULL, 
    1055                                JackPortIsPhysical|JackPortIsInput)) == NULL) { 
    1056     fprintf (stderr, "Cannot find any physical playback ports\n"); 
    1057     exit (1); 
    1058   } 
    1059  
    1060   if (jack_connect (client, jack_port_name (output_port), ports[0])) { 
    1061     fprintf (stderr, "Cannot connect output ports\n"); 
    1062   } 
    1063  
    1064   free (ports); 
    1065 } 
    1066  
    1067985void 
    1068986setup (void) 
  • beatfish/trunk/src/beatfish.h

    r331 r363  
    3838void update_cursor (void); 
    3939 
     40void setup_jack (char * client_name); 
    4041 
    4142#ifdef __cplusplus