* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <pthread.h>
#include <jack/jack.h>
#include <glib.h>
#include <stdio.h>
#include "lock_free_fifo.h"
#include "plugin.h"
#include "jack_rack.h"
+#include "framework/mlt_log.h"
#ifndef _
#define _(x) x
#endif
+extern pthread_mutex_t g_activate_mutex;
+
#define USEC_PER_SEC 1000000
#define MSEC_PER_SEC 1000
#define TIME_RUN_SKIP_COUNT 5
procinfo->jack_input_buffers[channel] = jack_port_get_buffer (procinfo->jack_input_ports[channel], frames);
if (!procinfo->jack_input_buffers[channel])
{
- fprintf (stderr, "%s: no jack buffer for input port %ld\n", __FUNCTION__, channel);
+ mlt_log_verbose( NULL, "%s: no jack buffer for input port %ld\n", __FUNCTION__, channel);
return 1;
}
procinfo->jack_output_buffers[channel] = jack_port_get_buffer (procinfo->jack_output_ports[channel], frames);
if (!procinfo->jack_output_buffers[channel])
{
- fprintf (stderr, "%s: no jack buffer for output port %ld\n", __FUNCTION__, channel);
+ mlt_log_verbose( NULL, "%s: no jack buffer for output port %ld\n", __FUNCTION__, channel);
return 1;
}
}
}
/* input buffers for first plugin */
- plugin_connect_input_ports (first_enabled, procinfo->jack_input_buffers);
+ if( plugin->desc->has_input )
+ plugin_connect_input_ports (first_enabled, procinfo->jack_input_buffers);
}
void
if (!procinfo)
{
- fprintf (stderr, "%s: no process_info from jack!\n", __FUNCTION__);
+ mlt_log_error( NULL, "%s: no process_info from jack!\n", __FUNCTION__);
return 1;
}
for (channel = 0; channel < procinfo->channels; channel++)
{
- procinfo->jack_input_buffers[channel] = inputs[channel];
- if (!procinfo->jack_input_buffers[channel])
+ if(get_first_enabled_plugin (procinfo)->desc->has_input)
{
- fprintf (stderr, "%s: no jack buffer for input port %ld\n", __FUNCTION__, channel);
- return 1;
+ procinfo->jack_input_buffers[channel] = inputs[channel];
+ if (!procinfo->jack_input_buffers[channel])
+ {
+ mlt_log_verbose( NULL, "%s: no jack buffer for input port %ld\n", __FUNCTION__, channel);
+ return 1;
+ }
}
-
procinfo->jack_output_buffers[channel] = outputs[channel];
if (!procinfo->jack_output_buffers[channel])
{
- fprintf (stderr, "%s: no jack buffer for output port %ld\n", __FUNCTION__, channel);
+ mlt_log_verbose( NULL, "%s: no jack buffer for output port %ld\n", __FUNCTION__, channel);
return 1;
}
}
if (!procinfo)
{
- fprintf (stderr, "%s: no process_info from jack!\n", __FUNCTION__);
+ mlt_log_error( NULL, "%s: no process_info from jack!\n", __FUNCTION__);
return 1;
}
err = get_jack_buffers (procinfo, frames);
if (err)
{
- fprintf(stderr, "%s: failed to get jack ports, not processing\n", __FUNCTION__);
+ mlt_log_warning( NULL, "%s: failed to get jack ports, not processing\n", __FUNCTION__);
return 0;
}
static int
process_info_connect_jack (process_info_t * procinfo)
{
- printf (_("Connecting to JACK server with client name '%s'\n"), procinfo->jack_client_name);
+ mlt_log_info( NULL, _("Connecting to JACK server with client name '%s'\n"), procinfo->jack_client_name);
- procinfo->jack_client = jack_client_new (procinfo->jack_client_name);
+ procinfo->jack_client = jack_client_open (procinfo->jack_client_name, JackNullOption, NULL);
if (!procinfo->jack_client)
{
- fprintf (stderr, "%s: could not create jack client; is the jackd server running?\n", __FUNCTION__);
+ mlt_log_warning( NULL, "%s: could not create jack client; is the jackd server running?\n", __FUNCTION__);
return 1;
}
- printf (_("Connected to JACK server\n"));
+ mlt_log_verbose( NULL, _("Connected to JACK server\n"));
jack_set_process_callback (procinfo->jack_client, process_jack, procinfo);
jack_on_shutdown (procinfo->jack_client, jack_shutdown_cb, procinfo);
full_port_name = g_strdup_printf ("%s:%s", procinfo->jack_client_name, port_name);
- printf (_("Connecting ports '%s' and '%s'\n"), full_port_name, jack_ports[jack_port_index]);
+ mlt_log_debug( NULL, _("Connecting ports '%s' and '%s'\n"), full_port_name, jack_ports[jack_port_index]);
err = jack_connect (procinfo->jack_client,
in ? jack_ports[jack_port_index] : full_port_name,
in ? full_port_name : jack_ports[jack_port_index]);
if (err)
- fprintf (stderr, "%s: error connecting ports '%s' and '%s'\n",
+ mlt_log_warning( NULL, "%s: error connecting ports '%s' and '%s'\n",
__FUNCTION__, full_port_name, jack_ports[jack_port_index]);
else
- printf (_("Connected ports '%s' and '%s'\n"), full_port_name, jack_ports[jack_port_index]);
+ mlt_log_info( NULL, _("Connected ports '%s' and '%s'\n"), full_port_name, jack_ports[jack_port_index]);
free (full_port_name);
}
{
port_name = g_strdup_printf ("%s_%ld", in ? "in" : "out", i + 1);
- //printf (_("Creating %s port %s\n"), in ? "input" : "output", port_name);
+ //mlt_log_debug( NULL, _("Creating %s port %s\n"), in ? "input" : "output", port_name);
port_ptr = (in ? &procinfo->jack_input_ports[i]
: &procinfo->jack_output_ports[i]);
if (!*port_ptr)
{
- fprintf (stderr, "%s: could not register port '%s'; aborting\n",
+ mlt_log_error( NULL, "%s: could not register port '%s'; aborting\n",
__FUNCTION__, port_name);
return 1;
}
- //printf (_("Created %s port %s\n"), in ? "input" : "output", port_name);
+ //mlt_log_debug( NULL, _("Created %s port %s\n"), in ? "input" : "output", port_name);
if ((in && connect_inputs) || (!in && connect_outputs))
process_info_connect_port (procinfo, in, i, port_name);
buffer_size = jack_get_sample_rate (procinfo->jack_client);
jack_set_process_callback (procinfo->jack_client, process_jack, procinfo);
+ pthread_mutex_lock( &g_activate_mutex );
jack_on_shutdown (procinfo->jack_client, jack_shutdown_cb, procinfo);
+ pthread_mutex_unlock( &g_activate_mutex );
jack_activate (procinfo->jack_client);