We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2807

Summary: [patch] Not using CoreAudio on OS X when built via CMake
Product: SDL Reporter: Felix H. Dahlke <fhd>
Component: buildAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: fhd, icculus
Version: 2.0.3   
Hardware: x86   
OS: Mac OS X 10.8   
Attachments: Patch that defines SDL_AUDIO_DRIVER_COREAUDIO

Description Felix H. Dahlke 2014-12-06 23:03:09 UTC
Steps to reproduce
------------------

1. Build SDL 2.0.3 using CMake:

    mkdir build
    cd build
    cmake ..
    make

2. Link any SDL app doing `SDL_Init(SDL_INIT_AUDIO)` against the resulting libSDL2.a

3. Run the app

What happens
------------

SDL_Init() fails, SDL_GetError() returns: "No available audio device"

What should happen instead
--------------------------

It should just work, as it does when calling SDL_Init() without SDL_INIT_AUDIO.
Comment 1 Felix H. Dahlke 2014-12-06 23:07:02 UTC
Sorry, just realised this should probably be in the build component, changed that.

Also, I've investigated this a bit. Looking at the output of both ./configure and cmake, it seems that CoreAudio is detected and used in both cases just fine.

I'll gladly help debug this, but I think I need some pointers, I'm not overly confident with CMake, let alone autotools.
Comment 2 Felix H. Dahlke 2015-01-17 03:53:09 UTC
Created attachment 1992 [details]
Patch that defines SDL_AUDIO_DRIVER_COREAUDIO

Alright, dug into this and attached a patch that seems to do the trick.

Possible follow-up: I think the MACOSX_COREAUDIO define should go away. It's only used in src/audio/coreaudio/SDL_coreaudio.c, and looking at the other drivers, that one should probably use SDL_AUDIO_DRIVER_COREAUDIO instead.
Comment 3 Ryan C. Gordon 2015-01-18 07:51:13 UTC
(In reply to Felix H. Dahlke from comment #2)
> Alright, dug into this and attached a patch that seems to do the trick.

This is now https://hg.libsdl.org/SDL/rev/705bdbbb1f37, thanks!

> Possible follow-up: I think the MACOSX_COREAUDIO define should go away. It's
> only used in src/audio/coreaudio/SDL_coreaudio.c, and looking at the other
> drivers, that one should probably use SDL_AUDIO_DRIVER_COREAUDIO instead.

CoreAudio is available on iOS but doesn't have the pieces of the API that are masked off by that #define. I'm not sure why the CMake file tries to set it, that doesn't actually become a #define anyhow in that case.

I've removed it here: https://hg.libsdl.org/SDL/rev/6f04557c6e1f

Thanks!

--ryan.