Skip to content

Commit e967e30

Browse files
Fixes #10501. Adapt to new return ioctl return value in Linux 3.1.
Thanks to Anthony Messina for discovering the issue and the original patch. A different change was used only because #10501 will require a single point of exit from the functions affected.
1 parent b51e845 commit e967e30

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

mythtv/libs/libmythtv/mpegrecorder.cpp

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,8 @@ bool MpegRecorder::StartEncoding(int fd)
13381338

13391339
LOG(VB_RECORD, LOG_INFO, LOC + "StartEncoding");
13401340

1341-
if (ioctl(fd, VIDIOC_ENCODER_CMD, &command) == 0)
1341+
bool started = 0 == ioctl(fd, VIDIOC_ENCODER_CMD, &command);
1342+
if (started)
13421343
{
13431344
if (driver == "hdpvr")
13441345
{
@@ -1348,20 +1349,20 @@ bool MpegRecorder::StartEncoding(int fd)
13481349
}
13491350

13501351
LOG(VB_RECORD, LOG_INFO, LOC + "Encoding started");
1351-
return true;
1352+
}
1353+
else if ((ENOTTY == errno) || (EINVAL == errno))
1354+
{
1355+
// Some drivers do not support this ioctl at all. It is marked as
1356+
// "experimental" in the V4L2 API spec. These drivers return EINVAL
1357+
// in older kernels and ENOTTY in 3.1+
1358+
started = true;
1359+
}
1360+
else
1361+
{
1362+
LOG(VB_GENERAL, LOG_WARNING, LOC + "StartEncoding failed" + ENO);
13521363
}
13531364

1354-
// Some drivers do not support this ioctl at all. It is marked as
1355-
// "experimental" in the V4L2 API spec. If we fail with EINVAL (which
1356-
// happens if the ioctl isn't supported), treat it as a success, but
1357-
// put a warning in the logs. This should keep any driver without this
1358-
// support (such as saa7164) recording without affecting those that do
1359-
// use it.
1360-
if (errno == EINVAL)
1361-
return true;
1362-
1363-
LOG(VB_GENERAL, LOG_WARNING, LOC + "StartEncoding failed" + ENO);
1364-
return false;
1365+
return started;
13651366
}
13661367

13671368
bool MpegRecorder::StopEncoding(int fd)
@@ -1375,23 +1376,24 @@ bool MpegRecorder::StopEncoding(int fd)
13751376

13761377
LOG(VB_RECORD, LOG_INFO, LOC + "StopEncoding");
13771378

1378-
if (ioctl(fd, VIDIOC_ENCODER_CMD, &command) == 0)
1379+
bool stopped = 0 == ioctl(fd, VIDIOC_ENCODER_CMD, &command);
1380+
if (stopped)
13791381
{
13801382
LOG(VB_RECORD, LOG_INFO, LOC + "Encoding stopped");
1381-
return true;
1383+
}
1384+
else if ((ENOTTY == errno) || (EINVAL == errno))
1385+
{
1386+
// Some drivers do not support this ioctl at all. It is marked as
1387+
// "experimental" in the V4L2 API spec. These drivers return EINVAL
1388+
// in older kernels and ENOTTY in 3.1+
1389+
stopped = true;
1390+
}
1391+
else
1392+
{
1393+
LOG(VB_GENERAL, LOG_WARNING, LOC + "StopEncoding failed" + ENO);
13821394
}
13831395

1384-
// Some drivers do not support this ioctl at all. It is marked as
1385-
// "experimental" in the V4L2 API spec. If we fail with EINVAL (which
1386-
// happens if the ioctl isn't supported), treat it as a success, but
1387-
// put a warning in the logs. This should keep any driver without this
1388-
// support (such as saa7164) recording without affecting those that do
1389-
// use it.
1390-
if (errno == EINVAL)
1391-
return true;
1392-
1393-
LOG(VB_GENERAL, LOG_WARNING, LOC + "StopEncoding failed" + ENO);
1394-
return false;
1396+
return stopped;
13951397
}
13961398

13971399
void MpegRecorder::SetStreamData(void)

0 commit comments

Comments
 (0)