Difference between revisions of "MythTV on Mac x86"

From MythTV Official Wiki
Redirect page
Jump to: navigation, search
(Deleted very, very outdated text in favor of redirect to current info)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
{{Note box|For ongoing MythTV on Mac information, as well as binaries for both PowerPC and Intel based Macs, see the [[Myth on Mac OS X]] page.  It seems to be the page that is updated more regularly. }}
+
#REDIRECT [[Myth on Mac OS X]]
 
+
MythTV is working on the new Intel based Apple Macintosh platforms.  This page is intended to share information among the people attempting to build and optimize the Intel Mac code.
+
 
+
In the 'contrib' directory of the MythTV source code, there is a perl script which automates the build process for MythTV on MacOS systems.  The script is called [http://svn.mythtv.org/trac/browser/trunk/mythtv/contrib/OSX osx-packager.pl].  The descriptions of changes needed assume that script as a starting point.
+
 
+
==General Status and Binaries==
+
 
+
This page was created to exchange information in the effort to port MythFrontend to intel based Mac systems.  Those updates have been rolled into the mainstream 0.20 release, so the information on this page should not be needed for 0.20 or newer.  It may still be useful for someone trying to use an older version of MythTV with Mac OS X.
+
 
+
 
+
 
+
== 0.20.2 Status ==
+
 
+
29 Aug. 2007 -- Both frontend and backend compile and run on Intel Macs.  The backend supports the [[Silicondust HDHomeRun]], [[FireWire]] capture and [[IPTV]].  Guide data for North America can be retrieved from [[Schedules Direct]] and loaded with MythFillDatabase.  The frontend does what the frontend normally does!  ;-) - except that change aspect (the w key) does not work.
+
 
+
== 0.20 Status ==
+
 
+
March 30, 2007 -- Anyone running on Apple TV yet?  If so, please share.  http://www.appletvhacks.net/
+
 
+
(tji) It was reported on the MythTV mailing list that MythFrontend is now running on an AppleTV.  Copying of some Mac OS fonts was required to work around a Qt crash.  This may be a good option for SD playback, but will probably not support HD playback.
+
 
