diff -Nurd -x'*~' esound-0.2.36.orig/Makefile.in esound-0.2.36/Makefile.in --- esound-0.2.36.orig/Makefile.in 2005-06-06 21:04:14.000000000 -0400 +++ esound-0.2.36/Makefile.in 2005-09-30 18:29:03.000000000 -0400 @@ -422,7 +421,7 @@ esdplay.c LDADD = libesd.la $(AUDIOFILE_LIBS) -esd_LDADD = $(WRAP_LIB) $(LDADD) +esd_LDADD = $(WRAP_LIB) $(LDADD) $(SOUND_LIBS) m4datadir = $(datadir)/aclocal m4data_DATA = esd.m4 esdconfdir = $(sysconfdir) diff -Nurd -x'*~' esound-0.2.36.orig/esd.c esound-0.2.36/esd.c --- esound-0.2.36.orig/esd.c 2005-05-25 21:02:52.000000000 -0400 +++ esound-0.2.36/esd.c 2005-09-30 18:27:06.000000000 -0400 @@ -35,6 +35,13 @@ /* max arguments (argc + tokenized esd.conf) can't be more than this */ #define MAX_OPTS 128 +#if defined (__APPLE__) +#include +#include +#include +#include +#endif + typedef const char *(*audio_devices_t)(void); typedef int (*audio_open_t)(void); typedef void (*audio_close_t)(void); @@ -641,6 +648,29 @@ int default_format = ESD_BITS16 | ESD_STEREO; /* end test scaffolding parameters */ +#if defined (__APPLE__) + /* get realtime priority */ + { + struct thread_time_constraint_policy ttcpolicy; + int bus_speed, mib [2] = { CTL_HW, HW_BUS_FREQ }; + size_t len; + + len = sizeof (bus_speed); + sysctl (mib, 2, &bus_speed, &len, NULL, 0); + + /* Is it enough? */ + ttcpolicy.period = bus_speed / 120; + ttcpolicy.computation = bus_speed / 2400; + ttcpolicy.constraint = bus_speed / 1200; + ttcpolicy.preemptible = 1; + + thread_policy_set (mach_thread_self (), + THREAD_TIME_CONSTRAINT_POLICY, + (int*)&ttcpolicy, + THREAD_TIME_CONSTRAINT_POLICY_COUNT); + } +#endif + programname = *argv; #ifdef DRIVER_ARTS diff -Nurd -x'*~' esound-0.2.36.orig/esd.conf esound-0.2.36/esd.conf --- esound-0.2.36.orig/esd.conf 2004-08-18 15:01:41.000000000 -0400 +++ esound-0.2.36/esd.conf 2005-09-30 18:27:06.000000000 -0400 @@ -1,6 +1,6 @@ [esd] auto_spawn=1 spawn_options=-terminate -nobeeps -as 2 -spawn_wait_ms=100 +spawn_wait_ms=999 # default options are used in spawned and non-spawned mode default_options= diff -Nurd -x'*~' esound-0.2.36.orig/esd_config.c esound-0.2.36/esd_config.c --- esound-0.2.36.orig/esd_config.c 2005-05-25 19:50:41.000000000 -0400 +++ esound-0.2.36/esd_config.c 2005-09-30 18:27:06.000000000 -0400 @@ -9,7 +9,7 @@ int esd_no_spawn=1; /* If we can't even find the system config file, things are screwed up - don't try to make things worse. */ -int esd_spawn_wait_ms=100; /* Time to wait trying to connect to an +int esd_spawn_wait_ms=999; /* Time to wait trying to connect to an autospawned ESD, in milliseconds. */ char esd_spawn_options[LINEBUF_SIZE] = "-terminate -nobeeps -as 2"; diff -urN esound-0.2.36.orig/audio_coreaudio.c esound-0.2.36/audio_coreaudio.c --- esound-0.2.36.orig/audio_coreaudio.c 2003-06-18 08:12:23.000000000 -0400 +++ esound-0.2.36/audio_coreaudio.c 2007-09-07 18:53:46.000000000 -0400 @@ -90,7 +90,7 @@ #define ARCH_esd_audio_devices const char *esd_audio_devices() { - return "coreaudio API only"; + return "Built-in Output, Built-in Input, etc."; } /* @@ -116,18 +116,158 @@ return (0); } - /********************** playback section ***************************/ - /* get default output device */ - propertySize = sizeof(gOutputDeviceID); - status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, - &propertySize, - &gOutputDeviceID); - if (status) { - fprintf(stderr, "get default output device failed, status = %d\n", - (int)status); - return (-2); + if (esd_audio_device) { + /* search for DeviceID of specified device */ + UInt32 outSize; + UInt32 devIndex, numDevs; + UInt32 buffIndex, numChannels; + AudioDeviceID dev, *devList = NULL; + AudioBufferList *buffList = NULL; + + outSize = 0; + status = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, + &outSize, + NULL); + if (status || outSize == 0) { + fprintf(stderr, "get device list info failed, status = %d\n", + (int)status); + return (-2); + } + + numDevs = outSize/sizeof(AudioDeviceID); + + /* allocate and get the device list */ + devList = (AudioDeviceID*)malloc(outSize); + if (!devList) { + fprintf(stderr, "memory allocation failed\n"); + return (-2); + } + status = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, + &outSize, + devList); + if (status) { + fprintf(stderr, "get device list failed, status = %d\n", + (int)status); + if (devList) free(devList); + return (-2); + } + + /* iterate through device list */ + for (devIndex = 0; devIndex < numDevs; ++devIndex) { + outSize = LEN_DEVICE_NAME; + status = AudioDeviceGetProperty(devList[devIndex], + 0, + 0, + kAudioDevicePropertyDeviceName, + &outSize, + deviceName); + if (status) { + fprintf(stderr, "get device name failed, status = %d\n", + (int)status); + if (devList) free(devList); + return (-2); + } + + /* is this the specified device? */ + if (strncmp(deviceName, esd_audio_device, strlen(esd_audio_device)) == 0) { + /* device found, now probe for num inputs/outputs */ + dev = devList[devIndex]; + + /* get number of input channels */ + outSize = 0; + numChannels = 0; + status = AudioDeviceGetPropertyInfo(dev, + 0, + 1, + kAudioDevicePropertyStreamConfiguration, + &outSize, + NULL); + if(!status && (outSize != 0)) { + buffList = (AudioBufferList*)malloc(outSize); + if (!buffList) { + fprintf(stderr, "memory allocation failed\n");; + return (-2); + } + /* get the input stream configuration */ + status = AudioDeviceGetProperty(dev, + 0, + 1, + kAudioDevicePropertyStreamConfiguration, + &outSize, + buffList); + if(!status) { + /* count the total number of input channels in the stream */ + for(buffIndex = 0; buffIndex < buffList->mNumberBuffers; ++buffIndex) + numChannels += buffList->mBuffers[buffIndex].mNumberChannels; + } + } + + /* set input device */ + if (numChannels == 0) + gInputDeviceID = kAudioDeviceUnknown; + else + gInputDeviceID = dev; + + + /* get number of output channels */ + outSize = 0; + numChannels = 0; + status = AudioDeviceGetPropertyInfo(dev, + 0, + 0, + kAudioDevicePropertyStreamConfiguration, + &outSize, + NULL); + if(!status && (outSize != 0)) { + buffList = (AudioBufferList*)malloc(outSize); + if (!buffList) { + fprintf(stderr, "memory allocation failed\n"); + return (-2); + } + /* get the input stream configuration */ + status = AudioDeviceGetProperty(dev, + 0, + 0, + kAudioDevicePropertyStreamConfiguration, + &outSize, + buffList); + if(!status) { + // count the total number of input channels in the stream + for(buffIndex = 0; buffIndex < buffList->mNumberBuffers; ++buffIndex) + numChannels += buffList->mBuffers[buffIndex].mNumberChannels; + } + } + + if (numChannels == 0) + gOutputDeviceID = kAudioDeviceUnknown; + else + gOutputDeviceID = dev; + + /* found specified device so break */ + break; + } + } + if (devList) free(devList); + if (devIndex >= numDevs) { + fprintf(stderr, "device not found\n"); + return (-2); + } } + /********************** playback section ***************************/ + if (gOutputDeviceID == kAudioDeviceUnknown) { + /* get default output device */ + propertySize = sizeof(gOutputDeviceID); + status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, + &propertySize, + &gOutputDeviceID); + if (status) { + fprintf(stderr, "get default output device failed, status = %d\n", + (int)status); + return (-2); + } + } + if (gOutputDeviceID != kAudioDeviceUnknown) { /* got default output device */ coreaudio_has_output_device = 1; @@ -206,15 +346,17 @@ } /********************** record section ***************************/ - /* get default input device */ - propertySize = sizeof(gInputDeviceID); - status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, - &propertySize, - &gInputDeviceID); - if (status) { - fprintf(stderr, "get default input device failed, status = %d\n", - (int)status); - return (-2); + if (gInputDeviceID == kAudioDeviceUnknown) { + /* get default input device */ + propertySize = sizeof(gInputDeviceID); + status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, + &propertySize, + &gInputDeviceID); + if (status) { + fprintf(stderr, "get default input device failed, status = %d\n", + (int)status); + return (-2); + } } if (gInputDeviceID != kAudioDeviceUnknown) { diff -Naur esound-0.2.38.orig/esdlib.c esound-0.2.38/esdlib.c --- esound-0.2.38.orig/esdlib.c 2007-04-19 14:43:59.000000000 +0000 +++ esound-0.2.38/esdlib.c 2010-01-27 17:02:20.000000000 +0000 @@ -708,7 +708,7 @@ if ( !host ) host = getenv("ESPEAKER"); display = getenv( "DISPLAY" ); - if ( !(host && *host) && display ) { + if ( !(host && *host) && display /* Fink: launchd socket */ && display[0] != '/') { /* no espeaker specified, but the app should be directed to a remote display, so try routing the default port over there and see if we strike gold */