WASAPI skeleton

This commit is contained in:
Andrew Kelley 2015-08-08 15:22:50 -07:00
parent 34ba7e7564
commit 21bf405859
8 changed files with 194 additions and 0 deletions

View file

@ -77,6 +77,16 @@ else()
set(AUDIOUNIT_LIBRARY "")
endif()
find_package(WASAPI)
if(WASAPI_FOUND)
set(STATUS_WASAPI "OK")
set(SOUNDIO_HAVE_WASAPI true)
else()
set(STATUS_WASAPI "not found")
set(SOUNDIO_HAVE_WASAPI false)
set(WASAPI_LIBRARIES "")
endif()
set(LIBSOUNDIO_SOURCES
"${CMAKE_SOURCE_DIR}/src/soundio.cpp"
@ -136,6 +146,14 @@ if(SOUNDIO_HAVE_COREAUDIO)
"${CMAKE_SOURCE_DIR}/src/coreaudio.cpp"
)
endif()
if(SOUNDIO_HAVE_WASAPI)
set(LIBSOUNDIO_SOURCES ${LIBSOUNDIO_SOURCES}
"${CMAKE_SOURCE_DIR}/src/wasapi.cpp"
)
set(TEST_SOURCES ${TEST_SOURCES}
"${CMAKE_SOURCE_DIR}/src/wasapi.cpp"
)
endif()
# GTFO, -lstdc++ !!
@ -186,6 +204,7 @@ target_link_libraries(libsoundio_shared LINK_PUBLIC
${COREAUDIO_LIBRARY}
${COREFOUNDATION_LIBRARY}
${AUDIOUNIT_LIBRARY}
${WASAPI_LIBRARIES}
m
${CMAKE_THREAD_LIBS_INIT}
)
@ -242,6 +261,7 @@ target_link_libraries(unit_tests LINK_PUBLIC
${COREAUDIO_LIBRARY}
${COREFOUNDATION_LIBRARY}
${AUDIOUNIT_LIBRARY}
${WASAPI_LIBRARIES}
m
)
set_target_properties(unit_tests PROPERTIES
@ -289,4 +309,5 @@ message(
"* PulseAudio (optional) : ${STATUS_PULSEAUDIO}\n"
"* ALSA (optional) : ${STATUS_ALSA}\n"
"* CoreAudio (optional) : ${STATUS_COREAUDIO}\n"
"* WASAPI (optional) : ${STATUS_WASAPI}\n"
)

18
cmake/FindWASAPI.cmake Normal file
View file

@ -0,0 +1,18 @@
# Copyright (c) 2015 Andrew Kelley
# This file is MIT licensed.
# See http://opensource.org/licenses/MIT
# WASAPI_FOUND
# WASAPI_INCLUDE_DIR
# WASAPI_LIBRARIES
if (WIN32)
find_path(WASAPI_INCLUDE_DIR NAMES audioclient.h)
set(WASAPI_LIBRARIES "")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WASAPI DEFAULT_MSG WASAPI_INCLUDE_DIR)
mark_as_advanced(WASAPI_INCLUDE_DIR WASAPI_LIBRARIES)

View file

@ -154,6 +154,7 @@ enum SoundIoBackend {
SoundIoBackendPulseAudio,
SoundIoBackendAlsa,
SoundIoBackendCoreAudio,
SoundIoBackendWasapi,
SoundIoBackendDummy,
};

View file

@ -20,5 +20,6 @@
#cmakedefine SOUNDIO_HAVE_PULSEAUDIO
#cmakedefine SOUNDIO_HAVE_ALSA
#cmakedefine SOUNDIO_HAVE_COREAUDIO
#cmakedefine SOUNDIO_HAVE_WASAPI
#endif

View file

@ -25,6 +25,9 @@ static const SoundIoBackend available_backends[] = {
#endif
#ifdef SOUNDIO_HAVE_COREAUDIO
SoundIoBackendCoreAudio,
#endif
#ifdef SOUNDIO_HAVE_WASAPI
SoundIoBackendWasapi,
#endif
SoundIoBackendDummy,
};
@ -50,6 +53,11 @@ static int (*backend_init_fns[])(SoundIoPrivate *) = {
[SoundIoBackendCoreAudio] = soundio_coreaudio_init,
#else
[SoundIoBackendCoreAudio] = nullptr,
#endif
#ifdef SOUNDIO_HAVE_WASAPI
[SoundIoBackendWasapi] = soundio_wasapi_init,
#else
[SoundIoBackendWasapi] = nullptr,
#endif
[SoundIoBackendDummy] = soundio_dummy_init,
};
@ -137,6 +145,7 @@ const char *soundio_backend_name(enum SoundIoBackend backend) {
case SoundIoBackendPulseAudio: return "PulseAudio";
case SoundIoBackendAlsa: return "ALSA";
case SoundIoBackendCoreAudio: return "CoreAudio";
case SoundIoBackendWasapi: return "WASAPI";
case SoundIoBackendDummy: return "Dummy";
}
return "(invalid backend)";

View file

