• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: function pointer in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: function pointer in Cocoa


  • Subject: Re: function pointer in Cocoa
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Thu, 3 Jun 2004 09:29:02 -0700

Hello...

Is this something like what you wanted to do?

- - - file: yourFunction.h - - -

#include <CoreAudio/CoreAudio.h>

extern OSStatus yourIOProc (AudioDeviceID inDevice, const AudioTimeStamp* inNow, const AudioBufferList* inInputData, const AudioTimeStamp* inInputTime, AudioBufferList* outOutputData, const AudioTimeStamp* inOutputTime, void* inClientData);

- - - end: yourFunction.h - - -


- - - file: yourFunction.c - - -

#include "yourFunction.h"

OSStatus yourIOProc (AudioDeviceID inDevice, const AudioTimeStamp* inNow, const AudioBufferList* inInputData, const AudioTimeStamp* inInputTime, AudioBufferList* outOutputData, const AudioTimeStamp* inOutputTime, void* inClientData)
{
/* ... your function code here ... */
}

- - - end: yourFunction.c - - -

- - - file: SoundCard.h - - -

#import <Cocoa/Cocoa.h>
#import <CoreAudio/CoreAudio.h>

/* ... */

@interface SoundCard: NSObject
{
/* ... */
AudioDeviceIOProc customIOProc;
}

/* ... */

@end

- - - end: SoundCard.h - - -

- - - file: SoundCard.m - - -

#import "SoundCard.h"
#import "yourFunction.h"

/* ... */

@implementation SoundCard

- (id)init
{
if ((self = [super init]))
{
/* ... */
customIOProc = yourIOProc;
}

return self;
}

/* ... */

@end

- - - end: SoundCard.m - - -



Hi, there,
Is there anyone having experience using function pointer in Cocoa? I am currently developing an application for my experiment using OSX's CoreAudio. In particular, there is a function AudioDeviceStart, which calls a C-type function pointer (*AudioDeviceIOProc). To utilize this function, I create a class called "SoundCard" (I want fully control of the soundcard, Revolution 7.1). The question I have is, how to handle this function pointer? Can I declare it as the instance variable of "SoundCard" class? If so, how and where to define the function? Since the function needs to be implemented in C? I could make the program working if I put the definition of the C-function in the SoundCard.m file. However, it is really ugly. Any idea?
Ding
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: function pointer in Cocoa
      • From: Dingcai Cao <email@hidden>
References: 
 >function pointer in Cocoa (From: Dingcai Cao <email@hidden>)

  • Prev by Date: Re: Feeding NSUnarchiver bad data can cause crash
  • Next by Date: Fwd: World-Wide (ish) NeXT Meetups
  • Previous by thread: Re: function pointer in Cocoa
  • Next by thread: Re: function pointer in Cocoa
  • Index(es):
    • Date
    • Thread