Reputation: 54251
Good Day wonderful computer people of the planet Earth!
Here is the struct in a file called AudioQueue.h:
typedef struct AudioQueueBuffer {
const UInt32 mAudioDataBytesCapacity;
void * const mAudioData;
UInt32 mAudioDataByteSize;
void * mUserData;
const UInt32 mPacketDescriptionCapacity;
AudioStreamPacketDescription * const mPacketDescriptions;
UInt32 mPacketDescriptionCount;
#ifdef __cplusplus
AudioQueueBuffer() : mAudioDataBytesCapacity(0), mAudioData(0), mPacketDescriptionCapacity(0), mPacketDescriptions(0) { }
#endif
} AudioQueueBuffer;
/*!
@typedef AudioQueueBufferRef
@abstract An pointer to an AudioQueueBuffer.
*/
typedef AudioQueueBuffer *AudioQueueBufferRef;
And then later on there is this in the header of AudioPlayer.h:
AudioQueueBufferRef mBuffers[kNumberBuffers];
And then what I'm trying to do:
for (int i = 0; i < kNumberBuffers; ++i) {
printf("%i\n", &mBuffers[i].mAudioData );
XThrowIfError(AudioQueueAllocateBufferWithPacketDescriptions(mQueue, bufferByteSize, (isFormatVBR ? mNumPacketsToRead : 0), &mBuffers[i]), "AudioQueueAllocateBuffer failed");
Basically I'm trying to access the information in mAudioData, but get the error:
request for member 'mAudioData' in '((AQPlayer*)this)->AQPlayer::mBuffers[i]', which is of non-class type 'AudioQueueBuffer*'
Any help greatly appreciated!
Upvotes: 0
Views: 3358
Reputation: 104698
you're dealing with an array of pointers to AudioQueueBuffer.
try accessing fields using ->
instead of .
:
assert(mBuffers[i]);
std::cout << &mBuffers[i]->mAudioData << "\n";
EDIT: moonshadow beat me to it
Upvotes: 1
Reputation: 89055
AudioQueueBufferRef
is an AudioQueueBuffer
pointer. mBuffers
is an array of these. So when referring to members of elements of mBuffers
, you should be using ->
not .
:
printf("%i\n", &mBuffers[i]->mAudioData );
(I'm guessing you probably don't want the &
either - the address held by mAudioData seems a more useful thing to be printing than the position of that member within its AudioQueueBuffer structure)
Upvotes: 7