IOAudioEngineUserClient.h [plain text]
#ifndef _IOKIT_IOAUDIOENGINEUSERCLIENT_H
#define _IOKIT_IOAUDIOENGINEUSERCLIENT_H
#include <IOKit/IOUserClient.h>
#include <IOKit/audio/IOAudioEngine.h>
#include <IOKit/audio/IOAudioTypes.h>
#include <IOKit/IOBufferMemoryDescriptor.h>
class IOAudioEngine;
class IOAudioStream;
class IOMemoryDescriptor;
class IOCommandGate;
class IOWorkLoop;
class IOAudioEngineUserClient;
class IOAudioClientBufferSet;
typedef struct IOAudioFormatNotification;
typedef struct IOAudioClientBuffer {
IOAudioEngineUserClient *userClient;
IOAudioStream *audioStream;
void *sourceBuffer;
IOMemoryDescriptor *sourceBufferDescriptor;
IOMemoryMap *sourceBufferMap;
void *unmappedSourceBuffer;
UInt32 numSampleFrames;
UInt32 numChannels;
IOAudioEnginePosition mixedPosition;
struct IOAudioClientBuffer *next;
struct IOAudioClientBuffer *nextClip;
struct IOAudioClientBuffer *previousClip;
struct IOAudioClientBuffer *nextClient;
IOAudioBufferDataDescriptor *bufferDataDescriptor;
} IOAudioClientBuffer;
typedef struct IOAudioClientBufferExtendedInfo {
UInt32 bufferSetID;
void *paramBuffer;
IOMemoryDescriptor *paramBufferDescriptor;
IOMemoryMap *paramBufferMap;
void *unmappedParamBuffer;
struct IOAudioClientBufferExtendedInfo *next;
} IOAudioClientBufferExtendedInfo;
class IOAudioEngineUserClient : public IOUserClient
{
OSDeclareDefaultStructors(IOAudioEngineUserClient)
friend class IOAudioEngine;
friend class IOAudioClientBufferSet;
friend class IOAudioStream;
protected:
IOAudioEngine *audioEngine;
IOWorkLoop *workLoop;
IOCommandGate *commandGate;
IOExternalMethod old_methods[5]; IOExternalTrap trap;
task_t clientTask;
UInt32 numSampleFrames;
IOAudioClientBufferSet *clientBufferSetList;
IORecursiveLock *clientBufferLock;
IOAudioNotificationMessage *notificationMessage;
bool online;
protected:
struct ExpansionData {
IOAudioClientBufferExtendedInfo *extendedInfo;
IOExternalMethod methods[kIOAudioEngineNumCalls]; UInt32 classicMode;
};
ExpansionData *reserved;
public:
virtual IOReturn registerClientParameterBuffer (void *parameterBuffer, UInt32 bufferSetID);
virtual IOAudioClientBufferExtendedInfo * findExtendedInfo(UInt32 bufferSetID);
virtual IOReturn getNearestStartTime(IOAudioStream *audioStream, IOAudioTimeStamp *ioTimeStamp, UInt32 isInput);
virtual IOReturn getClientNearestStartTime(IOAudioStream *audioStream, IOAudioTimeStamp *ioTimeStamp, UInt32 isInput);
virtual IOReturn safeRegisterClientBuffer(UInt32 audioStreamIndex, void *sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);
#if !(defined(__ppc__) && defined(KPI_10_4_0_PPC_COMPAT))
virtual bool initWithAudioEngine(IOAudioEngine *engine, task_t task, void *securityToken, UInt32 type, OSDictionary *properties);
#endif
private:
OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 0);
OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 1);
OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 2);
OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 3);
OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 4);
#if !(defined(__ppc__) && defined(KPI_10_4_0_PPC_COMPAT))
OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 5);
#else
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 5);
#endif
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 6);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 7);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 8);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 9);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 10);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 11);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 12);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 13);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 14);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 15);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 16);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 17);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 18);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 19);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 20);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 21);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 22);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 23);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 24);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 25);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 26);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 27);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 28);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 29);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 30);
OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 31);
protected:
virtual IOReturn clientClose();
virtual IOReturn clientDied();
static IOReturn closeClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
virtual IOReturn closeClient();
virtual IOReturn clientMemoryForType(UInt32 type, UInt32 *flags, IOMemoryDescriptor **memory);
virtual IOExternalMethod *getExternalMethodForIndex(UInt32 index);
virtual IOExternalTrap *getExternalTrapForIndex(UInt32 index);
virtual IOReturn registerNotificationPort(mach_port_t port, UInt32 type, UInt32 refCon);
static IOReturn registerNotificationAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
virtual IOReturn registerNotification(mach_port_t port, UInt32 refCon);
virtual void setOnline(bool newOnline);
virtual IOReturn performClientOutput(UInt32 firstSampleFrame, UInt32 loopCount, IOAudioClientBufferSet *bufferSet, UInt32 sampleIntervalHi, UInt32 sampleIntervalLo);
virtual IOReturn performClientInput(UInt32 firstSampleFrame, IOAudioClientBufferSet *bufferSet);
virtual void performWatchdogOutput(IOAudioClientBufferSet *clientBufferSet, UInt32 generationCount);
virtual void lockBuffers();
virtual void unlockBuffers();
public:
static IOAudioEngineUserClient *withAudioEngine(IOAudioEngine *engine, task_t clientTask, void *securityToken, UInt32 type);
static IOAudioEngineUserClient *withAudioEngine(IOAudioEngine *engine, task_t clientTask, void *securityToken, UInt32 type, OSDictionary *properties);
virtual bool initWithAudioEngine(IOAudioEngine *engine, task_t task, void *securityToken, UInt32 type);
virtual void free();
virtual void freeClientBufferSetList();
virtual void freeClientBuffer(IOAudioClientBuffer *clientBuffer);
virtual void stop(IOService *provider);
virtual bool isOnline();
virtual IOReturn registerBuffer(IOAudioStream *audioStream, void *sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);
virtual IOReturn unregisterBuffer(void *sourceBuffer, UInt32 bufferSetID);
static IOReturn registerBufferAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
static IOReturn unregisterBufferAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
virtual IOReturn registerClientBuffer(IOAudioStream *audioStream, void *sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);
virtual IOReturn unregisterClientBuffer(void *sourceBuffer, UInt32 bufferSetID);
static IOReturn getNearestStartTimeAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
virtual IOAudioClientBufferSet *findBufferSet(UInt32 bufferSetID);
virtual void removeBufferSet(IOAudioClientBufferSet *bufferSet);
virtual IOReturn getConnectionID(UInt32 *connectionID);
virtual IOReturn clientStart();
virtual IOReturn clientStop();
static IOReturn startClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
static IOReturn stopClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
virtual IOReturn startClient();
virtual IOReturn stopClient();
virtual IOReturn performClientIO(UInt32 firstSampleFrame, UInt32 loopCount, bool inputIO, UInt32 bufferSetID, UInt32 sampleIntervalHi, UInt32 sampleIntervalLo);
virtual void sendFormatChangeNotification(IOAudioStream *audioStream);
virtual IOReturn sendNotification(UInt32 notificationType);
};
#endif