Ticket #3381: fifowriter.rev3.patch

File fifowriter.rev3.patch, 1.8 KB (added by russell@…, 13 years ago)
  • libs/libmythtv/fifowriter.cpp

     
    3737    full_cond = new pthread_cond_t[count];
    3838    for (int i = 0; i < count; i++)
    3939    {
    40       pthread_cond_init(&empty_cond[i], NULL);
    41       pthread_cond_init(&full_cond[i], NULL);
     40        pthread_cond_init(&empty_cond[i], NULL);
     41        pthread_cond_init(&full_cond[i], NULL);
     42        pthread_mutex_init(&fifo_lock[i], NULL);
    4243    }
    4344    filename = new QString [count];
    4445    fbdesc = new QString [count];
     
    4950    for (int i = 0; i <num_fifos; i++)
    5051    {
    5152        killwr[i] = 1;
     53
     54        pthread_mutex_lock(&fifo_lock[i]);
    5255        pthread_cond_signal(&empty_cond[i]);
     56        pthread_mutex_unlock(&fifo_lock[i]);
     57
    5358        pthread_join(fifothrds[i], NULL);
     59
     60        pthread_cond_destroy(&empty_cond[i]);
     61        pthread_cond_destroy(&full_cond[i]);
     62        pthread_mutex_destroy(&fifo_lock[i]);
    5463    }
    5564    delete [] maxblksize;
    5665    delete [] fifo_buf;
     
    5968    delete [] fifothrds;
    6069    delete [] full_cond;
    6170    delete [] empty_cond;
     71    delete [] fifo_lock;
    6272    delete [] filename;
    6373    delete [] fbdesc;
    6474    delete [] killwr;
     
    95105    }
    96106    fb_inptr[id]  = fifo_buf[id];
    97107    fb_outptr[id] = fifo_buf[id];
    98     pthread_mutex_init(&fifo_lock[id], NULL);
    99108
    100109    cur_id = id;
    101110
     
    214223            if (fb_inptr[i] == fb_outptr[i])
    215224            {
    216225                killwr[i] = 1;
     226                pthread_mutex_lock(&fifo_lock[i]);
    217227                pthread_cond_signal(&empty_cond[i]);
     228                pthread_mutex_unlock(&fifo_lock[i]);
    218229                count++;
    219230            }
    220231        }