caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "SooHyoung Oh" <shoh@duonix.com>
To: "Likai Liu" <liulk@bu.edu>, <caml-list@inria.fr>
Cc: "Likai Liu" <liulk@acs.bu.edu>
Subject: Re: [Caml-list] PortAudio on ocaml
Date: Tue, 15 Jul 2003 09:37:49 +0900	[thread overview]
Message-ID: <000801c34a69$51f8fec0$fe00a8c0@hama> (raw)
In-Reply-To: <Pine.A41.4.33.0307141618320.96990-100000@acsn03.bu.edu>


I didn't read your message seriously,
but in my first glance, what you want to seems to be asychroneous threads.
Why don't you use Event module of threads library?
It's a Concurrent ML.

---
SooHyoung Oh
----- Original Message -----
From: "Likai Liu" <liulk@bu.edu>
To: <caml-list@inria.fr>
Cc: "Likai Liu" <liulk@acs.bu.edu>
Sent: Tuesday, July 15, 2003 5:55 AM
Subject: [Caml-list] PortAudio on ocaml


> Hello,
>
> I'm trying to evaluate on porting PortAudio API to O'Caml, which would
> enable an entire genre of sound applications being written in this nice
> language. What concerns me is that PortAudio uses asynchronous callbacks,
> much like signals, to tell the application that some audio sample has
> arrived, needs to be played, or both. I looked at the signal.c of asmrun
> and byterun and found out that signals are normally deferred if it
> interrupts a running O'Caml program until a garbage collection cycle
> occurs. It doesn't seem fesible to have these real-time audio callbacks
> implemented this way; threads seems to be the only way.
>
> If I were to enforce using threads semantics, then the synchronization
> issue might have some light. However, the original PortAudio API is meant
> for a program to continue its execution when callback keeps coming.
> Depending on the implementation on a certain platform, it might interrupt
> the program completely while it processes the callback, or the program
> might run concurrently with the callback on different threads. Since only
> one O'Caml section can hold the global mutex lock at any given time, it's
> likely that the callback will block trying to acquire the lock in either
> cases. It seems necessary to change the PortAudio interface on O'Caml to
> block the running program while the audio transaction is carried out.
>
> Before I make such a radical decision, I'm wondering if there is a better
> solution. A possibility after soul searching the source code of threads is
> that, in the case of bytecode, when a thread does Unix.select, the thread
> scheduler would let go the lock momentarily so the callback doesn't block
> forever; in the case of native thread, when a thread calls Threads.yield,
> then the lock is released momentarily. I'm not sure if it's a good idea to
> rely on these deep internals of O'Caml, or maybe it's better to stay on
> the light side, that is, restrict the API for workaround, instead. What do
> the O'Caml developers say about this?
>
> There is a simplified interface of PortAudio called Pablio that doesn't
> use the callback, but a conventional blocking I/O style read/write
> functions. Pablio interface is straightforward to implement. So at least
> the current plan is to get pablio working first, and leave the actual
> PortAudio API unimplemented with some provided interface stub for
> reference purpose.
>
> liulk
>
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives:
http://caml.inria.fr
> Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ:
http://caml.inria.fr/FAQ/
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-07-15  0:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-14 20:55 Likai Liu
2003-07-15  0:37 ` SooHyoung Oh [this message]
2003-07-15  2:12   ` Likai Liu
2003-07-16  9:55 ` Xavier Leroy
2003-07-16 11:59   ` Likai Liu
2003-07-16 16:57     ` Damien Doligez
2003-07-16 17:46       ` Likai Liu
2003-07-18 13:32         ` Damien Doligez
2003-07-19 13:37       ` Likai Liu
2003-07-22 11:17         ` Damien Doligez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000801c34a69$51f8fec0$fe00a8c0@hama' \
    --to=shoh@duonix.com \
    --cc=caml-list@inria.fr \
    --cc=liulk@acs.bu.edu \
    --cc=liulk@bu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).