• 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: Dingcai Cao <email@hidden>
  • Date: Thu, 3 Jun 2004 11:52:31 -0500

Louis, I think it is a good idea to lay out the files as you suggested. I will try it. Dingcai
On Jun 3, 2004, at 11:29 AM, Louis C. Sacha wrote:

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

Dingcai Cao, PhD
----------------------------------------------------------------
Biostatistical Consulting Laboratory
And Visual Science Laboratories
University of Chicago
Phone: 773-834-2654 (O)
Email: email@hidden
URL: http://ccp.uchicago.edu/~dcao
----------------------------------------------------------------
_______________________________________________
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.


References: 
 >function pointer in Cocoa (From: Dingcai Cao <email@hidden>)
 >Re: function pointer in Cocoa (From: "Louis C. Sacha" <email@hidden>)

  • Prev by Date: Re: Debugging under 10.2
  • Next by Date: URL info in Pasteboards
  • Previous by thread: Re: function pointer in Cocoa
  • Next by thread: Help for a prefPane?
  • Index(es):
    • Date
    • Thread