# HG changeset patch # User John Tsiombikas # Date 1392180810 -7200 # Node ID 711698580eb0d9cb61faff58db583e6c215a0236 # Parent 43a9fe4a80eed7f51a05a31e09fd7c89f8880445 fixed visual studio build directories fixed debug id problem with the thread pool diff -r 43a9fe4a80ee -r 711698580eb0 examples/imgthumbs/src/thumbs.c --- a/examples/imgthumbs/src/thumbs.c Tue Feb 11 18:48:24 2014 +0200 +++ b/examples/imgthumbs/src/thumbs.c Wed Feb 12 06:53:30 2014 +0200 @@ -9,7 +9,7 @@ #include "thumbs.h" #include "resman.h" -#define DBG_SYNC +#undef DBG_SYNC #ifndef GL_COMPRESSED_RGB #define GL_COMPRESSED_RGB 0x84ed @@ -45,8 +45,7 @@ while((dent = readdir(dir))) { #ifdef DBG_SYNC - int xsz, ysz; - unsigned char *pixels; + struct img_pixmap img; #endif struct thumbnail *node; @@ -71,7 +70,9 @@ #ifndef DBG_SYNC resman_lookup(texman, node->fname, node); #else - if(!(pixels = img_load_pixels(node->fname, &xsz, &ysz, IMG_FMT_RGBA32))) { + img_init(&img); + if(img_load(&img, node->fname) == -1) { + img_destroy(&img); free(node->fname); free(node); continue; @@ -79,14 +80,14 @@ printf("loaded image: %s\n", node->fname); + node->aspect = (float)img.width / (float)img.height; + glGenTextures(1, &node->tex); glBindTexture(GL_TEXTURE_2D, node->tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, xsz, ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - img_free_pixels(pixels); - - node->aspect = (float)xsz / (float)ysz; + glTexImage2D(GL_TEXTURE_2D, 0, img_glintfmt(&img), img.width, img.height, 0, img_glfmt(&img), img_gltype(&img), img.pixels); + img_destroy(&img); #endif node->next = list->next; diff -r 43a9fe4a80ee -r 711698580eb0 libresman-static.vcproj --- a/libresman-static.vcproj Tue Feb 11 18:48:24 2014 +0200 +++ b/libresman-static.vcproj Wed Feb 12 06:53:30 2014 +0200 @@ -18,7 +18,7 @@ start_cond, 0); + for(i=0; iworkers + i, 0, thread_func, tpool) == -1) { fprintf(stderr, "%s: failed to create thread %d\n", __FUNCTION__, i); @@ -62,6 +68,8 @@ return -1; } } + tpool->start = 1; + pthread_cond_broadcast(&tpool->start_cond); return 0; } @@ -142,8 +150,15 @@ struct thread_pool *tpool = tp; pthread_t tid = pthread_self(); + /* wait for the start signal :) */ + pthread_mutex_lock(&tpool->work_lock); + while(!tpool->start) { + pthread_cond_wait(&tpool->start_cond, &tpool->work_lock); + } + pthread_mutex_unlock(&tpool->work_lock); + for(i=0; inum_workers; i++) { - if(tpool[i].workers[i] == tid) { + if(pthread_equal(tpool->workers[i], tid)) { tidx = i; break; } @@ -157,13 +172,11 @@ continue; /* spurious wakeup, go back to sleep */ } - printf("TPOOL: worker %d start job: %d\n", tidx, job->id); - job = tpool->work_list; tpool->work_list = tpool->work_list->next; + printf("TPOOL: worker %d start job: %d\n", tidx, job->id); tpool->work_func(job->data, tpool->cls); - printf("TPOOL: worker %d completed job: %d\n", tidx, job->id); free_node(job); }