[pulseaudio-commits] src/modules
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Sun Nov 5 11:46:57 UTC 2017
src/modules/macosx/module-coreaudio-detect.c | 30 ++++++++++++++++++++++++---
src/modules/macosx/module-coreaudio-device.c | 23 ++++++++++++++++++--
2 files changed, 47 insertions(+), 6 deletions(-)
New commits:
commit 584aad3c0630abf9c43d77e4e6bc1bd0ef34dc4a
Author: Mihai Moldovan <ionic at ionic.de>
Date: Thu Feb 11 03:25:33 2016 +0100
module-coreaudio-{device, detect}: implement record and playback modargs, curtesy of module-waveout.
Signed-off-by: Mihai Moldovan <ionic at ionic.de>
diff --git a/src/modules/macosx/module-coreaudio-detect.c b/src/modules/macosx/module-coreaudio-detect.c
index 81067ce7..eebca1f4 100644
--- a/src/modules/macosx/module-coreaudio-detect.c
+++ b/src/modules/macosx/module-coreaudio-detect.c
@@ -39,10 +39,14 @@ PA_MODULE_AUTHOR("Daniel Mack");
PA_MODULE_DESCRIPTION("CoreAudio device detection");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(true);
-PA_MODULE_USAGE("ioproc_frames=<passed on to module-coreaudio-device> ");
+PA_MODULE_USAGE("ioproc_frames=<passed on to module-coreaudio-device> "
+ "record=<enable source?> "
+ "playback=<enable sink?> ");
static const char* const valid_modargs[] = {
"ioproc_frames",
+ "record",
+ "playback",
NULL
};
@@ -58,6 +62,8 @@ struct userdata {
int detect_fds[2];
pa_io_event *detect_io;
unsigned int ioproc_frames;
+ bool record;
+ bool playback;
PA_LLIST_HEAD(ca_device, devices);
};
@@ -87,9 +93,9 @@ static int ca_device_added(struct pa_module *m, AudioObjectID id) {
return 0;
if (u->ioproc_frames)
- args = pa_sprintf_malloc("object_id=%d ioproc_frames=%d", (int) id, u->ioproc_frames);
+ args = pa_sprintf_malloc("object_id=%d ioproc_frames=%d record=%d playback=%d", (int) id, u->ioproc_frames, (int) u->record, (int) u->playback);
else
- args = pa_sprintf_malloc("object_id=%d", (int) id);
+ args = pa_sprintf_malloc("object_id=%d record=%d playback=%d", (int) id, (int) u->record, (int) u->playback);
pa_log_debug("Loading %s with arguments '%s'", DEVICE_MODULE_NAME, args);
pa_module_load(&mod, m->core, DEVICE_MODULE_NAME, args);
@@ -212,6 +218,7 @@ int pa__init(pa_module *m) {
pa_modargs *ma;
pa_assert(m);
+ pa_assert(m->core);
m->userdata = u;
@@ -220,6 +227,23 @@ int pa__init(pa_module *m) {
goto fail;
}
+ /*
+ * Set default value to true if not given as a modarg.
+ * In such a case, pa_modargs_get_value_boolean() will not touch the
+ * buffer.
+ */
+ u->playback = u->record = true;
+
+ if (pa_modargs_get_value_boolean(ma, "record", &u->record) < 0 || pa_modargs_get_value_boolean(ma, "playback", &u->playback) < 0) {
+ pa_log("record= and playback= expect boolean argument.");
+ goto fail;
+ }
+
+ if (!u->playback && !u->record) {
+ pa_log("neither playback nor record enabled for device.");
+ goto fail;
+ }
+
pa_modargs_get_value_u32(ma, "ioproc_frames", &u->ioproc_frames);
property_address.mSelector = kAudioHardwarePropertyDevices;
diff --git a/src/modules/macosx/module-coreaudio-device.c b/src/modules/macosx/module-coreaudio-device.c
index 48faf083..2e02630d 100644
--- a/src/modules/macosx/module-coreaudio-device.c
+++ b/src/modules/macosx/module-coreaudio-device.c
@@ -57,11 +57,15 @@ PA_MODULE_DESCRIPTION("CoreAudio device");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(false);
PA_MODULE_USAGE("object_id=<the CoreAudio device id> "
- "ioproc_frames=<audio frames per IOProc call> ");
+ "ioproc_frames=<audio frames per IOProc call> "
+ "record=<enable source?> "
+ "playback=<enable sink?> ");
static const char* const valid_modargs[] = {
"object_id",
"ioproc_frames",
+ "record",
+ "playback",
NULL
};
@@ -757,6 +761,7 @@ int pa__init(pa_module *m) {
UInt32 size, frames;
struct userdata *u = NULL;
pa_modargs *ma = NULL;
+ bool record = true, playback = true;
char tmp[64];
pa_card_new_data card_new_data;
pa_card_profile *p;
@@ -771,6 +776,16 @@ int pa__init(pa_module *m) {
goto fail;
}
+ if (pa_modargs_get_value_boolean(ma, "record", &record) < 0 || pa_modargs_get_value_boolean(ma, "playback", &playback) < 0) {
+ pa_log("record= and playback= expect boolean argument.");
+ goto fail;
+ }
+
+ if (!playback && !record) {
+ pa_log("neither playback nor record enabled for device.");
+ goto fail;
+ }
+
u = pa_xnew0(struct userdata, 1);
u->module = m;
m->userdata = u;
@@ -842,10 +857,12 @@ int pa__init(pa_module *m) {
PA_LLIST_HEAD_INIT(coreaudio_sink, u->sinks);
/* create sinks */
- ca_device_create_streams(m, false);
+ if (playback)
+ ca_device_create_streams(m, false);
/* create sources */
- ca_device_create_streams(m, true);
+ if (record)
+ ca_device_create_streams(m, true);
/* create the message thread */
if (!(u->thread = pa_thread_new(u->device_name, thread_func, u))) {
More information about the pulseaudio-commits
mailing list