[LAD] jack ringbuffer question

Paul Davis paul at linuxaudiosystems.com
Wed Dec 2 02:37:10 UTC 2009


On Tue, Dec 1, 2009 at 9:22 PM, lieven moors <lievenmoors at gmail.com> wrote:

> if( (jack_ringbuffer_read_space( (*arps_jack)[i].rb ) ) ==
>        (sizeof( Arp ) * 2) )
> {
>   jack_ringbuffer_read_advance( (*arps_jack)[i].rb, sizeof(Arp) ) ;
> }

You've just moved the read ptrs, before reading any data. Why did you
check to see if there were 2 Arp structures available, and then skip
one of them?

> if( (jack_ringbuffer_read_space( (*arps_jack)[i].rb ) ) ==
>        sizeof( Arp ) )

this won't return true unless there ONLY one Arp struct to read.

> {
>   jack_ringbuffer_data_t data[2] ;
>   jack_ringbuffer_get_read_vector( (*arps_jack)[i].rb, data ) ;

now you've got a read vector, but *after* you advanced the read ptr.

>   if ( data[0].len > 0 )
>   {
>    arp = reinterpret_cast<Arp*>( data[0].buf ) ;
>    steps = &arp->steps ;
>    scale = &arp->scale ;
>   }
>   else if( data[1].len > 0)
>   {
>    cout << "data in second part of ringbuffer, this should not
>        happen!" <<  endl ;
>   }

now you've used the data from the ringbuffer, but not advanced the read ptr.
if you're going to use get_read_vector() you want to do that first,
then explicitly advanced the read ptr.

not sure if this is all that is going wrong, but this looks odd/wrong
to me as a starting point.



More information about the Linux-audio-dev mailing list