Screen/Windows: Change load order for gstreamer dll's.

When trying ot runtime LoadLibrary() GStreamer dll's, try GStreamer-SDK
dll's before the old OSSBuilds runtime dll's.
This is in preparation of switch to GStreamer SDK for 32-Bit Matlab on
Windows.
-> Screen for 32/64-Bit Matlab on Windows rebuilt and tested. Works as
expected.
iViewXComm: Add subfunction 'receivelast'.

Allows to fetch the most recent eyetracker data packet, e.g.,
if a queue of pending packets has built up, but we're interested
in live data.

See mesg #16300 and earlier for the reason. This solution is not
the greatest yet. Might be a good idea to switch the receive code
in this function to non-blocking operation (polling). Current blocking
operation can introduce a delay of ~0.5 msecs on Linux/OSX and ~1 msec
on Windows. This should be still ok'ish on Linux and OSX, but on Windows,
1 msec timeout will cause maximum sampling rate to drop below 1000 Hz,
which can be troublesome with the latest iView eyetrackers that can do
> 1000 Hz tracking.
Screen('WaitBlanking'): Small fix for PsychOSGetVBLTimeAndCount() fallback.

This path didn't update tvbl and time of last vbl, so returned wrong
'framesSincelastWait' return value and baseline.

Not crucial, as this function is seldomly used, and the specific
fallback path normally not executed in the first place.

-> No rebuild of mex files. Fold it into next regular Screen() rebuild.
Screen: NULL-out texture memory pointer received from GStreamer early.

NULL-out the reference to GStreamer owned and memory-managed video
memory buffer immediately after PsychCreateTexture() was used to create
an OpenGL texture from it. This is not really needed, as
PsychCreateTexture() does this already after texture creation if
clientstorage is not enabled, ie., always by default. We add this
explicit redundant NULL assignment as an annotation to the code, to
simplify correctness review of the code wrt. memory management somewhat.

-> Screen.mexw64 for 64-Bit Matlab on Windows rebuilt and tested.
Screen/Windows: Switch 32-Bit build from OSSBuilds Gstreamer to Gstreamer SDK.

Update build file to compile and link against 32-Bit GStreamer SDK
instead of 32-Bit OSSBuilds runtime. Enable GstEncodingProfiles for
video recording on 32-Bit Windows in source code. Update PsychStartup.m
to setup path to 32-Bit SDK.

-> Screen for 32-Bit Matlab on Windows rebuilt.
Fix a few glitches in printout, mostly fixing case statement options.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Comment clean up.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Comment clean up.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Renamed to match the transition of vset -> isetbio.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Added comment about where isetbio lives on gitHub.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Core: Do not use stdint.h on MS-Windows, but #define needed types ourselves.

If we want to build mex files for Windows-PTB against the Microsoft
common C runtime library (msvcrt.dll) instead of the Microsoft Visual
Studio 2010 C libraries, we can't #include <stdint.h> as this will
cause various compile errors.

Therefore don't include stdint.h but #define the two needed constants
INT64_MAX and INT32_MAX ourselves.

Tested and shown to compile correctly with all mex files on 64-Bit
Matlab on Windows.
Screen('DrawText')/Windows: Only use process-global text encoding locales.

Turns out the Microsoft common C runtime doesn't support
_create_locale() and _free_locale() for creation of locale setting
objects. To remove the need for these functions and unify more code
paths, get rid of these local locale settings.

We now only use setlocale() + caching of locale settings to change the
process-global locale setting during text conversion as part of
Screen('DrawText'), ie., store backup copy of global setting, change
global setting to our wanted setting, perform decoding with that
setting, restore original process locale. This temporary change of
locale should hopefully not have side effects.

-> Allow buildings with MSCRT.dll
windowsmakeit64: Switch build of Screen.mexw64 to use mscrt.dll.

Add the hodgepdoge of compiler and linker options to build against the
mscrt.lib/dll provided by the "Windows Driver Development Kit"
(WinDDK). With the WinDDK from Microsoft installed, this allows
building of Screen.mexw64 against mscrt.dll instead of the Microsoft
Visual Studio 2010 C runtime.

Small Plus: Consistent with GStreamer dll's.
Big Minus: Code review shows that the "plus" shouldn't matter given how
we use the GStreamer dll's. We already avoid all potential interactions
with GStreamer which could cause hazards. Building against mscrt.dll
makes it impossible for us to pass environment variables from Matlab to
Screen() or GStreamer, effectively disabling almost all PsychTweak()
functionality and reducing the effectiveness of workarounds for broken
computer clocks.

-> Hopefully this change won't be needed, it is a big net minus!

Here are the things that could cause trouble according to MSDN
documentation if we don't build against mscrt.dll: 1. Passing
environment variables (won't work - they don't show up across dll
boundaries), 2. Passing file handles (which we don't do), 3. Passing
locale settings (which we don't do), 4. malloc()'ing memory on our side
and provide it to GStreamer to own it (which we don't do), 5. free()ing
memory pointers provided by GStreamer (which we don't do). Point 1
explains why the GStreamer debug environment variable settings via
PsychTweak() never had an effect on Windows, but only on OSX and Linux.
Point 2 and 3 we don't do. Point 4 or 5 would cause heap corruption,
but we don't do this. So for all practical means and purposes we should
be just fine using the standard msvc2010 runtime libs as in the past.
Screen for 32/64-Bit Matlab on Windows rebuilt and tested.

32-Bit Screen() just incorporates the locale setting changes from
previous commit.
64-Bit Screen() is linked against mscrt.dll instead of the MS-VisualC
2010 dll's.
-> The latter one is important for testing.
Added many more checks for consistency in the routines that compute photoreceptor parameters.

It is now harder to do something stupid, such as specify a nomogram for absorbance and then pass absorbance directly, thus ignoring the nomogram that you specified.

And, the returned structure is more informative about what was computed and what was supplied.

I checked that none of these changes break test routines within the PTB.   But if you were cleverly overriding values set by DefaultPhotoreceptors, you may now need to explictly set some sources to 'None' or some values to the empty matrix.  The error messages should be moderately informative about how to go about this, and there are some examples of this being done in CIEConeFundamentalsTest (where such changes were made.)

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
New demo for simple use of sound schedules: SimpleSoundScheduleDemo.
Tightening up cone fundamental generation code

Added options to DefaultPhotoreceptors that will produce the CIE (aka Stockman-Sharpe) 2 and 10 degree fundamentals.

Added a lot of comments about relation between various routines that do similar things.

Added check that FillInPhotoreceptors and ComputeRawConeFundamentals are consistent with one another, and added extra return args to ComputeCIEConeFundamentals and ComputeRawConeFundamentals to allow access to unnormalized quantal sensitivity functions.

Added other miscellaneous comments.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Screen: Make g_thread_init() call conditional on GLib version.

g_thread_init() is only needed up to GLib version < 2.31.0, but
deprecated above. Add a version check macro to avoid compiling it on
GLib >=2.31.0.
Screen/Windows: Add special GStreamer debug code for msvcrt builds.

On Windows + msvcrt builds, no env variables can be passed from Matlab
to Screen+Gstreamer, therefore use a trick to define GST_DEBUG env
variable at Screen verbosity > 20 inside Screen to pass it to
GStreamer. Didn't work either on R2012a, probably because stderr gets
redirected to nirvana. Whatever...
Screen.mexw64 for 64-Bit Matlab on Windows rebuilt and tested.

Another minor candidate for crash testing. Previous builds didn't
improve situation on affected machine out there.