-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor and start working on a pulseaudio backend
- Loading branch information
Showing
12 changed files
with
930 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.idea | ||
cmake-build* | ||
.DS_Store | ||
*.user | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
#include <optional> | ||
#include <cassert> | ||
#include <string_view> | ||
#include <atomic> | ||
|
||
// TODO: this is a temporary measure until std::span becomes available | ||
#include "cpp/span.hpp" | ||
using namespace TCB_SPAN_NAMESPACE_NAME; | ||
|
||
#define _LIBSTDAUDIO_NAMESPACE std::experimental | ||
|
||
#define _LIBSTDAUDIO_NAMESPACE_BEGIN namespace _LIBSTDAUDIO_NAMESPACE { | ||
#define _LIBSTDAUDIO_NAMESPACE_END } | ||
|
||
_LIBSTDAUDIO_NAMESPACE_BEGIN | ||
|
||
struct audio_null_driver_t {}; | ||
|
||
#ifdef __APPLE__ | ||
struct __coreaudio_driver_t {}; | ||
using audio_default_driver_t = __coreaudio_driver_t; | ||
#else | ||
|
||
#if __has_include(<pulse/pulseaudio.h>) | ||
struct __pulseaudio_driver_t {}; | ||
#endif | ||
#if __has_include(<portaudio.h>) | ||
struct __portaudio_driver_t {}; | ||
#endif | ||
|
||
#if __has_include(<pulse/pulseaudio.h>) | ||
using audio_default_driver_t = __pulseaudio_driver_t; | ||
#elif __has_include(<portaudio.h>) | ||
using audio_default_driver_t = __portaudio_driver_t; | ||
#endif | ||
#endif // __APPLE__ | ||
|
||
_LIBSTDAUDIO_NAMESPACE_END | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
#include <__audio_base.h> | ||
#include <stdexcept> | ||
|
||
_LIBSTDAUDIO_NAMESPACE_BEGIN | ||
|
||
struct audio_device_exception : public runtime_error { | ||
explicit audio_device_exception(const char* what) | ||
: runtime_error(what) { | ||
} | ||
}; | ||
|
||
_LIBSTDAUDIO_NAMESPACE_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#pragma once | ||
#include <__audio_base.h> | ||
|
||
#if defined(_WIN32) | ||
#define __STDAUDIO_HAS_DYLIB 1 | ||
#include <windows.h> | ||
#elif __has_include(<dlfcn.h>) | ||
#define __STDAUDIO_HAS_DYLIB 1 | ||
#include <dlfcn.h> | ||
#endif | ||
|
||
_LIBSTDAUDIO_NAMESPACE_BEGIN | ||
#if __STDAUDIO_HAS_DYLIB | ||
class __dynamic_library | ||
{ | ||
public: | ||
explicit __dynamic_library(const char* const so) /* not noexcept - some DLL constructors can throw */ | ||
{ | ||
#ifdef _WIN32 | ||
impl = (void*)LoadLibraryA(so); | ||
#else | ||
impl = dlopen(so, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE); | ||
#endif | ||
} | ||
|
||
__dynamic_library(const __dynamic_library&) noexcept = delete; | ||
__dynamic_library& operator=(const __dynamic_library&) noexcept = delete; | ||
__dynamic_library(__dynamic_library&& other) | ||
{ | ||
impl = other.impl; | ||
other.impl = nullptr; | ||
} | ||
|
||
__dynamic_library& operator=(__dynamic_library&& other) noexcept | ||
{ | ||
impl = other.impl; | ||
other.impl = nullptr; | ||
return *this; | ||
} | ||
|
||
~__dynamic_library() | ||
{ | ||
if (impl) | ||
{ | ||
#ifdef _WIN32 | ||
FreeLibrary((HMODULE)impl); | ||
#else | ||
dlclose(impl); | ||
#endif | ||
} | ||
} | ||
|
||
template <typename T> | ||
T symbol(const char* const sym) const noexcept | ||
{ | ||
#ifdef _WIN32 | ||
return (T)GetProcAddress((HMODULE)impl, sym); | ||
#else | ||
return (T)dlsym(impl, sym); | ||
#endif | ||
} | ||
|
||
operator bool() const { return bool(impl); } | ||
|
||
private: | ||
void* impl{}; | ||
}; | ||
#endif | ||
|
||
_LIBSTDAUDIO_NAMESPACE_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.