diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2008-11-15 21:04:13 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2008-11-15 21:04:13 +0000 |
commit | 9a74509219f0493546b86960058bdcfa17ab42f2 (patch) | |
tree | a75d0ee70687d2d6fb0e88ab108f9a60840b1f0c /recordmydesktop/src | |
parent | f54124e18ec18c7a97db7221e2a2ba23313e5ff4 (diff) |
configure.ac, doc/recordmydesktop.1, src/rmd.c, src/rmd_cache_audio.c, src/rmd_encode_sound_buffer.c,
src/rmd_initialize_data.c, src/rmd_jack.c, src/rmd_jack.h, src/rmd_parseargs.c, src/rmd_threads.c, src/rmd_types.h:
Changed the way Jack support is offered, from dlopening at runtime to normal
linking at compilation.
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@569 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r-- | recordmydesktop/src/rmd.c | 2 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_cache_audio.c | 8 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_encode_sound_buffer.c | 8 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_initialize_data.c | 2 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_jack.c | 124 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_jack.h | 8 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_parseargs.c | 4 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_threads.c | 4 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_types.h | 8 |
9 files changed, 36 insertions, 132 deletions
diff --git a/recordmydesktop/src/rmd.c b/recordmydesktop/src/rmd.c index c88a4c4..ce36a2b 100644 --- a/recordmydesktop/src/rmd.c +++ b/recordmydesktop/src/rmd.c @@ -72,7 +72,7 @@ int main(int argc,char **argv){ else{ EncData enc_data; CacheData cache_data; -#ifdef HAVE_JACK_H +#ifdef HAVE_LIBJACK JackData jdata; // Give jack access to program data, mainly for program state diff --git a/recordmydesktop/src/rmd_cache_audio.c b/recordmydesktop/src/rmd_cache_audio.c index dc2edf3..d31b607 100644 --- a/recordmydesktop/src/rmd_cache_audio.c +++ b/recordmydesktop/src/rmd_cache_audio.c @@ -39,7 +39,7 @@ void *CacheSoundBuffer(ProgData *pdata){ //It's sound is tiny compared to that of image, so //compressing would reducethe overall size by only an //insignificant fraction. -#ifdef HAVE_JACK_H +#ifdef HAVE_LIBJACK void *jackbuf=NULL; if(pdata->args.use_jack){ jackbuf=malloc(pdata->sound_framesize*pdata->jdata->buffersize); @@ -76,10 +76,10 @@ void *CacheSoundBuffer(ProgData *pdata){ free(buff); } else{ -#ifdef HAVE_JACK_H - if((*jack_ringbuffer_read_space_p)(pdata->jdata->sound_buffer)>= +#ifdef HAVE_LIBJACK + if((*jack_ringbuffer_read_space)(pdata->jdata->sound_buffer)>= (pdata->sound_framesize*pdata->jdata->buffersize)){ - (*jack_ringbuffer_read_p)(pdata->jdata->sound_buffer, + (*jack_ringbuffer_read)(pdata->jdata->sound_buffer, jackbuf, (pdata->sound_framesize* pdata->jdata->buffersize)); diff --git a/recordmydesktop/src/rmd_encode_sound_buffer.c b/recordmydesktop/src/rmd_encode_sound_buffer.c index 3f67d40..4a04d71 100644 --- a/recordmydesktop/src/rmd_encode_sound_buffer.c +++ b/recordmydesktop/src/rmd_encode_sound_buffer.c @@ -36,7 +36,7 @@ void *EncodeSoundBuffer(ProgData *pdata){ int sampread=pdata->periodsize; -#ifdef HAVE_JACK_H +#ifdef HAVE_LIBJACK void *jackbuf=NULL; if(pdata->args.use_jack){ jackbuf=malloc(pdata->sound_framesize*pdata->jdata->buffersize); @@ -85,10 +85,10 @@ void *EncodeSoundBuffer(ProgData *pdata){ free(buff); } else{ -#ifdef HAVE_JACK_H - if((*jack_ringbuffer_read_space_p)(pdata->jdata->sound_buffer)>= +#ifdef HAVE_LIBJACK + if((*jack_ringbuffer_read_space)(pdata->jdata->sound_buffer)>= (pdata->sound_framesize*pdata->jdata->buffersize)){ - (*jack_ringbuffer_read_p)(pdata->jdata->sound_buffer, + (*jack_ringbuffer_read)(pdata->jdata->sound_buffer, jackbuf, (pdata->sound_framesize* pdata->jdata->buffersize)); diff --git a/recordmydesktop/src/rmd_initialize_data.c b/recordmydesktop/src/rmd_initialize_data.c index 5ec8bc3..7451866 100644 --- a/recordmydesktop/src/rmd_initialize_data.c +++ b/recordmydesktop/src/rmd_initialize_data.c @@ -138,7 +138,7 @@ int InitializeData(ProgData *pdata, } } else{ -#ifdef HAVE_JACK_H +#ifdef HAVE_LIBJACK int jack_error=0; pdata->jdata->port_names=pdata->args.jack_port_names; pdata->jdata->nports=pdata->args.jack_nports; diff --git a/recordmydesktop/src/rmd_jack.c b/recordmydesktop/src/rmd_jack.c index 7ace370..9236ad4 100644 --- a/recordmydesktop/src/rmd_jack.c +++ b/recordmydesktop/src/rmd_jack.c @@ -33,53 +33,7 @@ #include "rmd_jack.h" -#ifdef HAVE_JACK_H - - -#define CHECK_DLERRORS_FATAL(__error_p)\ - if((__error_p=dlerror())!=NULL){\ - fprintf(stderr,"%s\n",__error_p);\ - return 1;\ - } - -#define DLSYM_AND_CHECK(lib_handle,__call_name__,__error_p)\ - __call_name__##_p=dlsym(lib_handle,#__call_name__);\ - CHECK_DLERRORS_FATAL(__error_p) - - -/** -* -* Fuction Pointers To Jack API Calls (shouldn't a jack header provide these?) -* -*/ -jack_client_t *(*jack_client_new_p)(const char *client_name); -jack_nframes_t (*jack_get_sample_rate_p)(jack_client_t * client); -int (*jack_set_buffer_size_p)(jack_client_t *client, jack_nframes_t nframes); -jack_nframes_t (*jack_get_buffer_size_p)(jack_client_t *client); -int (*jack_set_process_callback_p)(jack_client_t *client, - JackProcessCallback process_callback, - void *arg); -void (*jack_on_shutdown_p)(jack_client_t *client, - void(*function)(void *arg), - void *arg); -int (*jack_activate_p)(jack_client_t *client); -int (*jack_client_close_p)(jack_client_t *client); -void *(*jack_port_get_buffer_p)(jack_port_t *port,jack_nframes_t); -jack_port_t *(*jack_port_register_p)(jack_client_t *client, - const char *port_name, - const char *port_type, - unsigned long flags, - unsigned long buffer_size); -int (*jack_connect_p)(jack_client_t *client, - const char *source_port, - const char *destination_port); -const char *(*jack_port_name_p)(const jack_port_t *port); -int (*jack_port_name_size_p)(void); -jack_ringbuffer_t *(*jack_ringbuffer_create_p)(size_t sz); -void (*jack_ringbuffer_free_p)(jack_ringbuffer_t *rb); -size_t (*jack_ringbuffer_write_p)(jack_ringbuffer_t *rb, - const char *src, - size_t cnt); +#ifdef HAVE_LIBJACK /** @@ -101,12 +55,12 @@ static int JackCapture(jack_nframes_t nframes,void *jdata_t) { } for(i= 0;i<jdata->nports;i++) - jdata->portbuf[i]=jack_port_get_buffer_p(jdata->ports[i],nframes); + jdata->portbuf[i]=jack_port_get_buffer(jdata->ports[i],nframes); //vorbis analysis buffer wants uninterleaved data //so we are simply placing the buffers for every channel //sequentially on the ringbuffer for(i=0;i<jdata->nports;i++) - (*jack_ringbuffer_write_p)(jdata->sound_buffer, + (*jack_ringbuffer_write)(jdata->sound_buffer, (void *)(jdata->portbuf[i]), nframes* sizeof(jack_default_audio_sample_t)); @@ -148,7 +102,7 @@ static int SetupPorts(JackData *jdata) { strcpy(name,"input_"); snprintf( num, 8, "%d", i+1 ); strcat(name,num); - if((jdata->ports[i]=jack_port_register_p(jdata->client, + if((jdata->ports[i]=jack_port_register(jdata->client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, @@ -156,11 +110,11 @@ static int SetupPorts(JackData *jdata) { fprintf(stderr,"Cannot register input port \"%s\"!\n",name); return 1; } - if(jack_connect_p(jdata->client, + if(jack_connect(jdata->client, jdata->port_names[i], - jack_port_name_p(jdata->ports[i]))){ + jack_port_name(jdata->ports[i]))){ fprintf(stderr,"Cannot connect input port %s to %s\n", - jack_port_name_p(jdata->ports[i]), + jack_port_name(jdata->ports[i]), jdata->port_names[i]); return 1; } @@ -168,46 +122,6 @@ static int SetupPorts(JackData *jdata) { return 0; } -/** -* dlopen libjack and dlsym all needed functions -* -* \param jack_lib_handle Pointer to handle for jack library -* -* \returns 0 on Success, 1 on failure -*/ -static int LoadJackLib(void *jack_lib_handle) { - char *error; - jack_lib_handle=dlopen("libjack.so",RTLD_LAZY); - if(!jack_lib_handle){ - fprintf(stderr,"%s\n",dlerror()); - return 1; - } - if((error=dlerror())!=NULL){ - fprintf(stderr,"%s\n",dlerror()); - } -//this macro will call return with status 1 on failure - DLSYM_AND_CHECK(jack_lib_handle,jack_client_new,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_get_sample_rate,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_set_buffer_size,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_get_buffer_size,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_set_process_callback,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_on_shutdown,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_activate,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_client_close,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_port_get_buffer,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_port_register,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_connect,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_port_name,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_port_name_size,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_ringbuffer_create,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_ringbuffer_free,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_ringbuffer_read,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_ringbuffer_read_space,error) - DLSYM_AND_CHECK(jack_lib_handle,jack_ringbuffer_write,error) - - return 0; -} - //in case the jack server shuts down //the program should stop recording, //encode the result(if not on the fly) @@ -236,11 +150,7 @@ int StartJackClient(JackData *jdata){ snprintf( pidbuf, 8, "%d", pid ); strcat(rmd_client_name,pidbuf); - if(LoadJackLib(jdata->jack_lib_handle)){ - fprintf (stderr,"Couldn't load the Jack library (libjack.so)!\n"); - return 14; - } - if ((jdata->client=(*jack_client_new_p)(rmd_client_name))==0){ + if ((jdata->client=(*jack_client_new)(rmd_client_name))==0){ fprintf(stderr,"Could not create new client!\n" "Make sure that Jack server is running!\n"); return 15; @@ -258,23 +168,23 @@ int StartJackClient(JackData *jdata){ //(it might be in some cases, but it will certainly be the cause //of unpredicted problems). A clean exit is preferable //and any recording up to that point will be encoded and saved. - jdata->frequency=jack_get_sample_rate_p(jdata->client); - jdata->buffersize=jack_get_buffer_size_p(jdata->client); + jdata->frequency=jack_get_sample_rate(jdata->client); + jdata->buffersize=jack_get_buffer_size(jdata->client); ring_buffer_size=(jdata->ringbuffer_secs* jdata->frequency* sizeof(jack_default_audio_sample_t)* jdata->nports); jdata->sound_buffer= - (*jack_ringbuffer_create_p)((int)(ring_buffer_size+0.5));//round up - jack_set_process_callback_p(jdata->client,JackCapture,jdata); - jack_on_shutdown_p(jdata->client,JackShutdown,jdata); + (*jack_ringbuffer_create)((int)(ring_buffer_size+0.5));//round up + jack_set_process_callback(jdata->client,JackCapture,jdata); + jack_on_shutdown(jdata->client,JackShutdown,jdata); - if (jack_activate_p(jdata->client)) { + if (jack_activate(jdata->client)) { fprintf(stderr,"cannot activate client!\n"); return 16; } if(SetupPorts(jdata)){ - jack_client_close_p(jdata->client); + jack_client_close(jdata->client); return 17; } @@ -284,8 +194,8 @@ int StartJackClient(JackData *jdata){ int StopJackClient(JackData *jdata){ int ret=0; - (*jack_ringbuffer_free_p)(jdata->sound_buffer); - if(jack_client_close_p(jdata->client)){ + (*jack_ringbuffer_free)(jdata->sound_buffer); + if(jack_client_close(jdata->client)){ fprintf(stderr,"Cannot close Jack client!\n"); ret=1; } diff --git a/recordmydesktop/src/rmd_jack.h b/recordmydesktop/src/rmd_jack.h index 55d8991..e322cba 100644 --- a/recordmydesktop/src/rmd_jack.h +++ b/recordmydesktop/src/rmd_jack.h @@ -30,14 +30,10 @@ #include "rmd_types.h" -#ifdef HAVE_JACK_H - -size_t (*jack_ringbuffer_read_p)(jack_ringbuffer_t *rb, - char *dest, size_t cnt); -size_t (*jack_ringbuffer_read_space_p)(const jack_ringbuffer_t *rb); +#ifdef HAVE_LIBJACK /** -* Load libjack, create and activate client,register ports +* create and activate client,register ports * * \param jdata_t Pointer to JackData struct containing port * and client information diff --git a/recordmydesktop/src/rmd_parseargs.c b/recordmydesktop/src/rmd_parseargs.c index aff752e..758f515 100644 --- a/recordmydesktop/src/rmd_parseargs.c +++ b/recordmydesktop/src/rmd_parseargs.c @@ -34,7 +34,7 @@ static void PrintConfig(void) { fprintf(stderr,"\nrecordMyDesktop was compiled with" " the following options:\n\n"); -#ifdef HAVE_JACK_H +#ifdef HAVE_LIBJACK fprintf(stdout,"Jack\t\t\t:Enabled\n"); #else fprintf(stdout,"Jack\t\t\t:Disabled\n"); @@ -489,7 +489,7 @@ boolean ParseArgs(int argc, char **argv, ProgArgs *arg_return) { else if (strcmp(argv[i], "--use-jack") == 0 || strcmp(argv[i], "-use-jack") == 0) { if(i+1<argc){ -#ifdef HAVE_JACK_H +#ifdef HAVE_LIBJACK int k=i+1; arg_return->jack_nports=0; while((k<argc)&&(argv[k][0]!='-')){ diff --git a/recordmydesktop/src/rmd_threads.c b/recordmydesktop/src/rmd_threads.c index f500384..b658a49 100644 --- a/recordmydesktop/src/rmd_threads.c +++ b/recordmydesktop/src/rmd_threads.c @@ -107,7 +107,7 @@ void rmdThreads(ProgData *pdata){ (void *)rmdTimer, (void *)pdata); fprintf(stderr,"Capturing!\n"); -#ifdef HAVE_JACK_H +#ifdef HAVE_LIBJACK if(pdata->args.use_jack){ pdata->jdata->capture_started=1; } @@ -132,7 +132,7 @@ void rmdThreads(ProgData *pdata){ fprintf(stderr,"."); if(!pdata->args.nosound){ -#ifdef HAVE_JACK_H +#ifdef HAVE_LIBJACK if(pdata->args.use_jack) StopJackClient(pdata->jdata); #endif diff --git a/recordmydesktop/src/rmd_types.h b/recordmydesktop/src/rmd_types.h index 601cfa0..404a495 100644 --- a/recordmydesktop/src/rmd_types.h +++ b/recordmydesktop/src/rmd_types.h @@ -46,10 +46,9 @@ #define DEFAULT_AUDIO_DEVICE "/dev/dsp" #endif -#ifdef HAVE_JACK_H +#ifdef HAVE_LIBJACK #include <jack/jack.h> #include <jack/ringbuffer.h> - #include <dlfcn.h> #endif @@ -223,10 +222,9 @@ typedef struct _SndBuffer{ struct _SndBuffer *next; }SndBuffer; -#ifdef HAVE_JACK_H +#ifdef HAVE_LIBJACK typedef struct _JackData{ ProgData *pdata; //pointer to prog data - void *jack_lib_handle; //handle for jack library (loaded with dlopen). jack_client_t *client; unsigned int buffersize, //buffer size for every port in frames. frequency, //samplerate with which jack server was started. @@ -264,7 +262,7 @@ struct _ProgData { CacheData *cache_data; HotKey pause_key, //Shortcuts stop_key; -#ifdef HAVE_JACK_H +#ifdef HAVE_LIBJACK JackData *jdata; #endif /**X related info*/ |