From a284b8c124e0719cf7bde9f3ad4f91a67b7c7f85 Mon Sep 17 00:00:00 2001
From: Good Guy <good1.2guy@gmail.com>
Date: Sun, 9 Oct 2016 16:10:38 -0600
Subject: [PATCH] fixes for prefs wrt compiler flags, correct comments

---
 cinelerra-5.1/cinelerra/adeviceprefs.C | 12 +++++++++++-
 cinelerra-5.1/cinelerra/audioesound.C  |  2 +-
 cinelerra-5.1/cinelerra/overlayframe.h |  6 +++---
 cinelerra-5.1/cinelerra/vdeviceprefs.C |  2 ++
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/cinelerra-5.1/cinelerra/adeviceprefs.C b/cinelerra-5.1/cinelerra/adeviceprefs.C
index f3a10893..cff01da0 100644
--- a/cinelerra-5.1/cinelerra/adeviceprefs.C
+++ b/cinelerra-5.1/cinelerra/adeviceprefs.C
@@ -615,22 +615,32 @@ ADriverMenu::~ADriverMenu()
 
 void ADriverMenu::create_objects()
 {
+#ifdef HAVE_OSS
 	add_item(new ADriverItem(this, AUDIO_OSS_TITLE, AUDIO_OSS));
 	add_item(new ADriverItem(this, AUDIO_OSS_ENVY24_TITLE, AUDIO_OSS_ENVY24));
+#endif
 
 #ifdef HAVE_ALSA
 	add_item(new ADriverItem(this, AUDIO_ALSA_TITLE, AUDIO_ALSA));
 #endif
 
+#ifdef HAVE_ESOUND
 	if(!do_input) add_item(new ADriverItem(this, AUDIO_ESOUND_TITLE, AUDIO_ESOUND));
-//	add_item(new ADriverItem(this, AUDIO_NAS_TITLE, AUDIO_NAS));
+#endif
+
 #ifdef HAVE_FIREWIRE
 	if(!do_input) add_item(new ADriverItem(this, AUDIO_1394_TITLE, AUDIO_1394));
 	add_item(new ADriverItem(this, AUDIO_DV1394_TITLE, AUDIO_DV1394));
 	add_item(new ADriverItem(this, AUDIO_IEC61883_TITLE, AUDIO_IEC61883));
 #endif
+
+#ifdef HAVE_DVB
 	if(do_input) add_item(new ADriverItem(this, AUDIO_DVB_TITLE, AUDIO_DVB));
+#endif
+
+#ifdef HAVE_VIDEO4LINUX2
 	if(do_input) add_item(new ADriverItem(this, AUDIO_V4L2MPEG_TITLE, AUDIO_V4L2MPEG));
+#endif
 }
 
 char* ADriverMenu::adriver_to_string(int driver)
diff --git a/cinelerra-5.1/cinelerra/audioesound.C b/cinelerra-5.1/cinelerra/audioesound.C
index f5a9dd0d..b5f0ecd5 100644
--- a/cinelerra-5.1/cinelerra/audioesound.C
+++ b/cinelerra-5.1/cinelerra/audioesound.C
@@ -152,7 +152,7 @@ int AudioESound::read_buffer(char *buffer, int size)
 
 int AudioESound::write_buffer(char *buffer, int size)
 {
-	return esd_out_fd>0 ? write(esd_out_fd, buffer, size) : 0;
+	return esd_out_fd>0 && write(esd_out_fd, buffer, size) > 0 ? 0 : -1;
 }
 
 // No flushing in ESD
diff --git a/cinelerra-5.1/cinelerra/overlayframe.h b/cinelerra-5.1/cinelerra/overlayframe.h
index 730be374..620f8e18 100644
--- a/cinelerra-5.1/cinelerra/overlayframe.h
+++ b/cinelerra-5.1/cinelerra/overlayframe.h
@@ -151,7 +151,7 @@
 #define COLOR_SRC_OVER(mx, Sc, Sa, Dc, Da) (Sc + Dc * (mx - Sa) / mx)
 #define CHROMA_SRC_OVER COLOR_SRC_OVER
 
-// AND 	[Sa + Da - Sa * Da, Sc * Dc]
+// AND 	[Sa * Da, Sc * Dc]
 #define ALPHA_AND(mx, Sa, Da) ((Sa * Da) / mx)
 #define COLOR_AND(mx, Sc, Sa, Dc, Da) ((Sc * Dc) / mx)
 #define CHROMA_AND COLOR_AND
@@ -161,7 +161,7 @@
 #define COLOR_OR(mx, Sc, Sa, Dc, Da) (Sc + Dc - (Sc * Dc) / mx)
 #define CHROMA_OR COLOR_OR
 
-// XOR  	[Sa * (1 - Da) + Da * (1 - Sa), Sa + Da - 2 * Sa * Da]
+// XOR 	[Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + Dc * (1 - Sa)]
 #define ALPHA_XOR(mx, Sa, Da) (Sa + Da - (TWO * Sa * Da / mx))
 #define COLOR_XOR(mx, Sc, Sa, Dc, Da) ((Sc * (mx - Da) + Dc * (mx - Sa)) / mx)
 #define CHROMA_XOR COLOR_XOR
@@ -214,7 +214,7 @@
 #define CHROMA_SOFTLIGHT COLOR_SOFTLIGHT
 
 // DIFFERENCE [Sa + Da - Sa * Da,  Sc*(1 - Da) + Dc*(1 - Sa) +
-//  abs(Sc * Da - Sc * Sa)]
+//  abs(Sc * Da - Dc * Sa)]
 #define ALPHA_DIFFERENCE STD_ALPHA
 #define COLOR_DIFFERENCE(mx, Sc, Sa, Dc, Da) (STD_BLEND(mx,Sc,Sa,Dc,Da) + \
   (mabs(Sc * Da - Dc * Sa) / mx))
diff --git a/cinelerra-5.1/cinelerra/vdeviceprefs.C b/cinelerra-5.1/cinelerra/vdeviceprefs.C
index ac396dc0..a64ca40d 100644
--- a/cinelerra-5.1/cinelerra/vdeviceprefs.C
+++ b/cinelerra-5.1/cinelerra/vdeviceprefs.C
@@ -604,7 +604,9 @@ void VDriverMenu::create_objects()
 		add_item(new VDriverItem(this, CAPTURE_FIREWIRE_TITLE, CAPTURE_FIREWIRE));
 		add_item(new VDriverItem(this, CAPTURE_IEC61883_TITLE, CAPTURE_IEC61883));
 #endif
+#ifdef HAVE_DVB
 		add_item(new VDriverItem(this, CAPTURE_DVB_TITLE, CAPTURE_DVB));
+#endif
 	}
 	else
 	{
-- 
2.26.2