+
'''MythTV on AppleTV''' is working just fine.  Get more info here... [http://wiki.awkwardtv.org/wiki/MythTV awkwardTV]
+
*Some font's are needed, but the pre-compiled binaries work fine. [[User:Dr Omega|Dr Omega]] 05:00, 28 May 2007 (UTC)
+
 
+
Sept 21, 2006 -- You will need, in addition to XCode Tools, svn-client installed on your Mac for the osx-packager script to work. Fink installed it easily ('sudo apt-get install svn-client', or from the Fink GUI).
+
 
+
After installing svn-client, MythTV installed and worked perfectly.
+
 
+
 
+
Sept 14, 2006 -- Most of the build issues were resolved in recent svn updates.  With the final 0.20 release, running osx-packager.pl will result in a working build, with no modifications.  0.20 included some late additions for MacOS, including an MMX optimized colorspace conversion routine for intel Macs resulting in lower CPU usage. 
+
 
+
* The Apple Remote code was included in 0.20, and provides basic control in the standard frontend.
+
* The 'enable Altivec colorspace conversion' option was changed to 'enable vector optimized colorspace conversion' to include MMX/SSE in intel based Macs.
+
* '''Make sure the vector optimized colorspace option is enabled for Intel Macs.'''  Without this enabled, video output may be distorted.
+
 
+
== Current Functionality ==
+
 
+
MythTV frontend functions properly. HD MPEG2 video can be played on a Core Duo 1.66GHz Mac Mini.  AC3 Pass-through (Dolby Digital surround sound on some digital broadcasts) is very buggy, as discussed in {{Ticket|5552}}.
+
 
+
Couple things to watch out for:
+
 
+
* Make sure your configuration is set to use vector accelerated colorspace conversion, otherwise video may show corrupted.
+
 
+
* Set 'QT Style' to "Windows" in the frontend setup.  Otherwise, some QT menus appear to have messed up colors, making them difficult to read.  For example, when exiting mythtv, the "are you sure" menu shows up as white text on a light gray background, which is very difficult to read from viewing distance.
+
 
+
== Development In Progess ==
+
 
+
Here are some tickets that are of interest to Mac x86 users.  They are all 'in progress' and may have significant drawbacks or stability issues compared to the standard code base..  So, try them at your own risk.  The URLs listed below have patches which you can use to build and test these new features.
+
 
+
* {{Ticket|2381}} Core Video display module.  Use Mac OS X 10.4 / Tiger's new 'Core Video' API for video output.  This currently offers about the same functionality as the Quartz output, but may allow for GPU offload of things like deinterlacing and colorspace conversion in the future.
+
 
+
* {{Ticket|2539}} Enhance Core Audio code to handle AC3 S/PDIF passthrough. This has been applied, but if passthru is set and you don't have appropriate hardware, may do strange things.
+
 
+
* {{Ticket|2406}} Use Mac OS X DVD Playback Framework for Myth internal DVD.
+
 
+
* {{Ticket|1279} MPEG2 Hardware accleration for Mac OS X.  This has been partly integrated into the SVN releases, but is still very much a work in progress. This feature is probably more relevant on underpowered PowerPC system, like the G4 Mini, or maybe even the G3s.
+
 
+
==MythVideo Plugin==
+
 
+
MythVideo is working well, here are some tips to get you up and running.
+
 
+
If you want to use mplayer with MythVideo then install the MPlayer MacOSX binary (http://www.mplayerhq.hu) but then create a symlink to the command-line player as per the help instructions for MPlayer:
+
 
+
  Unless you have darwin ports installed, you might need to create /usr/local/bin :
+
  sudo mkdir -p /usr/local/bin
+
 
+
  For Intel Mac :
+
  sudo ln -s "/Applications/MPlayer OSX.app/Contents/Resources/External_Binaries/mplayer_intel.app/Contents/MacOS/mplayer" /usr/local/bin/mplayer
+
 
+
  For PowerPC Mac :
+
  sudo ln -s "/Applications/MPlayer OSX.app/Contents/Resources/External_Binaries/mplayer_ppc.app/Contents/MacOS/mplayer" /usr/local/bin/mplayer
+
 
+
Specify this symlink as the video player in MythVideo using the full pathname: /usr/local/bin/mplayer
+
 
+
If you want to automount a Windows/Samba share from another server that stores all of your videos, then try this guide: http://www.macosxhints.com/article.php?story=20031022164821984
+
 
+
Note that you must configure the automount entry while logged in as your mythtv user.
+
 
+
Video Manager:  If you want to use the TMDB search script to find metadata for your videos, you will need LWP User Agent support in libwww-perl, which can be found at (http://www.linpro.no/lwp/)
+
You will need XCodeTools installed; then follow the make instructions in the README file.
+
 
+
==Changes Needed for older builds==
+
Here's a brief summary of changes needed to build MythTV on an Intel based Mac system:
+
 
+
* Update QT version being used.  3.3.4 doesn't compile with gcc 4.0; 3.3.5 compiles but generates a bus error when displaying Myth menus. Using a development snapshot of 3.3.6 seems to work.  Replace the QT url in osx-packager with the following:  ftp://ftp.trolltech.com/qt/snapshots/qt-mac-free-3.3.6-snapshot-20060311.tar.gz  (these snapshots are changed frequently, pick a current one from that directory)
+
A.Weder (18.03.2006): I had to remove "-no-style-mac" from the qt-mt conf options in osx-packager.pl, since I got compile errors about QMacStyle not being defined in widgets/qtabbar.cpp. This is for the qt 20060317 snapshot of qt-mac 3.3.6, but also seems to hold for earlier snapshots.
+
 
+
* Override Host for sourceforge?  I found the availability of packages to be spotty on the default host, if it fails, replace the hostname with a working host.
+
 
+
* libdvdnav:  Endian byte swapping missing from src/dvdread/bswap.h  The following can be added to use Apple-supplied routines:
+
{{Code box|src/dvdread/bswap.h|
+
<pre>
+
#elif defined(__APPLE__)
+
#include <libkern/OSByteOrder.h>
+
#define B2N_16(x) x = OSSwapBigToHostConstInt16(x)
+
#define B2N_32(x) x = OSSwapBigToHostConstInt32(x)
+
#define B2N_64(x) x = OSSwapBigToHostConstInt64(x)
+
</pre>
+
}}
+
 
+
Note that this is not required with the latest version of the mythtv source and osx-packager.pl, because that library is not built.
+
 
+
* libexif: compile failed.  replace 'static ExifSShort' by just 'ExifSShort' in libexif/exif-utils.c near line 83. The latest osx-packager.pl uses the latest libexif and auto-applies a small fix for it to compile.
+
 
+
* libdvdread:  Endian byte swapping missing from dvdread/bswap.h  See bswap.h changes above.
+
 
+
 
+
MythTV changes: 
+
 
+
* Update osx-packager.pl to add configure parameters used in building MythTV.  In the section "configure mythplugins, and mythtv, etc", the 'mythtv' portion should look something like this:
+
 
+
  'mythtv'
+
  =>  [
+
        '--disable-distcc',
+
        '--disable-mmx',
+
        '--arch=pentium-m',
+
        '--extra-cxxflags=-msse -msse2 -msse3',
+
        '--prefix=' . $PREFIX,
+
      ],
+
 
+
* Adding '--disable-firewire' may be needed, if you get an error about a missing "AVCVideoServices" framework.
+
 
+
* This diff, against the released 0.19 codebase, fixes a crash and allows video to work:
+
<pre>
+
diff -ur mythtv-0.19/libs/libavcodec/liba52/resample.c /Users/ogre/src/mythtv-0.19/libs/libavcodec/liba52/resample.c
+
--- mythtv-0.19/libs/libavcodec/liba52/resample.c      2006-01-05 15:19:29.000000000 -0800
+
+++ /Users/ogre/src/mythtv-0.19/libs/libavcodec/liba52/resample.c      2006-03-16 13:31:42.000000000 -0800
+
@@ -13,14 +13,14 @@
+
+
#include "resample_c.c"
+
+
-#ifdef ARCH_X86
+
+#ifdef HAVE_MMX
+
#include "resample_mmx.c"
+
#endif
+
+
void* a52_resample_init(uint32_t mm_accel,int flags,int chans){
+
void* tmp;
+
+
-#ifdef ARCH_X86
+
+#ifdef HAVE_MMX
+
    if(mm_accel&MM_ACCEL_X86_MMX){
+
        tmp=a52_resample_MMX(flags,chans);
+
        if(tmp){
+
diff -ur mythtv-0.19/libs/libavcodec/msmpeg4.c /Users/ogre/src/mythtv-0.19/libs/libavcodec/msmpeg4.c
+
--- mythtv-0.19/libs/libavcodec/msmpeg4.c      2006-01-15 23:14:43.000000000 -0800
+
+++ /Users/ogre/src/mythtv-0.19/libs/libavcodec/msmpeg4.c      2006-03-16 13:25:10.000000000 -0800
+
@@ -725,7 +725,7 @@
+
        necessitate to modify mpegvideo.c. The problem comes from the
+
        fact they decided to store the quantized DC (which would lead
+
        to problems if Q could vary !) */
+
-#if (defined(ARCH_X86) || defined(ARCH_X86_64)) && !defined PIC
+
+#if defined(HAVE_MMX) && (defined(ARCH_X86) || defined(ARCH_X86_64)) && !defined PIC
+
    asm volatile(
+
        "movl %3, %%eax        \n\t"
+
        "shrl $1, %%eax        \n\t"
+
diff -ur mythtv-0.19/libs/libmythtv/videoout_quartz.cpp /Users/ogre/src/mythtv-0.19/libs/libmythtv/videoout_quartz.cpp
+
--- mythtv-0.19/libs/libmythtv/videoout_quartz.cpp      2005-11-26 08:38:42.000000000 -0800
+
+++ /Users/ogre/src/mythtv-0.19/libs/libmythtv/videoout_quartz.cpp      2006-03-16 13:59:53.000000000 -0800
+
@@ -1315,10 +1315,12 @@
+
    data->windowedMode = gContext->GetNumSetting("RunFrontendInWindow", 0);
+
    data->correctGamma = gContext->GetNumSetting("MacGammaCorrect", 0);
+
   
+
+#ifdef HAVE_ALTIVEC
+
    if (gContext->GetNumSetting("MacYuvConversion", 1))
+
        data->yuvConverter = yuv2vuy_init_altivec();
+
    else
+
-        data->yuvConverter = NULL;
+
+#endif
+
+        data->yuvConverter = yuv2vuy_init_plain();
+
+
    if (!CreateQuartzBuffers())
+
    {
+
diff -ur mythtv-0.19/libs/libmythtv/yuv2rgb.cpp /Users/ogre/src/mythtv-0.19/libs/libmythtv/yuv2rgb.cpp
+
--- mythtv-0.19/libs/libmythtv/yuv2rgb.cpp      2006-01-19 21:04:02.000000000 -0800
+
+++ /Users/ogre/src/mythtv-0.19/libs/libmythtv/yuv2rgb.cpp      2006-03-16 14:06:33.000000000 -0800
+
@@ -682,7 +682,6 @@
+
    }
+
}
+
+
-#ifdef HAVE_ALTIVEC
+
static void non_vec_yuv420_2vuy (uint8_t * image, uint8_t * py,
+
                                  uint8_t * pu, uint8_t * pv,
+
                                  int h_size, int v_size,
+
@@ -717,6 +716,13 @@
+
    }
+
}
+
+
+yuv2vuy_fun yuv2vuy_init_plain(void)
+
+{
+
+      return non_vec_yuv420_2vuy;
+
+}
+
+
+
+#ifdef HAVE_ALTIVEC
+
+
+
// Altivec code adapted from VLC's i420_yuv2.c (thanks to Titer and Paul Jara)
+
+
#define VEC_NEXT_LINES()                                                    \
+
diff -ur mythtv-0.19/libs/libmythtv/yuv2rgb.h /Users/ogre/src/mythtv-0.19/libs/libmythtv/yuv2rgb.h
+
--- mythtv-0.19/libs/libmythtv/yuv2rgb.h        2005-04-21 07:14:28.000000000 -0700
+
+++ /Users/ogre/src/mythtv-0.19/libs/libmythtv/yuv2rgb.h        2006-03-16 14:01:06.000000000 -0800
+
@@ -50,6 +50,7 @@
+
                              int vuy_stride, int y_stride, int uv_stride);
+
+
yuv2vuy_fun yuv2vuy_init_altivec (void);
+
+yuv2vuy_fun yuv2vuy_init_plain(void);
+
+
typedef void (* vuy2yuv_fun) (uint8_t * image, uint8_t * py,
+
                              uint8_t * pu, uint8_t * pv,
+
 
+
</pre>
+
* This fixes audio in v0.19.  More recent versions (''e.g.'' 0.19-fixes and 0.20) already have this fix:
+
<pre>
+
diff -ur mythtv-0.19/libs/libmyth/audiooutputca.cpp /Users/ogre/src/mythtv-0.19/libs/libmyth/audiooutp\
+
utca.cpp                                                                                             
+
--- mythtv-0.19/libs/libmyth/audiooutputca.cpp  2005-10-10 17:30:51.000000000 -0700                   
+
+++ /Users/ogre/src/mythtv-0.19/libs/libmyth/audiooutputca.cpp  2006-03-16 15:01:02.000000000 -0800   
+
@@ -107,8 +107,13 @@                                                                                 
+
    bzero(&conv_in_desc, sizeof(AudioStreamBasicDescription));                                       
+
    conv_in_desc.mSampleRate      = audio_samplerate;                                               
+
    conv_in_desc.mFormatID        = kAudioFormatLinearPCM;                                         
+
-    conv_in_desc.mFormatFlags      = kLinearPCMFormatFlagIsSignedInteger                             
+
-                                    | kLinearPCMFormatFlagIsBigEndian;                             
+
+    conv_in_desc.mFormatFlags      = kLinearPCMFormatFlagIsSignedInteger;
+
+#ifdef WORDS_BIGENDIAN                                                                               
+
+    conv_in_desc.mFormatFlags    |= kLinearPCMFormatFlagIsBigEndian;                                 
+
+#endif                                                                                               
+
    conv_in_desc.mBytesPerPacket  = audio_bytes_per_sample;                                         
+
    conv_in_desc.mFramesPerPacket  = 1;                                                             
+
    conv_in_desc.mBytesPerFrame    = audio_bytes_per_sample;                                         
+
</pre>
+
 
+
The following steps are necessary in 0.19 to re-enable the MMX code (in conjuction with the changes to osx-packager.pl documented elsewhere on this page.
+
 
+
* Add "-read_only_relocs,warning" to the QMAKE_LFLAGS line in the MythTV build config.  Without this change, I get an error: "ld: resample.o has local relocation entries in non-writable section (__TEXT,__text)"
+
 
+
* Apply the patch found at [http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2006-February/007608.html this link].  This changes involve mostly syntax revisions, to appease Apple's choice of tools. 
+
 
+
* For 0.19-fixes:  I got "Undefined Symbols" errors in the MMX assembly code, related to the "relocation entries" errors above.  The only way I could get it to compile is to remove the "MANGLE" macros in the assembly code in libavcodec.  To 'mangle' the variables by hand, just add an underscore before the name.  So the code would change from '"movq "MANGLE(magicF2W)", %%mm7 \n\t"' to '"movq _magicF2W, %%mm7 \n\t"'.  The files affected are:
+
  libs/libavcodec/i386/dsputil_mmx.c
+
  libs/libavcodec/i386/motion_est_mmx.c
+
  libs/libavcodec/i386/simple_idct_mmx.c
+
  libs/libavcodec/liba52/resample_mmx.c
+
 
+
The MANGLE macro was fixed in the 0.20 svn code.  So, a simpler solution would be to add those updates.  I'll try to go back and do a clean build, with the 0.20 svn updates, and revise the info here.
+
 
+
== Enabling MMX ==
+
The frontend will run fine without MMX, but you can save a lot of CPU overhead by re-enabling the MMX optimizations in the MPEG2 decoding code, especially for HD video.  Faster iMac or MacBook systems may be able to get by without this.  To do HD video on the Mac Mini, the MMX patch is probably necessary.
+
 
+
* Enable MMX and memlign_hack in the configure options in osx-packager.pl
+
 
+
  'mythtv'
+
  =>  [
+
        '--disable-distcc',
+
        '--disable-firewire',
+
        '--enable-mmx',
+
        '--arch=pentium-m',
+
        '--enable-memalign-hack',
+
        '--extra-cxxflags=-msse -msse2 -msse3',
+
        '--prefix=' . $PREFIX,
+
      ],
+
 
+
== Enabling Apple Remote for 0.19 ==
+
 
+
* To get the apple remote working, apply the patch attached to {{Ticket|2017}} This patch is for the 0.19.fixes branch. The 0.20 release contains this code already.
+
 
+
== Front Row integration ==
+
 
+
If you'd like the iTunes-compatible digital audio files (namely MP3s) on your MythBackend to be visible to iTunes and Front Row, you will need to install and configure Firefly Media Server (formerly mt-daapd). Movies can also be served by DAAP, but Firefly Media Server does not currently support that ability.
+
 
+
If you're using the stock Apple Remote, you won't be able to activate Front Row, because MythFrontend.app uses all of the Apple Remote's buttons. It is, however, fairly easy to launch Front Row from within MythFrontend.
+
 
+
First, create an AppleScript that launches Front Row by pasting the following code into Script Editor (usually found in /Applications/AppleScript):
+
  tell application "System Events"
+
    key code 53 using {command down}
+
    delay 0.5
+
    key code 53
+
  end tell
+
 
+
Save this file as a script, give it a name such as frontrow.scpt,  and save it to /usr/local/bin.
+
 
+
To add a Front Row menu item to your MythFrontend Media Library page, paste the following text into /Applications/MythFrontend.app/Contents/Resources/share/mythtv/library.xml:
+
 
+
  <button>
+
    <type>MUSIC</type>
+
    <text>Front Row</text>
+
    <action>EXEC osascript /usr/local/bin/frontrow.scpt</action>
+
  </button>
+
 
+
You can add the Front Row menu item to any menu you wish by pasting the above text into the xml file for your desired menu. Most of these menus are named rather straightforwardly: mainmenu.xml is the main menu, videomenu.xml is the Videos menu, and so forth.
+
 
+
==Hulu Desktop Integration==
+
 
+
It is quite easy to launch [http://www.hulu.com/labs/hulu-desktop Hulu Desktop] from MythTV. 
+
 
+
First, download [http://download.hulu.com/HuluDesktop.dmg Hulu Desktop for Mac] and install it to the system Applications folder.
+
 
+
Second, add a Hulu menu item to your MythFrontend Media Library page.  Paste the following text into /Applications/MythFrontend.app/Contents/Resources/share/mythtv/library.xml:
+
 
+
  <button>
+
    <type>STREAM</type>
+
    <text>Hulu</text>
+
    <action>EXEC open /Applications/Hulu\ Desktop.app</action>
+
  </button>
+
 
+
==Useful Links==
+
* Links on the IR receiver / remote included in the last iMac G5 and all intel based Macs.  Basic integration, passing arrow keys, ESC, enter to mythfrontend should be feasible.
+
[http://www.cocoadev.com/index.pl?UsingTheAppleRemoteControl http://www.cocoadev.com/index.pl?UsingTheAppleRemoteControl]<br>
+
[http://www.osxbook.com/software/iremoted/ http://www.osxbook.com/software/iremoted/]<br>
+
* Apps to extend the functionality of the Apple remote:
+
[http://www.iospirit.com/index.php?mode=view&obj_type=infogroup&obj_id=23 http://www.iospirit.com/index.php?mode=view&obj_type=infogroup&obj_id=23]<br>
+
[http://www.filewell.com/iRedLite/ http://www.filewell.com/iRedLite/]<br>
+
* [http://en.wikipedia.org/wiki/Mac_OS_X Mac OS Wiki]
+
* [http://www.mac-how.net/ Mac Related Articles]
+
* [http://developer.apple.com/documentation/GraphicsImaging/Conceptual/CoreVideo/CVProg_Intro/chapter_1_section_1.html Core Video Programming Guide] All Intel Macs support Core Image / Core Video, which can be used for optimized video playback and offloading effects such as de-interlacing to the GPU.
+
* [http://cocoamysql.sourceforge.net/ CocoaMySQL] - Excellent MySQL database GUI.  Allows easy tweaking of MythTV settings in backend.
+
* [http://www.freethinking.textdriven.com/?p=19 MythGrowl]  - A handy Mac OS X application to notify you via Growl when your backend starts or finishes a recording.
+
* [http://www.defyne.org/dvb/ DVB and ATSC drivers for MacOS] - Might allow porting of the backend at some point.
+
[[Category:Developer Documentation]] [[Category:Distribution_Specific_Install_Guides]] [[Category:MacOS]]
+

Latest revision as of 10:20, 28 August 2012