Browse Source

Carla: RtAudio fixes

tags/v0.9.0
falkTX 13 years ago
parent
commit
9eeffd1b76
5 changed files with 57 additions and 39 deletions
  1. +5
    -2
      src/carla-backend/Makefile
  2. +7
    -3
      src/carla-backend/Makefile.dbg
  3. +22
    -5
      src/carla-backend/carla_backend_standalone.cpp
  4. +23
    -23
      src/carla-backend/rtaudio-4.0.11/RtAudio.cpp
  5. +0
    -6
      src/carla-includes/carla_lv2_includes.h

+ 5
- 2
src/carla-backend/Makefile View File

@@ -39,7 +39,7 @@ endif

ifeq ($(HAVE_PULSEAUDIO),true)
WANT_RTAUDIO = true
CARLA_CXX_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSEAUDIO__
CARLA_CXX_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
CARLA_LD_FLAGS += $(shell pkg-config --libs libpulse-simple)
endif

@@ -92,5 +92,8 @@ carla_backend.so: $(OBJS)
.cpp.o:
$(CXX) -c $< $(CARLA_CXX_FLAGS) -o $@

../carla-lilv/carla_lilv.a:
$(MAKE) -C ../carla-lilv

clean:
rm -f *.o lv2-rtmempool/*.o *.so *.dll
rm -f *.o lv2-rtmempool/*.o rtaudio-4.0.11/*.o rtmidi-2.0.0/*.o *.so *.dll

+ 7
- 3
src/carla-backend/Makefile.dbg View File

@@ -39,7 +39,7 @@ endif

ifeq ($(HAVE_PULSEAUDIO),true)
WANT_RTAUDIO = true
CARLA_CXX_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSEAUDIO__
CARLA_CXX_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
CARLA_LD_FLAGS += $(shell pkg-config --libs libpulse-simple)
endif

@@ -72,7 +72,8 @@ OBJS = \
../carla-lilv/carla_lilv.a

ifeq ($(WANT_RTAUDIO),true)
CARLA_CXX_FLAGS += -Irtaudio-4.0.11 -Irtmidi-4.0.11 -DCARLA_ENGINE_RTAUDIO -DHAVE_GETTIMEOFDAY
CARLA_CXX_FLAGS += -Irtaudio-4.0.11 -Irtmidi-4.0.11 -DCARLA_ENGINE_RTAUDIO -DHAVE_GETTIMEOFDAY
CARLA_CXX_FLAGS += -D__RTAUDIO_DEBUG__ -D__RTMIDI_DEBUG__
OBJS += rtaudio-4.0.11/RtAudio.o
OBJS += rtmidi-2.0.0/RtMidi.o
endif
@@ -92,5 +93,8 @@ carla_backend.so: $(OBJS)
.cpp.o:
$(CXX) -c $< $(CARLA_CXX_FLAGS) -o $@

../carla-lilv/carla_lilv.a:
$(MAKE) -C ../carla-lilv

clean:
rm -f *.o lv2-rtmempool/*.o *.so *.dll
rm -f *.o lv2-rtmempool/*.o rtaudio-4.0.11/*.o rtmidi-2.0.0/*.o *.so *.dll

+ 22
- 5
src/carla-backend/carla_backend_standalone.cpp View File

@@ -95,23 +95,40 @@ bool engine_init(const char* driver_name, const char* client_name)
if (strcmp(driver_name, "JACK") == 0)
carla_engine = new CarlaBackend::CarlaEngineJack;
#endif

#ifdef CARLA_ENGINE_RTAUDIO
#ifdef __LINUX_ALSA__
if (strcmp(driver_name, "ALSA") == 0)
carla_engine = new CarlaBackend::CarlaEngineRtAudio(RtAudio::LINUX_ALSA);
else if (strcmp(driver_name, "PulseAudio") == 0)
#endif
#ifdef __LINUX_PULSE__
if (strcmp(driver_name, "PulseAudio") == 0)
carla_engine = new CarlaBackend::CarlaEngineRtAudio(RtAudio::LINUX_PULSE);
else if (strcmp(driver_name, "OSS") == 0)
#endif
#ifdef __LINUX_OSS__
if (strcmp(driver_name, "OSS") == 0)
carla_engine = new CarlaBackend::CarlaEngineRtAudio(RtAudio::LINUX_OSS);
else if (strcmp(driver_name, "JACK (RtAudio)") == 0)
#endif
#ifdef __UNIX_JACK__
if (strcmp(driver_name, "JACK (RtAudio)") == 0)
carla_engine = new CarlaBackend::CarlaEngineRtAudio(RtAudio::UNIX_JACK);
else if (strcmp(driver_name, "CoreAudio") == 0)
#endif
#ifdef __MACOSX_CORE__
if (strcmp(driver_name, "CoreAudio") == 0)
carla_engine = new CarlaBackend::CarlaEngineRtAudio(RtAudio::MACOSX_CORE);
else if (strcmp(driver_name, "ASIO") == 0)
#endif
#ifdef __WINDOWS_ASIO__
if (strcmp(driver_name, "ASIO") == 0)
carla_engine = new CarlaBackend::CarlaEngineRtAudio(RtAudio::WINDOWS_ASIO);
#endif
#ifdef __WINDOWS_DS__
else if (strcmp(driver_name, "DirectSound") == 0)
carla_engine = new CarlaBackend::CarlaEngineRtAudio(RtAudio::WINDOWS_DS);
#endif
#ifdef __RTAUDIO_DUMMY__
else if (strcmp(driver_name, "Dummy") == 0)
carla_engine = new CarlaBackend::CarlaEngineRtAudio(RtAudio::RTAUDIO_DUMMY);
#endif
#endif

if (! carla_engine)


+ 23
- 23
src/carla-backend/rtaudio-4.0.11/RtAudio.cpp View File

@@ -367,7 +367,7 @@ double RtApi :: getStreamTime( void )
then = stream_.lastTickTimestamp;
return stream_.streamTime +
((now.tv_sec + 0.000001 * now.tv_usec) -
(then.tv_sec + 0.000001 * then.tv_usec));
(then.tv_sec + 0.000001 * then.tv_usec));
#else
return stream_.streamTime;
#endif
@@ -741,7 +741,7 @@ OSStatus callbackHandler( AudioDeviceID inDevice,
const AudioBufferList* inInputData,
const AudioTimeStamp* inInputTime,
AudioBufferList* outOutputData,
const AudioTimeStamp* inOutputTime,
const AudioTimeStamp* inOutputTime,
void* infoPointer )
{
CallbackInfo *info = (CallbackInfo *) infoPointer;
@@ -1710,7 +1710,7 @@ bool RtApiCore :: callbackEvent( AudioDeviceID deviceId,
channelsLeft -= streamChannels;
}
}
if ( stream_.doConvertBuffer[1] ) { // convert from our internal "device" buffer
convertBuffer( stream_.userBuffer[1],
stream_.deviceBuffer,
@@ -2583,7 +2583,7 @@ RtApiAsio :: RtApiAsio()
// CoInitialize beforehand, but it must be for appartment threading
// (in which case, CoInitilialize will return S_FALSE here).
coInitialized_ = false;
HRESULT hr = CoInitialize( NULL );
HRESULT hr = CoInitialize( NULL );
if ( FAILED(hr) ) {
errorText_ = "RtApiAsio::ASIO requires a single-threaded appartment. Call CoInitializeEx(0,COINIT_APARTMENTTHREADED)";
error( RtError::WARNING );
@@ -2934,7 +2934,7 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
handle = new AsioHandle;
}
catch ( std::bad_alloc& ) {
//if ( handle == NULL ) {
//if ( handle == NULL ) {
drivers.removeCurrentDriver();
errorText_ = "RtApiAsio::probeDeviceOpen: error allocating AsioHandle memory.";
return FAILURE;
@@ -3470,13 +3470,13 @@ long asioMessages( long selector, long value, void* message, double* opt )
static const char* getAsioErrorString( ASIOError result )
{
struct Messages
struct Messages
{
ASIOError value;
const char*message;
};
static Messages m[] =
static Messages m[] =
{
{ ASE_NotPresent, "Hardware input or output is not present or available." },
{ ASE_HWMalfunction, "Hardware is malfunctioning." },
@@ -3499,7 +3499,7 @@ static const char* getAsioErrorString( ASIOError result )
#if defined(__WINDOWS_DS__) // Windows DirectSound API
// Modified by Robin Davies, October 2005
// - Improvements to DirectX pointer chasing.
// - Improvements to DirectX pointer chasing.
// - Bug fix for non-power-of-two Asio granularity used by Edirol PCR-A30.
// - Auto-call CoInitialize for DSOUND and ASIO platforms.
// Various revisions for RtAudio 4.0 by Gary Scavone, April 2007
@@ -3539,7 +3539,7 @@ struct DsHandle {
void *id[2];
void *buffer[2];
bool xrun[2];
UINT bufferPointer[2];
UINT bufferPointer[2];
DWORD dsBufferSize[2];
DWORD dsPointerLeadTime[2]; // the number of bytes ahead of the safe pointer to lead by.
HANDLE condition;
@@ -4377,7 +4377,7 @@ void RtApiDs :: startStream()
// Increase scheduler frequency on lesser windows (a side-effect of
// increasing timer accuracy). On greater windows (Win2K or later),
// this is already in effect.
timeBeginPeriod( 1 );
timeBeginPeriod( 1 );
buffersRolling = false;
duplexPrerollBytes = 0;
@@ -4675,7 +4675,7 @@ void RtApiDs :: callbackEvent()
}
if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) {
LPDIRECTSOUNDBUFFER dsBuffer = (LPDIRECTSOUNDBUFFER) handle->buffer[0];
if ( handle->drainCounter > 1 ) { // write zeros to the output stream
@@ -4740,7 +4740,7 @@ void RtApiDs :: callbackEvent()
}
if ( dsPointerBetween( nextWritePointer, safeWritePointer, currentWritePointer, dsBufferSize )
|| dsPointerBetween( endWrite, safeWritePointer, currentWritePointer, dsBufferSize ) ) {
|| dsPointerBetween( endWrite, safeWritePointer, currentWritePointer, dsBufferSize ) ) {
// We've strayed into the forbidden zone ... resync the read pointer.
handle->xrun[0] = true;
nextWritePointer = safeWritePointer + handle->dsPointerLeadTime[0] - bufferBytes;
@@ -4807,14 +4807,14 @@ void RtApiDs :: callbackEvent()
if ( safeReadPointer < (DWORD)nextReadPointer ) safeReadPointer += dsBufferSize; // unwrap offset
DWORD endRead = nextReadPointer + bufferBytes;
// Handling depends on whether we are INPUT or DUPLEX.
// Handling depends on whether we are INPUT or DUPLEX.
// If we're in INPUT mode then waiting is a good thing. If we're in DUPLEX mode,
// then a wait here will drag the write pointers into the forbidden zone.
//
// In DUPLEX mode, rather than wait, we will back off the read pointer until
// it's in a safe position. This causes dropouts, but it seems to be the only
// practical way to sync up the read and write pointers reliably, given the
// the very complex relationship between phase and increment of the read and write
//
// In DUPLEX mode, rather than wait, we will back off the read pointer until
// it's in a safe position. This causes dropouts, but it seems to be the only
// practical way to sync up the read and write pointers reliably, given the
// the very complex relationship between phase and increment of the read and write
// pointers.
//
// In order to minimize audible dropouts in DUPLEX mode, we will
@@ -4863,7 +4863,7 @@ void RtApiDs :: callbackEvent()
errorText_ = errorStream_.str();
error( RtError::SYSTEM_ERROR );
}
if ( safeReadPointer < (DWORD)nextReadPointer ) safeReadPointer += dsBufferSize; // unwrap offset
}
}
@@ -6040,7 +6040,7 @@ void RtApiAlsa :: stopStream()
AlsaHandle *apiInfo = (AlsaHandle *) stream_.apiHandle;
snd_pcm_t **handle = (snd_pcm_t **) apiInfo->handles;
if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) {
if ( apiInfo->synchronized )
if ( apiInfo->synchronized )
result = snd_pcm_drop( handle[0] );
else
result = snd_pcm_drain( handle[0] );
@@ -6697,14 +6697,14 @@ bool RtApiPulse::probeDeviceOpen( unsigned int device, StreamMode mode,
int error;
switch ( mode ) {
case INPUT:
pah->s_rec = pa_simple_new( NULL, "RtAudio", PA_STREAM_RECORD, NULL, "Record", &ss, NULL, NULL, &error );
pah->s_rec = pa_simple_new( NULL, options->streamName.c_str(), PA_STREAM_RECORD, NULL, "Record", &ss, NULL, NULL, &error );
if ( !pah->s_rec ) {
errorText_ = "RtApiPulse::probeDeviceOpen: error connecting input to PulseAudio server.";
goto error;
}
break;
case OUTPUT:
pah->s_play = pa_simple_new( NULL, "RtAudio", PA_STREAM_PLAYBACK, NULL, "Playback", &ss, NULL, NULL, &error );
pah->s_play = pa_simple_new( NULL, options->streamName.c_str(), PA_STREAM_PLAYBACK, NULL, "Playback", &ss, NULL, NULL, &error );
if ( !pah->s_play ) {
errorText_ = "RtApiPulse::probeDeviceOpen: error connecting output to PulseAudio server.";
goto error;
@@ -6732,7 +6732,7 @@ bool RtApiPulse::probeDeviceOpen( unsigned int device, StreamMode mode,
}
}
return true;
error:
closeStream();
return false;


+ 0
- 6
src/carla-includes/carla_lv2_includes.h View File

@@ -596,10 +596,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI URI)
RDF_Port->Properties = LV2_PORT_TRIGGER;

if (Port.has_property(Lv2World.reportsLatency))
{
qWarning("Port Prop Latency!");
RDF_Port->Designation = LV2_PORT_LATENCY;
}
}

// --------------------------------------
@@ -607,12 +604,9 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI URI)
{
Lilv::Nodes DesignationNodes(Port.get_value(Lv2World.designation));

qWarning("Design = %i", DesignationNodes.size());

if (DesignationNodes.size() > 0)
{
const char* const designation = Lilv::Node(lilv_nodes_get(DesignationNodes, DesignationNodes.begin())).as_string();
qWarning("Design -> %s", designation);

if (strcmp(designation, LV2_TIME__bar) == 0)
RDF_Port->Designation = LV2_PORT_TIME_BAR;


Loading…
Cancel
Save