Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. void *digitizer()
  2. {
  3. char* dig_image;
  4. int tail = 0;
  5.  
  6. while(1) {
  7. dig_image = read();
  8.  
  9. pthread_mutex_lock(&buflock);
  10. if (bufavail == 0) {
  11. pthread_cond_wait(&buf_notempty, &buflock);
  12. }
  13. pthread_mutex_unlock(&buflock);
  14.  
  15. frame_buf[tail%MAX] = dig_image;
  16. tail = tail + 1;
  17.  
  18. pthread_mutex_lock(&buflock);
  19. bufavail = bufavail - 1;
  20. pthread_mutex_unlock(&buflock);
  21.  
  22. if(bufavail < MAX) {
  23. pthread_cond_broadcast(&buf_notfull);
  24. }
  25. }
  26. }
  27.  
  28. void *tracker()
  29. {
  30. char *pSource;
  31. char *pDestination;
  32. char* track_image;
  33. int head = 0;
  34.  
  35. while(1) {
  36. pthread_mutex_lock(&buflock);
  37. if (bufavail == MAX)
  38. pthread_cond_wait(&buf_notfull, &buflock);
  39. pthread_mutex_unlock(&buflock);
  40.  
  41. pSource = frame_buf[head%MAX];
  42. head = head + 1;
  43.  
  44. pthread_mutex_lock(&buflock);
  45. bufavail = bufavail + 1;
  46. pthread_mutex_unlock(&buflock);
  47.  
  48. if(bufavail > 0) {
  49. pthread_cond_broadcast(&buf_notempty);
  50. }
  51.  
  52. pDestination = (char *)malloc(HEIGHT * WIDTH);
  53. rotate(pSource, pDestination, HEIGHT, WIDTH);
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement