[MacRuby-devel] [MacRuby] #733: Proc as callback function for CoreAudio(AudioDeviceCreateIOProcID) isn't called
MacRuby
ruby-noreply at macosforge.org
Sat Jun 5 10:22:54 PDT 2010
#733: Proc as callback function for CoreAudio(AudioDeviceCreateIOProcID) isn't
called
-----------------------------------+----------------------------------------
Reporter: nagachika00@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords:
-----------------------------------+----------------------------------------
Comment(by martinlagardette@…):
If you look at the CoreAudio `AudioHardware.h` header file:
{{{
#!c
/*!
@typedef AudioDeviceIOProc
@abstract An AudioDeviceIOProc is called by an AudioDevice to
provide input data read from
the device and collect output data to be written to
the device for the current
IO cycle.
[...]
*/
typedef OSStatus
(*AudioDeviceIOProc)( AudioDeviceID inDevice,
const AudioTimeStamp* inNow,
const AudioBufferList* inInputData,
const AudioTimeStamp* inInputTime,
AudioBufferList* outOutputData,
const AudioTimeStamp* inOutputTime,
void* inClientData);
/*!
@typedef AudioDeviceIOProcID
@abstract An AudioDeviceIOProcID represents both an IOProc and
the client data that goes
with it. Once created, an AudioDeviceIOProcID can be
used everywhere one would
use a regular IOProc. The purpose for an
AudioDeviceIOProcID is to allow a
client to register the same function pointer as an
IOProc with a device multiple
times provided
*/
typedef AudioDeviceIOProc AudioDeviceIOProcID;
/* [...] */
extern OSStatus
AudioDeviceCreateIOProcID( AudioDeviceID inDevice,
AudioDeviceIOProc inProc,
void* inClientData,
AudioDeviceIOProcID* outIOProcID)
}}}
As you can see, `AudioDeviceCreateIOProcID`'s 4th argument is a pointer to
`AudioDeviceIOProcID`, which itself definitely is a function pointer. The
thing is, a pointer to a function pointer, here, is behaving a little as
if it was a return value. Even if we don't call this function pointer
directly, because we just pass it around other functions, well, we cannot
know that. Once the function returns, we *have* to convert every
"returned" variable to Ruby values so that they can be used around your
code, whatever you do with it.
--
Ticket URL: <http://www.macruby.org/trac/ticket/733#comment:5>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list