Re: Help with writing jack client

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Help with writing jack client

Gavin Band
Hi

> >
> > int jackProcess( jack_nframes_t nframes, void* arg )
> > {
> > if( nframes > bufferSize )
> > nframes = bufferSize;
> >
> > // sound processing occurs here, it puts nframes samples
> > // into outBufferL and outBufferR
> >
> > sample_t* outR = ( sample_t * )
> >     jack_port_get_buffer( outputPortRight, nframes );
> > sample_t* outL = ( sample_t * )
> >        jack_port_get_buffer( outputPortLeft, nframes );
> >
> > memcpy( outL, outBufferL, sizeof (sample_t) * nframes );
> > memcpy( outR, outBufferR, sizeof (sample_t) * nframes );
> >
> > return 0;
> > }
>
> Why
>
> > if( nframes > bufferSize ) nframes = bufferSize;
>
> ???
>
> You *have to* deliver 'nframes' frames. Not negociable AFAIK.
> This means also that you could as well move up the get_buffer
> calls and write directly to these pointers, dumping the
> intermediate buffers.

Yes...except that internal processing is currently done with ints, not
floats, for legacy reasons, so that there are seperate buffers anyway.  

> I wonder, if bufferSize < nframes, you would not fill up
> jack's buffers. If any NaN or Inf are left there, that
> would generate trouble.

I see.  Well, originally this comparison was to prevent me from
overrunning my own buffers (which are statically allocated).  Looking at
my code, it doesn't seem necessary now.  Currently I am getting the
value of bufferSize like this:

bufferSize = jack_get_buffer_size( client );

in my jack initialisation routine.  Is it possible that (nframes >
bufferSize) in my process callback?

(I don't think the buffer_size_callback is being called by jack because
my callback prints a debug statement which I didn't see.)

> That is indeed the strange part of this problem. Normally when
> a non-behaving app gets kicked out, jackd manages to get on with
> life. This caused me to believe you were writing outside the
> buffers or something similar, but your memcpy() seems to exclude
> that.
>

Hmm.  Ok, well I will have another bash at testing it soon and see if I
can delve a bit deeper.  

Thanks again for your help,
Gavin Band.




-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel