summaryrefslogtreecommitdiff
path: root/recordmydesktop/src/rmd_jack.c
diff options
context:
space:
mode:
authorenselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-09-11 19:26:27 +0000
committerenselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-09-11 19:26:27 +0000
commit7487ea601384016ed6185e9083ea3e0d1b71fa46 (patch)
tree96ae8bc30fb07f7b06372c2780eeb2671af24e02 /recordmydesktop/src/rmd_jack.c
parentf635b1be3ea9c3a3892936e95e9306b121d1bb5e (diff)
Started working towards a more clean include hierarchy and
distinguishable program modules. First step: move stuff from global headers that is only used in one source file to those source files. include/rmdfunc.h include/rmdmacro.h include/rmdtypes.h: Move stuff from here src/rmd_jack.c src/get_frame.c src/rmd_cache.c src/load_cache.c src/rectinsert.c src/cache_frame.c src/poll_events.c src/setbrwindow.c src/recordmydesktop.c: To here. git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@508 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/src/rmd_jack.c')
-rw-r--r--recordmydesktop/src/rmd_jack.c80
1 files changed, 77 insertions, 3 deletions
diff --git a/recordmydesktop/src/rmd_jack.c b/recordmydesktop/src/rmd_jack.c
index 05bcf1a..aacb883 100644
--- a/recordmydesktop/src/rmd_jack.c
+++ b/recordmydesktop/src/rmd_jack.c
@@ -28,7 +28,65 @@
#include <recordmydesktop.h>
#ifdef HAVE_JACK_H
-int JackCapture(jack_nframes_t nframes,void *jdata_t){
+
+
+#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);
+
+
+/**
+* Callback for capture through jack
+*
+* \param nframes Number of frames captured
+*
+* \param jdata_t Pointer to JackData struct containing port
+* and client information
+*
+* \returns Zero always
+*/
+static int JackCapture(jack_nframes_t nframes,void *jdata_t) {
int i=0;
JackData *jdata=(JackData *)jdata_t;
@@ -59,7 +117,15 @@ int JackCapture(jack_nframes_t nframes,void *jdata_t){
return 0;
}
-int SetupPorts(JackData *jdata){
+/**
+* Register and Activate specified ports
+*
+* \param jdata_t Pointer to JackData struct containing port
+* and client information
+*
+* \returns 0 on Success, 1 on failure
+*/
+static int SetupPorts(JackData *jdata) {
int i=0;
jdata->ports=malloc(sizeof(jack_port_t *)*
jdata->nports);
@@ -94,7 +160,14 @@ int SetupPorts(JackData *jdata){
return 0;
}
-int LoadJackLib(void *jack_lib_handle){
+/**
+* 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){
@@ -126,6 +199,7 @@ int LoadJackLib(void *jack_lib_handle){
return 0;
}
+
//in case the jack server shuts down
//the program should stop recording,
//encode the result(if not on the fly)
© All Rights Reserved