Re: [patch] release the capture buffers on device closing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Oliver Endriss wrote:
> e9hack wrote:
>> Hi,
>>
>> if the video-device (saa7146 on a FF card) was open for capturing,
>> the close call doesn't release the capture buffers. 
>> The attached patch may fix this problem. Possible there is more
>> cleanup necessary. 
> 
>> diff -r 1109998234b4 linux/drivers/media/common/saa7146_video.c
>> --- a/linux/drivers/media/common/saa7146_video.c        Fri Mar 30 10:58:01 2007 -0300
>> +++ b/linux/drivers/media/common/saa7146_video.c        Sat Mar 31 19:50:55 2007 +0200
>> @@ -1429,6 +1429,7 @@ static void video_close(struct saa7146_d
>>  {
>>         struct saa7146_fh *fh = (struct saa7146_fh *)file->private_data;
>>         struct saa7146_vv *vv = dev->vv_data;
>> +       struct videobuf_queue *q = &fh->video_q;
>>         int err;
>>  
>>         if (IS_CAPTURE_ACTIVE(fh) != 0) {
>> @@ -1436,6 +1437,11 @@ static void video_close(struct saa7146_d
>>         } else if (IS_OVERLAY_ACTIVE(fh) != 0) {
>>                 err = saa7146_stop_preview(fh);
>>         }
>> +       
>> +       // release all capture buffers
>> +       mutex_lock(&q->lock);
>> +       videobuf_read_stop(q);
>> +       mutex_unlock(&q->lock);
> 
> Hm, I'm not sure: Is it safe to call videobuf_read_stop()
> if capturing was never active?

I think it's safe. videobuf_read_stop() calls videobuf_queue_cancel() and frees all buffers. If capturing was never
active, videobuf_queue_cancel() walks through an empty queue and does nothing. But the buffers must be freed.

- Hartmut


_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux