[mythtv] MythTV 0.15 Port for FreeBSD
Stacey Son
mythdev at son.org
Thu Jun 3 20:26:32 EDT 2004
Matt Zimmerman wrote:
>Sounds good, I've committed the necessary changes to CVS. See if you can
>revert those patches now, and then we'll review whatever's left in your
>tree.
>
>
>
I am eliminated a few more patches and here is what is left (patches are
attached):
patch-avformatdecoder.cpp patch-mythcdrom.cpp
patch-mythmediamonitor.cpp
patch-videodev_myth.h patch-videoout_ivtv.cpp patch-vsync.c
The patch to avformatdecoder.cpp elminates the need to increase the
thread stack size for a couple of threads. (This is the last of them.)
The patches for mythcdrom.cpp and mythmediamonitor.cpp still need some
work. (CDROM device dependent stuff.)
The patch for videodev_myth.h now does the proper typdef for __s32 will
fixes the problem with the template in channel.cpp and eliminates that
patch.
The patch for videoout_ivtv.cpp unfortunately still has roundf(). I
need to talk to guys working on the c99 stuff for FreeBSD to see if I
can help them add this.
Best Regards,
-stacey.
-------------- next part --------------
Index: ./libs/libmythtv/avformatdecoder.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/avformatdecoder.cpp,v
retrieving revision 1.83
diff -u -r1.83 avformatdecoder.cpp
--- ./libs/libmythtv/avformatdecoder.cpp 26 May 2004 06:18:36 -0000 1.83
+++ ./libs/libmythtv/avformatdecoder.cpp 4 Jun 2004 00:03:19 -0000
@@ -1026,7 +1026,7 @@
AVPacket *pkt = NULL;
int len, ret = 0;
unsigned char *ptr;
- short samples[AVCODEC_MAX_AUDIO_FRAME_SIZE / 2];
+ short *samples = new short[AVCODEC_MAX_AUDIO_FRAME_SIZE / 2];
int data_size = 0;
long long pts;
bool firstloop = false;
@@ -1074,6 +1074,7 @@
{
ateof = true;
m_parent->SetEof();
+ delete[] samples;
return;
}
}
@@ -1315,6 +1316,7 @@
delete pkt;
m_parent->SetFramesPlayed(framesPlayed);
+ delete[] samples;
}
bool AvFormatDecoder::DoRewind(long long desiredFrame)
-------------- next part --------------
Index: ./libs/libmyth/mythcdrom.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcdrom.cpp,v
retrieving revision 1.5
diff -u -r1.5 mythcdrom.cpp
--- ./libs/libmyth/mythcdrom.cpp 24 Feb 2004 07:31:08 -0000 1.5
+++ ./libs/libmyth/mythcdrom.cpp 4 Jun 2004 00:06:36 -0000
@@ -1,6 +1,10 @@
#include "mythcdrom.h"
#include <sys/ioctl.h> // ioctls
+#ifdef __FreeBSD__
+#include <sys/cdio.h>
+#else
#include <linux/cdrom.h> // old ioctls for cdrom
+#endif
#include <sys/stat.h>
#include "mythcontext.h"
@@ -37,7 +41,11 @@
{
// If allow eject is on, unlock the door.
if (m_AllowEject)
+#ifdef __FreeBSD__
+ (void) ioctl (m_DeviceHandle, CDIOCALLOW);
+#else
ioctl(m_DeviceHandle, CDROM_LOCKDOOR, 0);
+#endif
return true;
}
@@ -47,19 +55,32 @@
MediaError MythCDROM::eject()
{
+#ifdef __FreeBSD__
+ return (ioctl(m_DeviceHandle, CDIOCEJECT) == 0) ? MEDIAERR_OK :
+ MEDIAERR_FAILED;
+#else
return (ioctl(m_DeviceHandle, CDROMEJECT) == 0) ? MEDIAERR_OK :
MEDIAERR_FAILED;
+#endif
}
bool MythCDROM::mediaChanged()
{
+#ifdef __FreeBSD__
+ return (0); // no support for detecting media change
+#else
return (ioctl(m_DeviceHandle, CDROM_MEDIA_CHANGED, CDSL_CURRENT) > 0);
+#endif
}
bool MythCDROM::checkOK()
{
+#ifdef __FreeBSD__
+ return(1);
+#else
return (ioctl(m_DeviceHandle, CDROM_DRIVE_STATUS, CDSL_CURRENT) ==
CDS_DISC_OK);
+#endif
}
// Helper function, perform a sanity check on the device
@@ -88,7 +109,11 @@
}
// Since the device was is/was open we can get it's status...
+#ifdef __FreeBSD__
+ int Stat = 1;
+#else
int Stat = ioctl(m_DeviceHandle, CDROM_DRIVE_STATUS, CDSL_CURRENT);
+#endif
// Be nice and close the device if we opened it, otherwise it might be locked when the user doesn't want it to be.
if (OpenedHere)
@@ -114,6 +139,7 @@
if (!isDeviceOpen())
OpenedHere = openDevice();
+#ifndef __FreeBSD__
if (isDeviceOpen())
{
//cout << "device is open - ";
@@ -210,6 +236,7 @@
}// mediaChanged()
} // isDeviceOpen();
else
+#endif // __FreeBSD__
{
//cout << "device not open returning unknown" << endl;
m_MediaType = MEDIATYPE_UNKNOWN;
@@ -227,7 +254,11 @@
{
MediaError ret = MythMediaDevice::lock();
if (ret == MEDIAERR_OK)
+#ifdef __FreeBSD__
+ ioctl(m_DeviceHandle, CDIOCPREVENT);
+#else
ioctl(m_DeviceHandle, CDROM_LOCKDOOR, 1);
+#endif
return ret;
}
@@ -238,7 +269,11 @@
{
// The call to the base unlock will close it if needed.
VERBOSE( VB_ALL, "Unlocking CDROM door");
+#ifdef __FreeBSD__
+ ioctl(m_DeviceHandle, CDIOCALLOW);
+#else
ioctl(m_DeviceHandle, CDROM_LOCKDOOR, 0);
+#endif
}
else
{
-------------- next part --------------
Index: ./libs/libmyth/mythmediamonitor.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythmediamonitor.cpp,v
retrieving revision 1.3
diff -u -r1.3 mythmediamonitor.cpp
--- ./libs/libmyth/mythmediamonitor.cpp 2 Feb 2004 23:17:35 -0000 1.3
+++ ./libs/libmyth/mythmediamonitor.cpp 4 Jun 2004 00:06:08 -0000
@@ -5,7 +5,9 @@
#include <fcntl.h>
#include <dirent.h>
#include <cstdio>
+#ifndef __FreeBSD__
#include <mntent.h>
+#endif
#include <iostream>
#include <unistd.h>
@@ -69,6 +71,7 @@
// Loop through the file system table and add any supported devices.
bool MediaMonitor::addFSTab()
{
+#ifndef __FreeBSD__
struct mntent * mep = NULL;
FILE* vt = NULL;
@@ -91,7 +94,7 @@
if (m_Devices.isEmpty())
return false;
-
+#endif
return true;
}
@@ -107,6 +110,7 @@
// add it to our collection.
bool MediaMonitor::addDevice(const char* devPath )
{
+#ifndef __FreeBSD__
QString devicePath( devPath );
//cout << "addDevice - " << devicePath << endl;
@@ -222,7 +226,7 @@
delete pDevice;
}
}
-
+#endif
return false;
}
-------------- next part --------------
Index: ./libs/libmythtv/videodev_myth.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/videodev_myth.h,v
retrieving revision 1.3
diff -u -r1.3 videodev_myth.h
--- ./libs/libmythtv/videodev_myth.h 20 Feb 2004 08:45:20 -0000 1.3
+++ ./libs/libmythtv/videodev_myth.h 4 Jun 2004 00:05:26 -0000
@@ -1,8 +1,17 @@
#ifndef __LINUX_VIDEODEV_H
#define __LINUX_VIDEODEV_H
+#ifdef __FreeBSD__
+#include <sys/types.h>
+typedef unsigned long __u32;
+typedef unsigned short __u16;
+typedef int __s32;
+typedef unsigned char __u8;
+typedef unsigned long long __u64;
+#else
#include <linux/types.h>
#include <linux/version.h>
+#endif /* __FreeBSD__ */
#if 1
/*
-------------- next part --------------
Index: ./libs/libmythtv/videoout_ivtv.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/videoout_ivtv.cpp,v
retrieving revision 1.30
diff -u -r1.30 videoout_ivtv.cpp
--- ./libs/libmythtv/videoout_ivtv.cpp 20 May 2004 06:15:53 -0000 1.30
+++ ./libs/libmythtv/videoout_ivtv.cpp 4 Jun 2004 00:04:38 -0000
@@ -12,7 +12,11 @@
#include <cerrno>
#include <sys/ioctl.h>
#include <sys/mman.h>
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#else
#include <sys/user.h>
+#endif
#include <sys/poll.h>
#include <map>
@@ -34,6 +38,10 @@
#include "../libavcodec/avcodec.h"
#include "yuv2rgb.h"
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0
+#endif
+
VideoOutputIvtv::VideoOutputIvtv(void)
{
videofd = -1;
@@ -533,6 +541,29 @@
return frameinfo.frame;
}
+#ifdef __FreeBSD__
+/* roundf(x)
+ * Round to nearest integral value. If the argument is halfway between two
+ * integral values then round away from zero.
+ */
+
+float
+roundf(float x)
+{
+ float t;
+
+ if (x >= 0.0) {
+ t = ceilf(x);
+ if (t - x > 0.5) t -= 1.0;
+ return t;
+ } else {
+ t = ceilf(-x);
+ if (t + x > 0.5) t -= 1.0;
+ return -t;
+ }
+}
+#endif /* __FreeBSD */
+
bool VideoOutputIvtv::Play(float speed, bool normal)
{
if (speed > 3.0)
-------------- next part --------------
Index: ./libs/libmythtv/vsync.c
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/vsync.c,v
retrieving revision 1.7
diff -u -r1.7 vsync.c
--- ./libs/libmythtv/vsync.c 31 May 2004 21:53:15 -0000 1.7
+++ ./libs/libmythtv/vsync.c 4 Jun 2004 00:03:43 -0000
@@ -22,7 +22,13 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/time.h>
+#ifdef __FreeBSD__
+#include <machine/sysarch.h>
+#include <machine/cpufunc.h>
+#define ioperm i386_set_ioperm
+#else
#include <sys/io.h>
+#endif
#include <sys/poll.h>
#include <fcntl.h>
#include <errno.h>
More information about the mythtv-dev
mailing list