Merge pull request #2 from Psychtoolbox-3/master

pull in latest beta
Merge pull request #172 from kleinerm/master

Pull Linux display locking fixes.
Merge pull request #174 from kleinerm/master

PTB BETA RELEASE "Hammertime!" SP4 - "Deadlock"

* XLib threading fixes for regressions introduced into Linux PTB.
* Make DaqDeviceIndex a bit more robust on OSX.
* Make IsomerizationInEye/DishDemo work again on Octave and fix some bugs.
* Reenable parts of PsychCV for 64-Bit Octave on Linux. (Experimental)
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
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>
Expanded comment.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Fix stray characters at end.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Screen: Fix formatting of PsychVideoCaptureSupportLibDC1394.c

Make it less ugly by fixing indentation etc. Also remove some
superfluous fflush()es along the way and suppress two false
compiler warnings to get a clean compile.

-> Screen for 64-Bit Octave on Linux rebuilt and tested.
Screen: Add pixeldepth 5 "YUV" support to libdc1394 engine.

So usercode can explicitely request YUV capture from a camera
to save bus bandwidth on the firewire bus.
Screen: Make framerate calculation in firewire mode 7 less wrong.

Don't have a camera that doesn't report bogus values, so this
is probably still wrong and only the fallback path reports
correct values. However, the old formula was definitely wrong,
so this is less wrong.
Screen/OSX: Add AppNap protection et al. for OSX 10.9+

Whenever Screen() gets initialized, AppNap protection is enabled.
Whenever it gets clear'ed, AppNap protection is disabled. As Screen()
is also called by Priority() on OSX, this will imply protection for
anything visual and anything using Priority() to imply it is timing
sensitive.

What does it do? On pre 10.9 nothing. On 10.9+ it uses the new
"Activity" API to tell the OS to prevent or enable certain
actions/optimizations to make sure the system doesn't go to sleep or
nap, or the display doesn't go to sleep or nap, or the application
isn't starved of cpu cycles (=forced to nap) during PTB operations. It
also tells the OS that this app is "NSActivityLatencyCritical".

We somewhat abuse th api's here, which will lead to shortened battery
life as long as Screen() isn't flushed, but correctness is more
important than battery life, and i don't have time or nerves to think
of a more intelligent and balanced approach. Better safe than sorry.

-> Screen for 64-Bit Matlab and Octave on OSX rebuilt and tested.
-> While it seems to work and doesn't seem to cause problems i also
can't see any measureable benefit in timing behaviour. On my machine
OSX 10.9 just sucks display-timing wise and i haven't tested other
modalities.
Merge branch 'master' of https://github.com/kleinerm/Psychtoolbox-3
Screen: Add multi-camera sync support to dc1394 video capture - Part I

This is the control code for starting and stopping synchronous
capture + setup code in 'SetVideocaptureParameter' for selecting
master/slave role and sync strategy.

We allow:

a) Software sync: Start/Stop on a best-effort software basis.
b) Firewire bus sync via broadcast of iso on/off signals from master.
c) Hardware sync via trigger cable.

For c) the setup code for trigger source/mode/polarity is still
missing - tbd.

-> Tested for basic function, but sync precision testing is tbd.
-> VideoMultiCameraCaptureDemo updated to allow multicam sync testing.
-> Screen for Octave on Linux rebuilt and tested.

This is part I of sync support.
Merge branch 'upstream/master'
Screen: Finish libdc1394 multicamera sync support (Part II).

All hardware trigger control settings implemented and tested:
- Trigger source enumeration, query and select.
- Trigger polarity query and select.
- Trigger mode query and select.
- All sync modes incl. fallbacks: Hardware, Bus, Software.
- Bandwidth query as bonus.
- Improved error handling and also node enumeration.

-> This is relatively well tested and seems to provide resonable
   sync in software mode, where start of master also triggers
   start of slaves by quickly emitting the iso-on commands. About
   < 1 msec error.

-> Both bus sync and hardware trigger sync seem to be sub-msec
   accurate. Microsecond accuracy is expected for hardware triggers,
   but bus sync seems to be also accurate in the low microsecond
   range for cameras of identical model and vendor --> No need for
   external sync cables and trigger inputs if all cameras are identical
   and can be driven from one shared firewire bus (ie. if bandwidth is
   sufficient).

-> Screen for 64-Bit Octave on Linux rebuilt and tested.
-> VideoMultiCameraCaptureDemo updated and tested in various modes,
   also with hardware triggers on identical cameras.
Screen: Allow raw->bayer->rgb and yuv->rgb conversion in libdc1394 video capture.

New optional parameters allow to receive video data in raw8 or mono8
format from camera, ie., raw sensor data, to save firewire bus bandwidth,
and then perform Bayer filtering from raw -> rgb8 in software via libdc's
builtin Bayer conversion algorithms.

Also reworked the yuv->rgb conversion pass to make it consistent with
bayer path.

Also allow return of unfiltered raw8/mono8 sensor data for offline
debayering or self-made debayering (gpu anyone?).

New parameters allow to select debayering algorithm (quality - speed tradeoff)
and bayer pattern if it can't get auto-detected (Auto-Detection only possible
in Format-7 modes due to IIDC limitations).

-> Some dead code removal when we are at it.
-> Screen for 64-Bit Octave on Linux rebuilt and tested.
-> VideoMultiCameraCaptureDemo updated for testing.

-> Both hardware sync and bus sync confirmed to be accurate now.
Screen: Tiny compiler warning fix for libdc1394 video capture.

And some tiny fixes for VideoMultiCameraCaptureDemo.m
Screen: Honor a new optional specialflags setting 'kPsychGUIWindowWMPositioned'

If specified together with kPsychGUIWindow, it tells Screen() to leave
window placement of onscreen GUI windows to the window manager instead
of to Screen.
This will ignore the [left, top, ...] parameter in the 'rect'. Size of
the window will still be defined by the 'rect', but not its absolute
position. The hope is that the window manager will do a better job at
window placement, although testing on OSX 10.9 Mavericks shows that at
least on OSX this hope was not warranted.

-> Screen for 64-Bit Octave and Matlab on OSX rebuilt and tested.
-> Screen on other os'es pending.
-> New flag definition file kPsychGUIWindowWMPositioned.m added.
Screen/Linux: Test WM managed GUI window positioning.

Works more or less.

-> Screen for 64-Bit Octave on Linux rebuilt and tested.
-> VideoMultiCameraCaptureDemo modified for testing this.
-> KDE needs to be switched into "tiling" window placement to get
   good automatic multi-onscreen-window placement this way.