• 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: SetProperty/GetProperty
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SetProperty/GetProperty


  • Subject: Re: SetProperty/GetProperty
  • From: William Stewart <email@hidden>
  • Date: Wed, 15 Nov 2006 19:14:45 -0800


On 15/11/2006, at 3:36 PM, Art Gillespie wrote:

In an effort to make sure my Views don't make any assumptions about running in the same address space as their AU, I'm looking to GetProperty/SetProperty to replace direct method calls.

Obviously in testing on current hosts, I can use the void* parameter in either call and treat it as an io param:

...

float32 MyView::SomeMethodProxy(uint32 inParam)
{
   struct someMethodParams params;
   params.p1 = inParam;
   params.retval = NO_VALUE;
   s = sizeof(params);
   AudioUnitGetProperty(mEditAudioUnit,
      kMyProperty_SomeMethodOnTheAU,
      kAudioUnitScope_Global,
      0,
      &params,
      &s);
   return param.retval;
}

...

since all the current hosts do run views in the same address space.

My question is whether we can reasonably expect this behavior to be reproduced by a host marshaling parameters across process/machine boundaries, or whether these void* parameters are intended to be one direction only.

At some point the host would have to marshall this... So the care that needs to be taken is this - don't embed pointers in these structs, but rather have the memory you pass in to the Get/Set calls be flat and complete. So, in your example above how you have this is fine (presuming of course that retval is a value not an address!).


The more general case is when you need to get more complex data. For instance:

struct AmpBins {
	int numBins;
	float bins[1];
};

When you allocate AmpBins it would be allocated by:
int sizeToAllocate = sizeof(int) * sizeof(float) * numBins;
AmpBins *abin = malloc ( sizeToAllocate ); // where numBins is how many amplitude values (bins) you are going to pass in


AudioUnitGetProperty (... kAmpBinProperty, abin, &sizeToAllocate);

This is how we do this in the Filter demo AU. The host can marshall this across boundaries because it can get the entire contents of the memory.

The following would be wrong:
struct BadAmpBins {
	int numBins;
	float * bins;
};

The structure contains a pointer to allocated memory:
BadAmpBins abBAD;
abBAD.bins = malloc ( sizeof(float) * numBins );

So, when you made the call to Get/Set property, your size is just the sizeof (abBAD) - (say 8 bytes) - when marshalling, the host can't do anything with what the embedded pointer is pointing too (it doesn't know its there) - and you can't just pass this pointer around because it won't be valid in a different address space.

HTH

Bill


Thanks,

Art




_______________________________________________ Do not post admin requests to the list. They will be ignored. Coreaudio-api mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________ __
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________ __


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: SetProperty/GetProperty
      • From: Sebastien Beaulieu <email@hidden>
References: 
 >SetProperty/GetProperty (From: "Art Gillespie" <email@hidden>)

  • Prev by Date: Re: Mixing arbitrary numbers of sounds out an AUHAL unit (was: MOTU devices on Intel machines)
  • Next by Date: Updated Audio Unit Programming Guide + sample code
  • Previous by thread: SetProperty/GetProperty
  • Next by thread: Re: SetProperty/GetProperty
  • Index(es):
    • Date
    • Thread