diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test5/capture.c | 16 | ||||
-rwxr-xr-x | tests/test5/compil.sh | 6 | ||||
-rw-r--r-- | tests/test5/test5.c | 16 | ||||
-rw-r--r-- | tests/test5/win_main.c | 6 |
4 files changed, 28 insertions, 16 deletions
diff --git a/tests/test5/capture.c b/tests/test5/capture.c index d003fe8..441a6ac 100644 --- a/tests/test5/capture.c +++ b/tests/test5/capture.c @@ -5,6 +5,8 @@ #define APP_TITLE "Test 5 lpo" #define BUFSIZE 1024 +extern void my_process(gint sound_level, void *userdata); + capture_sound_level_cb_t *capture_sound_level_cb=NULL; int capture_init(pa_mainloop **m, pa_context **c); @@ -26,7 +28,7 @@ void audio_thread(void *args) { capture_sound_level_cb=(capture_sound_level_cb_t *)args; - printf("debug : args==%p capture_sound_level_cb==%p\n", args, capture_sound_level_cb); + //printf("debug : args==%p capture_sound_level_cb==%p\n", args, capture_sound_level_cb); res=capture_init(&m, &c); g_assert(res==0); @@ -194,11 +196,14 @@ void stream_read_callback(pa_stream *s, size_t nbytes, void *userdata) { printf("pa_stream_peek() failed\n");//: %s", pa_strerror(pa_context_errno(context))); return; } - printf("level : %i\n", compute_level(p,nbytes)); + //printf("level : %i\n", compute_level(p,nbytes)); + +//printf("debug : before call capture_sound_level_cb==%p\n", capture_sound_level_cb); + + my_process(compute_level(p,nbytes), NULL); +// (*capture_sound_level_cb)(compute_level(p,nbytes), NULL); -printf("debug : before call capture_sound_level_cb==%p\n", capture_sound_level_cb); - (*capture_sound_level_cb)(compute_level(p,nbytes), NULL); -printf("debug : after call capture_sound_level_cb==%p\n", capture_sound_level_cb); +//printf("debug : after call capture_sound_level_cb==%p\n", capture_sound_level_cb); pa_stream_drop(s); } @@ -208,6 +213,7 @@ gint compute_level(const void *data, size_t nbytes) { gint val, level=0; for (i=0;i<nbytes/2;i++) { val=((int16_t *)data)[i]; + //printf("val==%i\n", val); if (val<0) val=-val; if (level<val) level=val; } diff --git a/tests/test5/compil.sh b/tests/test5/compil.sh index 4875cc1..776669a 100755 --- a/tests/test5/compil.sh +++ b/tests/test5/compil.sh @@ -1,7 +1,7 @@ #!/bin/bash -ex -#gcc -Wall -g -c gtkvumeter.c $(pkg-config --cflags gtk+-2.0) -#gcc -Wall -g -c win_main.c $(pkg-config --cflags gtk+-2.0) -#gcc -Wall -g -c compute.c $(pkg-config --cflags gtk+-2.0) +gcc -Wall -g -c gtkvumeter.c $(pkg-config --cflags gtk+-2.0) +gcc -Wall -g -c win_main.c $(pkg-config --cflags gtk+-2.0) +gcc -Wall -g -c compute.c $(pkg-config --cflags gtk+-2.0) gcc -Wall -g -c test5.c $(pkg-config --cflags gtk+-2.0 gthread-2.0 libpulse) gcc -Wall -g -c capture.c $(pkg-config --cflags gtk+-2.0 libpulse) gcc -Wall -o test5 *.o $(pkg-config --libs gtk+-2.0 gthread-2.0 libpulse) diff --git a/tests/test5/test5.c b/tests/test5/test5.c index 25dae23..a12c093 100644 --- a/tests/test5/test5.c +++ b/tests/test5/test5.c @@ -7,7 +7,7 @@ #include "capture.h" gint *audio_vumeter_val, *light_h, *light_s, *light_v, *light_r, *light_g, *light_b; -void process(gint sound_level, void *userdata); +void my_process(gint sound_level, void *userdata); int main (int argc, char **argv) { GtkWidget *mainwin; @@ -18,7 +18,7 @@ int main (int argc, char **argv) { light_s=vals_for_vumeters+2; light_v=vals_for_vumeters+3; light_r=vals_for_vumeters+4; - light_v=vals_for_vumeters+5; + light_g=vals_for_vumeters+5; light_b=vals_for_vumeters+6; pthread_t audio_analyzer; @@ -31,10 +31,10 @@ int main (int argc, char **argv) { mainwin=win_main_build(); gtk_widget_show_all (mainwin); -printf("debug : process==%p\n", process); - - pthread_create (&audio_analyzer, (void *)NULL, (void *)audio_thread, (void *)process); - g_timeout_add (10, win_main_update_vumeters, (gpointer)vals_for_vumeters); + printf("debug : main my_process==%p\n", my_process); + printf("debug : main (void *)my_process==%p\n", (void *)my_process); + pthread_create (&audio_analyzer, (void *)NULL, (void *)audio_thread, (void *)my_process); + g_timeout_add (100, win_main_update_vumeters, (gpointer)vals_for_vumeters); gtk_main (); gdk_threads_leave(); @@ -42,9 +42,9 @@ printf("debug : process==%p\n", process); return 0; } -void process(gint sound_level, void *userdata) { +void my_process(gint sound_level, void *userdata) { - printf("process(%i, %p)\n", sound_level, userdata); +// printf("my_process(%i, %p)\n", sound_level, userdata); // Dummy code for audio capture *audio_vumeter_val=sound_level; diff --git a/tests/test5/win_main.c b/tests/test5/win_main.c index a139bc9..e5d681d 100644 --- a/tests/test5/win_main.c +++ b/tests/test5/win_main.c @@ -26,27 +26,33 @@ GtkWidget *win_main_build() { gtk_box_pack_start(GTK_BOX(hbox1), vumeter_sound, FALSE, FALSE, 0); vumeter_h = gtk_vu_meter_new (TRUE); + gtk_vu_meter_set_min_max (vumeter_h, 0, 65535); gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_h), 7, f_gradient_hue, 7, b_gradient_hue); gtk_box_pack_start(GTK_BOX(hbox1), vumeter_h, FALSE, FALSE, 0); vumeter_s = gtk_vu_meter_new (TRUE); + gtk_vu_meter_set_min_max (vumeter_s, 0, 65535); gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_s), 2, f_gradient_red, 2, b_gradient_red); gtk_box_pack_start(GTK_BOX(hbox1), vumeter_s, FALSE, FALSE, 0); vumeter_v = gtk_vu_meter_new (TRUE); + gtk_vu_meter_set_min_max (vumeter_v, 0, 65535); gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_v), 2, f_gradient_red, 2, b_gradient_red); gtk_box_pack_start(GTK_BOX(hbox1), vumeter_v, FALSE, FALSE, 0); vumeter_r = gtk_vu_meter_new (TRUE); + gtk_vu_meter_set_min_max (vumeter_r, 0, 255); gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_r), 2, f_gradient_red, 2, b_gradient_red); gtk_box_pack_start(GTK_BOX(hbox1), vumeter_r, FALSE, FALSE, 0); vumeter_g = gtk_vu_meter_new (TRUE); + gtk_vu_meter_set_min_max (vumeter_g, 0, 255); gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_g), 2, f_gradient_green, 2, b_gradient_green); gtk_box_pack_start(GTK_BOX(hbox1), vumeter_g, FALSE, FALSE, 0); vumeter_b = gtk_vu_meter_new (TRUE); + gtk_vu_meter_set_min_max (vumeter_b, 0, 255); gtk_vu_meter_set_gradient(GTK_VU_METER(vumeter_b), 2, f_gradient_blue, 2, b_gradient_blue); gtk_box_pack_start(GTK_BOX(hbox1), vumeter_b, FALSE, FALSE, 0); |