--- snd-22.3/audio.c	2021-10-05 21:24:38.000000000 +0200
+++ snd-22.4/audio.c	2022-05-24 15:06:03.000000000 +0200
@@ -21,7 +21,7 @@
  *    HPUX
  *    OpenBSD
  *    NetBSD
- *    PulseAudio (in progress?)
+ *    PulseAudio
  *    PortAudio
  */
 
@@ -3164,6 +3164,9 @@
 #if HAVE_OSX_10_5
   static AudioDeviceIOProcID read_procId, write_procId;
 #endif 
+#if (!defined(MAC_OS_VERSION_12_0)) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
+  #define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
+#endif
 
 int mus_audio_close(int line) 
 {
@@ -3206,7 +3209,7 @@
 	      {
 		AudioObjectPropertyAddress device_address = { kAudioDevicePropertyDeviceIsRunning,
 							      kAudioDevicePropertyScopeOutput,
-							      kAudioObjectPropertyElementMaster };
+							      kAudioObjectPropertyElementMain};
 		err = AudioObjectGetPropertyData(device, &device_address, 0, NULL, &sizeof_running, &running);
 	      }	      
 	    }
@@ -3216,7 +3219,7 @@
 	      {
 		AudioObjectPropertyAddress device_address = { kAudioDevicePropertyDeviceIsRunning,
 							      kAudioDevicePropertyScopeOutput,
-							      kAudioObjectPropertyElementMaster };
+							      kAudioObjectPropertyElementMain};
 		err = AudioObjectGetPropertyData(device, &device_address, 0, NULL, &sizeof_running, &running);
 	      }
 	    }
@@ -3274,7 +3277,7 @@
   {
     AudioObjectPropertyAddress device_address = { kAudioHardwarePropertyDefaultOutputDevice,
 						  kAudioObjectPropertyScopeGlobal,
-						  kAudioObjectPropertyElementMaster };
+						  kAudioObjectPropertyElementMain};
     err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &device_address, 0, NULL, &sizeof_device, &device);
   }
 
@@ -3285,7 +3288,7 @@
       {
 	AudioObjectPropertyAddress device_address = { kAudioDevicePropertyBufferSize,
 						      kAudioDevicePropertyScopeOutput,
-						      kAudioObjectPropertyElementMaster };
+						      kAudioObjectPropertyElementMain};
 	err = AudioObjectGetPropertyData(device, &device_address, 0, NULL, &sizeof_bufsize, &bufsize);
       }
     }
@@ -3300,7 +3303,7 @@
   {
     AudioObjectPropertyAddress device_address = { kAudioDevicePropertyStreamFormat,
 						  kAudioDevicePropertyScopeOutput,
-						  kAudioObjectPropertyElementMaster };
+						  kAudioObjectPropertyElementMain};
     err = AudioObjectGetPropertyData(device, &device_address, 0, NULL, &sizeof_format, &device_desc);
   }
 
@@ -3330,7 +3333,7 @@
 	  {
 	    AudioObjectPropertyAddress device_address = { kAudioDevicePropertyStreamFormat,
 							  kAudioDevicePropertyScopeOutput,
-							  kAudioObjectPropertyElementMaster };
+							  kAudioObjectPropertyElementMain};
 	    err = AudioObjectSetPropertyData(device, &device_address, 0, NULL, sizeof_format, &device_desc);
 	  }
 	  
@@ -3355,7 +3358,7 @@
 	      {
 		AudioObjectPropertyAddress device_address = { kAudioDevicePropertyStreamFormat,
 							      kAudioDevicePropertyScopeOutput,
-							      kAudioObjectPropertyElementMaster };
+							      kAudioObjectPropertyElementMain};
 		err = AudioObjectSetPropertyData(device, &device_address, 0, NULL, sizeof_format, &device_desc);
 	      }
 	      if (err != noErr)
@@ -3365,7 +3368,7 @@
 		  {
 		    AudioObjectPropertyAddress device_address = { kAudioDevicePropertyStreamFormatMatch,
 								  kAudioDevicePropertyScopeOutput,
-								  kAudioObjectPropertyElementMaster };
+								  kAudioObjectPropertyElementMain};
 		    err = AudioObjectGetPropertyData(device, &device_address, 0, NULL, &sizeof_format, &device_desc);
 		  }
 
@@ -3380,7 +3383,7 @@
 		      {
 			AudioObjectPropertyAddress device_address = { kAudioDevicePropertyStreamFormat,
 								      kAudioDevicePropertyScopeOutput,
-								      kAudioObjectPropertyElementMaster };
+								      kAudioObjectPropertyElementMain};
 			err = AudioObjectSetPropertyData(device, &device_address, 0, NULL, sizeof_format, &device_desc);
 		      }
 		      if (err != noErr) 
@@ -3391,7 +3394,7 @@
 			  {
 			    AudioObjectPropertyAddress device_address = { kAudioDevicePropertyStreamFormat,
 									  kAudioDevicePropertyScopeOutput,
-									  kAudioObjectPropertyElementMaster };
+									  kAudioObjectPropertyElementMain};
 			    err = AudioObjectGetPropertyData(device, &device_address, 0, NULL, &sizeof_format, &device_desc);
 			  }
 			}
@@ -3405,7 +3408,7 @@
 		  {
 		    AudioObjectPropertyAddress device_address = { kAudioDevicePropertyStreamFormat,
 								  kAudioDevicePropertyScopeOutput,
-								  kAudioObjectPropertyElementMaster };
+								  kAudioObjectPropertyElementMain};
 		    err = AudioObjectGetPropertyData(device, &device_address, 0, NULL, &sizeof_format, &device_desc);
 		  }
 		}
@@ -3625,7 +3628,7 @@
 	  {
 	    AudioObjectPropertyAddress device_address = { kAudioDevicePropertyDeviceIsRunning,
 							  kAudioDevicePropertyScopeOutput,
-							  kAudioObjectPropertyElementMaster };
+							  kAudioObjectPropertyElementMain};
 	    err = AudioObjectGetPropertyData(device, &device_address, 0, NULL, &sizeof_running, &running);
 	  }
 	  /* usleep(10); */
@@ -3658,7 +3661,7 @@
   {
     AudioObjectPropertyAddress device_address = { kAudioHardwarePropertyDefaultInputDevice,
 						  kAudioObjectPropertyScopeGlobal,
-						  kAudioObjectPropertyElementMaster };
+						  kAudioObjectPropertyElementMain};
     err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &device_address, 0, NULL, &sizeof_device, &device);
   }
 
@@ -3669,7 +3672,7 @@
       {
 	AudioObjectPropertyAddress device_address = { kAudioDevicePropertyBufferSize,
 						      kAudioDevicePropertyScopeInput,
-						      kAudioObjectPropertyElementMaster };
+						      kAudioObjectPropertyElementMain};
 	err = AudioObjectGetPropertyData(device, &device_address, 0, NULL, &sizeof_bufsize, &bufsize);
       }
     }
@@ -3733,7 +3736,7 @@
 	  {
 	    AudioObjectPropertyAddress device_address = { kAudioDevicePropertyDeviceIsRunning,
 							  kAudioDevicePropertyScopeInput,
-							  kAudioObjectPropertyElementMaster };
+							  kAudioObjectPropertyElementMain};
 	    err = AudioObjectGetPropertyData(device, &device_address, 0, NULL, &sizeof_running, &running);
 	  }
 	  if (err != noErr) 
@@ -5175,12 +5178,6 @@
 #define AUDIO_OK 1
 
 
-/* this code compiles/loads, but I don't know if it works -- paplay itself
- *   doesn't work on my machine due to either a libtool/dlopen mismatch
- *   or some problem with "pulse-rt".
- */
-
-
 #include <pulse/simple.h>
 #include <pulse/error.h>
 #include <pulse/gccmacro.h>
@@ -5205,7 +5202,23 @@
       return(0);
       break;
     }
-} 
+}
+
+
+static int pulseaudio_sample_types(int ur_dev, mus_sample_t *vals)
+{
+  vals[0] = (mus_sample_t)9;
+  vals[1] = MUS_BSHORT;
+  vals[2] = MUS_LSHORT;
+  vals[3] = MUS_BFLOAT;
+  vals[4] = MUS_LFLOAT;
+  vals[5] = MUS_ALAW;
+  vals[6] = MUS_MULAW;
+  vals[7] = MUS_BINT;
+  vals[8] = MUS_LINT;
+  vals[9] = MUS_BYTE;
+  return(MUS_NO_ERROR);
+}
 
 
 static pa_simple *pa_out = NULL, *pa_in = NULL;
@@ -5671,6 +5684,11 @@
 #endif
 #endif
 
+#if defined(MUS_PULSEAUDIO)
+  if (mixer_vals[0] == MUS_UNKNOWN_SAMPLE)
+    pulseaudio_sample_types(dev, mixer_vals);
+#endif
+
   samp_type = look_for_sample_type(mixer_vals, MUS_AUDIO_COMPATIBLE_SAMPLE_TYPE);
   if (samp_type != MUS_UNKNOWN_SAMPLE)
     return(samp_type);
@@ -5682,7 +5700,10 @@
       samp_type = look_for_sample_type(mixer_vals, MUS_LSHORT);
       if (samp_type == MUS_UNKNOWN_SAMPLE)
 	samp_type = mixer_vals[1];
+      if (samp_type == MUS_UNKNOWN_SAMPLE) 
+	samp_type = MUS_LSHORT; /* jgm */
     }
+  
 #else
   samp_type = look_for_sample_type(mixer_vals, MUS_BFLOAT);
   if (samp_type == MUS_UNKNOWN_SAMPLE)
@@ -5690,6 +5711,8 @@
       samp_type = look_for_sample_type(mixer_vals, MUS_BSHORT);
       if (samp_type == MUS_UNKNOWN_SAMPLE)
 	samp_type = mixer_vals[1];
+      if (samp_type == MUS_UNKNOWN_SAMPLE) 
+	samp_type = MUS_BSHORT; /* jgm */
     }
 #endif
   return(samp_type);
