* Reading alsa midi-data inside the jack client process thread
@ 2005-07-08 10:36 Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no>
2005-07-08 11:42 ` Alfons Adriaensen
2005-07-08 13:57 ` Clemens Ladisch
0 siblings, 2 replies; 7+ messages in thread
From: Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> @ 2005-07-08 10:36 UTC (permalink / raw)
To: jackit-devel, alsa-devel
Is this legal (ie. non-blocking)?
int process (jack_nframes_t nframes, void *arg){
snd_seq_event_t *event;
if(snd_seq_event_input_pending(seq,1)){
snd_seq_event_input(seq, &event);
....
}
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: Reading alsa midi-data inside the jack client process thread 2005-07-08 10:36 Reading alsa midi-data inside the jack client process thread Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> @ 2005-07-08 11:42 ` Alfons Adriaensen 2005-07-08 12:30 ` [Jackit-devel] " Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> 2005-07-08 13:57 ` Clemens Ladisch 1 sibling, 1 reply; 7+ messages in thread From: Alfons Adriaensen @ 2005-07-08 11:42 UTC (permalink / raw) To: Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> Cc: jackit-devel, alsa-devel On Fri, Jul 08, 2005 at 12:36:40PM +0200, Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> wrote: > Is this legal (ie. non-blocking)? > > int process (jack_nframes_t nframes, void *arg){ > snd_seq_event_t *event; > if(snd_seq_event_input_pending(seq,1)){ > snd_seq_event_input(seq, &event); Don't have the sources at hand here, but ISTR that what I do in Aeolus is something like: if (snd_seq_event_input_pending (seq,1)) { do { snd_seq_event_input(seq, &event); ... } while (snd_seq_event_input_pending (seq,0)); } It has never blocked AFAICT. It may not be the best method if you use very short periods - a separate MIDI thread linked with a lock-free ringbuffer is to be preferred in that case. -- FA ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Jackit-devel] Reading alsa midi-data inside the jack client process thread 2005-07-08 11:42 ` Alfons Adriaensen @ 2005-07-08 12:30 ` Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> 2005-07-08 15:11 ` Alfons Adriaensen 2005-07-08 17:34 ` [Jackit-devel] " fons adriaensen 0 siblings, 2 replies; 7+ messages in thread From: Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> @ 2005-07-08 12:30 UTC (permalink / raw) To: Alfons Adriaensen; +Cc: Kjetil Svalastog Matheussen, jackit-devel, alsa-devel > On Fri, Jul 08, 2005 at 12:36:40PM +0200, Kjetil Svalastog Matheussen > <k.s.matheussen@notam02.no> wrote: > >> Is this legal (ie. non-blocking)? >> >> int process (jack_nframes_t nframes, void *arg){ >> snd_seq_event_t *event; >> if(snd_seq_event_input_pending(seq,1)){ >> snd_seq_event_input(seq, &event); > > > Don't have the sources at hand here, but ISTR that > what I do in Aeolus is something like: > > > if (snd_seq_event_input_pending (seq,1)) > { > do > { > snd_seq_event_input(seq, &event); > ... > } > while (snd_seq_event_input_pending (seq,0)); > } > > Thanks, reading your source, thats correct. (But I don't understand what the fetch_sequencer argument for snd_seq_event_input_pending does though: http://www.alsa-project.org/alsa-doc/alsa-lib/group___seq_event.html#a7 ) I also wonder whats the difference between your code above and this: if (snd_seq_event_input_pending (seq,1)) { while(snd_seq_event_input(seq,&event); .... } } which I think should do the same... Guess I just have to read the source. :-) ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Jackit-devel] Reading alsa midi-data inside the jack client process thread 2005-07-08 12:30 ` [Jackit-devel] " Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> @ 2005-07-08 15:11 ` Alfons Adriaensen 2005-07-08 16:26 ` Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> 2005-07-08 17:34 ` [Jackit-devel] " fons adriaensen 1 sibling, 1 reply; 7+ messages in thread From: Alfons Adriaensen @ 2005-07-08 15:11 UTC (permalink / raw) To: Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> Cc: jackit-devel, alsa-devel On Fri, Jul 08, 2005 at 02:30:27PM +0200, Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> wrote: > Thanks, reading your source, thats correct. (But I don't understand what > the fetch_sequencer argument for snd_seq_event_input_pending does though: > IIRC, if the second argument of snd_seq_event_input_pending () is 1, it will do a transfer of all available MIDI data from a system space buffer to user space. If it is zero, it examines only the user space buffer. > I also wonder whats the difference between your code above and this: > > if (snd_seq_event_input_pending (seq,1)) { > while(snd_seq_event_input(seq,&event); > .... > } > } The code as in Aeolus will do one system to user space transfer only, while if you put your code into a loop, it will do this every time. The rationale for doing it only once is that 1. it's a system call, and probably relatively expensive, 2. in the short time required to handle the MIDI events arrived during the past period, it is unlikely that anything new will arrive anyway. Point 1. is why you'd probably prefer a separate thread if your period size could be very small (64, 32, 16). The minimum for Aeolus is 64 anyway, so I didn't bother. This will change in the next release, which will handle OSC as well. -- FA ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Reading alsa midi-data inside the jack client process thread 2005-07-08 15:11 ` Alfons Adriaensen @ 2005-07-08 16:26 ` Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> 0 siblings, 0 replies; 7+ messages in thread From: Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> @ 2005-07-08 16:26 UTC (permalink / raw) To: Alfons Adriaensen; +Cc: Kjetil Svalastog Matheussen, jackit-devel, alsa-devel > On Fri, Jul 08, 2005 at 02:30:27PM +0200, Kjetil Svalastog Matheussen > <k.s.matheussen@notam02.no> wrote: > >> Thanks, reading your source, thats correct. (But I don't understand what >> the fetch_sequencer argument for snd_seq_event_input_pending does >> though: >> > > IIRC, if the second argument of snd_seq_event_input_pending () is > 1, it will do a transfer of all available MIDI data from a system > space buffer to user space. If it is zero, it examines only the user > space buffer. > >> I also wonder whats the difference between your code above and this: >> >> if (snd_seq_event_input_pending (seq,1)) { >> while(snd_seq_event_input(seq,&event); >> .... >> } >> } > > The code as in Aeolus will do one system to user space transfer only, > while if you put your code into a loop, it will do this every time. > The rationale for doing it only once is that > 1. it's a system call, and probably relatively expensive, > 2. in the short time required to handle the MIDI events arrived > during the past period, it is unlikely that anything new will > arrive anyway. > > Point 1. is why you'd probably prefer a separate thread if your > period size could be very small (64, 32, 16). The minimum for > Aeolus is 64 anyway, so I didn't bother. This will change in the > next release, which will handle OSC as well. > > Clemens Ladisch: >snd_seq_event_input_pending() will not block (it may call poll(), but >with a timeout of zero), and snd_seq_event_input() will not block if >snd_seq_event_input_pending() has returned a value greater than zero. Thank you both for the clear and understandable expanations. Everything is understood. Back to coding. :-) ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Jackit-devel] Reading alsa midi-data inside the jack client process thread 2005-07-08 12:30 ` [Jackit-devel] " Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> 2005-07-08 15:11 ` Alfons Adriaensen @ 2005-07-08 17:34 ` fons adriaensen 1 sibling, 0 replies; 7+ messages in thread From: fons adriaensen @ 2005-07-08 17:34 UTC (permalink / raw) To: Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> Cc: Alfons Adriaensen, jackit-devel, alsa-devel On Fri, Jul 08, 2005 at 02:30:27PM +0200, Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> wrote: > if (snd_seq_event_input_pending (seq,1)) { > while(snd_seq_event_input(seq,&event); > > which I think should do the same... Guess I just have to read the source. :-) OOPS, I didn't see the 'while' when commenting on this. AFAICT it will do the same as my code, if you set the seq to non-blocking mode. Happy coding ! -- FA ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Reading alsa midi-data inside the jack client process thread 2005-07-08 10:36 Reading alsa midi-data inside the jack client process thread Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> 2005-07-08 11:42 ` Alfons Adriaensen @ 2005-07-08 13:57 ` Clemens Ladisch 1 sibling, 0 replies; 7+ messages in thread From: Clemens Ladisch @ 2005-07-08 13:57 UTC (permalink / raw) To: Kjetil Svalastog Matheussen; +Cc: jackit-devel, alsa-devel Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> wrote: > Is this legal (ie. non-blocking)? > > int process (jack_nframes_t nframes, void *arg){ > snd_seq_event_t *event; > if(snd_seq_event_input_pending(seq,1)){ > snd_seq_event_input(seq, &event); > .... > } snd_seq_event_input_pending() will not block (it may call poll(), but with a timeout of zero), and snd_seq_event_input() will not block if snd_seq_event_input_pending() has returned a value greater than zero. HTH Clemens ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-07-08 17:34 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-07-08 10:36 Reading alsa midi-data inside the jack client process thread Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> 2005-07-08 11:42 ` Alfons Adriaensen 2005-07-08 12:30 ` [Jackit-devel] " Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> 2005-07-08 15:11 ` Alfons Adriaensen 2005-07-08 16:26 ` Kjetil Svalastog Matheussen <k.s.matheussen@notam02.no> 2005-07-08 17:34 ` [Jackit-devel] " fons adriaensen 2005-07-08 13:57 ` Clemens Ladisch
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.