mirror of https://github.com/encounter/SDL.git
pulseaudio: Optionally add "monitor" sources to device list.
There's a new hint to enable this. Fixes #2917.
This commit is contained in:
parent
8d790b10f8
commit
736a424ff4
|
@ -1675,6 +1675,25 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING "SDL_XINPUT_USE_OLD_JOYSTICK_MAPPING"
|
#define SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING "SDL_XINPUT_USE_OLD_JOYSTICK_MAPPING"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief A variable that causes SDL to not ignore audio "monitors"
|
||||||
|
*
|
||||||
|
* This is currently only used for PulseAudio and ignored elsewhere.
|
||||||
|
*
|
||||||
|
* By default, SDL ignores audio devices that aren't associated with physical
|
||||||
|
* hardware. Changing this hint to "1" will expose anything SDL sees that
|
||||||
|
* appears to be an audio source or sink. This will add "devices" to the list
|
||||||
|
* that the user probably doesn't want or need, but it can be useful in
|
||||||
|
* scenarios where you want to hook up SDL to some sort of virtual device,
|
||||||
|
* etc.
|
||||||
|
*
|
||||||
|
* The default value is "0". This hint must be set before SDL_Init().
|
||||||
|
*
|
||||||
|
* This hint is available since SDL 2.0.16. Before then, virtual devices are
|
||||||
|
* always ignored.
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_AUDIO_INCLUDE_MONITORS "SDL_AUDIO_INCLUDE_MONITORS"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief An enumeration of hint priorities
|
* \brief An enumeration of hint priorities
|
||||||
|
|
|
@ -46,6 +46,10 @@
|
||||||
#include "SDL_loadso.h"
|
#include "SDL_loadso.h"
|
||||||
#include "../../thread/SDL_systhread.h"
|
#include "../../thread/SDL_systhread.h"
|
||||||
|
|
||||||
|
/* should we include monitors in the device list? Set at SDL_Init time */
|
||||||
|
static SDL_bool include_monitors = SDL_FALSE;
|
||||||
|
|
||||||
|
|
||||||
#if (PA_API_VERSION < 12)
|
#if (PA_API_VERSION < 12)
|
||||||
/** Return non-zero if the passed state is one of the connected states */
|
/** Return non-zero if the passed state is one of the connected states */
|
||||||
static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x) {
|
static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x) {
|
||||||
|
@ -744,8 +748,8 @@ SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *da
|
||||||
{
|
{
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
if (i) {
|
if (i) {
|
||||||
/* Skip "monitor" sources. These are just output from other sinks. */
|
/* Maybe skip "monitor" sources. These are just output from other sinks. */
|
||||||
if (i->monitor_of_sink == PA_INVALID_INDEX) {
|
if (include_monitors || (i->monitor_of_sink == PA_INVALID_INDEX)) {
|
||||||
spec.freq = i->sample_spec.rate;
|
spec.freq = i->sample_spec.rate;
|
||||||
spec.channels = i->sample_spec.channels;
|
spec.channels = i->sample_spec.channels;
|
||||||
spec.format = PulseFormatToSDLFormat(i->sample_spec.format);
|
spec.format = PulseFormatToSDLFormat(i->sample_spec.format);
|
||||||
|
@ -834,6 +838,8 @@ PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include_monitors = SDL_GetHintBoolean(SDL_HINT_AUDIO_INCLUDE_MONITORS, SDL_FALSE);
|
||||||
|
|
||||||
/* Set the function pointers */
|
/* Set the function pointers */
|
||||||
impl->DetectDevices = PULSEAUDIO_DetectDevices;
|
impl->DetectDevices = PULSEAUDIO_DetectDevices;
|
||||||
impl->OpenDevice = PULSEAUDIO_OpenDevice;
|
impl->OpenDevice = PULSEAUDIO_OpenDevice;
|
||||||
|
|
Loading…
Reference in New Issue