0

I am trying to write a program that uses IOAudioControl.h file in the IOKit, so that I learn dealing with IOKit directly without using Apple's APIs. Whenever I run a simple file like below I got tons of errors in IOAudioControl.h

#include <IOKit/audio/I0AudioControl.h>
#include <iostream>
int main(int argc, const char * argv]) (
{
  // insert code here.
  std: :cout << "Hello, world! \n"
  return 0:
}

Here is a screenshot for my build settings enter image description here

and here is a screenshot for the errors enter image description here

pmdj
  • 22,018
  • 3
  • 52
  • 103
ahmed botta
  • 7
  • 1
  • 6
  • [Please don't use screenshots for including code, settings or logs.](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question/285557#285557) Instead, include the code or logs in blocks surrounded by 3 backticks(```). – pmdj Feb 19 '22 at 20:28
  • I've now replaced the code screenshot with inline code for you. – pmdj Feb 22 '22 at 13:12

1 Answers1

1

IOAudioControl is a class that exists in the macOS Kernel (and its API is available to kexts), and it is also accessible from DriverKit extensions (dext) via the IOUserAudioControl API in AudioDriverKit.

From your code sample it looks like you're trying to include the kernel header file in a regular user space program. This will not work, kernel objects are not accessible from user space in this way.

You do not specify what you are ultimately trying to achieve, but:

  • If you are trying to implement an audio device driver, use either the Core Audio Server Plugin API or build your driver as a DriverKit extension. (Most kinds of audio kernel extensions are deprecated.)
  • If you want to access and modify the controls of an existing audio device in the system, use the Core Audio API.
  • If you wish to enumerate the kernel's IOAudioControl objects from user space, use the IOKit framework's service iteration APIs from your program.
pmdj
  • 22,018
  • 3
  • 52
  • 103