crackin with ring buffer

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

crackin with ring buffer

Pierre-Luc Beaudoin-2
Hi,

We implemented a Jack input plugin for VLC.  Here is the code, http://trac.videolan.org/vlc/browser/trunk/modules/access/jack.c

We use a ringbuffer.  Somehow, at line 402, we receive a value which does not divide by the number of speakers.  In our tests, we want to be able to input 8 channels, the call back is callled when i_read equals 8188.  This causes a big quality problem: the samples get mixed from one track to one other, but only for a short time. 

I decided to add this line:

i_read -= i_read % (p_sys->i_channels*p_sys->jack_sample_size);

Which solve the issue of samples on the wrong channel, but now all channels are shifted by minus one channel.

Shouldn't jac_ringbuffer_read_space return a value which can be divided by the number of channels? (meaning that each channels get the same number of samples)?

Thanks for your time,

--
Pierre-Luc Beaudoin
Savoir-faire Linux



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: crackin with ring buffer

Stéphane Letz

Le 21 août 07 à 15:30, Pierre-Luc Beaudoin a écrit :

> Hi,
>
> We implemented a Jack input plugin for VLC.  Here is the code,  
> http://trac.videolan.org/vlc/browser/trunk/modules/access/jack.c
>
> We use a ringbuffer.  Somehow, at line 402, we receive a value  
> which does not divide by the number of speakers.  In our tests, we  
> want to be able to input 8 channels, the call back is callled when  
> i_read equals 8188.  This causes a big quality problem: the samples  
> get mixed from one track to one other, but only for a short time.
>
> I decided to add this line:
>
> i_read -= i_read % (p_sys->i_channels*p_sys->jack_sample_size);
>
> Which solve the issue of samples on the wrong channel, but now all  
> channels are shifted by minus one channel.
>
> Shouldn't jac_ringbuffer_read_space return a value which can be  
> divided by the number of channels? (meaning that each channels get  
> the same number of samples)?
>
> Thanks for your time,
>


I think there is nothing like a "number of channels" notion in a ring  
buffer....: the ring buffer is initialized with a value expressed in  
bytes, and then consumer and producer are supposed to read/write data  
in it. But looking at the Jack input plugin for VLC code, I see a  
strange thing when initializing the ring buffer :

line 173:  p_sys->p_jack_ringbuffer = jack_ringbuffer_create( p_sys-
 >i_channels * jack_get_buffer_size( p_sys->p_jack_client ) * sizeof
( jack_default_audio_sample_t ) );

If I understand correctly, the ring buffer size get the exact value  
the producer (Jack callback) is going to write : this is a going to  
be problematic, if the consumer does not read fast enough. I guess  
the ring buffer  size should be twice this size at least.

HTH,

Stephane Letz
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: crackin with ring buffer

Ed Wildgoose-2
In reply to this post by Pierre-Luc Beaudoin-2
Pierre-Luc Beaudoin wrote:
Hi,

We implemented a Jack input plugin for VLC.  Here is the code, http://trac.videolan.org/vlc/browser/trunk/modules/access/jack.c

Very nice.

Note also that mplayer has a really very nice jack implementation.  I would hold it up as a fairly decent bit of coding if anyone would like a reference implementation of some code...   Worth browsing anyway and you can see their ringbuffer implementation for example

Ed W

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: crackin with ring buffer

Pierre-Luc Beaudoin-2
Thanks,

Stéphane Lets helped me.  He found out that our ring buffer was way too small. 

Le mercredi 22 août 2007 à 17:31 +0100, Ed W a écrit :
Pierre-Luc Beaudoin wrote:
Hi,

We implemented a Jack input plugin for VLC.  Here is the code, http://trac.videolan.org/vlc/browser/trunk/modules/access/jack.c

Very nice.

Note also that mplayer has a really very nice jack implementation.  I would hold it up as a fairly decent bit of coding if anyone would like a reference implementation of some code...   Worth browsing anyway and you can see their ringbuffer implementation for example

Ed W
--
Pierre-Luc Beaudoin
Savoir-faire Linux



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel