Moved c code from another project.

This commit is contained in:
John Shaver 2018-04-12 10:30:06 -07:00
commit efaaec9afe

65
miccontrol.c Normal file
View file

@ -0,0 +1,65 @@
/*
* miccontrol.c
* Copyright (C) 2018 jshaver <jshaver@je-laptop>
*
* Distributed under terms of the MIT license.
*/
#include "stdio.h"
#include "pulse/pulseaudio.h"
const char *NAME = "miccontrol";
static pa_context *context = NULL;
static pa_mainloop_api *mainloop_api = NULL;
static pa_mainloop *mainloop = NULL;
void querySources(pa_context *c, void *userdata);
void handleSourceList(struct pa_context *c, const pa_source_info *i, int eol, void *userdata);
int main() {
int ret = 1;
mainloop = pa_mainloop_new();
mainloop_api = pa_mainloop_get_api(mainloop);
context = pa_context_new(mainloop_api, NULL);
pa_context_set_state_callback(context, querySources, NULL);
pa_context_connect(context, NULL, 0, NULL);
//pa_operation_unref(getSourceOp);
pa_mainloop_run(mainloop, &ret);
pa_context_unref(context);
pa_mainloop_free(mainloop);
return ret;
}
void querySources(pa_context *c, void *userdata) {
if(pa_context_get_state(context) != PA_CONTEXT_READY) {
return;
}
pa_operation *getSourceOp = NULL;
getSourceOp = pa_context_get_source_info_list(context, handleSourceList, NULL);
if(!getSourceOp) {
} else {
pa_operation_state_t state = pa_operation_get_state(getSourceOp);
switch(state) {
case PA_OPERATION_RUNNING:
break;
case PA_OPERATION_DONE:
break;
case PA_OPERATION_CANCELLED:
}
}
}
void handleSourceList(pa_context *c, const pa_source_info *i, int eol, void *userdata) {
printf("Callback called...\n");
printf("eol is %d\n", eol);
printf(i->description);
printf("\n");
return;
}