Merge pull request #2 from Psychtoolbox-3/master

pull in latest beta
Eyelink: Improve error handling in Eyelink('Initialize').

Provide meaningful error message with abort if open_eyelink_system()
fails, instead of silent failure and confusing status return codes.
-> Minor problem, no need to rebuild Eyelink mex file. Will be folded
into release at next real rebuild.
New demo TurnTableDemo - Free your inner DJ!

A demo which uses PsychPortAudio's functions to simulate a good'ol turn
table for some recreational scratching and other auditory fun
activities.

Work in progress - This is a backup commit of a basic working state.
TurnTableDemo: Number zero does not map well - exclude it.
TurnTableDemo: Refine key mappings.

Right ALT doesn't work well on some setups, so use
Right SHIFT instead to stop looping sounds and drop
the old mute function of that right SHIFT key.

Minor cleanups.
10/24/13  dhb     Pass scaling args to packing routine and truncate test image.  These were needed to make this work with my Bits++ in Color++ mode today.  I think the cropping has to do with the spatial res of my
monitor.  How this ever worked without the scaling args, though, is unclear to me.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Merge branch 'master' of https://github.com/Psychtoolbox-3/Psychtoolbox-3
Screen/GStreamer: Allow passing arbitrary bins as video sources for video capture.

A deviceIndex of -1 in Screen('OpenVideoCapture') now accepts a
gst-launch style pipeline/bin description string as 'moviename'. The
string is parsed and converted into a GstBin and this bin is attached
as video source element for video capture and recording.

-> Should allow to build unusual or exotic capture pipelines or work
around system limitations.
-> Such a videosource will not allow auto-detection of video
resolution, nor will it validate a provided roi. Either secondary
detection will have to work, or usercode has to pass in a valid roi,
otherwise bad things will happen.

-> Screen.mexw64 for 64-Bit Matlab on Windows rebuilt and lightly
tested. Other mex files will have to wait for next beta release.
DaqDeviceIndex/OSX: Make sure selected daq has nroutputs > 0.

Not that it helped. DaqAInScan fails just as miserably on OSX 10.9 as
it did on 10.7 and 10.5. Seems that one 10.8 machine of user masondar
is the only one that actually works with 64-Bit PTB. Oh, and 10.9
scrambles ordering of daq interfaces even worse than 10.7 did. Strong
work Apple!
Make these work on at least one version of Linux, by letting the trials of various possible paths execute under Linux as well as OS/X.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
IOPort/Unix: Fix missing init assignment of lineTerminator to _POSIX_VDISABLE

Had a == instead of =, so the init was a no-op. Found by llvm clang
compiler.
Expanded comment.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Adapt to OSX 10.9 Mavericks and 10.9-SDK, rebuild all OSX mex files.

Change base SDK from 10.6 to 10.9, as 10.6 and 10.7 SDK's are no longer
available on the 10.9 build system. Change compiler to llvm-gcc from
llgv-gcc-4.2.
Make modifications to fix as many compile time warnings as possible.
Rebuild all Matlab and Octave mex files for 64-Bit OSX.

All mex files except Screen build without warnings. Remaining warnings
at this point:
- GStreamer deprecated function warnings. Those are on all platforms ->
unrelated.
- CGDisplayBitsPerPixel implicit declaration and CGDisplayBeamposition
implicit declaration. These have been removed from 10.9 SDK but code
still magically works.
- ATSUxxx function implicit declaration warnings in SCREENDrawText.
These have been removed from 64-Bit SDK headers but still magically
work.
-> This could only be fixed by rewriting the ATSUI text renderer into a
CoreText text renderer, and changing CGxxx api. Keep it for now as is,
as long as it works.
-> CGDisplayBeamposition() is a candidate for removal. It has limited
use on 10.6 (Only NVidia gpu's supported), even more limited use on
10.7 (slight inaccuracies, PsychtoolboxKernelDriver is always the
better option), almost no use on 10.8 (only works on VGA-CRT monitors)
and is completely dysfunctional on 10.9 - The function only returns the
-1 "feature unsupported" status code and triggers our fallbacks. All in
all the function is almost useless and mostly a maintenance burden at
this point.

-> This set of Octave mex files is compatible with the Octave-3.7.7+
GUI prototype, useful for testing with Octave GUI on OSX.
Screen/OSX: Rewrite screen glue to remove/fix use of deprecated functions.

Rewrite screen glue to use functions which are supported/current as of
OSX 10.9, to replace functions which are deprecated since 10.6.
Add missing function prototype of CGDisplayBeamPosition() - which was
completely removed in the OSX 10.9 SDK - until we decide if we should
already kill it completely, or let it linger around for a while longer.
Current status:
10.6 - Only works on NVidia gpus, 10.7 - Ditto, but slightly
broken/inaccurate - PTB driver is better solution, 10.8 Severely broken
for everything bug VGA-CRT's, 10.9 completely dysfunctional (always
returns zero on NVidia card).
Remove unused PsychGetNumScreenPlanes() function for all os'es as a
cleanup.

