1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

The device /dev/video is now opened only if necessary (to GRAB an image)

This commit is contained in:
Klaus Schmidinger 2001-11-04 12:13:01 +01:00
parent 9bba1ce73e
commit 2f7f2084a5
3 changed files with 87 additions and 88 deletions

View File

@ -863,3 +863,5 @@ Video Disk Recorder Revision History
- Removed all video overlay stuff from cDvbApi and SVDRP. Guido Fiala's new
'kvdr' version 0.4 now does these things itself. As a consequence of this you
will now need to use kvdr 0.4 or later.
- The device /dev/video is now opened only if necessary (to GRAB an image),
allowing other programs (like 'kvdr', for instance) to use that device.

View File

@ -7,7 +7,7 @@
* DVD support initially written by Andreas Schultz <aschultz@warp10.net>
* based on dvdplayer-0.5 by Matjaz Thaler <matjaz.thaler@guest.arnes.si>
*
* $Id: dvbapi.c 1.136 2001/11/04 11:30:00 kls Exp $
* $Id: dvbapi.c 1.137 2001/11/04 12:05:36 kls Exp $
*/
//#define DVDDEBUG 1
@ -2557,10 +2557,6 @@ cDvbApi::cDvbApi(int n)
fd_video = OstOpen(DEV_OST_VIDEO, n, O_RDWR | O_NONBLOCK);
fd_audio = OstOpen(DEV_OST_AUDIO, n, O_RDWR | O_NONBLOCK);
// Devices that may not be available, and are not necessary for normal operation:
videoDev = OstOpen(DEV_VIDEO, n, O_RDWR);
// Devices that will be dynamically opened and closed when necessary:
fd_dvr = -1;
@ -2725,17 +2721,15 @@ const cSchedules *cDvbApi::Schedules(cThreadLock *ThreadLock) const
bool cDvbApi::GrabImage(const char *FileName, bool Jpeg, int Quality, int SizeX, int SizeY)
{
if (videoDev < 0)
return false;
int result = 0;
// just do this once?
int videoDev = OstOpen(DEV_VIDEO, CardIndex(), O_RDWR);
if (videoDev >= 0) {
struct video_mbuf mbuf;
result |= ioctl(videoDev, VIDIOCGMBUF, &mbuf);
if (result == 0) {
int msize = mbuf.size;
// gf: this needs to be a protected member of cDvbApi! //XXX kls: WHY???
unsigned char *mem = (unsigned char *)mmap(0, msize, PROT_READ | PROT_WRITE, MAP_SHARED, videoDev, 0);
if (!mem || mem == (unsigned char *)-1)
return false;
if (mem && mem != (unsigned char *)-1) {
// set up the size and RGB
struct video_capability vc;
result |= ioctl(videoDev, VIDIOCGCAP, &vc);
@ -2751,7 +2745,6 @@ bool cDvbApi::GrabImage(const char *FileName, bool Jpeg, int Quality, int SizeX,
vm.height = vc.maxheight;
}
vm.format = VIDEO_PALETTE_RGB24;
// this needs to be done every time:
result |= ioctl(videoDev, VIDIOCMCAPTURE, &vm);
result |= ioctl(videoDev, VIDIOCSYNC, &vm.frame);
// make RGB out of BGR:
@ -2808,8 +2801,13 @@ bool cDvbApi::GrabImage(const char *FileName, bool Jpeg, int Quality, int SizeX,
LOG_ERROR_STR(FileName);
result |= 1;
}
munmap(mem, msize);
}
else
result |= 1;
}
close(videoDev);
}
return result == 0;
}

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: dvbapi.h 1.57 2001/11/04 11:27:18 kls Exp $
* $Id: dvbapi.h 1.58 2001/11/04 11:39:42 kls Exp $
*/
#ifndef __DVBAPI_H
@ -84,7 +84,6 @@ class cDvbApi {
friend class cTransferBuffer;
private:
FrontendType frontendType;
int videoDev;
int fd_osd, fd_frontend, fd_sec, fd_dvr, fd_audio, fd_video, fd_demuxa1, fd_demuxa2, fd_demuxd1, fd_demuxd2, fd_demuxv, fd_demuxt;
int vPid, aPid1, aPid2, dPid1, dPid2;
bool SetPid(int fd, dmxPesType_t PesType, int Pid, dmxOutput_t Output);