@ -27,6 +27,10 @@
#include "coreaudio.hpp"
#endif
#ifdef SOUNDIO_HAVE_WASAPI
#include "wasapi.hpp"
#endif
#include "dummy.hpp"
union SoundIoBackendData {
@ -41,6 +45,9 @@ union SoundIoBackendData {
#endif
#ifdef SOUNDIO_HAVE_COREAUDIO
SoundIoCoreAudio coreaudio;
#endif
#ifdef SOUNDIO_HAVE_WASAPI
SoundIoWasapi wasapi;
#endif
SoundIoDummy dummy;
};
@ -57,6 +64,9 @@ union SoundIoDeviceBackendData {
#endif
#ifdef SOUNDIO_HAVE_COREAUDIO
SoundIoDeviceCoreAudio coreaudio;
#endif
#ifdef SOUNDIO_HAVE_WASAPI
SoundIoDeviceWasapi wasapi;
#endif
SoundIoDeviceDummy dummy;
};
@ -73,6 +83,9 @@ union SoundIoOutStreamBackendData {
#endif
#ifdef SOUNDIO_HAVE_COREAUDIO
SoundIoOutStreamCoreAudio coreaudio;
#endif
#ifdef SOUNDIO_HAVE_WASAPI
SoundIoOutStreamWasapi wasapi;
#endif
SoundIoOutStreamDummy dummy;
};
@ -89,6 +102,9 @@ union SoundIoInStreamBackendData {
#endif
#ifdef SOUNDIO_HAVE_COREAUDIO
SoundIoInStreamCoreAudio coreaudio;
#endif
#ifdef SOUNDIO_HAVE_WASAPI
SoundIoInStreamWasapi wasapi;
#endif
SoundIoInStreamDummy dummy;
};

101
src/wasapi.cpp Normal file
View file

@ -0,0 +1,101 @@
#include "wasapi.hpp"
#include "soundio.hpp"
static void flush_events_wasapi(struct SoundIoPrivate *si) {
soundio_panic("TODO");
}
static void wait_events_wasapi(struct SoundIoPrivate *si) {
soundio_panic("TODO");
}
static void wakeup_wasapi(struct SoundIoPrivate *si) {
soundio_panic("TODO");
}
static void outstream_destroy_wasapi(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
soundio_panic("TODO");
}
static int outstream_open_wasapi(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
soundio_panic("TODO");
}
static int outstream_pause_wasapi(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) {
soundio_panic("TODO");
}
static int outstream_start_wasapi(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
soundio_panic("TODO");
}
static int outstream_begin_write_wasapi(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os,
SoundIoChannelArea **out_areas, int *frame_count)
{
soundio_panic("TODO");
}
static int outstream_end_write_wasapi(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
soundio_panic("TODO");
}
static int outstream_clear_buffer_wasapi(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
soundio_panic("TODO");
}
static void instream_destroy_wasapi(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
soundio_panic("TODO");
}
static int instream_open_wasapi(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
soundio_panic("TODO");
}
static int instream_pause_wasapi(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) {
soundio_panic("TODO");
}
static int instream_start_wasapi(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
soundio_panic("TODO");
}
static int instream_begin_read_wasapi(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is,
SoundIoChannelArea **out_areas, int *frame_count)
{
soundio_panic("TODO");
}
static int instream_end_read_wasapi(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
soundio_panic("TODO");
}
static void destroy_wasapi(struct SoundIoPrivate *si) {
soundio_panic("TODO");
}
int soundio_wasapi_init(SoundIoPrivate *si) {
si->destroy = destroy_wasapi;
si->flush_events = flush_events_wasapi;
si->wait_events = wait_events_wasapi;
si->wakeup = wakeup_wasapi;
si->outstream_open = outstream_open_wasapi;
si->outstream_destroy = outstream_destroy_wasapi;
si->outstream_start = outstream_start_wasapi;
si->outstream_begin_write = outstream_begin_write_wasapi;
si->outstream_end_write = outstream_end_write_wasapi;
si->outstream_clear_buffer = outstream_clear_buffer_wasapi;
si->outstream_pause = outstream_pause_wasapi;
si->instream_open = instream_open_wasapi;
si->instream_destroy = instream_destroy_wasapi;
si->instream_start = instream_start_wasapi;
si->instream_begin_read = instream_begin_read_wasapi;
si->instream_end_read = instream_end_read_wasapi;
si->instream_pause = instream_pause_wasapi;
return 0;
}

27
src/wasapi.hpp Normal file
View file

@ -0,0 +1,27 @@
/*
* Copyright (c) 2015 Andrew Kelley
*
* This file is part of libsoundio, which is MIT licensed.
* See http://opensource.org/licenses/MIT
*/
#ifndef SOUNDIO_WASAPI_HPP
#define SOUNDIO_WASAPI_HPP
#include "soundio/soundio.h"
int soundio_wasapi_init(struct SoundIoPrivate *si);
struct SoundIoDeviceWasapi {
};
struct SoundIoWasapi {
};
struct SoundIoOutStreamWasapi {
};
struct SoundIoInStreamWasapi {
};
#endif