mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 06:51:54 +00:00
Merge branch '2.2.x' into master
This commit is contained in:
commit
3ac9b6fbf0
4 changed files with 64 additions and 82 deletions
|
@ -16,7 +16,7 @@ and a description.
|
|||
|
||||
- jack: JACK Audio Connection Kit (Linux, Mac OS X, Windows)
|
||||
- alsa: Advanced Linux Sound Architecture (Linux)
|
||||
- oss: Open Sound System (Linux, Unix)
|
||||
- oss: Open Sound System (primarily needed on BSD, rarely also Linux and Unix in general)
|
||||
- pulseaudio: PulseAudio (Linux, Mac OS X, Windows)
|
||||
- coreaudio: Apple CoreAudio (Mac OS X)
|
||||
- dsound: Microsoft DirectSound (Windows)
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
#include "fluid_adriver.h"
|
||||
#include "fluid_settings.h"
|
||||
|
||||
/*
|
||||
/*
|
||||
* !!! Make sure that no include above includes <netinet/tcp.h> !!!
|
||||
* It #defines some macros that collide with enum definitions of OpenTransportProviders.h, which is included from OSServices.h, included from CoreServices.h
|
||||
*
|
||||
*
|
||||
* https://trac.macports.org/ticket/36962
|
||||
*/
|
||||
|
||||
|
@ -73,6 +73,10 @@ OSStatus fluid_core_audio_callback(void *data,
|
|||
|
||||
#define OK(x) (x == noErr)
|
||||
|
||||
#if MAC_OS_X_VERSION < 1200
|
||||
#define kAudioObjectPropertyElementMain (kAudioObjectPropertyElementMaster)
|
||||
#endif
|
||||
|
||||
int
|
||||
get_num_outputs(AudioDeviceID deviceID)
|
||||
{
|
||||
|
@ -81,7 +85,7 @@ get_num_outputs(AudioDeviceID deviceID)
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioDevicePropertyStreamConfiguration;
|
||||
pa.mScope = kAudioDevicePropertyScopeOutput;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = kAudioObjectPropertyElementMain;
|
||||
|
||||
if(OK(AudioObjectGetPropertyDataSize(deviceID, &pa, 0, 0, &size)) && size > 0)
|
||||
{
|
||||
|
@ -118,7 +122,7 @@ fluid_core_audio_driver_settings(fluid_settings_t *settings)
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioHardwarePropertyDevices;
|
||||
pa.mScope = kAudioObjectPropertyScopeWildcard;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = kAudioObjectPropertyElementMain;
|
||||
|
||||
fluid_settings_register_str(settings, "audio.coreaudio.device", "default", 0);
|
||||
fluid_settings_add_option(settings, "audio.coreaudio.device", "default");
|
||||
|
@ -172,6 +176,14 @@ new_fluid_core_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func
|
|||
OSStatus status;
|
||||
UInt32 size;
|
||||
int i;
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
ComponentDescription desc;
|
||||
Component comp;
|
||||
#else
|
||||
AudioComponentDescription desc;
|
||||
AudioComponent comp;
|
||||
#endif
|
||||
AURenderCallbackStruct render;
|
||||
|
||||
dev = FLUID_NEW(fluid_core_audio_driver_t);
|
||||
|
||||
|
@ -187,11 +199,6 @@ new_fluid_core_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func
|
|||
dev->data = data;
|
||||
|
||||
// Open the default output unit
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
ComponentDescription desc;
|
||||
#else
|
||||
AudioComponentDescription desc;
|
||||
#endif
|
||||
desc.componentType = kAudioUnitType_Output;
|
||||
desc.componentSubType = kAudioUnitSubType_HALOutput; //kAudioUnitSubType_DefaultOutput;
|
||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||
|
@ -199,9 +206,9 @@ new_fluid_core_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func
|
|||
desc.componentFlagsMask = 0;
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
Component comp = FindNextComponent(NULL, &desc);
|
||||
comp = FindNextComponent(NULL, &desc);
|
||||
#else
|
||||
AudioComponent comp = AudioComponentFindNext(NULL, &desc);
|
||||
comp = AudioComponentFindNext(NULL, &desc);
|
||||
#endif
|
||||
|
||||
if(comp == NULL)
|
||||
|
@ -223,7 +230,6 @@ new_fluid_core_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func
|
|||
}
|
||||
|
||||
// Set up a callback function to generate output
|
||||
AURenderCallbackStruct render;
|
||||
render.inputProc = fluid_core_audio_callback;
|
||||
render.inputProcRefCon = (void *) dev;
|
||||
status = AudioUnitSetProperty(dev->outputUnit,
|
||||
|
@ -250,7 +256,7 @@ new_fluid_core_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioHardwarePropertyDevices;
|
||||
pa.mScope = kAudioObjectPropertyScopeWildcard;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = kAudioObjectPropertyElementMain;
|
||||
|
||||
if(OK(AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &pa, 0, 0, &size)))
|
||||
{
|
||||
|
@ -342,7 +348,7 @@ new_fluid_core_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func
|
|||
|
||||
dev->buffers[0] = FLUID_ARRAY(float, dev->buffer_size);
|
||||
dev->buffers[1] = FLUID_ARRAY(float, dev->buffer_size);
|
||||
|
||||
|
||||
if(dev->buffers[0] == NULL || dev->buffers[1] == NULL)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Out of memory.");
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
/* End work around */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <os/log.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <CoreMIDI/MIDIServices.h>
|
||||
|
||||
|
@ -62,6 +63,10 @@ typedef struct
|
|||
int autoconn_inputs;
|
||||
} fluid_coremidi_driver_t;
|
||||
|
||||
static const MIDIClientRef invalid_client = (MIDIClientRef)-1;
|
||||
static const MIDIEndpointRef invalid_endpoint = (MIDIEndpointRef)-1;
|
||||
static const MIDIPortRef invalid_port = (MIDIPortRef)-1;
|
||||
|
||||
void fluid_coremidi_callback(const MIDIPacketList *list, void *p, void *src);
|
||||
|
||||
void fluid_coremidi_driver_settings(fluid_settings_t *settings)
|
||||
|
@ -108,6 +113,8 @@ new_fluid_coremidi_driver(fluid_settings_t *settings, handle_midi_event_func_t h
|
|||
char *id;
|
||||
CFStringRef str_portname;
|
||||
CFStringRef str_clientname;
|
||||
OSStatus result;
|
||||
CFStringRef str_input_portname;
|
||||
|
||||
/* not much use doing anything */
|
||||
if(handler == NULL)
|
||||
|
@ -124,9 +131,10 @@ new_fluid_coremidi_driver(fluid_settings_t *settings, handle_midi_event_func_t h
|
|||
return NULL;
|
||||
}
|
||||
|
||||
dev->client = 0;
|
||||
dev->endpoint = 0;
|
||||
dev->parser = 0;
|
||||
dev->client = invalid_client;
|
||||
dev->endpoint = invalid_endpoint;
|
||||
dev->input_port = invalid_port;
|
||||
dev->parser = NULL;
|
||||
dev->driver.handler = handler;
|
||||
dev->driver.data = data;
|
||||
|
||||
|
@ -173,7 +181,7 @@ new_fluid_coremidi_driver(fluid_settings_t *settings, handle_midi_event_func_t h
|
|||
FLUID_FREE(portname); /* -- free port name */
|
||||
}
|
||||
|
||||
OSStatus result = MIDIClientCreate(str_clientname, NULL, NULL, &client);
|
||||
result = MIDIClientCreate(str_clientname, NULL, NULL, &client);
|
||||
CFRelease(str_clientname);
|
||||
|
||||
if(result != noErr)
|
||||
|
@ -194,7 +202,7 @@ new_fluid_coremidi_driver(fluid_settings_t *settings, handle_midi_event_func_t h
|
|||
goto error_recovery;
|
||||
}
|
||||
|
||||
CFStringRef str_input_portname = CFSTR("input");
|
||||
str_input_portname = CFSTR("input");
|
||||
result = MIDIInputPortCreate(client, str_input_portname,
|
||||
fluid_coremidi_callback,
|
||||
(void *)dev, &dev->input_port);
|
||||
|
@ -231,17 +239,17 @@ delete_fluid_coremidi_driver(fluid_midi_driver_t *p)
|
|||
fluid_coremidi_driver_t *dev = (fluid_coremidi_driver_t *) p;
|
||||
fluid_return_if_fail(dev != NULL);
|
||||
|
||||
if(dev->input_port != NULL)
|
||||
if(dev->input_port != invalid_port)
|
||||
{
|
||||
MIDIPortDispose(dev->input_port);
|
||||
}
|
||||
|
||||
if(dev->client != NULL)
|
||||
if(dev->client != invalid_client)
|
||||
{
|
||||
MIDIClientDispose(dev->client);
|
||||
}
|
||||
|
||||
if(dev->endpoint != NULL)
|
||||
if(dev->endpoint != invalid_endpoint)
|
||||
{
|
||||
MIDIEndpointDispose(dev->endpoint);
|
||||
}
|
||||
|
|
|
@ -123,17 +123,6 @@ new_fluid_oss_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
char *devname = NULL;
|
||||
int format;
|
||||
|
||||
FLUID_LOG(FLUID_WARN,
|
||||
"\n\n"
|
||||
"================= OSS audio driver has been deprecated! ==================\n"
|
||||
"You're using the OSS driver. This driver is old, unmaintained and believed\n"
|
||||
"to be unused. If you still need it, pls. let us know by posting to our\n"
|
||||
"mailing list at fluid-dev@nongnu.org - otherwise this driver might be removed\n"
|
||||
"in a future release of FluidSynth!\n"
|
||||
"================= OSS audio driver has been deprecated! ==================\n"
|
||||
"\n"
|
||||
);
|
||||
|
||||
dev = FLUID_NEW(fluid_oss_audio_driver_t);
|
||||
|
||||
if(dev == NULL)
|
||||
|
@ -198,9 +187,18 @@ new_fluid_oss_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
}
|
||||
}
|
||||
|
||||
if(stat(devname, &devstat) == -1)
|
||||
dev->dspfd = open(devname, O_WRONLY, 0);
|
||||
|
||||
if(dev->dspfd == -1)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Device <%s> does not exists", devname);
|
||||
FLUID_LOG(FLUID_ERR, "Device <%s> could not be opened for writing: %s",
|
||||
devname, g_strerror(errno));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
if(fstat(dev->dspfd, &devstat) == -1)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "fstat failed on device <%s>: %s", devname, g_strerror(errno));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
@ -210,15 +208,6 @@ new_fluid_oss_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
|
|||
goto error_recovery;
|
||||
}
|
||||
|
||||
dev->dspfd = open(devname, O_WRONLY, 0);
|
||||
|
||||
if(dev->dspfd == -1)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Device <%s> could not be opened for writing: %s",
|
||||
devname, strerror(errno));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
if(fluid_oss_set_queue_size(dev, sample_size, 2, queuesize, period_size) < 0)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Can't set device buffer size");
|
||||
|
@ -307,17 +296,6 @@ new_fluid_oss_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func,
|
|||
int realtime_prio = 0;
|
||||
int format;
|
||||
|
||||
FLUID_LOG(FLUID_WARN,
|
||||
"\n\n"
|
||||
"================= OSS audio driver has been deprecated! ==================\n"
|
||||
"You're using the OSS driver. This driver is old, unmaintained and believed\n"
|
||||
"to be unused. If you still need it, pls. let us know by posting to our\n"
|
||||
"mailing list at fluid-dev@nongnu.org - otherwise this driver might be removed\n"
|
||||
"in a future release of FluidSynth!\n"
|
||||
"================= OSS audio driver has been deprecated! ==================\n"
|
||||
"\n"
|
||||
);
|
||||
|
||||
dev = FLUID_NEW(fluid_oss_audio_driver_t);
|
||||
|
||||
if(dev == NULL)
|
||||
|
@ -355,9 +333,18 @@ new_fluid_oss_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func,
|
|||
}
|
||||
}
|
||||
|
||||
if(stat(devname, &devstat) == -1)
|
||||
dev->dspfd = open(devname, O_WRONLY, 0);
|
||||
|
||||
if(dev->dspfd == -1)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Device <%s> does not exists", devname);
|
||||
FLUID_LOG(FLUID_ERR, "Device <%s> could not be opened for writing: %s",
|
||||
devname, g_strerror(errno));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
if(fstat(dev->dspfd, &devstat) == -1)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "fstat failed on device <%s>: %s", devname, g_strerror(errno));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
@ -367,16 +354,6 @@ new_fluid_oss_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func,
|
|||
goto error_recovery;
|
||||
}
|
||||
|
||||
dev->dspfd = open(devname, O_WRONLY, 0);
|
||||
|
||||
if(dev->dspfd == -1)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Device <%s> could not be opened for writing: %s",
|
||||
devname, strerror(errno));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
||||
if(fluid_oss_set_queue_size(dev, 16, 2, queuesize, period_size) < 0)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Can't set device buffer size");
|
||||
|
@ -426,7 +403,7 @@ new_fluid_oss_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func,
|
|||
goto error_recovery;
|
||||
}
|
||||
|
||||
/* allocate the buffers. FIXME!!! don't use interleaved samples */
|
||||
/* allocate the buffers. */
|
||||
dev->buffer = FLUID_MALLOC(dev->buffer_byte_size);
|
||||
dev->buffers[0] = FLUID_ARRAY(float, dev->buffer_size);
|
||||
dev->buffers[1] = FLUID_ARRAY(float, dev->buffer_size);
|
||||
|
@ -486,6 +463,8 @@ delete_fluid_oss_audio_driver(fluid_audio_driver_t *p)
|
|||
}
|
||||
|
||||
FLUID_FREE(dev->buffer);
|
||||
FLUID_FREE(dev->buffers[0]);
|
||||
FLUID_FREE(dev->buffers[1]);
|
||||
FLUID_FREE(dev);
|
||||
}
|
||||
|
||||
|
@ -629,17 +608,6 @@ new_fluid_oss_midi_driver(fluid_settings_t *settings,
|
|||
int realtime_prio = 0;
|
||||
char *device = NULL;
|
||||
|
||||
FLUID_LOG(FLUID_WARN,
|
||||
"\n\n"
|
||||
"================= OSS MIDI driver has been deprecated! ==================\n"
|
||||
"You're using the OSS driver. This driver is old, unmaintained and believed\n"
|
||||
"to be unused. If you still need it, pls. let us know by posting to our\n"
|
||||
"mailing list at fluid-dev@nongnu.org - otherwise this driver might be removed\n"
|
||||
"in a future release of FluidSynth!\n"
|
||||
"================= OSS MIDI driver has been deprecated! ==================\n"
|
||||
"\n"
|
||||
);
|
||||
|
||||
/* not much use doing anything */
|
||||
if(handler == NULL)
|
||||
{
|
||||
|
@ -699,7 +667,7 @@ new_fluid_oss_midi_driver(fluid_settings_t *settings,
|
|||
if(fcntl(dev->fd, F_SETFL, O_NONBLOCK) == -1)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Failed to set OSS MIDI device to non-blocking: %s",
|
||||
strerror(errno));
|
||||
g_strerror(errno));
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
|
@ -788,7 +756,7 @@ fluid_oss_midi_run(void *d)
|
|||
|
||||
if(n < 0)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Error waiting for MIDI input: %s", strerror(errno));
|
||||
FLUID_LOG(FLUID_ERR, "Error waiting for MIDI input: %s", g_strerror(errno));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue