New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -8,21 +8,20 @@
|
|||
#include "mac-helpers.h"
|
||||
|
||||
static bool obs_enum_audio_monitoring_device(obs_enum_audio_device_cb cb,
|
||||
void *data, AudioDeviceID id, bool allow_inputs)
|
||||
void *data, AudioDeviceID id,
|
||||
bool allow_inputs)
|
||||
{
|
||||
UInt32 size = 0;
|
||||
UInt32 size = 0;
|
||||
CFStringRef cf_name = NULL;
|
||||
CFStringRef cf_uid = NULL;
|
||||
char *name = NULL;
|
||||
char *uid = NULL;
|
||||
OSStatus stat;
|
||||
bool cont = true;
|
||||
CFStringRef cf_uid = NULL;
|
||||
char *name = NULL;
|
||||
char *uid = NULL;
|
||||
OSStatus stat;
|
||||
bool cont = true;
|
||||
|
||||
AudioObjectPropertyAddress addr = {
|
||||
kAudioDevicePropertyStreams,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
AudioObjectPropertyAddress addr = {kAudioDevicePropertyStreams,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMaster};
|
||||
|
||||
/* Check if the device is capable of audio output. */
|
||||
AudioObjectGetPropertyDataSize(id, &addr, 0, NULL, &size);
|
||||
|
|
@ -66,33 +65,31 @@ fail:
|
|||
}
|
||||
|
||||
static void enum_audio_devices(obs_enum_audio_device_cb cb, void *data,
|
||||
bool allow_inputs)
|
||||
bool allow_inputs)
|
||||
{
|
||||
AudioObjectPropertyAddress addr = {
|
||||
kAudioHardwarePropertyDevices,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
AudioObjectPropertyAddress addr = {kAudioHardwarePropertyDevices,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster};
|
||||
|
||||
UInt32 size = 0;
|
||||
UInt32 count;
|
||||
OSStatus stat;
|
||||
UInt32 size = 0;
|
||||
UInt32 count;
|
||||
OSStatus stat;
|
||||
AudioDeviceID *ids;
|
||||
|
||||
stat = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size);
|
||||
0, NULL, &size);
|
||||
if (!success(stat, "get data size"))
|
||||
return;
|
||||
|
||||
ids = malloc(size);
|
||||
ids = malloc(size);
|
||||
count = size / sizeof(AudioDeviceID);
|
||||
|
||||
stat = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size, ids);
|
||||
stat = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0,
|
||||
NULL, &size, ids);
|
||||
if (success(stat, "get data")) {
|
||||
for (UInt32 i = 0; i < count; i++) {
|
||||
if (!obs_enum_audio_monitoring_device(cb, data, ids[i],
|
||||
allow_inputs))
|
||||
allow_inputs))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -119,21 +116,20 @@ static void get_default_id(char **p_id)
|
|||
AudioObjectPropertyAddress addr = {
|
||||
kAudioHardwarePropertyDefaultSystemOutputDevice,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
kAudioObjectPropertyElementMaster};
|
||||
|
||||
if (*p_id)
|
||||
return;
|
||||
|
||||
OSStatus stat;
|
||||
OSStatus stat;
|
||||
AudioDeviceID id = 0;
|
||||
UInt32 size = sizeof(id);
|
||||
UInt32 size = sizeof(id);
|
||||
|
||||
stat = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0,
|
||||
NULL, &size, &id);
|
||||
NULL, &size, &id);
|
||||
if (success(stat, "AudioObjectGetPropertyData"))
|
||||
obs_enum_audio_monitoring_device(alloc_default_id, p_id, id,
|
||||
true);
|
||||
true);
|
||||
if (!*p_id)
|
||||
*p_id = bzalloc(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,21 +13,21 @@
|
|||
#include "mac-helpers.h"
|
||||
|
||||
struct audio_monitor {
|
||||
obs_source_t *source;
|
||||
AudioQueueRef queue;
|
||||
AudioQueueBufferRef buffers[3];
|
||||
obs_source_t *source;
|
||||
AudioQueueRef queue;
|
||||
AudioQueueBufferRef buffers[3];
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
struct circlebuf empty_buffers;
|
||||
struct circlebuf new_data;
|
||||
audio_resampler_t *resampler;
|
||||
size_t buffer_size;
|
||||
size_t wait_size;
|
||||
uint32_t channels;
|
||||
pthread_mutex_t mutex;
|
||||
struct circlebuf empty_buffers;
|
||||
struct circlebuf new_data;
|
||||
audio_resampler_t *resampler;
|
||||
size_t buffer_size;
|
||||
size_t wait_size;
|
||||
uint32_t channels;
|
||||
|
||||
volatile bool active;
|
||||
bool paused;
|
||||
bool ignore;
|
||||
volatile bool active;
|
||||
bool paused;
|
||||
bool ignore;
|
||||
};
|
||||
|
||||
static inline bool fill_buffer(struct audio_monitor *monitor)
|
||||
|
|
@ -41,21 +41,21 @@ static inline bool fill_buffer(struct audio_monitor *monitor)
|
|||
|
||||
circlebuf_pop_front(&monitor->empty_buffers, &buf, sizeof(buf));
|
||||
circlebuf_pop_front(&monitor->new_data, buf->mAudioData,
|
||||
monitor->buffer_size);
|
||||
monitor->buffer_size);
|
||||
|
||||
buf->mAudioDataByteSize = monitor->buffer_size;
|
||||
|
||||
stat = AudioQueueEnqueueBuffer(monitor->queue, buf, 0, NULL);
|
||||
if (!success(stat, "AudioQueueEnqueueBuffer")) {
|
||||
blog(LOG_WARNING, "%s: %s", __FUNCTION__,
|
||||
"Failed to enqueue buffer");
|
||||
"Failed to enqueue buffer");
|
||||
AudioQueueStop(monitor->queue, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void on_audio_playback(void *param, obs_source_t *source,
|
||||
const struct audio_data *audio_data, bool muted)
|
||||
const struct audio_data *audio_data, bool muted)
|
||||
{
|
||||
struct audio_monitor *monitor = param;
|
||||
float vol = source->user_volume;
|
||||
|
|
@ -72,10 +72,10 @@ static void on_audio_playback(void *param, obs_source_t *source,
|
|||
uint64_t ts_offset;
|
||||
bool success;
|
||||
|
||||
success = audio_resampler_resample(monitor->resampler, resample_data,
|
||||
&resample_frames, &ts_offset,
|
||||
(const uint8_t *const *)audio_data->data,
|
||||
(uint32_t)audio_data->frames);
|
||||
success = audio_resampler_resample(
|
||||
monitor->resampler, resample_data, &resample_frames, &ts_offset,
|
||||
(const uint8_t *const *)audio_data->data,
|
||||
(uint32_t)audio_data->frames);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -87,9 +87,9 @@ static void on_audio_playback(void *param, obs_source_t *source,
|
|||
} else {
|
||||
/* apply volume */
|
||||
if (!close_float(vol, 1.0f, EPSILON)) {
|
||||
register float *cur = (float*)resample_data[0];
|
||||
register float *end = cur +
|
||||
resample_frames * monitor->channels;
|
||||
register float *cur = (float *)resample_data[0];
|
||||
register float *end =
|
||||
cur + resample_frames * monitor->channels;
|
||||
|
||||
while (cur < end)
|
||||
*(cur++) *= vol;
|
||||
|
|
@ -141,10 +141,10 @@ static void buffer_audio(void *data, AudioQueueRef aq, AudioQueueBufferRef buf)
|
|||
extern bool devices_match(const char *id1, const char *id2);
|
||||
|
||||
static bool audio_monitor_init(struct audio_monitor *monitor,
|
||||
obs_source_t *source)
|
||||
obs_source_t *source)
|
||||
{
|
||||
const struct audio_output_info *info = audio_output_get_info(
|
||||
obs->audio.audio);
|
||||
const struct audio_output_info *info =
|
||||
audio_output_get_info(obs->audio.audio);
|
||||
uint32_t channels = get_audio_channels(info->speakers);
|
||||
OSStatus stat;
|
||||
|
||||
|
|
@ -152,13 +152,12 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
.mSampleRate = (Float64)info->samples_per_sec,
|
||||
.mFormatID = kAudioFormatLinearPCM,
|
||||
.mFormatFlags = kAudioFormatFlagIsFloat |
|
||||
kAudioFormatFlagIsPacked,
|
||||
kAudioFormatFlagIsPacked,
|
||||
.mBytesPerPacket = sizeof(float) * channels,
|
||||
.mFramesPerPacket = 1,
|
||||
.mBytesPerFrame = sizeof(float) * channels,
|
||||
.mChannelsPerFrame = channels,
|
||||
.mBitsPerChannel = sizeof(float) * 8
|
||||
};
|
||||
.mBitsPerChannel = sizeof(float) * 8};
|
||||
|
||||
monitor->source = source;
|
||||
|
||||
|
|
@ -187,20 +186,19 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
}
|
||||
|
||||
stat = AudioQueueNewOutput(&desc, buffer_audio, monitor, NULL, NULL, 0,
|
||||
&monitor->queue);
|
||||
&monitor->queue);
|
||||
if (!success(stat, "AudioStreamBasicDescription")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcmp(uid, "default") != 0) {
|
||||
CFStringRef cf_uid = CFStringCreateWithBytes(NULL,
|
||||
(const UInt8*)uid, strlen(uid),
|
||||
kCFStringEncodingUTF8,
|
||||
false);
|
||||
CFStringRef cf_uid = CFStringCreateWithBytes(
|
||||
NULL, (const UInt8 *)uid, strlen(uid),
|
||||
kCFStringEncodingUTF8, false);
|
||||
|
||||
stat = AudioQueueSetProperty(monitor->queue,
|
||||
kAudioQueueProperty_CurrentDevice,
|
||||
&cf_uid, sizeof(cf_uid));
|
||||
kAudioQueueProperty_CurrentDevice,
|
||||
&cf_uid, sizeof(cf_uid));
|
||||
CFRelease(cf_uid);
|
||||
|
||||
if (!success(stat, "set current device")) {
|
||||
|
|
@ -208,45 +206,42 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
}
|
||||
}
|
||||
|
||||
stat = AudioQueueSetParameter(monitor->queue,
|
||||
kAudioQueueParam_Volume, 1.0);
|
||||
stat = AudioQueueSetParameter(monitor->queue, kAudioQueueParam_Volume,
|
||||
1.0);
|
||||
if (!success(stat, "set volume")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
stat = AudioQueueAllocateBuffer(monitor->queue,
|
||||
monitor->buffer_size, &monitor->buffers[i]);
|
||||
monitor->buffer_size,
|
||||
&monitor->buffers[i]);
|
||||
if (!success(stat, "allocation of buffer")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
circlebuf_push_back(&monitor->empty_buffers,
|
||||
&monitor->buffers[i],
|
||||
sizeof(monitor->buffers[i]));
|
||||
&monitor->buffers[i],
|
||||
sizeof(monitor->buffers[i]));
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&monitor->mutex, NULL) != 0) {
|
||||
blog(LOG_WARNING, "%s: %s", __FUNCTION__,
|
||||
"Failed to init mutex");
|
||||
"Failed to init mutex");
|
||||
return false;
|
||||
}
|
||||
|
||||
struct resample_info from = {
|
||||
.samples_per_sec = info->samples_per_sec,
|
||||
.speakers = info->speakers,
|
||||
.format = AUDIO_FORMAT_FLOAT_PLANAR
|
||||
};
|
||||
struct resample_info to = {
|
||||
.samples_per_sec = info->samples_per_sec,
|
||||
.speakers = info->speakers,
|
||||
.format = AUDIO_FORMAT_FLOAT
|
||||
};
|
||||
struct resample_info from = {.samples_per_sec = info->samples_per_sec,
|
||||
.speakers = info->speakers,
|
||||
.format = AUDIO_FORMAT_FLOAT_PLANAR};
|
||||
struct resample_info to = {.samples_per_sec = info->samples_per_sec,
|
||||
.speakers = info->speakers,
|
||||
.format = AUDIO_FORMAT_FLOAT};
|
||||
|
||||
monitor->resampler = audio_resampler_create(&to, &from);
|
||||
if (!monitor->resampler) {
|
||||
blog(LOG_WARNING, "%s: %s", __FUNCTION__,
|
||||
"Failed to create resampler");
|
||||
"Failed to create resampler");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -263,7 +258,7 @@ static void audio_monitor_free(struct audio_monitor *monitor)
|
|||
{
|
||||
if (monitor->source) {
|
||||
obs_source_remove_audio_capture_callback(
|
||||
monitor->source, on_audio_playback, monitor);
|
||||
monitor->source, on_audio_playback, monitor);
|
||||
}
|
||||
if (monitor->active) {
|
||||
AudioQueueStop(monitor->queue, true);
|
||||
|
|
@ -271,7 +266,7 @@ static void audio_monitor_free(struct audio_monitor *monitor)
|
|||
for (size_t i = 0; i < 3; i++) {
|
||||
if (monitor->buffers[i]) {
|
||||
AudioQueueFreeBuffer(monitor->queue,
|
||||
monitor->buffers[i]);
|
||||
monitor->buffers[i]);
|
||||
}
|
||||
}
|
||||
if (monitor->queue) {
|
||||
|
|
@ -290,7 +285,7 @@ static void audio_monitor_init_final(struct audio_monitor *monitor)
|
|||
return;
|
||||
|
||||
obs_source_add_audio_capture_callback(monitor->source,
|
||||
on_audio_playback, monitor);
|
||||
on_audio_playback, monitor);
|
||||
}
|
||||
|
||||
struct audio_monitor *audio_monitor_create(obs_source_t *source)
|
||||
|
|
|
|||
|
|
@ -3,13 +3,11 @@
|
|||
static bool success_(OSStatus stat, const char *func, const char *call)
|
||||
{
|
||||
if (stat != noErr) {
|
||||
blog(LOG_WARNING, "%s: %s failed: %d",
|
||||
func, call, (int)stat);
|
||||
blog(LOG_WARNING, "%s: %s failed: %d", func, call, (int)stat);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define success(stat, call) \
|
||||
success_(stat, __FUNCTION__, call)
|
||||
#define success(stat, call) success_(stat, __FUNCTION__, call)
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
#include "pulseaudio-wrapper.h"
|
||||
|
||||
static void pulseaudio_output_info(pa_context *c, const pa_source_info *i,
|
||||
int eol, void *userdata)
|
||||
int eol, void *userdata)
|
||||
{
|
||||
UNUSED_PARAMETER(c);
|
||||
if (eol != 0 || i->monitor_of_sink == PA_INVALID_INDEX)
|
||||
goto skip;
|
||||
|
||||
struct enum_cb *ecb = (struct enum_cb *) userdata;
|
||||
struct enum_cb *ecb = (struct enum_cb *)userdata;
|
||||
if (ecb->cont)
|
||||
ecb->cont = ecb->cb(ecb->data, i->description, i->name);
|
||||
|
||||
|
|
@ -16,8 +16,7 @@ skip:
|
|||
pulseaudio_signal(0);
|
||||
}
|
||||
|
||||
void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb,
|
||||
void *data)
|
||||
void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb, void *data)
|
||||
{
|
||||
struct enum_cb *ecb = bzalloc(sizeof(struct enum_cb));
|
||||
ecb->cb = cb;
|
||||
|
|
@ -26,7 +25,7 @@ void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb,
|
|||
|
||||
pulseaudio_init();
|
||||
pa_source_info_cb_t pa_cb = pulseaudio_output_info;
|
||||
pulseaudio_get_source_info_list(pa_cb, (void *) ecb);
|
||||
pulseaudio_get_source_info_list(pa_cb, (void *)ecb);
|
||||
pulseaudio_unref();
|
||||
|
||||
bfree(ecb);
|
||||
|
|
|
|||
|
|
@ -5,47 +5,56 @@
|
|||
#define blog(level, msg, ...) blog(level, "pulse-am: " msg, ##__VA_ARGS__)
|
||||
|
||||
struct audio_monitor {
|
||||
obs_source_t *source;
|
||||
pa_stream *stream;
|
||||
char *device;
|
||||
pa_buffer_attr attr;
|
||||
enum speaker_layout speakers;
|
||||
pa_sample_format_t format;
|
||||
uint_fast32_t samples_per_sec;
|
||||
uint_fast32_t bytes_per_frame;
|
||||
uint_fast8_t channels;
|
||||
obs_source_t *source;
|
||||
pa_stream *stream;
|
||||
char *device;
|
||||
pa_buffer_attr attr;
|
||||
enum speaker_layout speakers;
|
||||
pa_sample_format_t format;
|
||||
uint_fast32_t samples_per_sec;
|
||||
uint_fast32_t bytes_per_frame;
|
||||
uint_fast8_t channels;
|
||||
|
||||
uint_fast32_t packets;
|
||||
uint_fast64_t frames;
|
||||
uint_fast32_t packets;
|
||||
uint_fast64_t frames;
|
||||
|
||||
struct circlebuf new_data;
|
||||
audio_resampler_t *resampler;
|
||||
size_t buffer_size;
|
||||
size_t bytesRemaining;
|
||||
size_t bytes_per_channel;
|
||||
struct circlebuf new_data;
|
||||
audio_resampler_t *resampler;
|
||||
size_t buffer_size;
|
||||
size_t bytesRemaining;
|
||||
size_t bytes_per_channel;
|
||||
|
||||
bool ignore;
|
||||
pthread_mutex_t playback_mutex;
|
||||
bool ignore;
|
||||
pthread_mutex_t playback_mutex;
|
||||
};
|
||||
|
||||
static enum speaker_layout pulseaudio_channels_to_obs_speakers(
|
||||
uint_fast32_t channels)
|
||||
static enum speaker_layout
|
||||
pulseaudio_channels_to_obs_speakers(uint_fast32_t channels)
|
||||
{
|
||||
switch (channels) {
|
||||
case 0: return SPEAKERS_UNKNOWN;
|
||||
case 1: return SPEAKERS_MONO;
|
||||
case 2: return SPEAKERS_STEREO;
|
||||
case 3: return SPEAKERS_2POINT1;
|
||||
case 4: return SPEAKERS_4POINT0;
|
||||
case 5: return SPEAKERS_4POINT1;
|
||||
case 6: return SPEAKERS_5POINT1;
|
||||
case 8: return SPEAKERS_7POINT1;
|
||||
default: return SPEAKERS_UNKNOWN;
|
||||
case 0:
|
||||
return SPEAKERS_UNKNOWN;
|
||||
case 1:
|
||||
return SPEAKERS_MONO;
|
||||
case 2:
|
||||
return SPEAKERS_STEREO;
|
||||
case 3:
|
||||
return SPEAKERS_2POINT1;
|
||||
case 4:
|
||||
return SPEAKERS_4POINT0;
|
||||
case 5:
|
||||
return SPEAKERS_4POINT1;
|
||||
case 6:
|
||||
return SPEAKERS_5POINT1;
|
||||
case 8:
|
||||
return SPEAKERS_7POINT1;
|
||||
default:
|
||||
return SPEAKERS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static enum audio_format pulseaudio_to_obs_audio_format(
|
||||
pa_sample_format_t format)
|
||||
static enum audio_format
|
||||
pulseaudio_to_obs_audio_format(pa_sample_format_t format)
|
||||
{
|
||||
switch (format) {
|
||||
case PA_SAMPLE_U8:
|
||||
|
|
@ -118,7 +127,7 @@ static pa_channel_map pulseaudio_channel_map(enum speaker_layout layout)
|
|||
|
||||
static void process_byte(void *p, size_t frames, size_t channels, float vol)
|
||||
{
|
||||
register char *cur = (char *) p;
|
||||
register char *cur = (char *)p;
|
||||
register char *end = cur + frames * channels;
|
||||
|
||||
while (cur < end)
|
||||
|
|
@ -127,7 +136,7 @@ static void process_byte(void *p, size_t frames, size_t channels, float vol)
|
|||
|
||||
static void process_short(void *p, size_t frames, size_t channels, float vol)
|
||||
{
|
||||
register short *cur = (short *) p;
|
||||
register short *cur = (short *)p;
|
||||
register short *end = cur + frames * channels;
|
||||
|
||||
while (cur < end)
|
||||
|
|
@ -136,7 +145,7 @@ static void process_short(void *p, size_t frames, size_t channels, float vol)
|
|||
|
||||
static void process_float(void *p, size_t frames, size_t channels, float vol)
|
||||
{
|
||||
register float *cur = (float *) p;
|
||||
register float *cur = (float *)p;
|
||||
register float *end = cur + frames * channels;
|
||||
|
||||
while (cur < end)
|
||||
|
|
@ -144,20 +153,20 @@ static void process_float(void *p, size_t frames, size_t channels, float vol)
|
|||
}
|
||||
|
||||
void process_volume(const struct audio_monitor *monitor, float vol,
|
||||
uint8_t *const *resample_data, uint32_t resample_frames)
|
||||
uint8_t *const *resample_data, uint32_t resample_frames)
|
||||
{
|
||||
switch (monitor->bytes_per_channel) {
|
||||
case 1:
|
||||
process_byte(resample_data[0], resample_frames,
|
||||
monitor->channels, vol);
|
||||
monitor->channels, vol);
|
||||
break;
|
||||
case 2:
|
||||
process_short(resample_data[0], resample_frames,
|
||||
monitor->channels, vol);
|
||||
monitor->channels, vol);
|
||||
break;
|
||||
default:
|
||||
process_float(resample_data[0], resample_frames,
|
||||
monitor->channels, vol);
|
||||
monitor->channels, vol);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -168,20 +177,20 @@ static void do_stream_write(void *param)
|
|||
uint8_t *buffer = NULL;
|
||||
|
||||
while (data->new_data.size >= data->buffer_size &&
|
||||
data->bytesRemaining > 0) {
|
||||
data->bytesRemaining > 0) {
|
||||
size_t bytesToFill = data->buffer_size;
|
||||
|
||||
if (bytesToFill > data->bytesRemaining)
|
||||
bytesToFill = data->bytesRemaining;
|
||||
|
||||
pa_stream_begin_write(data->stream, (void **) &buffer,
|
||||
&bytesToFill);
|
||||
pa_stream_begin_write(data->stream, (void **)&buffer,
|
||||
&bytesToFill);
|
||||
|
||||
circlebuf_pop_front(&data->new_data, buffer, bytesToFill);
|
||||
|
||||
pulseaudio_lock();
|
||||
pa_stream_write(data->stream, buffer, bytesToFill, NULL,
|
||||
0LL, PA_SEEK_RELATIVE);
|
||||
pa_stream_write(data->stream, buffer, bytesToFill, NULL, 0LL,
|
||||
PA_SEEK_RELATIVE);
|
||||
pulseaudio_unlock();
|
||||
|
||||
data->bytesRemaining -= bytesToFill;
|
||||
|
|
@ -189,7 +198,7 @@ static void do_stream_write(void *param)
|
|||
}
|
||||
|
||||
static void on_audio_playback(void *param, obs_source_t *source,
|
||||
const struct audio_data *audio_data, bool muted)
|
||||
const struct audio_data *audio_data, bool muted)
|
||||
{
|
||||
struct audio_monitor *monitor = param;
|
||||
float vol = source->user_volume;
|
||||
|
|
@ -206,10 +215,10 @@ static void on_audio_playback(void *param, obs_source_t *source,
|
|||
if (os_atomic_load_long(&source->activate_refs) == 0)
|
||||
goto unlock;
|
||||
|
||||
success = audio_resampler_resample(monitor->resampler, resample_data,
|
||||
&resample_frames, &ts_offset,
|
||||
(const uint8_t *const *) audio_data->data,
|
||||
(uint32_t) audio_data->frames);
|
||||
success = audio_resampler_resample(
|
||||
monitor->resampler, resample_data, &resample_frames, &ts_offset,
|
||||
(const uint8_t *const *)audio_data->data,
|
||||
(uint32_t)audio_data->frames);
|
||||
|
||||
if (!success)
|
||||
goto unlock;
|
||||
|
|
@ -221,7 +230,7 @@ static void on_audio_playback(void *param, obs_source_t *source,
|
|||
} else {
|
||||
if (!close_float(vol, 1.0f, EPSILON)) {
|
||||
process_volume(monitor, vol, resample_data,
|
||||
resample_frames);
|
||||
resample_frames);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -262,19 +271,19 @@ static void pulseaudio_underflow(pa_stream *p, void *userdata)
|
|||
}
|
||||
|
||||
static void pulseaudio_server_info(pa_context *c, const pa_server_info *i,
|
||||
void *userdata)
|
||||
void *userdata)
|
||||
{
|
||||
UNUSED_PARAMETER(c);
|
||||
UNUSED_PARAMETER(userdata);
|
||||
|
||||
blog(LOG_INFO, "Server name: '%s %s'", i->server_name,
|
||||
i->server_version);
|
||||
i->server_version);
|
||||
|
||||
pulseaudio_signal(0);
|
||||
}
|
||||
|
||||
static void pulseaudio_source_info(pa_context *c, const pa_source_info *i,
|
||||
int eol, void *userdata)
|
||||
int eol, void *userdata)
|
||||
{
|
||||
UNUSED_PARAMETER(c);
|
||||
PULSE_DATA(userdata);
|
||||
|
|
@ -287,29 +296,29 @@ static void pulseaudio_source_info(pa_context *c, const pa_source_info *i,
|
|||
if (eol > 0)
|
||||
goto skip;
|
||||
|
||||
blog(LOG_INFO, "Audio format: %s, %"PRIu32" Hz, %"PRIu8" channels",
|
||||
pa_sample_format_to_string(i->sample_spec.format),
|
||||
i->sample_spec.rate, i->sample_spec.channels);
|
||||
blog(LOG_INFO, "Audio format: %s, %" PRIu32 " Hz, %" PRIu8 " channels",
|
||||
pa_sample_format_to_string(i->sample_spec.format),
|
||||
i->sample_spec.rate, i->sample_spec.channels);
|
||||
|
||||
pa_sample_format_t format = i->sample_spec.format;
|
||||
if (pulseaudio_to_obs_audio_format(format) == AUDIO_FORMAT_UNKNOWN) {
|
||||
format = PA_SAMPLE_FLOAT32LE;
|
||||
|
||||
blog(LOG_INFO, "Sample format %s not supported by OBS,"
|
||||
"using %s instead for recording",
|
||||
pa_sample_format_to_string(
|
||||
i->sample_spec.format),
|
||||
pa_sample_format_to_string(format));
|
||||
blog(LOG_INFO,
|
||||
"Sample format %s not supported by OBS,"
|
||||
"using %s instead for recording",
|
||||
pa_sample_format_to_string(i->sample_spec.format),
|
||||
pa_sample_format_to_string(format));
|
||||
}
|
||||
|
||||
uint8_t channels = i->sample_spec.channels;
|
||||
if (pulseaudio_channels_to_obs_speakers(channels) == SPEAKERS_UNKNOWN) {
|
||||
channels = 2;
|
||||
|
||||
blog(LOG_INFO, "%c channels not supported by OBS,"
|
||||
"using %c instead for recording",
|
||||
i->sample_spec.channels,
|
||||
channels);
|
||||
blog(LOG_INFO,
|
||||
"%c channels not supported by OBS,"
|
||||
"using %c instead for recording",
|
||||
i->sample_spec.channels, channels);
|
||||
}
|
||||
|
||||
data->format = format;
|
||||
|
|
@ -328,15 +337,16 @@ static void pulseaudio_stop_playback(struct audio_monitor *monitor)
|
|||
}
|
||||
|
||||
blog(LOG_INFO, "Stopped Monitoring in '%s'", monitor->device);
|
||||
blog(LOG_INFO, "Got %"PRIuFAST32" packets with %"PRIuFAST64" frames",
|
||||
monitor->packets, monitor->frames);
|
||||
blog(LOG_INFO,
|
||||
"Got %" PRIuFAST32 " packets with %" PRIuFAST64 " frames",
|
||||
monitor->packets, monitor->frames);
|
||||
|
||||
monitor->packets = 0;
|
||||
monitor->frames = 0;
|
||||
}
|
||||
|
||||
static bool audio_monitor_init(struct audio_monitor *monitor,
|
||||
obs_source_t *source)
|
||||
obs_source_t *source)
|
||||
{
|
||||
pthread_mutex_init_value(&monitor->playback_mutex);
|
||||
|
||||
|
|
@ -355,7 +365,7 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
if (match) {
|
||||
monitor->ignore = true;
|
||||
blog(LOG_INFO, "Prevented feedback-loop in '%s'",
|
||||
s_dev_id);
|
||||
s_dev_id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -371,25 +381,25 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
return false;
|
||||
|
||||
if (pulseaudio_get_server_info(pulseaudio_server_info,
|
||||
(void *) monitor) < 0) {
|
||||
(void *)monitor) < 0) {
|
||||
blog(LOG_ERROR, "Unable to get server info !");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pulseaudio_get_source_info(pulseaudio_source_info, monitor->device,
|
||||
(void *) monitor) < 0) {
|
||||
(void *)monitor) < 0) {
|
||||
blog(LOG_ERROR, "Unable to get source info !");
|
||||
return false;
|
||||
}
|
||||
if (monitor->format == PA_SAMPLE_INVALID) {
|
||||
blog(LOG_ERROR,
|
||||
"An error occurred while getting the source info!");
|
||||
"An error occurred while getting the source info!");
|
||||
return false;
|
||||
}
|
||||
|
||||
pa_sample_spec spec;
|
||||
spec.format = monitor->format;
|
||||
spec.rate = (uint32_t) monitor->samples_per_sec;
|
||||
spec.rate = (uint32_t)monitor->samples_per_sec;
|
||||
spec.channels = monitor->channels;
|
||||
|
||||
if (!pa_sample_spec_valid(&spec)) {
|
||||
|
|
@ -397,31 +407,27 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
return false;
|
||||
}
|
||||
|
||||
const struct audio_output_info *info = audio_output_get_info(
|
||||
obs->audio.audio);
|
||||
const struct audio_output_info *info =
|
||||
audio_output_get_info(obs->audio.audio);
|
||||
|
||||
struct resample_info from = {
|
||||
.samples_per_sec = info->samples_per_sec,
|
||||
.speakers = info->speakers,
|
||||
.format = AUDIO_FORMAT_FLOAT_PLANAR
|
||||
};
|
||||
struct resample_info from = {.samples_per_sec = info->samples_per_sec,
|
||||
.speakers = info->speakers,
|
||||
.format = AUDIO_FORMAT_FLOAT_PLANAR};
|
||||
struct resample_info to = {
|
||||
.samples_per_sec = (uint32_t) monitor->samples_per_sec,
|
||||
.speakers = pulseaudio_channels_to_obs_speakers(
|
||||
monitor->channels),
|
||||
.format = pulseaudio_to_obs_audio_format
|
||||
(monitor->format)
|
||||
};
|
||||
.samples_per_sec = (uint32_t)monitor->samples_per_sec,
|
||||
.speakers =
|
||||
pulseaudio_channels_to_obs_speakers(monitor->channels),
|
||||
.format = pulseaudio_to_obs_audio_format(monitor->format)};
|
||||
|
||||
monitor->resampler = audio_resampler_create(&to, &from);
|
||||
if (!monitor->resampler) {
|
||||
blog(LOG_WARNING, "%s: %s", __FUNCTION__,
|
||||
"Failed to create resampler");
|
||||
"Failed to create resampler");
|
||||
return false;
|
||||
}
|
||||
|
||||
monitor->bytes_per_channel = get_audio_bytes_per_channel(
|
||||
pulseaudio_to_obs_audio_format(monitor->format));
|
||||
pulseaudio_to_obs_audio_format(monitor->format));
|
||||
monitor->speakers = pulseaudio_channels_to_obs_speakers(spec.channels);
|
||||
monitor->bytes_per_frame = pa_frame_size(&spec);
|
||||
|
||||
|
|
@ -434,26 +440,26 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
return false;
|
||||
}
|
||||
|
||||
monitor->attr.fragsize = (uint32_t) -1;
|
||||
monitor->attr.maxlength = (uint32_t) -1;
|
||||
monitor->attr.minreq = (uint32_t) -1;
|
||||
monitor->attr.prebuf = (uint32_t) -1;
|
||||
monitor->attr.fragsize = (uint32_t)-1;
|
||||
monitor->attr.maxlength = (uint32_t)-1;
|
||||
monitor->attr.minreq = (uint32_t)-1;
|
||||
monitor->attr.prebuf = (uint32_t)-1;
|
||||
monitor->attr.tlength = pa_usec_to_bytes(25000, &spec);
|
||||
|
||||
monitor->buffer_size = monitor->bytes_per_frame *
|
||||
pa_usec_to_bytes(5000, &spec);
|
||||
monitor->buffer_size =
|
||||
monitor->bytes_per_frame * pa_usec_to_bytes(5000, &spec);
|
||||
|
||||
pa_stream_flags_t flags = PA_STREAM_INTERPOLATE_TIMING |
|
||||
PA_STREAM_AUTO_TIMING_UPDATE;
|
||||
PA_STREAM_AUTO_TIMING_UPDATE;
|
||||
|
||||
if (pthread_mutex_init(&monitor->playback_mutex, NULL) != 0) {
|
||||
blog(LOG_WARNING, "%s: %s", __FUNCTION__,
|
||||
"Failed to init mutex");
|
||||
"Failed to init mutex");
|
||||
return false;
|
||||
}
|
||||
|
||||
int_fast32_t ret = pulseaudio_connect_playback(monitor->stream,
|
||||
monitor->device, &monitor->attr, flags);
|
||||
int_fast32_t ret = pulseaudio_connect_playback(
|
||||
monitor->stream, monitor->device, &monitor->attr, flags);
|
||||
if (ret < 0) {
|
||||
pulseaudio_stop_playback(monitor);
|
||||
blog(LOG_ERROR, "Unable to connect to stream");
|
||||
|
|
@ -470,13 +476,13 @@ static void audio_monitor_init_final(struct audio_monitor *monitor)
|
|||
return;
|
||||
|
||||
obs_source_add_audio_capture_callback(monitor->source,
|
||||
on_audio_playback, monitor);
|
||||
on_audio_playback, monitor);
|
||||
|
||||
pulseaudio_write_callback(monitor->stream, pulseaudio_stream_write,
|
||||
(void *) monitor);
|
||||
(void *)monitor);
|
||||
|
||||
pulseaudio_set_underflow_callback(monitor->stream, pulseaudio_underflow,
|
||||
(void *) monitor);
|
||||
(void *)monitor);
|
||||
}
|
||||
|
||||
static inline void audio_monitor_free(struct audio_monitor *monitor)
|
||||
|
|
@ -485,8 +491,8 @@ static inline void audio_monitor_free(struct audio_monitor *monitor)
|
|||
return;
|
||||
|
||||
if (monitor->source)
|
||||
obs_source_remove_audio_capture_callback(monitor->source,
|
||||
on_audio_playback, monitor);
|
||||
obs_source_remove_audio_capture_callback(
|
||||
monitor->source, on_audio_playback, monitor);
|
||||
|
||||
audio_resampler_destroy(monitor->resampler);
|
||||
circlebuf_free(&monitor->new_data);
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ static pa_threaded_mainloop *pulseaudio_mainloop = NULL;
|
|||
static pa_context *pulseaudio_context = NULL;
|
||||
|
||||
static void pulseaudio_default_devices(pa_context *c, const pa_server_info *i,
|
||||
void *userdata)
|
||||
void *userdata)
|
||||
{
|
||||
UNUSED_PARAMETER(c);
|
||||
struct pulseaudio_default_output *d =
|
||||
(struct pulseaudio_default_output *) userdata;
|
||||
(struct pulseaudio_default_output *)userdata;
|
||||
d->default_sink_name = bstrdup(i->default_sink_name);
|
||||
pulseaudio_signal(0);
|
||||
}
|
||||
|
|
@ -44,11 +44,10 @@ static void pulseaudio_default_devices(pa_context *c, const pa_server_info *i,
|
|||
void get_default_id(char **id)
|
||||
{
|
||||
pulseaudio_init();
|
||||
struct pulseaudio_default_output *pdo = bzalloc(
|
||||
sizeof(struct pulseaudio_default_output));
|
||||
struct pulseaudio_default_output *pdo =
|
||||
bzalloc(sizeof(struct pulseaudio_default_output));
|
||||
pulseaudio_get_server_info(
|
||||
(pa_server_info_cb_t) pulseaudio_default_devices,
|
||||
(void *) pdo);
|
||||
(pa_server_info_cb_t)pulseaudio_default_devices, (void *)pdo);
|
||||
*id = bzalloc(strlen(pdo->default_sink_name) + 9);
|
||||
strcat(*id, pdo->default_sink_name);
|
||||
strcat(*id, ".monitor");
|
||||
|
|
@ -118,14 +117,14 @@ static void pulseaudio_init_context()
|
|||
|
||||
pa_proplist *p = pulseaudio_properties();
|
||||
pulseaudio_context = pa_context_new_with_proplist(
|
||||
pa_threaded_mainloop_get_api(pulseaudio_mainloop),
|
||||
"OBS-Monitor", p);
|
||||
pa_threaded_mainloop_get_api(pulseaudio_mainloop),
|
||||
"OBS-Monitor", p);
|
||||
|
||||
pa_context_set_state_callback(pulseaudio_context,
|
||||
pulseaudio_context_state_changed, NULL);
|
||||
pulseaudio_context_state_changed, NULL);
|
||||
|
||||
pa_context_connect(pulseaudio_context, NULL, PA_CONTEXT_NOAUTOSPAWN,
|
||||
NULL);
|
||||
NULL);
|
||||
pa_proplist_free(p);
|
||||
|
||||
pulseaudio_unlock();
|
||||
|
|
@ -217,15 +216,15 @@ void pulseaudio_accept()
|
|||
}
|
||||
|
||||
int_fast32_t pulseaudio_get_source_info_list(pa_source_info_cb_t cb,
|
||||
void *userdata)
|
||||
void *userdata)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return -1;
|
||||
|
||||
pulseaudio_lock();
|
||||
|
||||
pa_operation *op = pa_context_get_source_info_list(
|
||||
pulseaudio_context, cb, userdata);
|
||||
pa_operation *op = pa_context_get_source_info_list(pulseaudio_context,
|
||||
cb, userdata);
|
||||
if (!op) {
|
||||
pulseaudio_unlock();
|
||||
return -1;
|
||||
|
|
@ -240,7 +239,7 @@ int_fast32_t pulseaudio_get_source_info_list(pa_source_info_cb_t cb,
|
|||
}
|
||||
|
||||
int_fast32_t pulseaudio_get_source_info(pa_source_info_cb_t cb,
|
||||
const char *name, void *userdata)
|
||||
const char *name, void *userdata)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return -1;
|
||||
|
|
@ -248,7 +247,7 @@ int_fast32_t pulseaudio_get_source_info(pa_source_info_cb_t cb,
|
|||
pulseaudio_lock();
|
||||
|
||||
pa_operation *op = pa_context_get_source_info_by_name(
|
||||
pulseaudio_context, name, cb, userdata);
|
||||
pulseaudio_context, name, cb, userdata);
|
||||
if (!op) {
|
||||
pulseaudio_unlock();
|
||||
return -1;
|
||||
|
|
@ -269,8 +268,8 @@ int_fast32_t pulseaudio_get_server_info(pa_server_info_cb_t cb, void *userdata)
|
|||
|
||||
pulseaudio_lock();
|
||||
|
||||
pa_operation *op = pa_context_get_server_info(
|
||||
pulseaudio_context, cb, userdata);
|
||||
pa_operation *op =
|
||||
pa_context_get_server_info(pulseaudio_context, cb, userdata);
|
||||
if (!op) {
|
||||
pulseaudio_unlock();
|
||||
return -1;
|
||||
|
|
@ -284,7 +283,7 @@ int_fast32_t pulseaudio_get_server_info(pa_server_info_cb_t cb, void *userdata)
|
|||
}
|
||||
|
||||
pa_stream *pulseaudio_stream_new(const char *name, const pa_sample_spec *ss,
|
||||
const pa_channel_map *map)
|
||||
const pa_channel_map *map)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return NULL;
|
||||
|
|
@ -292,8 +291,8 @@ pa_stream *pulseaudio_stream_new(const char *name, const pa_sample_spec *ss,
|
|||
pulseaudio_lock();
|
||||
|
||||
pa_proplist *p = pulseaudio_properties();
|
||||
pa_stream *s = pa_stream_new_with_proplist(
|
||||
pulseaudio_context, name, ss, map, p);
|
||||
pa_stream *s = pa_stream_new_with_proplist(pulseaudio_context, name, ss,
|
||||
map, p);
|
||||
pa_proplist_free(p);
|
||||
|
||||
pulseaudio_unlock();
|
||||
|
|
@ -301,7 +300,8 @@ pa_stream *pulseaudio_stream_new(const char *name, const pa_sample_spec *ss,
|
|||
}
|
||||
|
||||
int_fast32_t pulseaudio_connect_playback(pa_stream *s, const char *name,
|
||||
const pa_buffer_attr *attr, pa_stream_flags_t flags)
|
||||
const pa_buffer_attr *attr,
|
||||
pa_stream_flags_t flags)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return -1;
|
||||
|
|
@ -311,8 +311,8 @@ int_fast32_t pulseaudio_connect_playback(pa_stream *s, const char *name,
|
|||
memcpy(device, name, dev_len);
|
||||
|
||||
pulseaudio_lock();
|
||||
int_fast32_t ret = pa_stream_connect_playback(s, device, attr, flags,
|
||||
NULL, NULL);
|
||||
int_fast32_t ret =
|
||||
pa_stream_connect_playback(s, device, attr, flags, NULL, NULL);
|
||||
pulseaudio_unlock();
|
||||
|
||||
bfree(device);
|
||||
|
|
@ -320,7 +320,7 @@ int_fast32_t pulseaudio_connect_playback(pa_stream *s, const char *name,
|
|||
}
|
||||
|
||||
void pulseaudio_write_callback(pa_stream *p, pa_stream_request_cb_t cb,
|
||||
void *userdata)
|
||||
void *userdata)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return;
|
||||
|
|
@ -331,7 +331,7 @@ void pulseaudio_write_callback(pa_stream *p, pa_stream_request_cb_t cb,
|
|||
}
|
||||
|
||||
void pulseaudio_set_underflow_callback(pa_stream *p, pa_stream_notify_cb_t cb,
|
||||
void *userdata)
|
||||
void *userdata)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ void pulseaudio_accept();
|
|||
* @warning call without active locks
|
||||
*/
|
||||
int_fast32_t pulseaudio_get_source_info_list(pa_source_info_cb_t cb,
|
||||
void *userdata);
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* Request source information from a specific source
|
||||
|
|
@ -126,7 +126,7 @@ int_fast32_t pulseaudio_get_source_info_list(pa_source_info_cb_t cb,
|
|||
* @warning call without active locks
|
||||
*/
|
||||
int_fast32_t pulseaudio_get_source_info(pa_source_info_cb_t cb,
|
||||
const char *name, void *userdata);
|
||||
const char *name, void *userdata);
|
||||
|
||||
/**
|
||||
* Request server information
|
||||
|
|
@ -150,7 +150,7 @@ int_fast32_t pulseaudio_get_server_info(pa_server_info_cb_t cb, void *userdata);
|
|||
* @warning call without active locks
|
||||
*/
|
||||
pa_stream *pulseaudio_stream_new(const char *name, const pa_sample_spec *ss,
|
||||
const pa_channel_map *map);
|
||||
const pa_channel_map *map);
|
||||
|
||||
/**
|
||||
* Connect to a pulseaudio playback stream
|
||||
|
|
@ -162,7 +162,8 @@ pa_stream *pulseaudio_stream_new(const char *name, const pa_sample_spec *ss,
|
|||
* @return negative on error
|
||||
*/
|
||||
int_fast32_t pulseaudio_connect_playback(pa_stream *s, const char *name,
|
||||
const pa_buffer_attr *attr, pa_stream_flags_t flags);
|
||||
const pa_buffer_attr *attr,
|
||||
pa_stream_flags_t flags);
|
||||
|
||||
/**
|
||||
* Sets a callback function for when data can be written to the stream
|
||||
|
|
@ -172,7 +173,7 @@ int_fast32_t pulseaudio_connect_playback(pa_stream *s, const char *name,
|
|||
* @param userdata pointer to userdata the callback will be called with
|
||||
*/
|
||||
void pulseaudio_write_callback(pa_stream *p, pa_stream_request_cb_t cb,
|
||||
void *userdata);
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* Sets a callback function for when an underflow happen
|
||||
|
|
@ -182,4 +183,4 @@ void pulseaudio_write_callback(pa_stream *p, pa_stream_request_cb_t cb,
|
|||
* @param userdata pointer to userdata the callback will be called with
|
||||
*/
|
||||
void pulseaudio_set_underflow_callback(pa_stream *p, pa_stream_notify_cb_t cb,
|
||||
void *userdata);
|
||||
void *userdata);
|
||||
|
|
|
|||
|
|
@ -10,10 +10,22 @@
|
|||
#undef DEFINE_PROPERTYKEY
|
||||
#endif
|
||||
#define DEFINE_PROPERTYKEY(id, a, b, c, d, e, f, g, h, i, j, k, l) \
|
||||
const PROPERTYKEY id = { { a,b,c, { d,e,f,g,h,i,j,k, } }, l };
|
||||
DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, \
|
||||
0xa45c254e, 0xdf1c, 0x4efd, 0x80, \
|
||||
0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14);
|
||||
const PROPERTYKEY id = {{a, \
|
||||
b, \
|
||||
c, \
|
||||
{ \
|
||||
d, \
|
||||
e, \
|
||||
f, \
|
||||
g, \
|
||||
h, \
|
||||
i, \
|
||||
j, \
|
||||
k, \
|
||||
}}, \
|
||||
l};
|
||||
DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80,
|
||||
0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14);
|
||||
|
||||
#else
|
||||
|
||||
|
|
@ -22,7 +34,7 @@ DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, \
|
|||
#endif
|
||||
|
||||
static bool get_device_info(obs_enum_audio_device_cb cb, void *data,
|
||||
IMMDeviceCollection *collection, UINT idx)
|
||||
IMMDeviceCollection *collection, UINT idx)
|
||||
{
|
||||
IPropertyStore *store = NULL;
|
||||
IMMDevice *device = NULL;
|
||||
|
|
@ -50,7 +62,7 @@ static bool get_device_info(obs_enum_audio_device_cb cb, void *data,
|
|||
|
||||
PropVariantInit(&name_var);
|
||||
hr = store->lpVtbl->GetValue(store, &PKEY_Device_FriendlyName,
|
||||
&name_var);
|
||||
&name_var);
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -68,8 +80,7 @@ fail:
|
|||
return cont;
|
||||
}
|
||||
|
||||
void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb,
|
||||
void *data)
|
||||
void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb, void *data)
|
||||
{
|
||||
IMMDeviceEnumerator *enumerator = NULL;
|
||||
IMMDeviceCollection *collection = NULL;
|
||||
|
|
@ -77,13 +88,13 @@ void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb,
|
|||
HRESULT hr;
|
||||
|
||||
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
||||
&IID_IMMDeviceEnumerator, &enumerator);
|
||||
&IID_IMMDeviceEnumerator, &enumerator);
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = enumerator->lpVtbl->EnumAudioEndpoints(enumerator, eRender,
|
||||
DEVICE_STATE_ACTIVE, &collection);
|
||||
hr = enumerator->lpVtbl->EnumAudioEndpoints(
|
||||
enumerator, eRender, DEVICE_STATE_ACTIVE, &collection);
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -115,13 +126,13 @@ static void get_default_id(char **p_id)
|
|||
return;
|
||||
|
||||
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
||||
&IID_IMMDeviceEnumerator, &immde);
|
||||
&IID_IMMDeviceEnumerator, &immde);
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = immde->lpVtbl->GetDefaultAudioEndpoint(immde,
|
||||
eRender, eConsole, &device);
|
||||
hr = immde->lpVtbl->GetDefaultAudioEndpoint(immde, eRender, eConsole,
|
||||
&device);
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,49 +7,45 @@
|
|||
#include "wasapi-output.h"
|
||||
|
||||
#define ACTUALLY_DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
||||
EXTERN_C const GUID DECLSPEC_SELECTANY name \
|
||||
= { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
|
||||
EXTERN_C const GUID DECLSPEC_SELECTANY name = { \
|
||||
l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
|
||||
|
||||
ACTUALLY_DEFINE_GUID(CLSID_MMDeviceEnumerator,
|
||||
0xBCDE0395, 0xE52F, 0x467C,
|
||||
0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E);
|
||||
ACTUALLY_DEFINE_GUID(IID_IMMDeviceEnumerator,
|
||||
0xA95664D2, 0x9614, 0x4F35,
|
||||
0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6);
|
||||
ACTUALLY_DEFINE_GUID(IID_IAudioClient,
|
||||
0x1CB9AD4C, 0xDBFA, 0x4C32,
|
||||
0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2);
|
||||
ACTUALLY_DEFINE_GUID(IID_IAudioRenderClient,
|
||||
0xF294ACFC, 0x3146, 0x4483,
|
||||
0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2);
|
||||
ACTUALLY_DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xBCDE0395, 0xE52F, 0x467C, 0x8E,
|
||||
0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E);
|
||||
ACTUALLY_DEFINE_GUID(IID_IMMDeviceEnumerator, 0xA95664D2, 0x9614, 0x4F35, 0xA7,
|
||||
0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6);
|
||||
ACTUALLY_DEFINE_GUID(IID_IAudioClient, 0x1CB9AD4C, 0xDBFA, 0x4C32, 0xB1, 0x78,
|
||||
0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2);
|
||||
ACTUALLY_DEFINE_GUID(IID_IAudioRenderClient, 0xF294ACFC, 0x3146, 0x4483, 0xA7,
|
||||
0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2);
|
||||
|
||||
struct audio_monitor {
|
||||
obs_source_t *source;
|
||||
IMMDevice *device;
|
||||
IAudioClient *client;
|
||||
obs_source_t *source;
|
||||
IMMDevice *device;
|
||||
IAudioClient *client;
|
||||
IAudioRenderClient *render;
|
||||
|
||||
uint64_t last_recv_time;
|
||||
uint64_t prev_video_ts;
|
||||
uint64_t time_since_prev;
|
||||
audio_resampler_t *resampler;
|
||||
uint32_t sample_rate;
|
||||
uint32_t channels;
|
||||
bool source_has_video;
|
||||
bool ignore;
|
||||
uint64_t last_recv_time;
|
||||
uint64_t prev_video_ts;
|
||||
uint64_t time_since_prev;
|
||||
audio_resampler_t *resampler;
|
||||
uint32_t sample_rate;
|
||||
uint32_t channels;
|
||||
bool source_has_video;
|
||||
bool ignore;
|
||||
|
||||
int64_t lowest_audio_offset;
|
||||
struct circlebuf delay_buffer;
|
||||
uint32_t delay_size;
|
||||
int64_t lowest_audio_offset;
|
||||
struct circlebuf delay_buffer;
|
||||
uint32_t delay_size;
|
||||
|
||||
DARRAY(float) buf;
|
||||
pthread_mutex_t playback_mutex;
|
||||
DARRAY(float) buf;
|
||||
pthread_mutex_t playback_mutex;
|
||||
};
|
||||
|
||||
/* #define DEBUG_AUDIO */
|
||||
|
||||
static bool process_audio_delay(struct audio_monitor *monitor,
|
||||
float **data, uint32_t *frames, uint64_t ts, uint32_t pad)
|
||||
static bool process_audio_delay(struct audio_monitor *monitor, float **data,
|
||||
uint32_t *frames, uint64_t ts, uint32_t pad)
|
||||
{
|
||||
obs_source_t *s = monitor->source;
|
||||
uint64_t last_frame_ts = s->last_frame_ts;
|
||||
|
|
@ -68,15 +64,14 @@ static bool process_audio_delay(struct audio_monitor *monitor,
|
|||
|
||||
circlebuf_push_back(&monitor->delay_buffer, &ts, sizeof(ts));
|
||||
circlebuf_push_back(&monitor->delay_buffer, frames, sizeof(*frames));
|
||||
circlebuf_push_back(&monitor->delay_buffer, *data,
|
||||
*frames * blocksize);
|
||||
circlebuf_push_back(&monitor->delay_buffer, *data, *frames * blocksize);
|
||||
|
||||
if (!monitor->prev_video_ts) {
|
||||
monitor->prev_video_ts = last_frame_ts;
|
||||
|
||||
} else if (monitor->prev_video_ts == last_frame_ts) {
|
||||
monitor->time_since_prev += (uint64_t)*frames *
|
||||
1000000000ULL / (uint64_t)monitor->sample_rate;
|
||||
monitor->time_since_prev += (uint64_t)*frames * 1000000000ULL /
|
||||
(uint64_t)monitor->sample_rate;
|
||||
} else {
|
||||
monitor->time_since_prev = 0;
|
||||
}
|
||||
|
|
@ -86,44 +81,45 @@ static bool process_audio_delay(struct audio_monitor *monitor,
|
|||
bool bad_diff;
|
||||
|
||||
circlebuf_peek_front(&monitor->delay_buffer, &cur_ts,
|
||||
sizeof(ts));
|
||||
front_ts = cur_ts -
|
||||
((uint64_t)pad * 1000000000ULL /
|
||||
(uint64_t)monitor->sample_rate);
|
||||
sizeof(ts));
|
||||
front_ts = cur_ts - ((uint64_t)pad * 1000000000ULL /
|
||||
(uint64_t)monitor->sample_rate);
|
||||
diff = (int64_t)front_ts - (int64_t)last_frame_ts;
|
||||
bad_diff = !last_frame_ts ||
|
||||
llabs(diff) > 5000000000 ||
|
||||
monitor->time_since_prev > 100000000ULL;
|
||||
bad_diff = !last_frame_ts || llabs(diff) > 5000000000 ||
|
||||
monitor->time_since_prev > 100000000ULL;
|
||||
|
||||
/* delay audio if rushing */
|
||||
if (!bad_diff && diff > 75000000) {
|
||||
#ifdef DEBUG_AUDIO
|
||||
blog(LOG_INFO, "audio rushing, cutting audio, "
|
||||
"diff: %lld, delay buffer size: %lu, "
|
||||
"v: %llu: a: %llu",
|
||||
diff, (int)monitor->delay_buffer.size,
|
||||
last_frame_ts, front_ts);
|
||||
blog(LOG_INFO,
|
||||
"audio rushing, cutting audio, "
|
||||
"diff: %lld, delay buffer size: %lu, "
|
||||
"v: %llu: a: %llu",
|
||||
diff, (int)monitor->delay_buffer.size,
|
||||
last_frame_ts, front_ts);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
circlebuf_pop_front(&monitor->delay_buffer, NULL, sizeof(ts));
|
||||
circlebuf_pop_front(&monitor->delay_buffer, frames,
|
||||
sizeof(*frames));
|
||||
sizeof(*frames));
|
||||
|
||||
size = *frames * blocksize;
|
||||
da_resize(monitor->buf, size);
|
||||
circlebuf_pop_front(&monitor->delay_buffer,
|
||||
monitor->buf.array, size);
|
||||
circlebuf_pop_front(&monitor->delay_buffer, monitor->buf.array,
|
||||
size);
|
||||
|
||||
/* cut audio if dragging */
|
||||
if (!bad_diff && diff < -75000000 && monitor->delay_buffer.size > 0) {
|
||||
if (!bad_diff && diff < -75000000 &&
|
||||
monitor->delay_buffer.size > 0) {
|
||||
#ifdef DEBUG_AUDIO
|
||||
blog(LOG_INFO, "audio dragging, cutting audio, "
|
||||
"diff: %lld, delay buffer size: %lu, "
|
||||
"v: %llu: a: %llu",
|
||||
diff, (int)monitor->delay_buffer.size,
|
||||
last_frame_ts, front_ts);
|
||||
blog(LOG_INFO,
|
||||
"audio dragging, cutting audio, "
|
||||
"diff: %lld, delay buffer size: %lu, "
|
||||
"v: %llu: a: %llu",
|
||||
diff, (int)monitor->delay_buffer.size,
|
||||
last_frame_ts, front_ts);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
|
@ -136,7 +132,7 @@ static bool process_audio_delay(struct audio_monitor *monitor,
|
|||
}
|
||||
|
||||
static void on_audio_playback(void *param, obs_source_t *source,
|
||||
const struct audio_data *audio_data, bool muted)
|
||||
const struct audio_data *audio_data, bool muted)
|
||||
{
|
||||
struct audio_monitor *monitor = param;
|
||||
IAudioRenderClient *render = monitor->render;
|
||||
|
|
@ -154,10 +150,10 @@ static void on_audio_playback(void *param, obs_source_t *source,
|
|||
goto unlock;
|
||||
}
|
||||
|
||||
success = audio_resampler_resample(monitor->resampler, resample_data,
|
||||
&resample_frames, &ts_offset,
|
||||
(const uint8_t *const *)audio_data->data,
|
||||
(uint32_t)audio_data->frames);
|
||||
success = audio_resampler_resample(
|
||||
monitor->resampler, resample_data, &resample_frames, &ts_offset,
|
||||
(const uint8_t *const *)audio_data->data,
|
||||
(uint32_t)audio_data->frames);
|
||||
if (!success) {
|
||||
goto unlock;
|
||||
}
|
||||
|
|
@ -165,20 +161,20 @@ static void on_audio_playback(void *param, obs_source_t *source,
|
|||
UINT32 pad = 0;
|
||||
monitor->client->lpVtbl->GetCurrentPadding(monitor->client, &pad);
|
||||
|
||||
bool decouple_audio =
|
||||
source->async_unbuffered && source->async_decoupled;
|
||||
bool decouple_audio = source->async_unbuffered &&
|
||||
source->async_decoupled;
|
||||
|
||||
if (monitor->source_has_video && !decouple_audio) {
|
||||
uint64_t ts = audio_data->timestamp - ts_offset;
|
||||
|
||||
if (!process_audio_delay(monitor, (float**)(&resample_data[0]),
|
||||
&resample_frames, ts, pad)) {
|
||||
if (!process_audio_delay(monitor, (float **)(&resample_data[0]),
|
||||
&resample_frames, ts, pad)) {
|
||||
goto unlock;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT hr = render->lpVtbl->GetBuffer(render, resample_frames,
|
||||
&output);
|
||||
HRESULT hr =
|
||||
render->lpVtbl->GetBuffer(render, resample_frames, &output);
|
||||
if (FAILED(hr)) {
|
||||
goto unlock;
|
||||
}
|
||||
|
|
@ -186,20 +182,19 @@ static void on_audio_playback(void *param, obs_source_t *source,
|
|||
if (!muted) {
|
||||
/* apply volume */
|
||||
if (!close_float(vol, 1.0f, EPSILON)) {
|
||||
register float *cur = (float*)resample_data[0];
|
||||
register float *end = cur +
|
||||
resample_frames * monitor->channels;
|
||||
register float *cur = (float *)resample_data[0];
|
||||
register float *end =
|
||||
cur + resample_frames * monitor->channels;
|
||||
|
||||
while (cur < end)
|
||||
*(cur++) *= vol;
|
||||
}
|
||||
memcpy(output, resample_data[0],
|
||||
resample_frames * monitor->channels *
|
||||
sizeof(float));
|
||||
resample_frames * monitor->channels * sizeof(float));
|
||||
}
|
||||
|
||||
render->lpVtbl->ReleaseBuffer(render, resample_frames,
|
||||
muted ? AUDCLNT_BUFFERFLAGS_SILENT : 0);
|
||||
muted ? AUDCLNT_BUFFERFLAGS_SILENT : 0);
|
||||
|
||||
unlock:
|
||||
pthread_mutex_unlock(&monitor->playback_mutex);
|
||||
|
|
@ -212,7 +207,7 @@ static inline void audio_monitor_free(struct audio_monitor *monitor)
|
|||
|
||||
if (monitor->source) {
|
||||
obs_source_remove_audio_capture_callback(
|
||||
monitor->source, on_audio_playback, monitor);
|
||||
monitor->source, on_audio_playback, monitor);
|
||||
}
|
||||
|
||||
if (monitor->client)
|
||||
|
|
@ -229,11 +224,16 @@ static inline void audio_monitor_free(struct audio_monitor *monitor)
|
|||
static enum speaker_layout convert_speaker_layout(DWORD layout, WORD channels)
|
||||
{
|
||||
switch (layout) {
|
||||
case KSAUDIO_SPEAKER_2POINT1: return SPEAKERS_2POINT1;
|
||||
case KSAUDIO_SPEAKER_SURROUND: return SPEAKERS_4POINT0;
|
||||
case KSAUDIO_SPEAKER_4POINT1: return SPEAKERS_4POINT1;
|
||||
case KSAUDIO_SPEAKER_5POINT1: return SPEAKERS_5POINT1;
|
||||
case KSAUDIO_SPEAKER_7POINT1: return SPEAKERS_7POINT1;
|
||||
case KSAUDIO_SPEAKER_2POINT1:
|
||||
return SPEAKERS_2POINT1;
|
||||
case KSAUDIO_SPEAKER_SURROUND:
|
||||
return SPEAKERS_4POINT0;
|
||||
case KSAUDIO_SPEAKER_4POINT1:
|
||||
return SPEAKERS_4POINT1;
|
||||
case KSAUDIO_SPEAKER_5POINT1:
|
||||
return SPEAKERS_5POINT1;
|
||||
case KSAUDIO_SPEAKER_7POINT1:
|
||||
return SPEAKERS_7POINT1;
|
||||
}
|
||||
|
||||
return (enum speaker_layout)channels;
|
||||
|
|
@ -242,7 +242,7 @@ static enum speaker_layout convert_speaker_layout(DWORD layout, WORD channels)
|
|||
extern bool devices_match(const char *id1, const char *id2);
|
||||
|
||||
static bool audio_monitor_init(struct audio_monitor *monitor,
|
||||
obs_source_t *source)
|
||||
obs_source_t *source)
|
||||
{
|
||||
IMMDeviceEnumerator *immde = NULL;
|
||||
WAVEFORMATEX *wfex = NULL;
|
||||
|
|
@ -275,14 +275,14 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
* Init device */
|
||||
|
||||
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
||||
&IID_IMMDeviceEnumerator, (void**)&immde);
|
||||
&IID_IMMDeviceEnumerator, (void **)&immde);
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcmp(id, "default") == 0) {
|
||||
hr = immde->lpVtbl->GetDefaultAudioEndpoint(immde,
|
||||
eRender, eConsole, &monitor->device);
|
||||
hr = immde->lpVtbl->GetDefaultAudioEndpoint(
|
||||
immde, eRender, eConsole, &monitor->device);
|
||||
} else {
|
||||
wchar_t w_id[512];
|
||||
os_utf8_to_wcs(id, 0, w_id, 512);
|
||||
|
|
@ -298,8 +298,8 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
* Init client */
|
||||
|
||||
hr = monitor->device->lpVtbl->Activate(monitor->device,
|
||||
&IID_IAudioClient, CLSCTX_ALL, NULL,
|
||||
(void**)&monitor->client);
|
||||
&IID_IAudioClient, CLSCTX_ALL,
|
||||
NULL, (void **)&monitor->client);
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -310,8 +310,8 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
}
|
||||
|
||||
hr = monitor->client->lpVtbl->Initialize(monitor->client,
|
||||
AUDCLNT_SHAREMODE_SHARED, 0,
|
||||
10000000, 0, wfex, NULL);
|
||||
AUDCLNT_SHAREMODE_SHARED, 0,
|
||||
10000000, 0, wfex, NULL);
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -319,9 +319,9 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
/* ------------------------------------------ *
|
||||
* Init resampler */
|
||||
|
||||
const struct audio_output_info *info = audio_output_get_info(
|
||||
obs->audio.audio);
|
||||
WAVEFORMATEXTENSIBLE *ext = (WAVEFORMATEXTENSIBLE*)wfex;
|
||||
const struct audio_output_info *info =
|
||||
audio_output_get_info(obs->audio.audio);
|
||||
WAVEFORMATEXTENSIBLE *ext = (WAVEFORMATEXTENSIBLE *)wfex;
|
||||
struct resample_info from;
|
||||
struct resample_info to;
|
||||
|
||||
|
|
@ -330,8 +330,8 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
from.format = AUDIO_FORMAT_FLOAT_PLANAR;
|
||||
|
||||
to.samples_per_sec = (uint32_t)wfex->nSamplesPerSec;
|
||||
to.speakers = convert_speaker_layout(ext->dwChannelMask,
|
||||
wfex->nChannels);
|
||||
to.speakers =
|
||||
convert_speaker_layout(ext->dwChannelMask, wfex->nChannels);
|
||||
to.format = AUDIO_FORMAT_FLOAT;
|
||||
|
||||
monitor->sample_rate = (uint32_t)wfex->nSamplesPerSec;
|
||||
|
|
@ -350,7 +350,8 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
}
|
||||
|
||||
hr = monitor->client->lpVtbl->GetService(monitor->client,
|
||||
&IID_IAudioRenderClient, (void**)&monitor->render);
|
||||
&IID_IAudioRenderClient,
|
||||
(void **)&monitor->render);
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -381,7 +382,7 @@ static void audio_monitor_init_final(struct audio_monitor *monitor)
|
|||
monitor->source_has_video =
|
||||
(monitor->source->info.output_flags & OBS_SOURCE_VIDEO) != 0;
|
||||
obs_source_add_audio_capture_callback(monitor->source,
|
||||
on_audio_playback, monitor);
|
||||
on_audio_playback, monitor);
|
||||
}
|
||||
|
||||
struct audio_monitor *audio_monitor_create(obs_source_t *source)
|
||||
|
|
|
|||
|
|
@ -4,21 +4,21 @@
|
|||
#include <mmdeviceapi.h>
|
||||
#include <audioclient.h>
|
||||
|
||||
|
||||
#ifndef KSAUDIO_SPEAKER_2POINT1
|
||||
#define KSAUDIO_SPEAKER_2POINT1 (KSAUDIO_SPEAKER_STEREO|SPEAKER_LOW_FREQUENCY)
|
||||
#define KSAUDIO_SPEAKER_2POINT1 (KSAUDIO_SPEAKER_STEREO | SPEAKER_LOW_FREQUENCY)
|
||||
#endif
|
||||
|
||||
#define KSAUDIO_SPEAKER_SURROUND_AVUTIL \
|
||||
(KSAUDIO_SPEAKER_STEREO|SPEAKER_FRONT_CENTER)
|
||||
(KSAUDIO_SPEAKER_STEREO | SPEAKER_FRONT_CENTER)
|
||||
|
||||
#ifndef KSAUDIO_SPEAKER_4POINT1
|
||||
#define KSAUDIO_SPEAKER_4POINT1 (KSAUDIO_SPEAKER_SURROUND|SPEAKER_LOW_FREQUENCY)
|
||||
#define KSAUDIO_SPEAKER_4POINT1 \
|
||||
(KSAUDIO_SPEAKER_SURROUND | SPEAKER_LOW_FREQUENCY)
|
||||
#endif
|
||||
|
||||
#define safe_release(ptr) \
|
||||
do { \
|
||||
if (ptr) { \
|
||||
#define safe_release(ptr) \
|
||||
do { \
|
||||
if (ptr) { \
|
||||
ptr->lpVtbl->Release(ptr); \
|
||||
} \
|
||||
} \
|
||||
} while (false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue