Make all mex files reentrant - But only apply to test build of Screen for now.

Make it possible for a PTB mex file / module to call itself
recursively, e.g., Screen() as part of imaging pipeline processing
calling into M-Functions or the interpreter which themselves call
Screen(), e.g., to query some properties.

So far this was impossible because some of the state in
PsychScriptingGlue, mostly for communicating with the scripting
environment, was global state to the file, stored on the heap or bss,
not on the function call stack. A function calling itself recursively
would have overwritten its own scripting glue state from a lower
recursion level and caused bad data corruption and trouble.

Now we implement our own mini-stack for those few variables (nlhs,
nrhs, plhs, pros, etc.) which need to be global to the file and not
just local to mexFunction(), with our own stack pointer variable
‘recLevel’ to index. recLevel is incremented and checked during entry
to the main dispatch mexFunction, decremented during regular exit from
mexFunction at return to the environment, as well as during error exits
before mexErrorMsgTxt(). Debugging output can be enabled via
setenv(‘PSYCH_RECURSION_DEBUG’,’1’); before first invocation of a
module. The stack depths and thereby max recursion level is #define’d
as MAX_RECURSIONLEVEL to a maximum of 5. I can’t think of any situation
where we’d need more than 2 or maybe 3 levels, so this should be plenty.

Tested via Screen’s imaging pipeline, both for regular completion and
error cases, both with and without async flips. Seems to perform
correctly.

-> Screen for 64-Bit Octave and Matlab on OSX rebuilt and tested. Works
on Octave and Matlab.
-> This currently has no benefit for modules other than Screen(),
because only Screen() can possibly call itself via its imaging pipeline.
-> Currently none of PTB’s code makes use of this feature, but it would
have been beneficial a couple of times in the past to simplify code or
make it more robust.
Core: Rename PsychScriptingGlue.cc -> .c for pure C build.

Changing PsychScriptingGlue's suffix from .cc to .c will
treat it as a C language file instead of a C++ language
file and thereby compile it as C instead of C++.

In the past, over 5 years ago, we needed this file to be
compiled as C++ for Octave compatibility, but we don't
need this any longer. A C build will do just fine. A C
build also avoids occassional trouble with C++ compilers
and C++ header files. C++ build was a recurring source
of build trouble with new compiler/framework/octave versions.

-> Renamed file.
-> Updated all make files and cleaned them up a bit in the process.
-> Test rebuild many mex files for many platforms.
Octave/Linux: Fix build for Octave 3.8.1 on Linux.

mkoctfile was implemented since forever as a well working
bash shell script. Somebody got bored and didn't like a
well working solution, so decided to throw it away and
rewrite mkoctfile as a compiled C++ executable with
less functionality for Octave 3.8 - Yay! :(

mkoctfile thereby lost the ability of wildcard expansion
of filenames like Common/Base/*.c and now screws up.

Reimplement wildcard expansion inside our linuxmakeitoctave3.m
make script by providing our own private override implementation
of Octave's mex.m inside our build script. This mex() function
is identical to Octave's, except it uses glob() to expand
filename wildcards like *.c into a list of all glob'bed files.
Then it passes those to mkoctfile.

-> linuxmakeitoctave3.m fixed.

-> Test rebuild of mex files under Octave 3.8.1 + Linux successfull.

-> Net result: Building PTB on Octave 3.8+ under Linux works again :)
               Another 24 hours of my life lost for no good purpose,
               just because somebody was bored and decided to make
               my life exciting.
PsychTweak: Make GstDumpFilterGraph more robust.

Strip trailing fileseparator, if any, because otherwise
GStreamer apparently ignores the directory, so dumping
of playback won't work.
Screen/Linux: Refine nouveau-kms broken pageflip event workaround.

Use video refresh interval * 0.8 if refresh interval is known post
refresh calibration. Use 7 msecs as in the past if refresh interval
not yet known, ie., during calibration itself. This is more adaptive
to true refresh rate.

Also blacklist all kernels >= 3.13 for now. We know 3.13 and 3.14
are definitely broken on nouveau-kms, but we don't know yet when
the fix will land - 3.15? 3.16? Later? Better play it safe and
assume all future kernels are broken until we know in which kernel
release the bug was finally fixed.
Screen/Linux: Expose more info in Screen('Computer')

Kernel, Hardware, Hostname, ...

-> Closer to OSX output.
Screen: Allow display of audio output device for GStreamer movie playback.

At 'Verbosity' > 3, print out the audio device (audio sink) used for
audio output during movie playback. This to help problems like "no sound"
during movie playback, e.g., due to misrouting of sound to wrong output.

-> Screen for 64-Bit Octave on Linux rebuilt and tested.
Screen/GStreamer: Allow selection of audio-sink during movie playback.

Introduce a new optional parameter 'movieOptions' to Screen('OpenMovie',...);
This allows to pass in an option string with key=value pairs of additional
playback options.

The only currently supported option is 'AudioSink=<sinkspec>', where
<sinkspec> must be a gst-launch style description of an audio-sink
plugin and parameter, e.g., 'AudioSink=pulseaudiosink device=Foo'
would use the pulseaudiosink plugin for audio output during movie
playback, and ask for output to audio device 'Foo'. This allows
in theory to control audio output routing if a system has more than
one soundcard or more than one output per soundcard.

Screen verbosity level 4 now also reports which audio device was
actually used during playback, to help debug audio routing problems,
e.g., because audio is routed to the HDMI output of the graphics card,
instead of the speakers, and one just wonders why there isn't any sound?

In practice, at least on KDE + PulseAudio on Linux i wasn't able to
override the selected order of preferences for audio outputs on my
MacbookPro. If i set the preferred audio output to DisplayPort/HDMI in
the KDE sound setup control panel, but asked PTB to play out over regular
speakers, the system ignored my wishes. Audio routing was properly set
at start of playback to the PTB spec, but immediately after start of
playback, the PulseAudio server reverted the audio sink to HDMI, ie.
overriding my settings. Soo, this new feature may be of limited utility
at least on some setups :(

-> Screen.mex for 64-Bit Octave on Linux rebuilt and tested -
   with limited success.

-> Another rather unfunny insight is that delivery of GStreamer bus
   messages doesn't work if Octave-3.8.1 is used with its GUI, at
   least for the GStreamer 0.10.36 installation of Ubuntu 14.04 LTS.
   It works with Octave 3.8.1 in command line mode, and with Matlab
   R2012a in GUI mode though. So something fishy is going on here with
   Octave GUI.

   Without proper bus message delivery, error handling is impaired,
   e.g., doesn't report why opening a movie file failed. Also looped
   video playback at default settings doesnt'w work, because the
   required EOS messages aren't received from the bus. Only method 64
   works, as it doesn't need the bus.

-> Another bad day in the life of our hero :(
Screen: Silence various compiler warnings.

The compiler found one real bug in Screen('GetImage'), although
one that was likely benign and never triggered.

There were various false positives about use of uninitialized
variables, mostly due to PsychErrorExitMsg() not being recognized
as the equivalent of a return() statement. This is just too convoluted
for the compiler to prove. Added some dummy assignments to silence
this noise and similar stuff that the compiler can't know is right.
Change Mk's e-mail address to preferred contact address.
IOPort: Do not set ReceiveLatency=0.000001 secs by default anymore.

Explictely setting ReceiveLatency by default during an
IOPort('OpenSerialPort', ...); call meant that the low-
latency setup code on OSX and Linux would always get
executed. Some serial port / serial-over-usb ports do
not support that setting and throw ugly errors. To avoid
this, do not set the parameter anymore by default.

Instead, relevant M-Files specify it now explicitely where
really low latency is needed, e.g., for response boxes,
trigger reception etc.

-> IOPort.mex for 64-Bit Octave on Linux rebuilt.

-> Multiple M-Files updated to accomodate the change, e.g.,
   PsychRTBox, CedrusResponseBox, CMUBox, BitsPlusPlus,
   ReceivingTriggerFromSerialPortDemo, ...
Rebuild Screen, IOPort for 64-Bit Octave/Matlab on Linux.
Screen/GStreamer: Only allow output of audio output device on Linux.

Turns out this is not supported on Windows at all and only in a
completely meaningless and source-code incompatible way on OSX, so this
is only useful for Linux + GStreamer.

-> Screen and IOPort for 64-Bit Octave/Matlab on OSX rebuilt and tested.
-> Setting audio sink on OSX works ok’ish, although the osxaudiosink
doesn’t respect volume settings and the device setting is essentially
useless on my MacbookPro with 10.9.2, as the only valid value is
device=0, which is the default anyway. Any other value causes failure.

-> In other news, GStreamer movie bus message delivery works on OSX
with Octave 3.8.0 + GUI, so either the problem is restricted to Linux
or to the specific set/versions of GStreamer plugins on my Ubuntu
14.04-LTS machine.
XCodeProject: Move PsychScriptingGlue.cc -> .c so Code search works again.
Add binary build of libportAudio.a 64-Bit for Linux to Cohorts/PortAudio folder.

… so we don’t need to go through recompiles on any new build system …
Fix Screen('Computer') for MS-Windows.

- Fix complete failure due to wrong field count for majorstruct.
- Remove empty MACAddress field - causes PsychtoolboxRegistration to
botch its job.
- Add “NT-“ prefix to ’system’ field, so we could use it directly for
OS version detection in PsychtoolboxRegistration instead of relying on
Matlab specific api, which may even report inaccurate info on Matlab
versions which predate a given os release.

- Also fix PsychSupportStatus() reporting: Should tell “supported” on
Windows-7 and “partially supported” on later Windows versions for the
moment, not the other way round.
Fix crash in Screen('OpenMovie') if optional 'movieOptions' is omitted.

This was dereferencing an uninitialised pointer, but worked by pure
chance in all tests with both Octave and Matlab on both Linux and OSX,
except for 64-Bit Matlab on Linux.
-> Init pointer to empty string to prevent the common case of no option
provided.
-> Do some white-space cleanup in PlayMoviesDemo.m.
Rebuild libptbdrawtext_ftgl64.so.1 on Debian-6 to fix load failures, e.g., on Ubuntu 12.04

Turns out, building it on a recent Linux distro (Ubuntu 13.10) caused
it to develop some unhealthy dependencies on recent stdlibc++ versions
which aren’t supported on either Debian-6 or Ubuntu 12.04 LTS.
Load failure with: “GLIBCXX_3.4.15 not found in libstdc++.so.6”

This poses a problem for our continued support of Ubuntu 12.04 LTS. May
need to keep an old Debian-6 VM around just to be able to build the
plugins.
IOPort and Screen for Linux and OSX rebuilt.

-> To integrate ‘ReceiveLatency’ change into IOPort.
-> To integrate latest Screen(‘OpenMovie’) fixes into Screen.
All mex files for 32/64 Bit Matlab on Windows rebuilt.