<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/07/0246c867e03ce642bf18a3fcaa245116"
  from="SooHyoung Oh &lt;shoh@d...&gt;"
  author="SooHyoung Oh"
  date="2003-07-15T00:37:44"
  subject="Re: [Caml-list] PortAudio on ocaml"
  prev="2003/07/f087c018f2b5dd9d20cee1fec0e2932e"
  next="2003/07/ed4b783ba287324e156a8716471da670"
  prev-in-thread="2003/07/54a6ceb53dfa0bd7ef618e45a55fec76"
  next-in-thread="2003/07/eff20a82be9cc2e2ec8b6cff76a4b7c6"
  prev-thread="2003/07/c35ce3ef11d645eaf3822cd5eb0f68c0"
  next-thread="2003/07/f087c018f2b5dd9d20cee1fec0e2932e"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] PortAudio on ocaml">
<msg 
  url="2003/07/54a6ceb53dfa0bd7ef618e45a55fec76"
  from="Likai Liu &lt;liulk@b...&gt;"
  author="Likai Liu"
  date="2003-07-14T20:55:48"
  subject="[Caml-list] PortAudio on ocaml">
<msg 
  url="2003/07/0246c867e03ce642bf18a3fcaa245116"
  from="SooHyoung Oh &lt;shoh@d...&gt;"
  author="SooHyoung Oh"
  date="2003-07-15T00:37:44"
  subject="Re: [Caml-list] PortAudio on ocaml">
<msg 
  url="2003/07/eff20a82be9cc2e2ec8b6cff76a4b7c6"
  from="Likai Liu &lt;liulk@b...&gt;"
  author="Likai Liu"
  date="2003-07-15T02:13:36"
  subject="Re: [Caml-list] PortAudio on ocaml">
</msg>
</msg>
<msg 
  url="2003/07/c5e526596332cf6571a2af65d85c1723"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2003-07-16T09:55:53"
  subject="Re: [Caml-list] PortAudio on ocaml">
<msg 
  url="2003/07/8961f54b5c536bc48f90bc349e8fdda8"
  from="Likai Liu &lt;liulk@b...&gt;"
  author="Likai Liu"
  date="2003-07-16T12:00:36"
  subject="Re: [Caml-list] PortAudio on ocaml">
<msg 
  url="2003/07/906539e8aefc2fb1784a561f5bc15d56"
  from="Damien Doligez &lt;Damien.Doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-07-16T16:57:29"
  subject="Re: [Caml-list] PortAudio on ocaml">
<msg 
  url="2003/07/f61061539242baa0c21b95280b6ad460"
  from="Likai Liu &lt;liulk@b...&gt;"
  author="Likai Liu"
  date="2003-07-16T17:47:26"
  subject="Re: [Caml-list] PortAudio on ocaml">
<msg 
  url="2003/07/eff3f424206ab79c6f72fa50d6d55585"
  from="Damien Doligez &lt;Damien.Doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-07-18T13:32:29"
  subject="Re: [Caml-list] PortAudio on ocaml">
</msg>
</msg>
<msg 
  url="2003/07/d7c69216c33f0f4864d0f0fc53dab975"
  from="Likai Liu &lt;liulk@b...&gt;"
  author="Likai Liu"
  date="2003-07-19T13:37:41"
  subject="Re: [Caml-list] PortAudio on ocaml">
<msg 
  url="2003/07/776d2c77ba72d4f7c3c9923252934201"
  from="Damien Doligez &lt;Damien.Doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-07-22T11:17:56"
  subject="Re: [Caml-list] PortAudio on ocaml">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>

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" &lt;liulk@bu.edu&gt;
To: &lt;caml-list@inria.fr&gt;
Cc: "Likai Liu" &lt;liulk@acs.bu.edu&gt;
Sent: Tuesday, July 15, 2003 5:55 AM
Subject: [Caml-list] PortAudio on ocaml


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

-------------------
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

</contents>

</message>