-> Screen for 64-Bit Matlab on OSX rebuilt and lightly tested.
Screen/GStreamer: Silence deprecation warnings on at least OSX and Linux.

When building on GLib version 2.32 and later, disable warnings about
deprecated API calls. This to silence g_value_array_get_nth() and
g_value_array_free() deprecation warning on GLib 2.32+. We know that
GValueArrays are deprecated and should be replaced by GArray's, but
some GStreamer-0.10 functions still use them, so we have to use them as
well until we upgrade to GStreamer-1.0 at some point.

Makes compiler output less cluttered. Also remove some deprecation
warning suppress from OSX Window glue when we're at it - it is no
longer needed.
Rebuild Screen mex files for Octave and Matlab on OSX as baseline.
Screen/OSX: Replace ATSUI text renderer by CoreText text renderer.

ATSUI is deprecated since 10.6 and difficult to support on 10.9+, so
let it die.
Screen('DrawText') for OSX specific textrenderer (type 0 and 1)
reimplemented by use of CoreText framework. Additional code cleanup.
As a little side effect, the CoreText renderer now supports
Screen('TextModes') which never had any function in PTB-3 and it
supports "underlined" text style - in theory, as i couldn't find any
font which actually supports that. As another bonus, the renderer can
now handle the "Kuenstler LT" script font which was so painful to use
in the old implementation.

-> Screen and FontInfo for 64-Bit Octave and Matlab on OSX rebuilt and
tested.
OSX: Transition fontglue from ATSUI to CoreText.

Remove all ATSUI based code for font enumeration and replace by
CoreText equivalents. This incurs some loss of information, as CoreText
doesn't expose some stuff ATSUI did:
* No QuickDraw name of the font anymore, instead an empty string.
* Some entries in the font metrics are now missing: avgAdvanceWidth,
minLeftSideBearing and minRightSideBearing, stemWidth and stemHeight.
These are now returned as zero.

-> Screen and FontInfo for 64-Bit Matlab on OSX rebuilt and tested.
OSX: Optimize/Reduce execution time of CoreText font enumeration.

Full query of all font properties, as reported by info =
FontInfo('Fonts'), is very costly in terms of execution time. It
requires to open->query->close every single font file to retrieve some
properties like font metrics etc. Most of the information is only
needed by FontInfo(). Screen() only needs the font family name and font
style descriptor for selecting a font via Screen('TextFont') [Selects
by font family name] and Screen('TextStyle') [Selects by style symbolic
traits descriptor], and the postscript name of a font for
Screen('DrawText') [Selects font to open/use for drawing via postscript
name]. Luckily the minimal information required by Screen() is also
available in the CTFontDescriptor's returned by the font database
without need to actually open the associated font file. Take advantage
of this: If enumeration is executing within the context of Screen() mex
startup, only perform cheap CTFontDescriptor queries but skip expensive
font open->query->close detailed queries. This saves a lot of startup
time on first load of Screen() mex after startup/clear Screen:

Before: 14-15 seconds for Screen initial startup on a 2010 MacBookPro
with OSX 10.9
Now: 0.137 seconds -> Over 100x faster -> Essentially not noticeable by
user!

-> Also cleanup a few now unused ATS and FM varirables from fontstruct.
-> Also simplify DrawHighQualityUnicodeTextDemo. No need for use of
FontInfo for defining japanese fonts anymore - font family is now
always ASCII encoded. Faster!

-> Screen and FontInfo for 64-Bit Octave and Matlab on OSX rebuilt and
tested.
Screen/OSX: Release font database at flush time.

Was missing a call to PsychFreeFontList() to cleanup font database at
clear Screen time, causing a memory leak over all these years! A small
one though...
-> Screen for Octave and Matlab on OSX rebuilt and tested.