On Wed, 25 Jul 2001 13:13:05 -0400
[EMAIL PROTECTED] wrote:
> >Paul, I am trying to use FLTK instead of GTK, but I don't get it to work...
> >It crashed inside X11 functions. I have seen this before, and it always
> >was related to multithreading and FLTK not being threadsafe, but I don't
> >understand how that could be a problem, since I run all fltk stuff in the
> >main thread.
> >
> >main()
> >{
> > ... setup fltk, e.g Fl_Window w(200,200); w.show();
> > laaga_client_t = laaga_open ("myname");
> > ... setup laaga ...
> > laaga_activate (client);
> > Fl::run ();
> > laaga_close (client);
> >}
> >
> >Any suggestions?
>
> send me the client source, and i'll try it out and try to understand
> whats going on.
It is a very simple example, it's your ae_client.c with a slider to control
the gain.
I try this on Debian potato, XFree86 3.3.6
Maarten
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
extern "C"
{
#include <laaga/laaga.h>
}
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Slider.H>
laaga_port_t *my_input_port;
laaga_port_t *my_output_port;
float gain = 1.;
int
process (nframes_t nframes, void *arg)
{
sample_t *out = (sample_t *) laaga_port_get_buffer (my_output_port, nframes);
sample_t *in = (sample_t *) laaga_port_get_buffer (my_input_port, nframes);
memcpy (out, in, sizeof (sample_t) * nframes);
for (unsigned int i = 0; i<nframes; i++)
{
out[i] *= gain;
}
return 0;
}
int
bufsize (nframes_t nframes, void *arg)
{
printf ("the maximum buffer size is now %lu\n", nframes);
return 0;
}
int
srate (nframes_t nframes, void *arg)
{
printf ("the sample rate is now %lu/sec\n", nframes);
return 0;
}
void callback(Fl_Slider* s)
{
gain = s->value();
}
int
main (int argc, char *argv[])
{
Fl_Window w(0,0,100,120);
Fl_Slider s(10,10,20,100);
w.show();
s.callback((Fl_Callback*) callback);
laaga_client_t *client;
if ((client = laaga_client_new ("fltktest")) == 0) {
fprintf (stderr, "laaga server not running?\n");
return 1;
}
laaga_set_process_callback (client, process, 0);
laaga_set_buffer_size_callback (client, bufsize, 0);
laaga_set_sample_rate_callback (client, srate, 0);
printf ("engine sample rate: %lu\n", laaga_get_sample_rate (client));
my_input_port = laaga_port_register (client, "myinput", LAAGA_DEFAULT_AUDIO_TYPE, LaagaPortIsInput, 0);
my_output_port = laaga_port_register (client, "myoutput", LAAGA_DEFAULT_AUDIO_TYPE, LaagaPortIsOutput, 0);
if (laaga_activate (client)) {
fprintf (stderr, "cannot activate client");
}
printf ("client activated\n");
if (laaga_port_connect (client, "ALSA I/O:Input 1", my_input_port->shared->name)) {
fprintf (stderr, "cannot connect input ports\n");
}
if (laaga_port_connect (client, my_output_port->shared->name, "ALSA I/O:Output 1")) {
fprintf (stderr, "cannot connect output ports\n");
}
Fl::run();
printf ("done sleeping, now closing...\n");
laaga_client_close (client);
exit (0);
}