On Tue, Dec 1, 2009 at 9:22 PM, lieven moors
<lievenmoors(a)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.
I want to repeat the same Arp, until there is an update to the text
file. One arp is allready
loaded in each ringbuffer in main(). When the file is modified, a second
one is added, and
process skips to the second one. Since I have only space for two arps in
the buffer, there
should always be exactly one which is readable. I know it is a bit
weird, but it seems to
work, apart from the problem I described.