#include "capture.h" #include #include #define APP_TITLE "Test 5 lpo" #define BUFSIZE 1024 pa_context *pa_ct=NULL; capture_sound_level_cb_t *capture_sound_level_cb=NULL; int capture_init(pa_mainloop **m); void context_state_callback(pa_context *c, void *userdata); void audio_thread(void *args) { pa_mainloop *m; int res, retval; capture_sound_level_cb=(capture_sound_level_cb_t *)args; res=capture_init(&m); g_assert(res==0); res=pa_mainloop_run(m,&retval); g_assert(res==0); g_assert(retval==0); // pa_context_disconnect(pa_ct); pa_mainloop_free(m); } int capture_init(pa_mainloop **m) { int res=0; *m=pa_mainloop_new(); g_assert(*m); pa_ct = pa_context_new(pa_mainloop_get_api(*m), APP_TITLE); g_assert(pa_ct); pa_context_set_state_callback(pa_ct, context_state_callback, NULL); res=pa_context_connect(pa_ct, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL); return res; } void context_state_callback(pa_context *c, void *userdata) { switch (pa_context_get_state(c)) { case PA_CONTEXT_UNCONNECTED: printf("PA_CONTEXT_UNCONNECTED\n"); break; case PA_CONTEXT_CONNECTING: printf("PA_CONTEXT_CONNECTING\n"); break; case PA_CONTEXT_AUTHORIZING: printf("PA_CONTEXT_AUTHORIZING\n"); break; case PA_CONTEXT_SETTING_NAME: printf("PA_CONTEXT_SETTING_NAME\n"); break; case PA_CONTEXT_READY: printf("PA_CONTEXT_READY\n"); //g_assert(!stream); //if (device_name && mode == RECORD) //pa_operation_unref(pa_context_get_source_info_by_name(c, device_name, context_get_source_info_callback, NULL)); /*else if (device_name && mode == PLAYBACK) pa_operation_unref(pa_context_get_sink_info_by_name(c, device_name, context_get_sink_info_callback, NULL)); else pa_operation_unref(pa_context_get_server_info(c, context_get_server_info_callback, NULL)); */ break; case PA_CONTEXT_FAILED: printf("PA_CONTEXT_FAILED\n"); break; case PA_CONTEXT_TERMINATED: printf("PA_CONTEXT_TERMINATED\n"); break; } }