---
title: "AudioServicesAddSystemSoundCompletion(_:_:_:_:_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/audioservicesaddsystemsoundcompletion(_:_:_:_:_:)"
---

# AudioServicesAddSystemSoundCompletion(_:_:_:_:_:)

Registers a callback function that is invoked when a specified system sound finishes playing.

## Declaration

```swift
func AudioServicesAddSystemSoundCompletion(_ inSystemSoundID: SystemSoundID, _ inRunLoop: CFRunLoop?, _ inRunLoopMode: CFString?, _ inCompletionRoutine: AudioServicesSystemSoundCompletionProc, _ inClientData: UnsafeMutableRawPointer?) -> OSStatus
```

## Parameters

- `inSystemSoundID`: The system sound that your callback function is to respond to.
- `inRunLoop`: The run loop in which the callback function should run. Pass NULL to use the main run loop.
- `inRunLoopMode`: The mode for the run loop in which the callback functions should run. Pass NULL to use the default run loop mode.
- `inCompletionRoutine`: The callback function to be invoked when the specified system sound has finished playing.
- `inClientData`: Application data to be passed to your callback function when it is invoked. Can be NULL.

## Return Value

Return Value A result code.

## Discussion

Discussion Because a system sound may play for several seconds, you might want to know when it has finished playing. For example, you may want to wait until a system sound has finished playing before you play another sound.

## See Also

### Related Documentation

- [AudioServicesCreateSystemSoundID(_:_:)](audiotoolbox/audioservicescreatesystemsoundid(_:_:).md)

### Adding and Removing System Sound Callbacks

- [AudioServicesRemoveSystemSoundCompletion(_:)](audiotoolbox/audioservicesremovesystemsoundcompletion(_:).md)
- [AudioServicesSystemSoundCompletionProc](audiotoolbox/audioservicessystemsoundcompletionproc.md)
