Sample CodeDriverKit, macOSReviewed 2026-07-21View on Apple Developer

Building an Audio Server Plug-in and Driver Extension

At a glance

Item Summary
Purpose Create a plug-in and driver extension to support an audio device in macOS.
App architecture A C++, C/Objective-C header, Shell sample centered on CAMutex, with direct use of CoreAudio, CoreFoundation, IOKit, mach.
Main patterns No named application pattern supported by the extracted structure
Project style 39 scanned source file(s) across C++, C/Objective-C header, Shell, organized around ranked entry, type, and file boundaries.

Project structure

Source bundle/
├── PublicUtility/
│   ├── CAMutex.h
│   ├── CACFArray.h
│   ├── CACFDictionary.h
│   ├── CAVolumeCurve.h
│   ├── CACFNumber.h
│   ├── CACFString.h
│   ├── CADispatchQueue.h
│   └── CAGuard.h
└── SimpleAudio/
    ├── ASP/
    │   ├── SA_Object.h
    │   ├── SA_PlugIn.h
    │   └── SA_Device.h
    └── DriverExtension/
        └── SimpleAudioDriverUserClient.cpp

Structure observations

  • Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
  • Primary languages: C++, C/Objective-C header, Shell.
  • The verified tree contains 7 project/configuration file(s) and 42 source declaration(s).

Overall architecture

Reference code

PublicUtility/CAMutex.h:33 — architecture anchor

class   CAMutex
{
    // ...
};

Interpretation

The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into Core Audio.

Ownership and state

Ownership evidence

SimpleAudio/ASP/SA_Object.h:11 — stored dependency or nearest verified ownership anchor

#if !defined(__SA_ObjectMap_h__)
#define __SA_ObjectMap_h__
// ...
#endif  //  __SA_ObjectMap_h__
Owner Object or state Relationship Mutation authority
CAMutex Core Audio APIs Uses framework types; no stored lifecycle relationship was detected in the architecture anchor. The declaring implementation controls calls.

Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.

Class and protocol design

PublicUtility/CAMutex.h:33 — representative type boundary

class   CAMutex
{
    // ...
};
Type Responsibility Depends on or conforms to
CAMutex Owns feature behavior and collaborator lifecycle Concrete collaborators/imported frameworks
Locker Owns feature behavior and collaborator lifecycle Concrete collaborators/imported frameworks
Unlocker Owns feature behavior and collaborator lifecycle Concrete collaborators/imported frameworks
Tryer Owns feature behavior and collaborator lifecycle Concrete collaborators/imported frameworks
SA_Object Owns feature behavior and collaborator lifecycle Concrete collaborators/imported frameworks
SA_ObjectMap Owns feature behavior and collaborator lifecycle Concrete collaborators/imported frameworks
ObjectInfo Represents feature data Concrete collaborators/imported frameworks
SA_ObjectReleaser Owns feature behavior and collaborator lifecycle Concrete collaborators/imported frameworks
SimpleAudioDriverUserClient_IVars Represents a feature value or composable behavior Concrete collaborators/imported frameworks
CACFDictionary Owns feature behavior and collaborator lifecycle Concrete collaborators/imported frameworks

No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.

Access control

Symbol Access Verified effect Likely rationale
CAMutex (PublicUtility/CAMutex.h:33) header-visible The declaration is exposed to translation units that import the header. Inference: declare a contract needed by other Objective-C/C translation units.
Locker (PublicUtility/CAMutex.h:62) header-visible The declaration is exposed to translation units that import the header. Inference: declare a contract needed by other Objective-C/C translation units.
Unlocker (PublicUtility/CAMutex.h:86) header-visible The declaration is exposed to translation units that import the header. Inference: declare a contract needed by other Objective-C/C translation units.
SimpleAudioDriverUserClient (SimpleAudio/DriverExtension/SimpleAudioDriverUserClient.cpp:13) language/file boundary Visibility follows header/implementation and language linkage rules. Inference: the language’s file or module boundary is sufficient for this sample collaboration.

Reference code

PublicUtility/CAMutex.h:33 — representative boundary

class   CAMutex
{
    // ...
};

Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.

Logic ownership and placement

Logic Owning type or file Placement rationale
Feature and framework orchestration CAMutex The sample keeps the demonstrated path in its primary concrete type.

Design patterns

Pattern Source evidence Purpose or tradeoff
No named application pattern PublicUtility/CAMutex.h:33 The verified source directly composes concrete framework types; this document avoids forcing a pattern name.

Naming conventions

  • Types: feature-specific names rather than reusable layer suffixes.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: no representative method name extracted from the architectural files.
  • Files: PublicUtility/CAMutex.h, SimpleAudio/ASP/SA_Object.h, PublicUtility/CACFArray.h, PublicUtility/CACFDictionary.h, PublicUtility/CAVolumeCurve.h, SimpleAudio/ASP/SA_PlugIn.h.

Architecture takeaways

  • CAMutex is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches CoreAudio, CoreFoundation, IOKit, mach through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
  • Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
  • Access-control conclusions separate verified language visibility from the likely design rationale.
  • The source does not justify labeling the design protocol-oriented.

Source map

Source file Relevant symbols
PublicUtility/CAMutex.h CAMutex, Locker, Unlocker, Tryer
SimpleAudio/ASP/SA_Object.h SA_Object, SA_ObjectMap, ObjectInfo, SA_ObjectReleaser
SimpleAudio/DriverExtension/SimpleAudioDriverUserClient.cpp SimpleAudioDriverUserClient_IVars
PublicUtility/CACFArray.h CACFDictionary, CACFString, CACFArray
PublicUtility/CACFDictionary.h CACFArray, CACFString, CACFDictionary
PublicUtility/CAVolumeCurve.h CARawPoint, CADBPoint, CAVolumeCurve
SimpleAudio/ASP/SA_PlugIn.h SA_Device, SA_PlugIn, DeviceInfo
PublicUtility/CACFNumber.h CACFBoolean, CACFNumber
PublicUtility/CACFString.h CACFString, CACFMutableString
PublicUtility/CADispatchQueue.h CADispatchQueue, EventSource