On Dec 4, 2013 4:38 PM, sathish1000 at gmail.com wrote: > > > > > Hi, > > > > > > > > I wrote a small c program to try to load a module.. But the module is > not getting loaded. > > > Can anybody help me with this ? I have pasted the code below. > > > > > > > > > > > > > > > #include <stdio.h> > > > > #include <string.h> > > > > #include <pulse/pulseaudio.h> > > > > > > > > #define CLEAR_LINE "\n" > > > > #define _(x) x > > > > > > > > /* > > > > // From pulsecore/macro.h > > > > #define pa_memzero(x,l) (memset((x), 0, (l))) > > > > #define pa_zero(x) (pa_memzero(&(x), sizeof(x))) > > > > */ > > > > > > > > int ret; > > > > pa_context *context; > > > > int clientindex; > > > > int sink_num_channels; > > > > int sink_input_index; > > > > > > > > void show_error(char *s) { > > > > /* stub */ > > > > } > > > > > > > > void load_module_cb(pa_context *context, int32_t index, void *userdata) > > > > { > > > > printf ("Going out \n"); > > > > int * return_value_pointer = (int *) userdata; > > > > if (return_value_pointer) > > > > { > > > > *return_value_pointer = index; > > > > } > > > > } > > > > > > > > // This callback gets called when our context changes state. We really > only > > > > // care about when it's ready or if it has failed > > > > void pa_state_cb(pa_context *c, void *userdata) { > > > > pa_context_state_t state; > > > > int *pa_ready = userdata; > > > > > > > > state = pa_context_get_state(c); > > > > switch (state) { > > > > // There are just here for reference > > > > case PA_CONTEXT_UNCONNECTED: > > > > case PA_CONTEXT_CONNECTING: > > > > case PA_CONTEXT_AUTHORIZING: > > > > case PA_CONTEXT_SETTING_NAME: > > > > default: > > > > break; > > > > case PA_CONTEXT_FAILED: > > > > case PA_CONTEXT_TERMINATED: > > > > *pa_ready = 2; > > > > break; > > > > case PA_CONTEXT_READY: > > > > *pa_ready = 1; > > > > break; > > > > } > > > > } > > > > > > > > int pa_get_devicelist() { > > > > // Define our pulse audio loop and connection variables > > > > pa_mainloop *pa_ml; > > > > pa_mainloop_api *pa_mlapi; > > > > pa_operation *pa_op; > > > > pa_context *pa_ctx; > > > > > > > > // We'll need these state variables to keep track of our requests > > > > int state = 0; > > > > int pa_ready = 0; > > > > > > > > > > > > // Create a mainloop API and connection to the default server > > > > pa_ml = pa_mainloop_new(); > > > > pa_mlapi = pa_mainloop_get_api(pa_ml); > > > > pa_ctx = pa_context_new(pa_mlapi, "test"); > > > > > > > > // This function connects to the pulse server > > > > pa_context_connect(pa_ctx, NULL, 0, NULL); > > > > > > > > // This function defines a callback so the server will tell us it's > state. > > > > // Our callback will wait for the state to be ready. The callback > will > > > > // modify the variable to 1 so we know when we have a connection and > it's > > > > // ready. > > > > // If there's an error, the callback will set pa_ready to 2 > > > > pa_context_set_state_callback(pa_ctx, pa_state_cb, &pa_ready); > > > > > > > > // Now we'll enter into an infinite loop until we get the data we > receive > > > > // or if there's an error > > > > //for (;;) { > > > > // We can't do anything until PA is ready, so just > iterate the mainloop > > > > // and continue > > > > if (pa_ready == 0) { > > > > printf ("Going in \n"); > > > > pa_op=pa_context_load_module(pa_ctx, "module-role-cork", > NULL, NULL, NULL); > > > > printf ("Going in1 \n"); > > > > if(pa_op) pa_operation_unref(pa_op); > > > > //continue; > > > > } > > > > // We couldn't get a connection to the server, so exit > out > > > > if (pa_ready == 2) { > > > > pa_context_disconnect(pa_ctx); > > > > pa_context_unref(pa_ctx); > > > > pa_mainloop_free(pa_ml); > > > > return -1; > > > > } > > > > > > > > pa_context_disconnect(pa_ctx); > > > > pa_context_unref(pa_ctx); > > > > pa_mainloop_free(pa_ml); > > > > return 0; > > > > } > > > > > > > > int main(int argc, char *argv[]) { > > > > > > > > if (pa_get_devicelist() < 0) { > > > > fprintf(stderr, "failed to get device list\n"); > > > > return 1; > > > > } > > > > > > > > return 0; > > > > } > > > > > > > > Thanks, > > > > Sathish > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20131204/ef9bc999/attachment-0001.html>