~schnouki/pustule

deaea5ed5f40a3bc631b3313c506233d3eb3b6f5 — Thomas Jost 4 years ago e49b276
Add function to suspend/resume a device
2 files changed, 13 insertions(+), 0 deletions(-)

M guile.c
M pustule.h
M guile.c => guile.c +12 -0
@@ 49,6 49,8 @@ struct pustule_exported_func {
     "Gets the name of the default device."},
    {"pustule-set-default-device", 1, 0, 0, &pustule_set_default_device,
     "Sets the default device to NAME."},
    {"pustule-suspend-device", 2, 0, 0, &pustule_suspend_device,
     "Suspend or resume device DEVICE-IDX."},
    {NULL, 0, 0, 0, NULL}
};



@@ 158,6 160,16 @@ SCM pustule_set_default_device(SCM name) {
      return SCM_BOOL_T;
}

/* Suspend/resume the specified device */
SCM pustule_suspend_device(SCM idx, SCM suspend) {
    uint32_t idx_ = scm_to_uint32(idx);
    uint32_t suspend_ = suspend == SCM_BOOL_T ? 1 : 0;

    pa_operation* op = pa_context_suspend_sink_by_index(pactx, idx_, suspend_, NULL, NULL);
    pa_operation_unref(op);
    return suspend;
}

/* Helpers */
static SCM _alist_add_str(SCM info, const char* name, const char* value) {
    return scm_acons(scm_from_utf8_string(name), scm_from_utf8_string(value), info);

M pustule.h => pustule.h +1 -0
@@ 92,6 92,7 @@ SCM pustule_get_device_volume(SCM idx);
SCM pustule_set_device_volume(SCM idx, SCM volume);
SCM pustule_get_default_device();
SCM pustule_set_default_device(SCM name);
SCM pustule_suspend_device(SCM idx, SCM suspend);

/* Guile helpers */
void pustule_init_guile();