Browse Source

rebase from trunk 3563:3613

git-svn-id: http://subversion.jackaudio.org/jack/jack2/branches/libjacknet@3614 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.8
sletz 16 years ago
parent
commit
187a3aedfa
81 changed files with 3585 additions and 1512 deletions
  1. +47
    -1
      ChangeLog
  2. +1
    -12
      README
  3. +1
    -7
      common/JackAPI.cpp
  4. +1
    -1
      common/JackActivationCount.h
  5. +3
    -2
      common/JackAtomicArrayState.h
  6. +4
    -4
      common/JackAtomicState.h
  7. +17
    -1
      common/JackAudioDriver.cpp
  8. +10
    -0
      common/JackAudioDriver.h
  9. +7
    -5
      common/JackConnectionManager.h
  10. +7
    -2
      common/JackConstants.h
  11. +7
    -1
      common/JackControlAPI.cpp
  12. +3
    -1
      common/JackControlAPI.h
  13. +1
    -1
      common/JackDriver.cpp
  14. +1
    -1
      common/JackDriver.h
  15. +4
    -4
      common/JackFilters.h
  16. +2
    -2
      common/JackFrameTimer.h
  17. +1
    -1
      common/JackFreewheelDriver.cpp
  18. +60
    -3
      common/JackLoopbackDriver.cpp
  19. +3
    -3
      common/JackNetDriver.cpp
  20. +1
    -1
      common/JackNetDriver.h
  21. +18
    -21
      common/JackNetInterface.cpp
  22. +1
    -1
      common/JackNetInterface.h
  23. +3
    -3
      common/JackNetManager.cpp
  24. +1
    -1
      common/JackNetManager.h
  25. +2
    -0
      common/JackServerGlobals.cpp
  26. +2
    -0
      common/JackServerGlobals.h
  27. +1
    -1
      common/JackThreadedDriver.cpp
  28. +0
    -1
      common/JackTransportEngine.h
  29. +1
    -1
      common/JackWaitThreadedDriver.h
  30. +85
    -11
      common/JackWeakAPI.cpp
  31. +34
    -12
      common/Jackdmp.cpp
  32. +6
    -1
      common/jack/control.h
  33. +31
    -21
      common/jack/jack.h
  34. +1
    -1
      common/jack/midiport.h
  35. +2
    -2
      common/jack/types.h
  36. +108
    -20
      common/memops.c
  37. +5
    -2
      common/wscript
  38. +65
    -32
      dbus/audio_reserve.c
  39. +3
    -2
      dbus/audio_reserve.h
  40. +64
    -1
      dbus/controller.c
  41. +1
    -0
      dbus/jackdbus.h
  42. +9
    -9
      dbus/reserve.c
  43. +15
    -0
      dbus/reserve.h
  44. +5
    -2
      dbus/wscript
  45. +1
    -1
      doxyfile
  46. +1
    -1
      example-clients/server_control.cpp
  47. +94
    -44
      linux/alsa/JackAlsaDriver.cpp
  48. +4
    -4
      linux/alsa/JackAlsaDriver.h
  49. +4
    -2
      linux/alsa/hammerfall.c
  50. +7
    -6
      linux/wscript
  51. +1
    -1
      macosx/Jack-Info.plist
  52. +1
    -1
      macosx/JackMachSemaphore.h
  53. +1
    -3
      macosx/JackPlatformPlug_os.h
  54. +1776
    -385
      macosx/Jackdmp.xcodeproj/project.pbxproj
  55. +8
    -3
      macosx/coreaudio/JackCoreAudioDriver.cpp
  56. +2
    -0
      macosx/install_jackdmp
  57. +2
    -0
      macosx/wscript
  58. +1
    -1
      posix/JackFifo.h
  59. +1
    -1
      posix/JackPosixSemaphore.h
  60. +5
    -3
      posix/JackPosixServerLaunch.cpp
  61. +149
    -142
      solaris/oss/JackBoomerDriver.cpp
  62. +50
    -19
      solaris/oss/JackBoomerDriver.h
  63. +1
    -1
      solaris/oss/JackOSSDriver.cpp
  64. +1
    -0
      solaris/wscript
  65. +17
    -17
      windows/JackCompilerDeps_os.h
  66. +6
    -6
      windows/JackNetWinSocket.cpp
  67. +1
    -1
      windows/JackTypes_os.h
  68. +55
    -55
      windows/JackWinProcessSync.cpp
  69. +1
    -1
      windows/JackWinSemaphore.h
  70. +26
    -26
      windows/JackWinServerLaunch.cpp
  71. BIN
      windows/Setup/JackRouter.dll
  72. +5
    -1
      windows/Setup/README
  73. +7
    -3
      windows/Setup/jack.ci
  74. +11
    -6
      windows/Setup/src/README
  75. +95
    -0
      windows/jack_loopback.cbp
  76. +1
    -0
      windows/jackd.workspace
  77. +2
    -2
      windows/portaudio/JackPortAudioDevices.cpp
  78. +59
    -59
      windows/portaudio/JackPortAudioDevices.h
  79. +15
    -15
      windows/resource_vc.h
  80. +506
    -501
      windows/winmme/JackWinMMEDriver.cpp
  81. +24
    -3
      wscript

+ 47
- 1
ChangeLog View File

@@ -23,11 +23,57 @@ Paul Davis
---------------------------
Jackdmp changes log
---------------------------
---------------------------

2009-07-17 Stephane Letz <letz@grame.fr>
* Loopback backend reborn as a dynamically loadable separated backend.
* -L parameter for loopback backend activated again in jackd.

2009-07-17 Stephane Letz <letz@grame.fr>
* Big rewrite of Solaris boomer driver, seems to work in duplex mode at least.
2009-07-16 Stephane Letz <letz@grame.fr>
* In combined --dbus and --classic compilation code, use PulseAudio acquire/release code.
2009-07-15 Stephane Letz <letz@grame.fr>
* Rename JackDriver::Init method to JackDriver::Initialize (to avoid confusion with JackThread::Init method).
* Update Solaris boomer driver.
* Report some cleanup and documentation improvements done on JACK1 timing functions.
2009-07-11 Stephane Letz <letz@grame.fr>
* Raise drivers time out used in synchronous mode.
2009-07-09 Stephane Letz <letz@grame.fr>
* Use __attribute__((__packed__)) again, more fixes for 64/32 mixed mode.
* Torben Hohn changes for 64/32 mixed mode in wscripts.
* Add compile time option for maximum ports per application.
2009-07-07 Stephane Letz <letz@grame.fr>
* Use __attribute__((__aligned__(32))) instead of __attribute__((__packed__)) for 64/32 mixed mode.
2009-07-03 Stephane Letz <letz@grame.fr>
* Another Tim Bechmann memops.c optimization patch.
2009-07-01 Stephane Letz <letz@grame.fr>
* Tim Bechmann memops.c optimization patch.
2009-06-30 Stephane Letz <letz@grame.fr>
* Tim Bechmann patch : hammerfall, only release monitor thread, if it has been created.
2009-06-19 Stephane Letz <letz@grame.fr>
* Correct JackTransportEngine::MakeAllLocating, sync callback has to be called in this case also.
* NetJack2 code : better error checkout, method renaming.
2009-06-17 Stephane Letz <letz@grame.fr>


+ 1
- 12
README View File

@@ -137,8 +137,6 @@ The binary elements are :
- JackRouter.dll : an ASIO/JACK driver that allows ASIO compatible applications to become JACK clients and access the JACK server. ASIO "jackified" applications appear with their names. Ableton Live, Samplitude, Reason, Arturia applications have been successfully tested. To install it, use "regsvr32 JackRouter.dll" in a terminal (use regsvr32 /u JackRouter.dll to uninstall). [VISTA special note: regsvr32 has to be used with "administrator" priviledges to properly register JackRouter.dll (Start Menu -> All Programs -> Accessories -> Right Click on Command Prompt -> Run As Administrator)]. A JackRouter.ini file is used by the driver to read parameters : an [IO] section allows to setup the number of input/output jack ports for the application and a [AUTO_CONNECT] section allows to setup jack ports autoconnection mode to machine input/output.
All dll are compiled in "release" mode. The "Debug" folder contains debug version of all dlls and libraries. MSVCRTD.dll and MSVCP60D.dll debug dll are also included.
WARNING !! WARNING !!
Depending of the used interface and driver settings, the PortAudio layer may add additionnal buffering between the real card interrupt and the jack server callback. This usually result in *unregular* calls of the jack server callback (for example if jack server used a 256 frames buffer and the card used a 512 frames, the jack server callback will be called twice every card interrupt). For proper functionning of jack server and clients in this case, the jack server has to be started in "synchronous" mode, using the "-S" parameter.
@@ -156,16 +154,6 @@ Automatic server launch
Starting from the 0.64 version, automatic server launch from client is implemented : when the server is not yet running, and if the client uses the "jack_client_open" API, the server will be started automatically. The server configuration is saved in a ".jackdrc" file located in the user home folder. The Qjackctl tool allows to save its configuration in this . jackdrc (setting can be done in Qjackctl Setup/Misc). If no configuration file is found, a default setup will be used.

WARNING : automatic server launch is not implemented on Windows

----------------
Loopback driver
----------------

An experimental loopback driver allows to manually "pipeline" applications connected in sequence, and thus parallelize sequential sub-graph. Lets say we have A ==> B graph, by using the loopback driver, it can be rewritten as : A ==> loopback driver ==> B. At each cycle, the loopback driver copy buffers received on its input ports (at the previous cycle) to its output ports. The resulting graph become parallel and thus can take profit of multi-processors machines, at each cycle A and B can be activated in parallel. Note that the loopback driver add a one buffer delay in the connection, which may be relevant in more complex graphs when having global synchronicity between clients is a desirable property.

To activate loopback driver, use :

- jackd (jackdmp) ... -L n ... where n is the number of input/output ports.
------------------
Validations tools
@@ -225,6 +213,7 @@ Note : To experiment with the -S option, jackdmp must be launched in a console.
1.9.0 : Waf based build system : Nedko Arnaudov, Grame for preliminary OSX support. Control API, dbus based server control access : Nedko Arnaudov, Grame. NetJack2 components (in progress) : jack_net backend, netmanager, audioadapter, netadapter : Romain Moret, Grame. Code restructuring to help port on other architectures : Michael Voigt. Code cleanup/optimization : Tim Blechmann. Improve handling of server internal clients that can now be loaded/unloaded using the new server control API : Grame. A lot of bug fix and improvements.
1.9.1 : Fix jackctl_server_unload_internal. Filter SIGPIPE to avoid having client get a SIGPIPE when trying to access a died server. Libjack shutdown handler does not "deactivate" (fActive = false) the client anymore, so that jack_deactivate correctly does the job later on. Better isolation of server and clients system resources to allow starting the server in several user account at the same time. Report ringbuffer.c fixes from jack1. Client and library global context cleanup in case of incorrect shutdown handling (that is applications not correctly closing client after server has shutdown). Use JACK_DRIVER_DIR variable in internal clients loader. For ALSA driver, synchronize with latest jack1 memops functions. Synchronize jack2 public headers with jack1 ones. Implement jack_client_real_time_priority and jack_client_max_real_time_priority API. Use up to BUFFER_SIZE_MAX frames in midi ports, fix for ticket #117. Cleanup server starting code for clients directly linked with libjackserver.so. JackMessageBuffer was using thread "Stop" scheme in destructor, now use the safer thread "Kill" way. Synchronize ALSA backend code with JACK1 one. Set default mode to 'slow' in JackNetDriver and JackNetAdapter. Simplify audio packet order verification. Fix JackNetInterface::SetNetBufferSize for socket buffer size computation and JackNetMasterInterface::DataRecv if synch packet is received, various cleanup. Better recovery of network overload situations, now "resynchronize" by skipping cycles.". Support for BIG_ENDIAN machines in NetJack2. Support for BIG_ENDIAN machines in NetJack2 for MIDI ports. Support for "-h" option in internal clients to print the parameters. In NetJack2, fix a bug when capture or playback only channels are used. Add a JACK_INTERNAL_DIR environment variable to be used for internal clients. Add a resample quality parameter in audioadapter. Now correctly return an error if JackServer::SetBufferSize could not change the buffer size (and was just restoring the current one). Use PRIu32 kind of macro in JackAlsaDriver again. Add a resample quality parameter in netadapter.
1.9.2 : Solaris version. New "profiling" tools. Rework the mutex/signal classes. Support for BIG_ENDIAN machines in NetJack2. D-BUS based device reservation to better coexist with PulseAudio on Linux. Add auto_connect parameter in netmanager and netadapter. Use Torben Hohn PI controler code for adapters. Client incorrect re-naming fixed : now done at socket and fifo level. Virtualize and allow overriding of thread creation function, to allow Wine support (from JACK1).
1.9.3 : New JackBoomerDriver class for Boomer driver on Solaris. Add mixed 32/64 bits mode (off by default). Native MIDI backend (JackCoreMidiDriver, JackWinMMEDriver). In ALSA audio card reservation code, tries to open the card even if reservation fails. Clock source setting on Linux. Add jackctl_server_switch_master API. Fix transport callback (timebase master, sync) issue when used after jack_activate (RT thread was not running). D-Bus access for jackctl_server_add_slave/jackctl_server_remove_slave API. Cleanup "loopback" stuff in server. Torben Hohn fix for InitTime and GetMicroSeconds in JackWinTime.c. New jack_free function added in jack.h. Reworked Torben Hohn fix for server restart issue on Windows. Correct jack_set_error_function, jack_set_info_function and jack_set_thread_creator functions. Correct JackFifo::TimedWait for EINTR handling. Move DBus based audio device reservation code in ALSA backend compilation. Correct JackTransportEngine::MakeAllLocating, sync callback has to be called in this case also. NetJack2 code : better error checkout, method renaming. Tim Bechmann patch : hammerfall, only release monitor thread, if it has been created. Tim Bechmann memops.c optimization patches. In combined --dbus and --classic compilation code, use PulseAudio acquire/release code. Big rewrite of Solaris boomer driver, seems to work in duplex mode at least. Loopback backend reborn as a dynamically loadable separated backend.
This is a work in progress but the implementation is now stable enough to be tested. jackdmp has been used successfully with the following applications : Ardour, Hydrogen, Jamin, Qjackctl, Jack-Rack, SooperLooper, AlsaPlayer...


+ 1
- 7
common/JackAPI.cpp View File

@@ -1465,14 +1465,8 @@ EXPORT jack_nframes_t jack_last_frame_time(const jack_client_t* ext_client)
#ifdef __CLIENTDEBUG__
JackLibGlobals::CheckContext();
#endif
JackTimer timer;
JackEngineControl* control = GetEngineControl();
if (control) {
control->ReadFrameTime(&timer);
return timer.CurFrame();
} else {
return 0;
}
return (control) ? control->fFrameTimer.ReadCurrentState()->CurFrame() : 0;
}

EXPORT float jack_cpu_load(jack_client_t* ext_client)


+ 1
- 1
common/JackActivationCount.h View File

@@ -73,7 +73,7 @@ class JackActivationCount
return fValue;
}

};
} POST_PACKED_STRUCTURE;

} // end of namespace



+ 3
- 2
common/JackAtomicArrayState.h View File

@@ -21,6 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define __JackAtomicArrayState__

#include "JackAtomic.h"
#include "JackCompilerDeps.h"
#include <string.h> // for memcpy

namespace Jack
@@ -67,7 +68,7 @@ struct AtomicArrayCounter
return *this;
}
};
} POST_PACKED_STRUCTURE;

#define Counter1(e) (e).info.fLongVal
#define GetIndex1(e, state) ((e).info.scounter.fByteVal[state])
@@ -247,7 +248,7 @@ class JackAtomicArrayState
WriteNextStateStopAux(state);
}

};
} POST_PACKED_STRUCTURE;

} // end of namespace



+ 4
- 4
common/JackAtomicState.h View File

@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define __JackAtomicState__

#include "JackAtomic.h"
#include "JackCompilerDeps.h"
#include <string.h> // for memcpy

namespace Jack
@@ -68,7 +69,7 @@ struct AtomicCounter
return *this;
}

};
} POST_PACKED_STRUCTURE;

#define Counter(e) (e).info.fLongVal
#define CurIndex(e) (e).info.scounter.fShortVal1
@@ -250,11 +251,10 @@ class JackAtomicState
} while (cur_index != next_index);
}
*/
};
} POST_PACKED_STRUCTURE;

} // end of namespace


#endif


+ 17
- 1
common/JackAudioDriver.cpp View File

@@ -79,6 +79,22 @@ int JackAudioDriver::Open(jack_nframes_t buffer_size,
return JackDriver::Open(buffer_size, samplerate, capturing, playing, inchannels, outchannels, monitor, capture_driver_name, playback_driver_name, capture_latency, playback_latency);
}

int JackAudioDriver::Open(bool capturing,
bool playing,
int inchannels,
int outchannels,
bool monitor,
const char* capture_driver_name,
const char* playback_driver_name,
jack_nframes_t capture_latency,
jack_nframes_t playback_latency)
{
fCaptureChannels = inchannels;
fPlaybackChannels = outchannels;
fWithMonitorPorts = monitor;
return JackDriver::Open(capturing, playing, inchannels, outchannels, monitor, capture_driver_name, playback_driver_name, capture_latency, playback_latency);
}

int JackAudioDriver::Attach()
{
JackPort* port;
@@ -269,7 +285,7 @@ void JackAudioDriver::ProcessGraphSync()
fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable);
if (ProcessSlaves() < 0)
jack_error("JackAudioDriver::ProcessSync ProcessSlaves error, engine may now behave abnormally!!");
if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, fEngineControl->fTimeOutUsecs) < 0)
if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0)
jack_error("JackAudioDriver::ProcessSync SuspendRefNum error, engine may now behave abnormally!!");
} else { // Graph not finished: do not activate it
jack_error("JackAudioDriver::ProcessSync: error");


+ 10
- 0
common/JackAudioDriver.h View File

@@ -74,6 +74,16 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver
jack_nframes_t capture_latency,
jack_nframes_t playback_latency);
virtual int Open(bool capturing,
bool playing,
int inchannels,
int outchannels,
bool monitor,
const char* capture_driver_name,
const char* playback_driver_name,
jack_nframes_t capture_latency,
jack_nframes_t playback_latency);
virtual int Process();
virtual int ProcessNull();



+ 7
- 5
common/JackConnectionManager.h View File

@@ -116,7 +116,7 @@ class JackFixedArray
return fCounter;
}

};
} POST_PACKED_STRUCTURE;

/*!
\brief Utility class.
@@ -151,7 +151,8 @@ class JackFixedArray1 : public JackFixedArray<SIZE>
return true;
}
}
};
} POST_PACKED_STRUCTURE;

/*!
\brief Utility class.
@@ -226,7 +227,7 @@ class JackFixedMatrix
return false;
}

};
} POST_PACKED_STRUCTURE;

/*!
\brief Utility class.
@@ -339,7 +340,7 @@ class JackLoopFeedback
return -1;
}

};
} POST_PACKED_STRUCTURE;

/*!
\brief For client timing measurements.
@@ -356,6 +357,7 @@ struct JackClientTiming
{}
~JackClientTiming()
{}
} POST_PACKED_STRUCTURE;

/*!
@@ -450,7 +452,7 @@ class SERVER_EXPORT JackConnectionManager
int ResumeRefNum(JackClientControl* control, JackSynchro* table, JackClientTiming* timing);
int SuspendRefNum(JackClientControl* control, JackSynchro* table, JackClientTiming* timing, long time_out_usec);
};
} POST_PACKED_STRUCTURE;

} // end of namespace



+ 7
- 2
common/JackConstants.h View File

@@ -38,10 +38,14 @@
#endif

#define DRIVER_PORT_NUM 256
#define PORT_NUM_FOR_CLIENT 256

#ifndef PORT_NUM_FOR_CLIENT
#define PORT_NUM_FOR_CLIENT 512
#endif

#define FIRST_AVAILABLE_PORT 1

#define CONNECTION_NUM_FOR_PORT 256
#define CONNECTION_NUM_FOR_PORT PORT_NUM_FOR_CLIENT

#ifndef CLIENT_NUM
#define CLIENT_NUM 64
@@ -86,6 +90,7 @@
#define SOCKET_TIME_OUT 5 // in sec
#define DRIVER_OPEN_TIMEOUT 5 // in sec
#define FREEWHEEL_DRIVER_TIMEOUT 10 // in sec
#define DRIVER_TIMEOUT_FACTOR 10

#define NO_PORT 0xFFFE



+ 7
- 1
common/JackControlAPI.cpp View File

@@ -43,6 +43,7 @@
#include "JackLockedEngine.h"
#include "JackConstants.h"
#include "JackDriverLoader.h"
#include "JackServerGlobals.h"

using namespace Jack;

@@ -618,7 +619,9 @@ get_realtime_priority_constraint()
return constraint_ptr;
}

EXPORT jackctl_server_t * jackctl_server_create()
EXPORT jackctl_server_t * jackctl_server_create(
bool (* on_device_acquire)(const char * device_name),
void (* on_device_release)(const char * device_name))
{
struct jackctl_server * server_ptr;
union jackctl_parameter_value value;
@@ -762,6 +765,9 @@ EXPORT jackctl_server_t * jackctl_server_create()
goto fail_free_parameters;
}

JackServerGlobals::on_device_acquire = on_device_acquire;
JackServerGlobals::on_device_release = on_device_release;

if (!jackctl_drivers_load(server_ptr))
{
goto fail_free_parameters;


+ 3
- 1
common/JackControlAPI.h View File

@@ -88,7 +88,9 @@ jackctl_wait_signals(
sigset_t signals);

EXPORT jackctl_server_t *
jackctl_server_create();
jackctl_server_create(
bool (* on_device_acquire)(const char * device_name),
void (* on_device_release)(const char * device_name));

EXPORT void
jackctl_server_destroy(


+ 1
- 1
common/JackDriver.cpp View File

@@ -339,7 +339,7 @@ int JackDriver::SetSampleRate(jack_nframes_t sample_rate)
return 0;
}

bool JackDriver::Init()
bool JackDriver::Initialize()
{
return true;
}


+ 1
- 1
common/JackDriver.h View File

@@ -203,7 +203,7 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
virtual JackClientControl* GetClientControl() const;
virtual bool IsRealTime() const;
virtual bool Init(); // To be called by the wrapping thread Init method when the driver is a "blocking" one
virtual bool Initialize(); // To be called by the wrapping thread Init method when the driver is a "blocking" one
};


+ 4
- 4
common/JackFilters.h View File

@@ -54,7 +54,8 @@ namespace Jack
mean += fTable[i];
return mean / MAX_SIZE;
}
};
} POST_PACKED_STRUCTURE;
class JackDelayLockedLoop
{
@@ -136,7 +137,7 @@ namespace Jack
return fCurrentWakeup;
}
};
} POST_PACKED_STRUCTURE;
class JackAtomicDelayLockedLoop : public JackAtomicState<JackDelayLockedLoop>
{
@@ -201,7 +202,7 @@ namespace Jack
return res;
}
};
} POST_PACKED_STRUCTURE;
/*
Torben Hohn PI controler from JACK1
@@ -301,7 +302,6 @@ namespace Jack
}
*/

double GetRatio(int error)
{
double smooth_offset = error;


+ 2
- 2
common/JackFrameTimer.h View File

@@ -44,8 +44,8 @@ class SERVER_EXPORT JackTimer
jack_time_t fCurrentCallback;
jack_time_t fNextWakeUp;
float fSecondOrderIntegrator;
bool fInitialized;
float fFilterCoefficient; /* set once, never altered */
bool fInitialized;

public:
@@ -67,7 +67,7 @@ class SERVER_EXPORT JackTimer
return fCurrentWakeup;
}

};
} POST_PACKED_STRUCTURE;

/*!
\brief A class using the JackAtomicState to manage jack time.


+ 1
- 1
common/JackFreewheelDriver.cpp View File

@@ -41,7 +41,7 @@ int JackFreewheelDriver::Process()
} else {
fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); // Signal all clients
if (fEngineControl->fSyncMode) {
if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, fEngineControl->fTimeOutUsecs) < 0) {
if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) {
jack_error("JackFreewheelDriver::ProcessSync SuspendRefNum error");
return -1;
}


+ 60
- 3
common/JackLoopbackDriver.cpp View File

@@ -20,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#include "JackSystemDeps.h"
#include "JackLoopbackDriver.h"
#include "JackDriverLoader.h"
#include "JackEngineControl.h"
#include "JackGraphManager.h"
#include "JackError.h"
@@ -31,8 +32,6 @@ namespace Jack

int JackLoopbackDriver::Process()
{
assert(fCaptureChannels == fPlaybackChannels);

// Loopback copy
for (int i = 0; i < fCaptureChannels; i++) {
memcpy(GetInputBuffer(i), GetOutputBuffer(i), sizeof(float) * fEngineControl->fBufferSize);
@@ -40,7 +39,7 @@ int JackLoopbackDriver::Process()

fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); // Signal all clients
if (fEngineControl->fSyncMode) {
if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, fEngineControl->fTimeOutUsecs) < 0) {
if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) {
jack_error("JackLoopbackDriver::ProcessSync SuspendRefNum error");
return -1;
}
@@ -49,3 +48,61 @@ int JackLoopbackDriver::Process()
}

} // end of namespace

#ifdef __cplusplus
extern "C"
{
#endif

SERVER_EXPORT jack_driver_desc_t * driver_get_descriptor()
{
jack_driver_desc_t * desc;
unsigned int i;

desc = (jack_driver_desc_t*)calloc (1, sizeof (jack_driver_desc_t));
strcpy(desc->name, "loopback"); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy(desc->desc, "Loopback backend"); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1

desc->nparams = 1;
desc->params = (jack_driver_param_desc_t*)calloc (desc->nparams, sizeof (jack_driver_param_desc_t));
i = 0;
strcpy(desc->params[i].name, "channels");
desc->params[i].character = 'c';
desc->params[i].type = JackDriverParamInt;
desc->params[i].value.ui = 0;
strcpy(desc->params[i].short_desc, "Maximum number of loopback ports");
strcpy(desc->params[i].long_desc, desc->params[i].short_desc);

return desc;
}

SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine* engine, Jack::JackSynchro* table, const JSList* params)
{
const JSList * node;
const jack_driver_param_t * param;
int channels = 2;
for (node = params; node; node = jack_slist_next (node)) {
param = (const jack_driver_param_t *) node->data;

switch (param->character) {

case 'c':
channels = param->value.ui;
break;
}
}
Jack::JackDriverClientInterface* driver = new Jack::JackLoopbackDriver(engine, table);
if (driver->Open(1, 1, channels, channels, false, "loopback", "loopback", 0, 0) == 0) {
return driver;
} else {
delete driver;
return NULL;
}
}

#ifdef __cplusplus
}
#endif

+ 3
- 3
common/JackNetDriver.cpp View File

@@ -121,13 +121,13 @@ namespace Jack
as a "dummy driver, until Init method returns.
*/
bool JackNetDriver::Init()
bool JackNetDriver::Initialize()
{
jack_log ( "JackNetDriver::Init()" );
jack_log("JackNetDriver::Initialize()");

//new loading, but existing socket, restart the driver
if (fSocket.IsSocket()) {
jack_info( "Restarting driver..." );
jack_info("Restarting driver...");
FreeAll();
}



+ 1
- 1
common/JackNetDriver.h View File

@@ -50,7 +50,7 @@ namespace Jack
JackGnuPlotMonitor<float>* fNetTimeMon;
#endif

bool Init();
bool Initialize();
void FreeAll();
int AllocPorts();


+ 18
- 21
common/JackNetInterface.cpp View File

@@ -204,8 +204,7 @@ namespace Jack
int rx_bytes = 0;

//socket
if ( fSocket.NewSocket() == SOCKET_ERROR )
{
if ( fSocket.NewSocket() == SOCKET_ERROR ) {
jack_error ( "Can't create socket : %s", StrError ( NET_ERROR_CODE ) );
return false;
}
@@ -215,8 +214,7 @@ namespace Jack
jack_error ( "Can't set timeout : %s", StrError ( NET_ERROR_CODE ) );
//connect
if ( fSocket.Connect() == SOCKET_ERROR )
{
if ( fSocket.Connect() == SOCKET_ERROR ) {
jack_error ( "Can't connect : %s", StrError ( NET_ERROR_CODE ) );
return false;
}
@@ -245,22 +243,19 @@ namespace Jack
SessionParamsNToH(&net_params, &host_params);
}
while ( ( GetPacketType ( &host_params ) != START_MASTER ) && ( ++attempt < SLAVE_SETUP_RETRY ) );
if ( attempt == SLAVE_SETUP_RETRY )
{
if ( attempt == SLAVE_SETUP_RETRY ) {
jack_error ( "Slave doesn't respond, exiting." );
return false;
}

//set the new timeout for the socket
if ( SetRxTimeout() == SOCKET_ERROR )
{
if ( SetRxTimeout() == SOCKET_ERROR ) {
jack_error ( "Can't set rx timeout : %s", StrError ( NET_ERROR_CODE ) );
return false;
}

//set the new rx buffer size
if ( SetNetBufferSize() == SOCKET_ERROR )
{
if ( SetNetBufferSize() == SOCKET_ERROR ) {
jack_error ( "Can't set net buffer sizes : %s", StrError ( NET_ERROR_CODE ) );
return false;
}
@@ -619,7 +614,7 @@ namespace Jack
//first, get a master, do it until a valid connection is running
do
{
status = GetNetMaster();
status = SendAvailableToMaster();
if ( status == NET_SOCKET_ERROR )
return false;
}
@@ -651,7 +646,7 @@ namespace Jack
do
{
//get a master
status = GetNetMaster();
status = SendAvailableToMaster();
if (status == NET_SOCKET_ERROR)
return false;
}
@@ -678,26 +673,27 @@ namespace Jack
return true;
}

net_status_t JackNetSlaveInterface::GetNetMaster()
net_status_t JackNetSlaveInterface::SendAvailableToMaster()
{
jack_log ( "JackNetSlaveInterface::GetNetMaster()" );
jack_log ( "JackNetSlaveInterface::SendAvailableToMaster()" );
//utility
session_params_t host_params;
int rx_bytes = 0;

//socket
if ( fSocket.NewSocket() == SOCKET_ERROR )
{
if ( fSocket.NewSocket() == SOCKET_ERROR ) {
jack_error ( "Fatal error : network unreachable - %s", StrError ( NET_ERROR_CODE ) );
return NET_SOCKET_ERROR;
}

//bind the socket
if ( fSocket.Bind() == SOCKET_ERROR )
if ( fSocket.Bind() == SOCKET_ERROR ) {
jack_error ( "Can't bind the socket : %s", StrError ( NET_ERROR_CODE ) );
return NET_SOCKET_ERROR;
}

//timeout on receive
if ( fSocket.SetTimeOut ( SLAVE_INIT_TIMEOUT ) == SOCKET_ERROR )
if ( fSocket.SetTimeOut ( SLAVE_INIT_TIMEOUT ) == SOCKET_ERROR )
jack_error ( "Can't set timeout : %s", StrError ( NET_ERROR_CODE ) );

//disable local loop
@@ -730,12 +726,13 @@ namespace Jack
fParams = host_params;

//set the new buffer sizes
if ( SetNetBufferSize() == SOCKET_ERROR )
if ( SetNetBufferSize() == SOCKET_ERROR ) {
jack_error ( "Can't set net buffer sizes : %s", StrError ( NET_ERROR_CODE ) );
return NET_SOCKET_ERROR;
}

//connect the socket
if ( fSocket.Connect() == SOCKET_ERROR )
{
if ( fSocket.Connect() == SOCKET_ERROR ) {
jack_error ( "Error in connect : %s", StrError ( NET_ERROR_CODE ) );
return NET_CONNECT_ERROR;
}


+ 1
- 1
common/JackNetInterface.h View File

@@ -151,7 +151,7 @@ namespace Jack
bool InitConnection();
bool InitRendering();
net_status_t GetNetMaster();
net_status_t SendAvailableToMaster();
net_status_t SendStartToMaster();
void SetParams();


+ 3
- 3
common/JackNetManager.cpp View File

@@ -618,7 +618,7 @@ namespace Jack
switch ( GetPacketType ( &host_params ) )
{
case SLAVE_AVAILABLE:
if ( ( net_master = MasterInit ( host_params ) ) )
if ( ( net_master = InitMaster ( host_params ) ) )
SessionParamsDisplay ( &net_master->fParams );
else
jack_error ( "Can't init new net master..." );
@@ -636,9 +636,9 @@ namespace Jack
while ( fRunning );
}

JackNetMaster* JackNetMasterManager::MasterInit ( session_params_t& params )
JackNetMaster* JackNetMasterManager::InitMaster ( session_params_t& params )
{
jack_log ( "JackNetMasterManager::MasterInit, Slave : %s", params.fName );
jack_log ( "JackNetMasterManager::InitMaster, Slave : %s", params.fName );
//check MASTER <<==> SLAVE network protocol coherency
if (params.fProtocolVersion != MASTER_PROTOCOL) {


+ 1
- 1
common/JackNetManager.h View File

@@ -105,7 +105,7 @@ namespace Jack
bool fAutoConnect;

void Run();
JackNetMaster* MasterInit ( session_params_t& params );
JackNetMaster* InitMaster ( session_params_t& params );
master_list_it_t FindMaster ( uint32_t client_id );
int KillMaster ( session_params_t* params );
void SetSlaveName ( session_params_t& params );


+ 2
- 0
common/JackServerGlobals.cpp View File

@@ -30,6 +30,8 @@ namespace Jack

JackServer* JackServerGlobals::fInstance;
unsigned int JackServerGlobals::fUserCount;
bool (* JackServerGlobals::on_device_acquire)(const char * device_name) = NULL;
void (* JackServerGlobals::on_device_release)(const char * device_name) = NULL;

int JackServerGlobals::Start(const char* server_name,
jack_driver_desc_t* driver_desc,


+ 2
- 0
common/JackServerGlobals.h View File

@@ -38,6 +38,8 @@ struct SERVER_EXPORT JackServerGlobals
{
static JackServer* fInstance;
static unsigned int fUserCount;
static bool (* on_device_acquire)(const char * device_name);
static void (* on_device_release)(const char * device_name);
JackServerGlobals();
~JackServerGlobals();


+ 1
- 1
common/JackThreadedDriver.cpp View File

@@ -209,7 +209,7 @@ bool JackThreadedDriver::Execute()

bool JackThreadedDriver::Init()
{
if (fDriver->Init()) {
if (fDriver->Initialize()) {
if (fDriver->IsRealTime()) {
jack_log("JackThreadedDriver::Init IsRealTime");
// Will do "something" on OSX only...


+ 0
- 1
common/JackTransportEngine.h View File

@@ -195,7 +195,6 @@ class SERVER_EXPORT JackTransportEngine : public JackAtomicArrayState<jack_posit

} POST_PACKED_STRUCTURE;


} // end of namespace

#endif

+ 1
- 1
common/JackWaitThreadedDriver.h View File

@@ -65,7 +65,7 @@ class SERVER_EXPORT JackWaitThreadedDriver : public JackThreadedDriver
bool Execute()
{
// Blocks until decorated driver is started (that is when it's Init method returns).
fDriver->Init();
fDriver->Initialize();
fRunning = true;
return false;
}


+ 85
- 11
common/JackWeakAPI.cpp View File

@@ -152,17 +152,91 @@ DECL_FUNCTION(const char**, jack_port_get_connections, (const jack_port_t *port)
DECL_FUNCTION(const char**, jack_port_get_all_connections, (const jack_port_t *port), (port));
DECL_FUNCTION(int, jack_port_tie, (jack_port_t *src, jack_port_t *dst), (src, dst));
DECL_FUNCTION(int, jack_port_untie, (jack_port_t *port), (port));


DECL_FUNCTION(jack_nframes_t, jack_get_buffer_size, (jack_client_t *client), (client));
DECL_FUNCTION(jack_nframes_t, jack_port_get_latency, (jack_port_t *port));
DECL_FUNCTION(jack_nframes_t, jack_port_get_total_latency ,(jack_client_t *), (jack_port_t *port));
DECL_VOID_FUNCTION(jack_port_set_latency, (jack_port_t *), (jack_nframes_t));
DECL_FUNCTION(int, jack_recompute_total_latency, (jack_client_t*), (jack_port_t* port));
DECL_FUNCTION(int, jack_recompute_total_latencies, (jack_client_t*));

DECL_FUNCTION(int, jack_port_set_name, (jack_port_t *port), (const char *port_name));
DECL_FUNCTION(int, jack_port_set_alias, (jack_port_t *port), (const char *alias));
DECL_FUNCTION(int, jack_port_unset_alias, (jack_port_t *port), (const char *alias));
DECL_FUNCTION(int, jack_port_get_aliases, (const jack_port_t *port), (char* const aliases[2]));
DECL_FUNCTION(int, jack_port_request_monitor, (jack_port_t *port), (int onoff));
DECL_FUNCTION(int, jack_port_request_monitor_by_name, (jack_client_t *client), (const char *port_name), (int onoff));
DECL_FUNCTION(int, jack_port_ensure_monitor, (jack_port_t *port), (int onoff));
DECL_FUNCTION(int, jack_port_monitoring_input, (jack_port_t *port));
DECL_FUNCTION(int, jack_connect, (jack_client_t *), (const char *source_port), (const char *destination_port));
DECL_FUNCTION(int, jack_disconnect, (jack_client_t *), (const char *source_port), (const char *destination_port));
DECL_FUNCTION(int, jack_port_disconnect, (jack_client_t *), (jack_port_t *));
DECL_FUNCTION(int, jack_port_name_size,(void));
DECL_FUNCTION(int, jack_port_type_size,(void));
DECL_FUNCTION(jack_nframes_t, jack_get_sample_rate, (jack_client_t *client), (client));
DECL_FUNCTION(jack_nframes_t, jack_port_get_total_latency, (jack_client_t *client, jack_port_t *port), (client, port));
DECL_VOID_FUNCTION(jack_set_error_function, (void (*func)(const char *)), (func));


DECL_FUNCTION(jack_nframes_t, jack_get_buffer_size, (jack_client_t *client), (client));
DECL_FUNCTION(const char**, jack_get_ports, (jack_client_t *client, const char *port_name_pattern, const char * type_name_pattern,
unsigned long flags), (client, port_name_pattern, type_name_pattern, flags));
DECL_FUNCTION(int, jack_connect, (jack_client_t *client, const char *source_port, const char *destination_port), (client, source_port, destination_port));
DECL_FUNCTION(int, jack_set_port_connect_callback, (jack_client_t *client, JackPortConnectCallback connect_callback, void *arg),
(client, connect_callback, arg));
DECL_FUNCTION(jack_port_t *, jack_port_by_id, (jack_client_t *client, jack_port_id_t port_id), (client, port_id));
DECL_FUNCTION(jack_port_t *, jack_port_by_name, (jack_client_t *), (const char *port_name));
DECL_FUNCTION(jack_port_t *, jack_port_by_id, (jack_client_t *client), (jack_port_id_t port_id));

DECL_FUNCTION(int, jack_engine_takeover_timebase, (jack_client_t *));
DECL_FUNCTION(jack_nframes_t, jack_frames_since_cycle_start, (const jack_client_t *));
DECL_FUNCTION(jack_time_t, jack_get_time());
DECL_FUNCTION(jack_nframes_t, jack_time_to_frames, (const jack_client_t *client), (jack_time_t time));
DECL_FUNCTION(jack_time_t, jack_frames_to_time, (const jack_client_t *client), (jack_nframes_t frames));
DECL_FUNCTION(jack_nframes_t, jack_frame_time, (const jack_client_t *));
DECL_FUNCTION(jack_nframes_t, jack_last_frame_time, (const jack_client_t *client));
DECL_FUNCTION(float, jack_cpu_load, (jack_client_t *client));
DECL_FUNCTION(pthread_t, jack_client_thread_id, (jack_client_t *));
DECL_VOID_FUNCTION(jack_set_error_function, (print_function));
DECL_VOID_FUNCTION(jack_set_info_function, (print_function));

DECL_FUNCTION(float, jack_get_max_delayed_usecs, (jack_client_t *client));
DECL_FUNCTION(float, jack_get_xrun_delayed_usecs, (jack_client_t *client));
DECL_VOID_FUNCTION(jack_reset_max_delayed_usecs, (jack_client_t *client));

DECL_FUNCTION(int, jack_release_timebase, (jack_client_t *client));
DECL_FUNCTION(int, jack_set_sync_callback, (jack_client_t *client, (JackSyncCallback sync_callback), (void *arg));
DECL_FUNCTION(int, jack_set_sync_timeout, (jack_client_t *client), (jack_time_t timeout));
DECL_FUNCTION(int, jack_set_timebase_callback, (jack_client_t *client), (int conditional), (JackTimebaseCallback timebase_callback), (void *arg));
DECL_FUNCTION(int, jack_transport_locate, (jack_client_t *client), (jack_nframes_t frame));
DECL_FUNCTION(jack_transport_state_t, jack_transport_query, (const jack_client_t *client), (jack_position_t *pos));
DECL_FUNCTION(jack_nframes_t, jack_get_current_transport_frame, (const jack_client_t *client));
DECL_FUNCTION(int, jack_transport_reposition, (jack_client_t *client), (jack_position_t *pos));
DECL_VOID_FUNCTION(jack_transport_start, (jack_client_t *client));
DECL_VOID_FUNCTION(jack_transport_stop, (jack_client_t *client));
DECL_VOID_FUNCTION(jack_get_transport_info, (jack_client_t *client), (jack_transport_info_t *tinfo));
DECL_VOID_FUNCTION(jack_set_transport_info, (jack_client_t *client), (jack_transport_info_t *tinfo));

DECL_FUNCTION(int, jack_client_real_time_priority, (jack_client_t*));
DECL_FUNCTION(int, jack_client_max_real_time_priority, (jack_client_t*));
DECL_FUNCTION(int, jack_acquire_real_time_scheduling, (pthread_t thread), (int priority));
DECL_FUNCTION(int, jack_client_create_thread, (jack_client_t* client),
(pthread_t *thread),
(int priority),
(int realtime), // boolean
(thread_routine routine),
(void *arg));
DECL_FUNCTION(int, jack_drop_real_time_scheduling, (pthread_t thread));

DECL_FUNCTION(int, jack_client_stop_thread, (jack_client_t* client), (pthread_t thread));
DECL_FUNCTION(int, jack_client_kill_thread, (jack_client_t* client), (pthread_t thread));
#ifndef WIN32
DECL_VOID_FUNCTION(jack_set_thread_creator, (jack_thread_creator_t jtc));
#endif
DECL_FUNCTION(char *, jack_get_internal_client_name, (jack_client_t *client, (jack_intclient_t intclient));
DECL_FUNCTION(jack_intclient_t, jack_internal_client_handle, (jack_client_t *client), (const char *client_name), (jack_status_t *status));
DECL_FUNCTION(jack_intclient_t, jack_internal_client_load, (jack_client_t *client), (const char *client_name), (jack_options_t options), (jack_status_t *status), ...));

DECL_FUNCTION(jack_status_t, jack_internal_client_unload, (jack_client_t *client), jack_intclient_t intclient));
DECL_VOID_FUNCTION(jack_free, (void* ptr));

// MIDI

DECL_FUNCTION(jack_nframes_t, jack_midi_get_event_count, (void* port_buffer));
DECL_FUNCTION(int jack_midi_event_get(jack_midi_event_t* event, void* port_buffer, jack_nframes_t event_index);
DECL_VOID_FUNCTION(jack_midi_clear_buffer, (void* port_buffer));
DECL_FUNCTION(size_t, jack_midi_max_event_size, (void* port_buffer));
DECL_FUNCTION(jack_midi_data_t*, jack_midi_event_reserve, (void* port_buffer), (jack_nframes_t time), (size_t data_size));
DECL_FUNCTIO(int jack_midi_event_write, (void* port_buffer), (jack_nframes_t time), (const jack_midi_data_t* data), (size_t data_size));
DECL_FUNCTION(jack_nframes_t, jack_midi_get_lost_event_count, (void* port_buffer));

+ 34
- 12
common/Jackdmp.cpp View File

@@ -32,6 +32,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackConstants.h"
#include "JackDriverLoader.h"

#if defined(JACK_DBUS) && defined(__linux__)
#include <dbus/dbus.h>
#include "audio_reserve.h"
#endif

/*
This is a simple port of the old jackdmp.cpp file to use the new Jack 2.0 control API. Available options for the server
are "hard-coded" in the source. A much better approach would be to use the control API to:
@@ -92,6 +97,7 @@ static void usage(FILE* file)
"usage: jackdmp [ --realtime OR -R [ --realtime-priority OR -P priority ] ]\n"
" [ --name OR -n server-name ]\n"
" [ --timeout OR -t client-timeout-in-msecs ]\n"
" [ --loopback OR -L loopback-port-number ]\n"
" [ --midi OR -X midi-driver ]\n"
" [ --verbose OR -v ]\n"
#ifdef __linux__
@@ -156,17 +162,19 @@ int main(int argc, char* argv[])
const char* server_name = "default";
jackctl_driver_t * audio_driver_ctl;
jackctl_driver_t * midi_driver_ctl;
jackctl_driver_t * loopback_driver_ctl;
#ifdef __linux__
const char *options = "-ad:X:P:uvrshVRL:STFl:t:mn:p:c:";
const char *options = "-ad:X:P:uvrshVRL:STFl:t:mn:p:c:L:";
#else
const char *options = "-ad:X:P:uvrshVRL:STFl:t:mn:p:";
const char *options = "-ad:X:P:uvrshVRL:STFl:t:mn:p:L:";
#endif
struct option long_options[] = {
#ifdef __linux__
{ "clock-source", 1, 0, 'c' },
#endif
{ "loopback-driver", 1, 0, 'L' },
{ "audio-driver", 1, 0, 'd' },
{ "midi-driver", 1, 0, 'X' },
{ "verbose", 0, 0, 'v' },
@@ -200,14 +208,18 @@ int main(int argc, char* argv[])
int port_max = 512;
int do_mlock = 1;
int do_unlock = 0;
int loopback = 0;
bool show_version = false;
sigset_t signals;
jackctl_parameter_t* param;
union jackctl_parameter_value value;

copyright(stdout);

server_ctl = jackctl_server_create();
#if defined(JACK_DBUS) && defined(__linux__)
server_ctl = jackctl_server_create(audio_acquire, audio_release);
#else
server_ctl = jackctl_server_create(NULL, NULL);
#endif
if (server_ctl == NULL) {
fprintf(stderr, "Failed to create server object\n");
return -1;
@@ -245,6 +257,10 @@ int main(int argc, char* argv[])
seen_audio_driver = true;
audio_driver_name = optarg;
break;
case 'L':
loopback = atoi(optarg);
break;

case 'X':
seen_midi_driver = true;
@@ -316,14 +332,6 @@ int main(int argc, char* argv[])
}
break;

case 'L':
param = jackctl_get_parameter(server_parameters, "loopback-ports");
if (param != NULL) {
value.ui = atoi(optarg);
jackctl_parameter_set_value(param, &value);
}
break;

case 'T':
param = jackctl_get_parameter(server_parameters, "temporary");
if (param != NULL) {
@@ -414,6 +422,20 @@ int main(int argc, char* argv[])

jackctl_server_add_slave(server_ctl, midi_driver_ctl);
}
// Loopback driver
if (loopback > 0) {
loopback_driver_ctl = jackctl_server_get_driver(server_ctl, "loopback");
if (loopback_driver_ctl != NULL) {
const JSList * loopback_parameters = jackctl_driver_get_parameters(loopback_driver_ctl);
param = jackctl_get_parameter(loopback_parameters, "channels");
if (param != NULL) {
value.ui = loopback;
jackctl_parameter_set_value(param, &value);
}
jackctl_server_add_slave(server_ctl, loopback_driver_ctl);
}
}

notify_server_start(server_name);



+ 6
- 1
common/jack/control.h View File

@@ -109,12 +109,17 @@ jackctl_wait_signals(
/**
* Call this function to create server object.
*
* @param on_device_acquire - Optional callback to be called before device is acquired. If false is returned, device usage will fail
* @param on_device_release - Optional callback to be called after device is released.
*
* @return server object handle, NULL if creation of server object
* failed. Successfully created server object must be destroyed with
* paired call to ::jackctl_server_destroy
*/
jackctl_server_t *
jackctl_server_create();
jackctl_server_create(
bool (* on_device_acquire)(const char * device_name),
void (* on_device_release)(const char * device_name));

/**
* Call this function to destroy server object.


+ 31
- 21
common/jack/jack.h View File

@@ -108,6 +108,7 @@ jack_client_t * jack_client_open (const char *client_name,
* \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
* NEW JACK CLIENTS
*
* @deprecated Please use jack_client_open().
*/
jack_client_t * jack_client_new (const char *client_name);

@@ -212,8 +213,7 @@ int jack_is_realtime (jack_client_t *client);
* \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
* NEW JACK CLIENTS.
*
* It should be replace by use of @ jack_cycle_wait and @ jack_cycle_signal functions.
*
* @deprecated Please use jack_cycle_wait() and jack_cycle_signal() functions.
*/
jack_nframes_t jack_thread_wait (jack_client_t*, int status);

@@ -236,7 +236,7 @@ void jack_cycle_signal (jack_client_t* client, int status);

/**
* Tell the Jack server to call @a thread_callback in the RT thread.
* Typical use are in conjunction with @a jack_cycle_wait and @ jack_cycle_signal functions.
* Typical use are in conjunction with @a jack_cycle_wait and @a jack_cycle_signal functions.
* The code in the supplied function must be suitable for real-time
* execution. That means that it cannot call functions that might
* block for a long time. This includes malloc, free, printf,
@@ -483,7 +483,7 @@ int jack_set_xrun_callback (jack_client_t *,
/*@}*/

/**
* @defgroup ServerControl Controlling & querying JACK server operation
* @defgroup ServerClientControl Controlling & querying JACK server operation
* @{
*/
@@ -835,7 +835,7 @@ int jack_port_set_alias (jack_port_t *port, const char *alias);
*/
int jack_port_unset_alias (jack_port_t *port, const char *alias);

/*
/**
* Get any aliases known for @port.
*
* @return the number of aliases discovered for the port
@@ -984,47 +984,57 @@ jack_port_t * jack_port_by_id (jack_client_t *client,
/**
* @defgroup TimeFunctions Handling time
* @{
*/
*
* JACK time is in units of 'frames', according to the current sample rate.
* The absolute value of frame times is meaningless, frame times have meaning
* only relative to each other.
*/

/**
* @return the time in frames that has passed since the JACK server
* began the current process cycle.
* @return the estimated time in frames that has passed since the JACK
* server began the current process cycle.
*/
jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);

/**
* @return an estimate of the current time in frames. This is a
* running counter, no significance should be attached to its value,
* but it can be compared to a previously returned value.
* @return the estimated current time in frames.
* This function is intended for use in other threads (not the process
* callback). The return value can be compared with the value of
* jack_last_frame_time to relate time in other threads to JACK time.
*/
jack_nframes_t jack_frame_time (const jack_client_t *);

/**
* @return the frame_time after the last processing of the graph
* this is only to be used from the process callback.
*
* This function can be used to put timestamps generated by
* jack_frame_time() in correlation to the current process cycle.
* @return the precise time at the start of the current process cycle.
* This function may only be used from the process callback, and can
* be used to interpret timestamps generated by jack_frame_time() in
* other threads with respect to the current process cycle.
*
* This is the only jack time function that returns exact time:
* when used during the process callback it always returns the same
* value (until the next process callback, where it will return
* that value + nframes, etc). The return value is guaranteed to be
* monotonic and linear in this fashion unless an xrun occurs.
* If an xrun occurs, clients must check this value again, as time
* may have advanced in a non-linear way (e.g. cycles may have been skipped).
*/
jack_nframes_t jack_last_frame_time (const jack_client_t *client);

/**
* @return estimated time in microseconds of the specified frame time
* @return the estimated time in microseconds of the specified frame time
*/
jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t);

/**
* @return estimated time in frames for the specified system time.
* @return the estimated time in frames for the specified system time.
*/
jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t);

/**
* @return return JACK's current system time in microseconds,
* using JACK clock source.
* using the JACK clock source.
*
* The value returned is guaranteed to be monotonic, but not linear.
*
* This function is a client version of @function jack_get_microseconds().
*/
jack_time_t jack_get_time();



+ 1
- 1
common/jack/midiport.h View File

@@ -47,7 +47,7 @@ typedef struct _jack_midi_event
* @{
*/

/* Get number of events in a port buffer.
/** Get number of events in a port buffer.
*
* @param port_buffer Port buffer from which to retrieve event.
* @return number of events inside @a port_buffer


+ 2
- 2
common/jack/types.h View File

@@ -454,6 +454,7 @@ typedef enum {
JackBBTFrameOffset = 0x40, /**< Frame offset of BBT information */
JackAudioVideoRatio = 0x80, /**< audio frames per video frame */
JackVideoFrameOffset = 0x100 /**< frame offset of first video frame */
} jack_position_bits_t;

/** all valid position bits */
@@ -641,7 +642,6 @@ typedef struct {
double ticks_per_beat;
double beats_per_minute;

}
jack_transport_info_t;
} jack_transport_info_t;

#endif /* __jack_types_h__ */

+ 108
- 20
common/memops.c View File

@@ -164,6 +164,32 @@
}


#if defined (__SSE2__) && !defined (__sun__)

/* generates same as _mm_set_ps(1.f, 1.f, 1f., 1f) but faster */
static inline __m128 gen_one(void)
{
volatile __m128i x;
__m128i ones = _mm_cmpeq_epi32(x, x);
return (__m128)_mm_slli_epi32 (_mm_srli_epi32(ones, 25), 23);
}

static inline __m128 clip(__m128 s, __m128 min, __m128 max)
{
return _mm_min_ps(max, _mm_max_ps(s, min));
}

static inline __m128i float_24_sse(__m128 s)
{
const __m128 upper_bound = gen_one(); /* NORMALIZED_FLOAT_MAX */
const __m128 lower_bound = _mm_sub_ps(_mm_setzero_ps(), upper_bound);

__m128 clipped = clip(s, lower_bound, upper_bound);
__m128 scaled = _mm_mul_ps(clipped, _mm_set1_ps(SAMPLE_24BIT_SCALING));
return _mm_cvtps_epi32(scaled);
}
#endif

/* Linear Congruential noise generator. From the music-dsp list
* less random than rand(), but good enough and 10x faster
*/
@@ -254,7 +280,7 @@ void sample_move_d32u24_sS (char *dst, jack_default_audio_sample_t *src, unsigne
while (unrolled--) {
__m128 in = _mm_load_ps(src);
__m128 scaled = _mm_mul_ps(in, factor);
__m128 clipped = _mm_min_ps(int_max, _mm_max_ps(scaled, int_min));
__m128 clipped = clip(scaled, int_min, int_max);

__m128i y = _mm_cvttps_epi32(clipped);
__m128i shifted = _mm_slli_epi32(y, 8);
@@ -264,13 +290,11 @@ void sample_move_d32u24_sS (char *dst, jack_default_audio_sample_t *src, unsigne
__m128i shuffled3 = _mm_shuffle_epi32(shifted, _MM_SHUFFLE(2, 1, 0, 3));

_mm_store_ss((float*)dst, (__m128)shifted);
dst += dst_skip;
_mm_store_ss((float*)dst, (__m128)shuffled1);
dst += dst_skip;
_mm_store_ss((float*)dst, (__m128)shuffled2);
dst += dst_skip;
_mm_store_ss((float*)dst, (__m128)shuffled3);
dst += dst_skip;

_mm_store_ss((float*)(dst+dst_skip), (__m128)shuffled1);
_mm_store_ss((float*)(dst+2*dst_skip), (__m128)shuffled2);
_mm_store_ss((float*)(dst+3*dst_skip), (__m128)shuffled3);
dst += 4*dst_skip;

src+= 4;
}
@@ -300,6 +324,8 @@ void sample_move_dS_s32u24s (jack_default_audio_sample_t *dst, char *src, unsign
{
/* ALERT: signed sign-extension portability !!! */

const jack_default_audio_sample_t scaling = 1.0/SAMPLE_24BIT_SCALING;

while (nsamples--) {
int x;
#if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -319,7 +345,7 @@ void sample_move_dS_s32u24s (jack_default_audio_sample_t *dst, char *src, unsign
x <<= 8;
x |= (unsigned char)(src[0]);
#endif
*dst = (x >> 8) / SAMPLE_24BIT_SCALING;
*dst = (x >> 8) * scaling;
dst++;
src += src_skip;
}
@@ -357,8 +383,9 @@ void sample_move_dS_s32u24 (jack_default_audio_sample_t *dst, char *src, unsigne

/* ALERT: signed sign-extension portability !!! */

const jack_default_audio_sample_t scaling = 1.0/SAMPLE_24BIT_SCALING;
while (nsamples--) {
*dst = (*((int *) src) >> 8) / SAMPLE_24BIT_SCALING;
*dst = (*((int *) src) >> 8) * scaling;
dst++;
src += src_skip;
}
@@ -386,8 +413,38 @@ void sample_move_d24_sSs (char *dst, jack_default_audio_sample_t *src, unsigned

void sample_move_d24_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
int32_t z;
#if defined (__SSE2__) && !defined (__sun__)
_MM_SET_ROUNDING_MODE(_MM_ROUND_NEAREST);
while (nsamples >= 4) {
int i;
int32_t z[4];
__m128 samples = _mm_loadu_ps(src);
__m128i converted = float_24_sse(samples);

__m128i shuffled1 = _mm_shuffle_epi32(converted, _MM_SHUFFLE(0, 3, 2, 1));
__m128i shuffled2 = _mm_shuffle_epi32(converted, _MM_SHUFFLE(1, 0, 3, 2));
__m128i shuffled3 = _mm_shuffle_epi32(converted, _MM_SHUFFLE(2, 1, 0, 3));

_mm_store_ss((float*)z, (__m128)converted);
_mm_store_ss((float*)z+1, (__m128)shuffled1);
_mm_store_ss((float*)z+2, (__m128)shuffled2);
_mm_store_ss((float*)z+3, (__m128)shuffled3);

for (i = 0; i != 4; ++i) {
#if __BYTE_ORDER == __LITTLE_ENDIAN
memcpy (dst, z+i, 3);
#elif __BYTE_ORDER == __BIG_ENDIAN
memcpy (dst, (float*)((char *)&z + 1)+i, 3);
#endif
dst += dst_skip;
}
nsamples -= 4;
src += 4;
}
#endif

int32_t z;

while (nsamples--) {
float_24 (*src, z);
#if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -398,12 +455,13 @@ void sample_move_d24_sS (char *dst, jack_default_audio_sample_t *src, unsigned l
dst += dst_skip;
src++;
}
}
}

void sample_move_dS_s24s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
{
/* ALERT: signed sign-extension portability !!! */

const jack_default_audio_sample_t scaling = 1.0/SAMPLE_24BIT_SCALING;
while (nsamples--) {
int x;
#if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -427,15 +485,43 @@ void sample_move_dS_s24s (jack_default_audio_sample_t *dst, char *src, unsigned
x |= 0xff << 24;
}
#endif
*dst = x / SAMPLE_24BIT_SCALING;
*dst = x * scaling;
dst++;
src += src_skip;
}
}
}

void sample_move_dS_s24 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
{
/* ALERT: signed sign-extension portability !!! */
const jack_default_audio_sample_t scaling = 1.f/SAMPLE_24BIT_SCALING;

#if defined (__SSE2__) && !defined (__sun__)
const __m128 scaling_block = _mm_set_ps1(scaling);
while (nsamples >= 4) {
int x0, x1, x2, x3;

#if __BYTE_ORDER == __LITTLE_ENDIAN
memcpy((char*)&x0 + 1, src, 3);
memcpy((char*)&x1 + 1, src+src_skip, 3);
memcpy((char*)&x2 + 1, src+2*src_skip, 3);
memcpy((char*)&x3 + 1, src+3*src_skip, 3);
#elif __BYTE_ORDER == __BIG_ENDIAN
memcpy(&x0, src, 3);
memcpy(&x1, src+src_skip, 3);
memcpy(&x2, src+2*src_skip, 3);
memcpy(&x3, src+3*src_skip, 3);
#endif
src += 4 * src_skip;

const __m128i block_i = _mm_set_epi32(x3, x2, x1, x0);
const __m128i shifted = _mm_srai_epi32(block_i, 8);
const __m128 converted = _mm_cvtepi32_ps (shifted);
const __m128 scaled = _mm_mul_ps(converted, scaling_block);
_mm_storeu_ps(dst, scaled);
dst += 4;
nsamples -= 4;
}
#endif

while (nsamples--) {
int x;
@@ -445,11 +531,11 @@ void sample_move_dS_s24 (jack_default_audio_sample_t *dst, char *src, unsigned l
memcpy(&x, src, 3);
#endif
x >>= 8;
*dst = x / SAMPLE_24BIT_SCALING;
*dst = x * scaling;
dst++;
src += src_skip;
}
}
}


void sample_move_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
@@ -636,6 +722,7 @@ void sample_move_dither_shaped_d16_sS (char *dst, jack_default_audio_sample_t *
void sample_move_dS_s16s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
{
short z;
const jack_default_audio_sample_t scaling = 1.0/SAMPLE_16BIT_SCALING;

/* ALERT: signed sign-extension portability !!! */
while (nsamples--) {
@@ -648,7 +735,7 @@ void sample_move_dS_s16s (jack_default_audio_sample_t *dst, char *src, unsigned
z <<= 8;
z |= (unsigned char)(src[0]);
#endif
*dst = z / SAMPLE_16BIT_SCALING;
*dst = z * scaling;
dst++;
src += src_skip;
}
@@ -657,8 +744,9 @@ void sample_move_dS_s16s (jack_default_audio_sample_t *dst, char *src, unsigned
void sample_move_dS_s16 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
{
/* ALERT: signed sign-extension portability !!! */
const jack_default_audio_sample_t scaling = 1.0/SAMPLE_16BIT_SCALING;
while (nsamples--) {
*dst = (*((short *) src)) / SAMPLE_16BIT_SCALING;
*dst = (*((short *) src)) * scaling;
dst++;
src += src_skip;
}


+ 5
- 2
common/wscript View File

@@ -119,7 +119,6 @@ def build(bld):
'JackExternalClient.cpp',
'JackFreewheelDriver.cpp',
'JackInternalClient.cpp',
'JackLoopbackDriver.cpp',
'JackServer.cpp',
'JackThreadedDriver.cpp',
'JackRestartThreadedDriver.cpp',
@@ -212,7 +211,7 @@ def build(bld):
clientlib.defines = 'HAVE_CONFIG_H'
clientlib.uselib = uselib
clientlib.install_path = '${LIBDIR}'
if bld.env['BUILD_JACKDBUS'] == True:
if bld.env['BUILD_JACKDBUS'] == True and bld.env['BUILD_JACKD'] == False:
clientlib.uselib.append('DBUS-1')
clientlib.includes = includes
clientlib.name = 'clientlib'
@@ -258,6 +257,10 @@ def build(bld):
if bld.env['IS_SUN']:
clientlib.env.append_value("LINKFLAGS", "-lnsl -lsocket")

if bld.env['BUILD_WITH_32_64']:
print "create 32bit lib..."
clientlib32bit = clientlib.clone('lib32')
create_jack_process_obj(bld, 'netmanager', 'JackNetManager.cpp', serverlib)

create_jack_process_obj(bld, 'profiler', 'JackProfiler.cpp', serverlib)


+ 65
- 32
dbus/audio_reserve.c View File

@@ -22,74 +22,107 @@
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <stdint.h>

#include "reserve.h"
#include "audio_reserve.h"
#include "JackError.h"

static DBusConnection* connection = NULL;
#define DEVICE_MAX 2

typedef struct reserved_audio_device {

char device_name[64];
rd_device * reserved_device;

} reserved_audio_device;

static DBusConnection* gConnection = NULL;
static reserved_audio_device gReservedDevice[DEVICE_MAX];
static int gReserveCount = 0;

SERVER_EXPORT int audio_reservation_init()
{
DBusError error;
dbus_error_init(&error);

if (!(connection = dbus_bus_get(DBUS_BUS_SESSION, &error))) {
if (!(gConnection = dbus_bus_get(DBUS_BUS_SESSION, &error))) {
jack_error("Failed to connect to session bus for device reservation %s\n", error.message);
return -1;
}

jack_info("audio_reservation_init");
return 0;
}

SERVER_EXPORT int audio_reservation_finish()
{
if (connection)
dbus_connection_unref(connection);
if (gConnection) {
dbus_connection_unref(gConnection);
gConnection = NULL;
jack_info("audio_reservation_finish");
}
return 0;
}

SERVER_EXPORT void* audio_acquire(int num)
SERVER_EXPORT bool audio_acquire(const char * device_name)
{
DBusError error;
rd_device* device;
char audio_name[32];
int e;

snprintf(audio_name, sizeof(audio_name) - 1, "Audio%d", num);
if ((e = rd_acquire(
&device,
connection,
audio_name,
DBusError error;
int ret;

// Open DBus connection first time
if (gReserveCount == 0)
audio_reservation_init();

assert(gReserveCount < DEVICE_MAX);

if ((ret= rd_acquire(
&gReservedDevice[gReserveCount].reserved_device,
gConnection,
device_name,
"Jack audio server",
INT32_MAX,
NULL,
&error)) < 0) {

jack_error("Failed to acquire device name : %s error : %s", audio_name, (error.message ? error.message : strerror(-e)));
return NULL;
jack_error("Failed to acquire device name : %s error : %s", device_name, (error.message ? error.message : strerror(-ret)));
return false;
}

jack_info("Acquire audio card %s", audio_name);
return (void*)device;
strcpy(gReservedDevice[gReserveCount].device_name, device_name);
gReserveCount++;
jack_info("Acquire audio card %s", device_name);
return true;
}

SERVER_EXPORT void audio_reserve_loop()
SERVER_EXPORT void audio_release(const char * device_name)
{
if (connection) {
while (dbus_connection_read_write_dispatch (connection, -1))
; // empty loop body
int i;

// Look for corresponding reserved device
for (i = 0; i < DEVICE_MAX; i++) {
if (strcmp(gReservedDevice[i].device_name, device_name) == 0)
break;
}
if (i < DEVICE_MAX) {
jack_info("Released audio card %s", device_name);
rd_release(gReservedDevice[i].reserved_device);
} else {
jack_error("Audio card %s not found!!", device_name);
}

// Close DBus connection last time
gReserveCount--;
if (gReserveCount == 0)
audio_reservation_finish();
}

SERVER_EXPORT void audio_release(void* dev)
SERVER_EXPORT void audio_reserve_loop()
{
rd_device* device = (rd_device*)dev;
if (device) {
jack_info("Release audio card");
rd_release(device);
} else {
jack_info("No audio card to release...");
}
if (gConnection != NULL) {
while (dbus_connection_read_write_dispatch (gConnection, -1))
; // empty loop body
}
}


+ 3
- 2
dbus/audio_reserve.h View File

@@ -20,6 +20,7 @@
#define __audio_reserve__

#include "JackCompilerDeps.h"
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
@@ -28,8 +29,8 @@ extern "C" {
SERVER_EXPORT int audio_reservation_init();
SERVER_EXPORT int audio_reservation_finish();

SERVER_EXPORT void* audio_acquire(int num);
SERVER_EXPORT void audio_release(void* dev);
SERVER_EXPORT bool audio_acquire(const char * device_name);
SERVER_EXPORT void audio_release(const char * device_name);
SERVER_EXPORT void audio_reserve_loop();

#ifdef __cplusplus


+ 64
- 1
dbus/controller.c View File

@@ -29,6 +29,7 @@
#include "controller.h"
#include "controller_internal.h"
#include "xml.h"
#include "reserve.h"

struct jack_dbus_interface_descriptor * g_jackcontroller_interfaces[] =
{
@@ -279,6 +280,68 @@ jack_controller_switch_master(
return TRUE;
}

#define DEVICE_MAX 2

typedef struct reserved_audio_device {

char device_name[64];
rd_device * reserved_device;

} reserved_audio_device;


int g_device_count = 0;
static reserved_audio_device g_reserved_device[DEVICE_MAX];

static
bool
on_device_acquire(const char * device_name)
{
int ret;
DBusError error;

ret = rd_acquire(
&g_reserved_device[g_device_count].reserved_device,
g_connection,
device_name,
"Jack audio server",
INT32_MAX,
NULL,
&error);
if (ret < 0)
{
jack_error("Failed to acquire device name : %s error : %s", device_name, (error.message ? error.message : strerror(-ret)));
return false;
}

strcpy(g_reserved_device[g_device_count].device_name, device_name);
g_device_count++;
jack_info("Acquired audio card %s", device_name);
return true;
}

static
void
on_device_release(const char * device_name)
{
int i;

// Look for corresponding reserved device
for (i = 0; i < DEVICE_MAX; i++) {
if (strcmp(g_reserved_device[i].device_name, device_name) == 0)
break;
}
if (i < DEVICE_MAX) {
jack_info("Released audio card %s", device_name);
rd_release(g_reserved_device[i].reserved_device);
} else {
jack_error("Audio card %s not found!!", device_name);
}

g_device_count--;
}

void *
jack_controller_create(
DBusConnection *connection)
@@ -303,7 +366,7 @@ jack_controller_create(
goto fail;
}

controller_ptr->server = jackctl_server_create();
controller_ptr->server = jackctl_server_create(on_device_acquire, on_device_release);
if (controller_ptr->server == NULL)
{
jack_error("Failed to create server object");


+ 1
- 0
dbus/jackdbus.h View File

@@ -312,5 +312,6 @@ jack_dbus_send_signal(
#define JACK_CONTROLLER_OBJECT_PATH "/org/jackaudio/Controller"

extern struct jack_dbus_interface_descriptor * g_jackcontroller_interfaces[];
extern DBusConnection * g_connection;

#endif /* #ifndef DBUS_H__3DB2458F_44B2_43EA_882A_9F888DF71A88__INCLUDED */

+ 9
- 9
dbus/reserve.c View File

@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <stdint.h>

#include "reserve.h"

@@ -120,7 +121,7 @@ static DBusHandlerResult object_handler(

dbus_error_init(&error);

d = userdata;
d = (rd_device*)userdata;
assert(d->ref >= 1);

if (dbus_message_is_method_call(
@@ -296,7 +297,7 @@ static DBusHandlerResult filter_handler(

dbus_error_init(&error);

d = userdata;
d = (rd_device*)userdata;

if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameLost")) {
const char *name;
@@ -352,10 +353,7 @@ oom:
return DBUS_HANDLER_RESULT_NEED_MEMORY;
}


static const struct DBusObjectPathVTable vtable ={
.message_function = object_handler
};
static DBusObjectPathVTable vtable;

int rd_acquire(
rd_device **_d,
@@ -372,6 +370,8 @@ int rd_acquire(
DBusMessage *m = NULL, *reply = NULL;
dbus_bool_t good;

vtable.message_function = object_handler;

if (!error)
error = &_error;

@@ -389,7 +389,7 @@ int rd_acquire(
if (!request_cb && priority != INT32_MAX)
return -EINVAL;

if (!(d = calloc(sizeof(rd_device), 1)))
if (!(d = (rd_device *)calloc(sizeof(rd_device), 1)))
return -ENOMEM;

d->ref = 1;
@@ -408,13 +408,13 @@ int rd_acquire(
d->connection = dbus_connection_ref(connection);
d->request_cb = request_cb;

if (!(d->service_name = malloc(sizeof(SERVICE_PREFIX) + strlen(device_name)))) {
if (!(d->service_name = (char*)malloc(sizeof(SERVICE_PREFIX) + strlen(device_name)))) {
r = -ENOMEM;
goto fail;
}
sprintf(d->service_name, SERVICE_PREFIX "%s", d->device_name);

if (!(d->object_path = malloc(sizeof(OBJECT_PREFIX) + strlen(device_name)))) {
if (!(d->object_path = (char*)malloc(sizeof(OBJECT_PREFIX) + strlen(device_name)))) {
r = -ENOMEM;
goto fail;
}


+ 15
- 0
dbus/reserve.h View File

@@ -28,6 +28,13 @@
#include <dbus/dbus.h>
#include <inttypes.h>

# ifndef INT32_MIN
# define INT32_MIN (-2147483647-1)
# endif
# ifndef INT32_MAX
# define INT32_MAX (2147483647)
# endif

typedef struct rd_device rd_device;

/* Prototype for a function that is called whenever someone else wants
@@ -40,6 +47,10 @@ typedef int (*rd_request_cb_t)(
rd_device *d,
int forced); /* Non-zero if an application forcibly took the lock away without asking. If this is the case then the return value of this call is ignored. */

#ifdef __cplusplus
extern "C" {
#endif

/* Try to lock the device. Returns 0 on success, a negative errno
* style return value on error. The DBus error might be set as well if
* the error was caused D-Bus. */
@@ -66,4 +77,8 @@ void rd_set_userdata(rd_device *d, void *userdata);
* userdata was set. */
void* rd_get_userdata(rd_device *d);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif

+ 5
- 2
dbus/wscript View File

@@ -32,10 +32,12 @@ def configure(conf):
if conf.is_defined('HAVE_EXPAT'):
conf.env['LIB_EXPAT'] = ['expat']

conf.env['BUILD_JACKDBUS'] = conf.is_defined('HAVE_EXPAT') and conf.is_defined('HAVE_DBUS_1')
conf.env['BUILD_JACKDBUS1'] = conf.is_defined('HAVE_EXPAT') and conf.is_defined('HAVE_DBUS_1')


def build(bld):
if bld.env["BUILD_JACKDBUS"] != True:

if bld.env['BUILD_JACKDBUS1'] != True:
return

obj = bld.new_task_gen('cc', 'program')
@@ -59,6 +61,7 @@ def build(bld):
#'xml_nop.c',
'xml_write_raw.c',
'sigsegv.c',
'reserve.c',
]
if bld.env['IS_LINUX']:
obj.uselib = 'PTHREAD DL RT DBUS-1 EXPAT'


+ 1
- 1
doxyfile View File

@@ -304,7 +304,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.

INPUT = common posix macosx macosx/coreaudio/ linux linux/alsa windows windows/portaudio common/jack/control.h
INPUT = common posix macosx macosx/coreaudio/ linux linux/alsa windows windows/portaudio common/jack/

# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp


+ 1
- 1
example-clients/server_control.cpp View File

@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
}
}
server = jackctl_server_create();
server = jackctl_server_create(NULL, NULL);
parameters = jackctl_server_get_parameters(server);
/*


+ 94
- 44
linux/alsa/JackAlsaDriver.cpp View File

@@ -48,8 +48,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "usx2y.h"
#include "generic.h"
#include "memops.h"
#include "JackServerGlobals.h"

#include "audio_reserve.h"

//#define DEBUG_WAKEUP 1

@@ -104,31 +104,48 @@ JackAlsaDriver::alsa_driver_check_capabilities (alsa_driver_t *driver)
return 0;
}

int
JackAlsaDriver::alsa_driver_check_card_type (alsa_driver_t *driver)
static
char *
get_control_device_name (const char * device_name)
{
int err;
snd_ctl_card_info_t *card_info;
char * ctl_name;
regex_t expression;

snd_ctl_card_info_alloca (&card_info);

regcomp(&expression, "(plug)?hw:[0-9](,[0-9])?", REG_ICASE | REG_EXTENDED);

if (!regexec(&expression, driver->alsa_name_playback, 0, NULL, 0)) {
if (!regexec(&expression, device_name, 0, NULL, 0)) {
/* the user wants a hw or plughw device, the ctl name
* should be hw:x where x is the card number */

char tmp[5];
strncpy(tmp, strstr(driver->alsa_name_playback, "hw"), 4);
strncpy(tmp, strstr(device_name, "hw"), 4);
tmp[4] = '\0';
jack_log("control device %s", tmp);
//jack_log("control device %s", tmp);
ctl_name = strdup(tmp);
} else {
ctl_name = strdup(driver->alsa_name_playback);
ctl_name = strdup(device_name);
}

regfree(&expression);

if (ctl_name == NULL) {
jack_error("strdup(\"%s\") failed.", ctl_name);
}

return ctl_name;
}

int
JackAlsaDriver::alsa_driver_check_card_type (alsa_driver_t *driver)
{
int err;
snd_ctl_card_info_t *card_info;
char * ctl_name;

snd_ctl_card_info_alloca (&card_info);

ctl_name = get_control_device_name(driver->alsa_name_playback);

// XXX: I don't know the "right" way to do this. Which to use
// driver->alsa_name_playback or driver->alsa_name_capture.
if ((err = snd_ctl_open (&driver->ctl_handle, ctl_name, 0)) < 0) {
@@ -145,9 +162,8 @@ JackAlsaDriver::alsa_driver_check_card_type (alsa_driver_t *driver)
}

driver->alsa_driver = strdup(snd_ctl_card_info_get_driver (card_info));
jack_info("Using ALSA driver %s running on %s", driver->alsa_driver, snd_ctl_card_info_get_longname(card_info));
jack_info("Using ALSA driver %s running on card %i - %s", driver->alsa_driver, snd_ctl_card_info_get_card(card_info), snd_ctl_card_info_get_longname(card_info));

regfree(&expression);
free(ctl_name);

return alsa_driver_check_capabilities (driver);
@@ -2143,22 +2159,45 @@ int JackAlsaDriver::Detach()
return JackAudioDriver::Detach();
}

#if defined(JACK_DBUS)
static int card_to_num(const char* device)
{
const char* t;
int i;
int err;
char* ctl_name;
snd_ctl_card_info_t *card_info;
snd_ctl_t* ctl_handle;
int i = -1;

if ((t = strchr(device, ':')))
device = t + 1;
snd_ctl_card_info_alloca (&card_info);

if ((i = snd_card_get_index(device)) < 0) {
i = atoi(device);
ctl_name = get_control_device_name(device);
if (ctl_name == NULL) {
jack_error("get_control_device_name() failed.");
goto fail;
}

if ((err = snd_ctl_open (&ctl_handle, ctl_name, 0)) < 0) {
jack_error ("control open \"%s\" (%s)", ctl_name,
snd_strerror(err));
goto free;
}

if ((err = snd_ctl_card_info(ctl_handle, card_info)) < 0) {
jack_error ("control hardware info \"%s\" (%s)",
device, snd_strerror (err));
goto close;
}

i = snd_ctl_card_info_get_card(card_info);

close:
snd_ctl_close(ctl_handle);

free:
free(ctl_name);

fail:
return i;
}
#endif

int JackAlsaDriver::Open(jack_nframes_t nframes,
jack_nframes_t user_nperiods,
@@ -2192,25 +2231,24 @@ int JackAlsaDriver::Open(jack_nframes_t nframes,
else if (strcmp(midi_driver_name, "raw") == 0)
midi = alsa_rawmidi_new((jack_client_t*)this);

#if defined(JACK_DBUS)
if (audio_reservation_init() < 0) {
jack_error("Audio device reservation service not available....");
} else if (strcmp(capture_driver_name, playback_driver_name) == 0) { // Same device for input and output
fReservedCaptureDevice = audio_acquire(card_to_num(capture_driver_name));
if (fReservedCaptureDevice == NULL) {
jack_error("Error audio device %s cannot be acquired, trying to open it anyway...", capture_driver_name);
}
} else {
fReservedCaptureDevice = audio_acquire(card_to_num(capture_driver_name));
if (fReservedCaptureDevice == NULL) {
jack_error("Error capture audio device %s cannot be acquired, trying to open it anyway...", capture_driver_name);
}
fReservedPlaybackDevice = audio_acquire(card_to_num(playback_driver_name));
if (fReservedPlaybackDevice == NULL) {
jack_error("Error playback audio device %s cannot be acquired, trying to open it anyway...", playback_driver_name);
}
if (JackServerGlobals::on_device_acquire != NULL)
{
int capture_card = card_to_num(capture_driver_name);
int playback_card = card_to_num(playback_driver_name);
char audio_name[32];
snprintf(audio_name, sizeof(audio_name) - 1, "Audio%d", capture_card);
if (!JackServerGlobals::on_device_acquire(audio_name)) {
jack_error("Audio device %s cannot be acquired, trying to open it anyway...", capture_driver_name);
}
if (playback_card != capture_card) {
snprintf(audio_name, sizeof(audio_name) - 1, "Audio%d", playback_card);
if (!JackServerGlobals::on_device_acquire(audio_name)) {
jack_error("Audio device %s cannot be acquired, trying to open it anyway...", playback_driver_name);
}
}
}
#endif

fDriver = alsa_driver_new ("alsa_pcm", (char*)playback_driver_name, (char*)capture_driver_name,
NULL,
@@ -2245,11 +2283,23 @@ int JackAlsaDriver::Close()
{
JackAudioDriver::Close();
alsa_driver_delete((alsa_driver_t*)fDriver);
#if defined(JACK_DBUS)
audio_release(fReservedCaptureDevice);
audio_release(fReservedPlaybackDevice);
audio_reservation_finish();
#endif

if (JackServerGlobals::on_device_release != NULL)
{
char audio_name[32];
int capture_card = card_to_num(fCaptureDriverName);
if (capture_card >= 0) {
snprintf(audio_name, sizeof(audio_name) - 1, "Audio%d", capture_card);
JackServerGlobals::on_device_release(audio_name);
}

int playback_card = card_to_num(fPlaybackDriverName);
if (playback_card >= 0 && playback_card != capture_card) {
snprintf(audio_name, sizeof(audio_name) - 1, "Audio%d", playback_card);
JackServerGlobals::on_device_release(audio_name);
}
}

return 0;
}



+ 4
- 4
linux/alsa/JackAlsaDriver.h View File

@@ -40,8 +40,8 @@ class JackAlsaDriver : public JackAudioDriver
private:

jack_driver_t* fDriver;
void* fReservedCaptureDevice;
void* fReservedPlaybackDevice;
int fReservedCaptureDevice;
int fReservedPlaybackDevice;
void alsa_driver_release_channel_dependent_memory(alsa_driver_t *driver);
int alsa_driver_check_capabilities(alsa_driver_t *driver);
@@ -121,8 +121,8 @@ class JackAlsaDriver : public JackAudioDriver
JackAlsaDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
: JackAudioDriver(name, alias, engine, table)
,fDriver(NULL)
,fReservedCaptureDevice(NULL)
,fReservedPlaybackDevice(NULL)
,fReservedCaptureDevice(-1)
,fReservedPlaybackDevice(-1)
{}
virtual ~JackAlsaDriver()
{}


+ 4
- 2
linux/alsa/hammerfall.c View File

@@ -206,8 +206,10 @@ hammerfall_release (jack_hardware_t *hw)
return;
}

pthread_cancel (h->monitor_thread);
pthread_join (h->monitor_thread, &status);
if (h->monitor_thread) {
pthread_cancel (h->monitor_thread);
pthread_join (h->monitor_thread, &status);
}

free (h);
}


+ 7
- 6
linux/wscript View File

@@ -31,10 +31,14 @@ def build(bld):
jackd.includes = ['../linux', '../posix', '../common/jack', '../common', '../dbus']
jackd.defines = 'HAVE_CONFIG_H'
jackd.source = ['../common/Jackdmp.cpp']
jackd.uselib = 'PTHREAD DL RT'
if bld.env['IS_LINUX'] and bld.env['BUILD_JACKDBUS']:
jackd.source += ['../dbus/reserve.c', '../dbus/audio_reserve.c']
jackd.uselib = 'PTHREAD DL RT DBUS-1'
else:
jackd.uselib = 'PTHREAD DL RT'
jackd.uselib_local = 'serverlib'
jackd.target = 'jackd'

create_jack_driver_obj(bld, 'dummy', '../common/JackDummyDriver.cpp')
alsa_driver_src = ['alsa/JackAlsaDriver.cpp',
@@ -47,10 +51,6 @@ def build(bld):
'alsa/hammerfall.c',
'alsa/ice1712.c'
]
if bld.env['BUILD_JACKDBUS']:
alsa_driver_src += ['../dbus/reserve.c', '../dbus/audio_reserve.c']

if bld.env['BUILD_DRIVER_ALSA'] == True:
create_jack_driver_obj(bld, 'alsa', alsa_driver_src, "ALSA")
@@ -63,3 +63,4 @@ def build(bld):

create_jack_driver_obj(bld, 'net', '../common/JackNetDriver.cpp')

create_jack_driver_obj(bld, 'loopback', '../common/JackLoopbackDriver.cpp')

+ 1
- 1
macosx/Jack-Info.plist View File

@@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.9.2</string>
<string>1.9.3</string>
</dict>
</plist>

+ 1
- 1
macosx/JackMachSemaphore.h View File

@@ -47,7 +47,7 @@ class SERVER_EXPORT JackMachSemaphore : public detail::JackSynchro

public:

JackMachSemaphore(): fSemaphore(0)
JackMachSemaphore():JackSynchro(), fSemaphore(0)
{}

bool Signal();


+ 1
- 3
macosx/JackPlatformPlug_os.h View File

@@ -35,7 +35,7 @@ namespace Jack

/* __JackPlatformMutex__ */
#include "JackPosixMutex.h"
namespace Jack {typedef JackPosixMutex JackMutex; }
namespace Jack { typedef JackPosixMutex JackMutex; }

/* __JackPlatformThread__ */
#include "JackMachThread.h"
@@ -47,8 +47,6 @@ namespace Jack { typedef JackMachSemaphore JackSynchro; }

/* __JackPlatformProcessSync__ */
#include "JackProcessSync.h"
//#include "JackMachProcessSync.h"
//namespace Jack { typedef JackMachProcessSync JackProcessSync; }
/* Only on windows a special JackProcessSync is used. It is directly defined by including JackProcessSync.h here */

/* __JackPlatformServerChannel__ */


+ 1776
- 385
macosx/Jackdmp.xcodeproj/project.pbxproj
File diff suppressed because it is too large
View File


+ 8
- 3
macosx/coreaudio/JackCoreAudioDriver.cpp View File

@@ -26,7 +26,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackDriverLoader.h"
#include "JackGlobals.h"
#include "JackCompilerDeps.h"

#include <iostream>
#include <CoreServices/CoreServices.h>

namespace Jack
{
@@ -255,19 +257,22 @@ OSStatus JackCoreAudioDriver::DeviceNotificationCallback(AudioDeviceID inDevice,
switch (inPropertyID) {

case kAudioDeviceProcessorOverload:
case kAudioDeviceProcessorOverload: {
jack_error("JackCoreAudioDriver::DeviceNotificationCallback kAudioDeviceProcessorOverload");
jack_time_t cur_time = GetMicroSeconds();
driver->NotifyXRun(cur_time, float(cur_time - driver->fBeginDateUst)); // Better this value than nothing...
break;
}

case kAudioDevicePropertyStreamConfiguration:
case kAudioDevicePropertyStreamConfiguration: {
jack_error("Cannot handle kAudioDevicePropertyStreamConfiguration : server may not work correctly anymore...");
return kAudioHardwareUnsupportedOperationError;
}
case kAudioDevicePropertyNominalSampleRate:
case kAudioDevicePropertyNominalSampleRate: {
jack_error("Cannot handle kAudioDevicePropertyNominalSampleRate : server may not work correctly anymore...");
return kAudioHardwareUnsupportedOperationError;
}
/*
case kAudioDevicePropertyNominalSampleRate: {


+ 2
- 0
macosx/install_jackdmp View File

@@ -15,7 +15,9 @@ sudo cp jackdmp /usr/local/bin
# Copy drivers
sudo install -d /usr/local/lib/jackmp
sudo cp jack_coreaudio.so /usr/local/lib/jackmp
sudo cp jack_coremidi.so /usr/local/lib/jackmp
sudo cp jack_dummy.so /usr/local/lib/jackmp
sudo cp jack_loopback.so /usr/local/lib/jackmp
[ -f jack_net.so ] && sudo cp jack_net.so /usr/local/lib/jackmp

# Copy tools


+ 2
- 0
macosx/wscript View File

@@ -58,6 +58,8 @@ def build(bld):

create_jack_driver_obj(bld, 'dummy', '../common/JackDummyDriver.cpp')

create_jack_driver_obj(bld, 'loopback', '../common/JackLoopbackDriver.cpp')

create_jack_audio_driver_obj(bld, 'coreaudio', 'coreaudio/JackCoreAudioDriver.cpp')

create_jack_midi_driver_obj(bld, 'coremidi', 'coremidi/JackCoreMidiDriver.cpp')


+ 1
- 1
posix/JackFifo.h View File

@@ -48,7 +48,7 @@ class SERVER_EXPORT JackFifo : public detail::JackSynchro

public:

JackFifo(): fFifo( -1)
JackFifo():JackSynchro(), fFifo(-1)
{}

bool Signal();


+ 1
- 1
posix/JackPosixSemaphore.h View File

@@ -46,7 +46,7 @@ class SERVER_EXPORT JackPosixSemaphore : public detail::JackSynchro

public:

JackPosixSemaphore(): fSemaphore(NULL)
JackPosixSemaphore():JackSynchro(), fSemaphore(NULL)
{}

bool Signal();


+ 5
- 3
posix/JackPosixServerLaunch.cpp View File

@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

using namespace Jack;

#if defined(JACK_DBUS)
#if defined(USE_LIBDBUS_AUTOLAUNCH)

#include <dbus/dbus.h>

@@ -73,7 +73,7 @@ static int start_server_dbus(const char* server_name)
return 0;
}

#endif
#else

/* Exec the JACK server in this process. Does not return. */
static void start_server_classic_aux(const char* server_name)
@@ -189,13 +189,15 @@ static int start_server_classic(const char* server_name)
return 0; /* (probably) successful */
}

#endif

static int start_server(const char* server_name, jack_options_t options)
{
if ((options & JackNoStartServer) || getenv("JACK_NO_START_SERVER")) {
return 1;
}

#if defined(JACK_DBUS)
#if defined(USE_LIBDBUS_AUTOLAUNCH)
return start_server_dbus(server_name);
#else
return start_server_classic(server_name);


+ 149
- 142
solaris/oss/JackBoomerDriver.cpp View File

@@ -61,7 +61,8 @@ struct OSSCycleTable {
};

OSSCycleTable gCycleTable;
int gCycleCount = 0;
int gCycleReadCount = 0;
int gCycleWriteCount = 0;

#endif

@@ -229,6 +230,26 @@ void JackBoomerDriver::DisplayDeviceInfo()
}
}

JackBoomerDriver::JackBoomerDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
: JackAudioDriver(name, alias, engine, table),
fInFD(-1), fOutFD(-1), fBits(0),
fSampleFormat(0), fNperiods(0), fRWMode(0), fExcl(false), fIgnoreHW(true),
fInputBufferSize(0), fOutputBufferSize(0),
fInputBuffer(NULL), fOutputBuffer(NULL),
fInputThread(&fInputHandler), fOutputThread(&fOutputHandler),
fInputHandler(this), fOutputHandler(this)
{
sem_init(&fReadSema, 0, 0);
sem_init(&fWriteSema, 0, 0);
}

JackBoomerDriver::~JackBoomerDriver()
{
sem_destroy(&fReadSema);
sem_destroy(&fWriteSema);
}

int JackBoomerDriver::OpenInput()
{
int flags = 0;
@@ -395,11 +416,11 @@ int JackBoomerDriver::Open(jack_nframes_t nframes,
return -1;
} else {

if (fEngineControl->fSyncMode) {
jack_error("Cannot run in synchronous mode, remove the -S parameter for jackd");
if (!fEngineControl->fSyncMode) {
jack_error("Cannot run in asynchronous mode, use the -S parameter for jackd");
return -1;
}
fRWMode |= ((capturing) ? kRead : 0);
fRWMode |= ((playing) ? kWrite : 0);
fBits = bits;
@@ -428,7 +449,7 @@ int JackBoomerDriver::Close()
if (file) {
jack_info("Writing OSS driver timing data....");
for (int i = 1; i < gCycleCount; i++) {
for (int i = 1; i < std::min(gCycleReadCount, gCycleWriteCount); i++) {
int d1 = gCycleTable.fTable[i].fAfterRead - gCycleTable.fTable[i].fBeforeRead;
int d2 = gCycleTable.fTable[i].fAfterReadConvert - gCycleTable.fTable[i].fAfterRead;
int d3 = gCycleTable.fTable[i].fAfterWrite - gCycleTable.fTable[i].fBeforeWrite;
@@ -487,15 +508,6 @@ int JackBoomerDriver::OpenAux()
return -1;
}
// Prepare ringbuffers used for output
if (fPlaybackChannels > 0) {
fRingBuffer = new jack_ringbuffer_t*[fPlaybackChannels];
for (int i = 0; i < fPlaybackChannels; i++) {
fRingBuffer[i] = jack_ringbuffer_create(fOutputBufferSize * 2);
jack_ringbuffer_read_advance(fRingBuffer[i], fOutputBufferSize);
}
}

DisplayDeviceInfo();
return 0;
}
@@ -519,15 +531,6 @@ void JackBoomerDriver::CloseAux()
if (fOutputBuffer)
free(fOutputBuffer);
fOutputBuffer = NULL;
for (int i = 0; i < fPlaybackChannels; i++) {
if (fRingBuffer[i])
jack_ringbuffer_free(fRingBuffer[i]);
fRingBuffer[i] = NULL;
}
delete [] fRingBuffer;
fRingBuffer = NULL;
}

int JackBoomerDriver::Start()
@@ -535,10 +538,18 @@ int JackBoomerDriver::Start()
jack_log("JackBoomerDriver::Start");
JackAudioDriver::Start();

// Start input thread only when needed
if (fInFD > 0) {
if (fInputThread.StartSync() < 0) {
jack_error("Cannot start input thread");
return -1;
}
}

// Start output thread only when needed
if (fOutFD > 0) {
if (fThread.StartSync() < 0) {
jack_error("Cannot start thread");
if (fOutputThread.StartSync() < 0) {
jack_error("Cannot start output thread");
return -1;
}
}
@@ -548,42 +559,81 @@ int JackBoomerDriver::Start()

int JackBoomerDriver::Stop()
{
// Stop input thread only when needed
if (fInFD > 0) {
fInputThread.Kill();
}

// Stop output thread only when needed
if (fOutFD > 0) {
return fThread.Kill();
} else {
return 0;
fOutputThread.Kill();
}

return 0;
}

int JackBoomerDriver::Read()
{
if (fInFD < 0) {
/*
// Keep begin cycle time
JackDriver::CycleTakeBeginTime();
*/

return 0;
}

int JackBoomerDriver::Write()
{
/*
// Keep begin cycle time
JackDriver::CycleTakeEndTime();
*/

return 0;
}

bool JackBoomerDriver::JackBoomerDriverInput::Init()
{
if (fDriver->IsRealTime()) {
jack_log("JackBoomerDriverInput::Init IsRealTime");
if (fDriver->fInputThread.AcquireRealTime(GetEngineControl()->fServerPriority) < 0) {
jack_error("AcquireRealTime error");
} else {
set_threaded_log_function();
}
}
return true;
}

bool JackBoomerDriver::JackBoomerDriverInput::Execute()
{
if (fDriver->fInFD < 0) {
// Keep begin cycle time
JackDriver::CycleTakeBeginTime();
return 0;
fDriver->CycleTakeBeginTime();
return true;
}
#ifdef JACK_MONITOR
gCycleTable.fTable[gCycleCount].fBeforeRead = GetMicroSeconds();
gCycleTable.fTable[gCycleReadCount].fBeforeRead = GetMicroSeconds();
#endif

audio_errinfo ei_in;
ssize_t count = ::read(fInFD, fInputBuffer, fInputBufferSize);
ssize_t count = ::read(fDriver->fInFD, fDriver->fInputBuffer, fDriver->fInputBufferSize);
#ifdef JACK_MONITOR
if (count > 0 && count != (int)fInputBufferSize)
jack_log("JackBoomerDriver::Read count = %ld", count / (fSampleSize * fCaptureChannels));
gCycleTable.fTable[gCycleCount].fAfterRead = GetMicroSeconds();
if (count > 0 && count != (int)fDriver->fInputBufferSize)
jack_log("JackBoomerDriverInput::Execute count = %ld", count / (fDriver->fSampleSize * fDriver->fCaptureChannels));
gCycleTable.fTable[gCycleReadCount].fAfterRead = GetMicroSeconds();
#endif
// XRun detection
if (ioctl(fInFD, SNDCTL_DSP_GETERROR, &ei_in) == 0) {
if (ioctl(fDriver->fInFD, SNDCTL_DSP_GETERROR, &ei_in) == 0) {

if (ei_in.rec_overruns > 0 ) {
jack_error("JackBoomerDriver::Read overruns");
jack_error("JackBoomerDriverInput::Execute overruns");
jack_time_t cur_time = GetMicroSeconds();
NotifyXRun(cur_time, float(cur_time - fBeginDateUst)); // Better this value than nothing...
fDriver->NotifyXRun(cur_time, float(cur_time - fDriver->fBeginDateUst)); // Better this value than nothing...
}

if (ei_in.rec_errorcount > 0 && ei_in.rec_lasterror != 0) {
@@ -592,47 +642,34 @@ int JackBoomerDriver::Read()
}
if (count < 0) {
jack_log("JackBoomerDriver::Read error = %s", strerror(errno));
return -1;
} else if (count < (int)fInputBufferSize) {
jack_error("JackBoomerDriver::Read error bytes read = %ld", count);
return -1;
jack_log("JackBoomerDriverInput::Execute error = %s", strerror(errno));
} else if (count < (int)fDriver->fInputBufferSize) {
jack_error("JackBoomerDriverInput::Execute error bytes read = %ld", count);
} else {

// Keep begin cycle time
JackDriver::CycleTakeBeginTime();
for (int i = 0; i < fCaptureChannels; i++) {
if (fGraphManager->GetConnectionsNum(fCapturePortList[i]) > 0) {
CopyAndConvertIn(GetInputBuffer(i), fInputBuffer, fEngineControl->fBufferSize, i, fCaptureChannels, fBits);
fDriver->CycleTakeBeginTime();
for (int i = 0; i < fDriver->fCaptureChannels; i++) {
if (fDriver->fGraphManager->GetConnectionsNum(fDriver->fCapturePortList[i]) > 0) {
CopyAndConvertIn(fDriver->GetInputBuffer(i), fDriver->fInputBuffer, fDriver->fEngineControl->fBufferSize, i, fDriver->fCaptureChannels, fDriver->fBits);
}
}

#ifdef JACK_MONITOR
gCycleTable.fTable[gCycleCount].fAfterReadConvert = GetMicroSeconds();
gCycleTable.fTable[gCycleReadCount].fAfterReadConvert = GetMicroSeconds();
gCycleReadCount = (gCycleReadCount == CYCLE_POINTS - 1) ? gCycleReadCount: gCycleReadCount + 1;
#endif
return 0;
}
}

int JackBoomerDriver::Write()
{
for (int i = 0; i < fPlaybackChannels; i++) {
if (fGraphManager->GetConnectionsNum(fPlaybackPortList[i]) > 0) {
if (jack_ringbuffer_write(fRingBuffer[i], (char*)GetOutputBuffer(i), fOutputBufferSize) < fOutputBufferSize) {
jack_log("JackBoomerDriver::Write ringbuffer full");
}
}
}

return 0;
fDriver->SynchronizeRead();
return true;
}

bool JackBoomerDriver::Init()
bool JackBoomerDriver::JackBoomerDriverOutput::Init()
{
if (IsRealTime()) {
jack_log("JackBoomerDriver::Init IsRealTime");
if (fThread.AcquireRealTime(GetEngineControl()->fServerPriority) < 0) {
if (fDriver->IsRealTime()) {
jack_log("JackBoomerDriverOutput::Init IsRealTime");
if (fDriver->fOutputThread.AcquireRealTime(GetEngineControl()->fServerPriority) < 0) {
jack_error("AcquireRealTime error");
} else {
set_threaded_log_function();
@@ -640,83 +677,64 @@ bool JackBoomerDriver::Init()
}

// Maybe necessary to write an empty output buffer first time : see http://manuals.opensound.com/developer/fulldup.c.html
memset(fOutputBuffer, 0, fOutputBufferSize);
memset(fDriver->fOutputBuffer, 0, fDriver->fOutputBufferSize);

// Prefill ouput buffer
if (fOutFD > 0) {
for (int i = 0; i < fNperiods; i++) {
ssize_t count = ::write(fOutFD, fOutputBuffer, fOutputBufferSize);
if (count < (int)fOutputBufferSize) {
if (fDriver->fOutFD > 0) {
for (int i = 0; i < fDriver->fNperiods; i++) {
ssize_t count = ::write(fDriver->fOutFD, fDriver->fOutputBuffer, fDriver->fOutputBufferSize);
if (count < (int)fDriver->fOutputBufferSize) {
jack_error("JackBoomerDriver::Write error bytes written = %ld", count);
}
}
int delay;
if (ioctl(fOutFD, SNDCTL_DSP_GETODELAY, &delay) == -1) {
if (ioctl(fDriver->fOutFD, SNDCTL_DSP_GETODELAY, &delay) == -1) {
jack_error("JackBoomerDriver::Write error get out delay : %s@%i, errno = %d", __FILE__, __LINE__, errno);
}
delay /= fSampleSize * fPlaybackChannels;
delay /= fDriver->fSampleSize * fDriver->fPlaybackChannels;
jack_info("JackBoomerDriver::Write output latency frames = %ld", delay);
}
return true;
}

bool JackBoomerDriver::Execute()
bool JackBoomerDriver::JackBoomerDriverOutput::Execute()
{
memset(fOutputBuffer, 0, fOutputBufferSize);
for (int i = 0; i < fPlaybackChannels; i++) {
if (fGraphManager->GetConnectionsNum(fPlaybackPortList[i]) > 0) {

jack_ringbuffer_data_t ring_buffer_data[2];
jack_ringbuffer_get_read_vector(fRingBuffer[i], ring_buffer_data);
memset(fDriver->fOutputBuffer, 0, fDriver->fOutputBufferSize);

unsigned int available_frames = (ring_buffer_data[0].len + ring_buffer_data[1].len) / sizeof(float);
jack_log("Output available = %ld", available_frames);

unsigned int needed_bytes = fOutputBufferSize;
float* output = (float*)fOutputBuffer;
for (int j = 0; j < 2; j++) {
unsigned int consumed_bytes = std::min(needed_bytes, ring_buffer_data[j].len);
CopyAndConvertOut(output, (float*)ring_buffer_data[j].buf, consumed_bytes / sizeof(float), i, fPlaybackChannels, fBits);
output += consumed_bytes / sizeof(float);
needed_bytes -= consumed_bytes;
}

if (needed_bytes > 0) {
jack_error("JackBoomerDriver::Execute missing frames = %ld", needed_bytes / sizeof(float));
}

jack_ringbuffer_read_advance(fRingBuffer[i], fOutputBufferSize - needed_bytes);
#ifdef JACK_MONITOR
gCycleTable.fTable[gCycleWriteCount].fBeforeWriteConvert = GetMicroSeconds();
#endif
for (int i = 0; i < fDriver->fPlaybackChannels; i++) {
if (fDriver->fGraphManager->GetConnectionsNum(fDriver->fPlaybackPortList[i]) > 0) {
CopyAndConvertOut(fDriver->fOutputBuffer, fDriver->GetOutputBuffer(i), fDriver->fEngineControl->fBufferSize, i, fDriver->fPlaybackChannels, fDriver->fBits);
}
}
#ifdef JACK_MONITOR
gCycleTable.fTable[gCycleCount].fBeforeWrite = GetMicroSeconds();
gCycleTable.fTable[gCycleWriteCount].fBeforeWrite = GetMicroSeconds();
#endif

// Keep end cycle time
JackDriver::CycleTakeEndTime();
ssize_t count = ::write(fOutFD, fOutputBuffer, fOutputBufferSize);
ssize_t count = ::write(fDriver->fOutFD, fDriver->fOutputBuffer, fDriver->fOutputBufferSize);

#ifdef JACK_MONITOR
if (count > 0 && count != (int)fOutputBufferSize)
jack_log("JackBoomerDriver::Execute count = %ld", count / (fSampleSize * fPlaybackChannels));
gCycleTable.fTable[gCycleCount].fAfterWrite = GetMicroSeconds();
gCycleCount = (gCycleCount == CYCLE_POINTS - 1) ? gCycleCount: gCycleCount + 1;
if (count > 0 && count != (int)fDriver->fOutputBufferSize)
jack_log("JackBoomerDriverOutput::Execute count = %ld", count / (fDriver->fSampleSize * fDriver->fPlaybackChannels));
gCycleTable.fTable[gCycleWriteCount].fAfterWrite = GetMicroSeconds();
gCycleWriteCount = (gCycleWriteCount == CYCLE_POINTS - 1) ? gCycleWriteCount: gCycleWriteCount + 1;
#endif

// XRun detection
audio_errinfo ei_out;
if (ioctl(fOutFD, SNDCTL_DSP_GETERROR, &ei_out) == 0) {
if (ioctl(fDriver->fOutFD, SNDCTL_DSP_GETERROR, &ei_out) == 0) {

if (ei_out.play_underruns > 0) {
jack_error("JackBoomerDriver::Execute underruns");
jack_error("JackBoomerDriverOutput::Execute underruns");
jack_time_t cur_time = GetMicroSeconds();
NotifyXRun(cur_time, float(cur_time - fBeginDateUst)); // Better this value than nothing...
fDriver->NotifyXRun(cur_time, float(cur_time - fDriver->fBeginDateUst)); // Better this value than nothing...
}

if (ei_out.play_errorcount > 0 && ei_out.play_lasterror != 0) {
@@ -725,14 +743,28 @@ bool JackBoomerDriver::Execute()
}
if (count < 0) {
jack_log("JackBoomerDriver::Execute error = %s", strerror(errno));
} else if (count < (int)fOutputBufferSize) {
jack_error("JackBoomerDriver::Execute error bytes written = %ld", count);
jack_log("JackBoomerDriverOutput::Execute error = %s", strerror(errno));
} else if (count < (int)fDriver->fOutputBufferSize) {
jack_error("JackBoomerDriverOutput::Execute error bytes written = %ld", count);
}
fDriver->SynchronizeWrite();
return true;
}

void JackBoomerDriver::SynchronizeRead()
{
sem_wait(&fWriteSema);
Process();
sem_post(&fReadSema);
}

void JackBoomerDriver::SynchronizeWrite()
{
sem_post(&fWriteSema);
sem_wait(&fReadSema);
}

int JackBoomerDriver::SetBufferSize(jack_nframes_t buffer_size)
{
CloseAux();
@@ -740,30 +772,6 @@ int JackBoomerDriver::SetBufferSize(jack_nframes_t buffer_size)
return OpenAux();
}

int JackBoomerDriver::ProcessAsync()
{
// Read input buffers for the current cycle
if (Read() < 0) {
jack_error("JackBoomerDriver::ProcessAsync: read error, skip cycle");
return 0; // Skip cycle, but continue processing...
}

// Write output buffers from the previous cycle
if (Write() < 0) {
jack_error("JackBoomerDriver::ProcessAsync: write error, skip cycle");
return 0; // Skip cycle, but continue processing...
}

if (fIsMaster) {
ProcessGraphAsync();
} else {
fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable);
}
// Keep end cycle time
JackDriver::CycleTakeEndTime();
return 0;
}

} // end of namespace

@@ -985,14 +993,13 @@ EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine
}

Jack::JackBoomerDriver* boomer_driver = new Jack::JackBoomerDriver("system", "boomer", engine, table);
Jack::JackDriverClientInterface* threaded_driver = new Jack::JackThreadedDriver(boomer_driver);
// Special open for OSS driver...
// Special open for Boomer driver...
if (boomer_driver->Open(frames_per_interrupt, nperiods, srate, capture, playback, chan_in, chan_out,
excl, monitor, capture_pcm_name, playback_pcm_name, systemic_input_latency, systemic_output_latency, bits, ignorehwbuf) == 0) {
return threaded_driver;
return boomer_driver;
} else {
delete threaded_driver; // Delete the decorated driver
delete boomer_driver; // Delete the driver
return NULL;
}
}


+ 50
- 19
solaris/oss/JackBoomerDriver.h View File

@@ -23,7 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackAudioDriver.h"
#include "JackPlatformPlug.h"
#include "ringbuffer.h"
//#include "JackThread.h"
#include <semaphore.h>

namespace Jack
{
@@ -43,13 +43,47 @@ typedef jack_default_audio_sample_t jack_sample_t;
\brief The Boomer driver.
*/

class JackBoomerDriver : public JackAudioDriver, public JackRunnableInterface
class JackBoomerDriver : public JackAudioDriver
{

enum { kRead = 1, kWrite = 2, kReadWrite = 3 };

private:

class JackBoomerDriverInput : public JackRunnableInterface {

private:
JackBoomerDriver* fDriver;

public:

JackBoomerDriverInput(JackBoomerDriver* driver): fDriver(driver)
{}
~JackBoomerDriverInput()
{}

bool Init();
bool Execute();
};

class JackBoomerDriverOutput : public JackRunnableInterface {

private:
JackBoomerDriver* fDriver;

public:

JackBoomerDriverOutput(JackBoomerDriver* driver): fDriver(driver)
{}
~JackBoomerDriverOutput()
{}

bool Init();
bool Execute();
};

int fInFD;
int fOutFD;
@@ -66,8 +100,15 @@ class JackBoomerDriver : public JackAudioDriver, public JackRunnableInterface
void* fInputBuffer;
void* fOutputBuffer;
jack_ringbuffer_t** fRingBuffer;
JackThread fThread;
sem_t fReadSema;
sem_t fWriteSema;

JackThread fInputThread;
JackThread fOutputThread;
JackBoomerDriverInput fInputHandler;
JackBoomerDriverOutput fOutputHandler;
int OpenInput();
int OpenOutput();
@@ -75,24 +116,14 @@ class JackBoomerDriver : public JackAudioDriver, public JackRunnableInterface
void CloseAux();
void SetSampleFormat();
void DisplayDeviceInfo();

// Redefining since timing for CPU load is specific
int ProcessAsync();
void SynchronizeRead();
void SynchronizeWrite();

public:

JackBoomerDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
: JackAudioDriver(name, alias, engine, table),
fInFD(-1), fOutFD(-1), fBits(0),
fSampleFormat(0), fNperiods(0), fRWMode(0), fExcl(false), fIgnoreHW(true),
fInputBufferSize(0), fOutputBufferSize(0),
fInputBuffer(NULL), fOutputBuffer(NULL),
fRingBuffer(NULL), fThread(this)
{}

virtual ~JackBoomerDriver()
{}

JackBoomerDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table);
virtual ~JackBoomerDriver();
int Open(jack_nframes_t frames_per_cycle,
int user_nperiods,
jack_nframes_t rate,


+ 1
- 1
solaris/oss/JackOSSDriver.cpp View File

@@ -558,7 +558,7 @@ int JackOSSDriver::Read()
ssize_t count;

#ifdef JACK_MONITOR
gCycleTable.fTable[gCycleCount].fBeforeRead = GetMicroSeconds();
gCycleTable.fTable[gCycleCount].fBeforeRead = GetMicroSeconds();
#endif

audio_errinfo ei_in;


+ 1
- 0
solaris/wscript View File

@@ -34,3 +34,4 @@ def build(bld):

create_jack_driver_obj(bld, 'net', '../common/JackNetDriver.cpp')

create_jack_driver_obj(bld, 'loopback', '../common/JackLoopbackDriver.cpp')

+ 17
- 17
windows/JackCompilerDeps_os.h View File

@@ -18,24 +18,24 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __JackCompilerDeps_WIN32__
#define __JackCompilerDeps_WIN32__
#define __JackCompilerDeps_WIN32__

#if __GNUC__
#ifndef POST_PACKED_STRUCTURE
/* POST_PACKED_STRUCTURE needs to be a macro which
expands into a compiler directive. The directive must
tell the compiler to arrange the preceding structure
declaration so that it is packed on byte-boundaries rather
than use the natural alignment of the processor and/or
compiler.
*/
#if (__GNUC__< 4) /* Does not seem to work with GCC 3.XX serie */
#define POST_PACKED_STRUCTURE
#elif defined(JACK_32_64)
#define POST_PACKED_STRUCTURE __attribute__((__packed__))
#else
#define POST_PACKED_STRUCTURE
#endif
#if __GNUC__
#ifndef POST_PACKED_STRUCTURE
/* POST_PACKED_STRUCTURE needs to be a macro which
expands into a compiler directive. The directive must
tell the compiler to arrange the preceding structure
declaration so that it is packed on byte-boundaries rather
than use the natural alignment of the processor and/or
compiler.
*/
#if (__GNUC__< 4) /* Does not seem to work with GCC 3.XX serie */
#define POST_PACKED_STRUCTURE
#elif defined(JACK_32_64)
#define POST_PACKED_STRUCTURE __attribute__((__packed__))
#else
#define POST_PACKED_STRUCTURE
#endif
#endif
#define MEM_ALIGN(x,y) x __attribute__((aligned(y)))
#define EXPORT __declspec(dllexport)


+ 6
- 6
windows/JackNetWinSocket.cpp View File

@@ -286,12 +286,12 @@ namespace Jack
//local loop*********************************************************************************************************
int JackNetWinSocket::SetLocalLoop()
{
//char disable = 0;
/*
see http://msdn.microsoft.com/en-us/library/aa916098.aspx
Default value is TRUE. When TRUE, data that is sent from the local interface to the multicast group to
which the socket is joined, including data sent from the same socket, will be echoed to its receive buffer.
*/
//char disable = 0;
/*
see http://msdn.microsoft.com/en-us/library/aa916098.aspx
Default value is TRUE. When TRUE, data that is sent from the local interface to the multicast group to
which the socket is joined, including data sent from the same socket, will be echoed to its receive buffer.
*/
char disable = 1;
return SetOption ( IPPROTO_IP, IP_MULTICAST_LOOP, &disable, sizeof ( disable ) );
}


+ 1
- 1
windows/JackTypes_os.h View File

@@ -20,7 +20,7 @@
#ifndef __JackTypes_WIN32__
#define __JackTypes_WIN32__

#include <windows.h>
#include <windows.h>
#include "types.h"

typedef ULONGLONG UInt64;


+ 55
- 55
windows/JackWinProcessSync.cpp View File

@@ -32,7 +32,7 @@ void JackWinProcessSync::LockedSignal()
{
WaitForSingleObject(fMutex, INFINITE);
SetEvent(fEvent);
ReleaseMutex(fMutex);
ReleaseMutex(fMutex);
}

void JackWinProcessSync::SignalAll()
@@ -44,71 +44,71 @@ void JackWinProcessSync::LockedSignalAll()
{
WaitForSingleObject(fMutex, INFINITE);
SetEvent(fEvent);
ReleaseMutex(fMutex);
}
void JackWinProcessSync::Wait()
{
ReleaseMutex(fMutex);
WaitForSingleObject(fEvent, INFINITE);
}
void JackWinProcessSync::LockedWait()
{
/* Does it make sense on Windows, use non-locked version for now... */
Wait();
}
bool JackWinProcessSync::TimedWait(long usec)
{
ReleaseMutex(fMutex);
DWORD res = WaitForSingleObject(fEvent, usec / 1000);
return (res == WAIT_OBJECT_0);
}
bool JackWinProcessSync::LockedTimedWait(long usec)
{
/* Does it make sense on Windows, use non-locked version for now...*/
return TimedWait(usec);
}
/*
Code from CAGuard.cpp : does ot sees to work as expected..
void JackWinProcessSync::Wait()
{
ReleaseMutex(fMutex);
HANDLE handles[] = { fMutex, fEvent };
DWORD res = WaitForMultipleObjects(2, handles, true, INFINITE);
if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
jack_error("Wait error err = %d", GetLastError());
ResetEvent(fEvent);
}
ReleaseMutex(fMutex);
}

void JackWinProcessSync::Wait()
{
ReleaseMutex(fMutex);
WaitForSingleObject(fEvent, INFINITE);
}

void JackWinProcessSync::LockedWait()
{
WaitForSingleObject(fMutex, INFINITE);
{
/* Does it make sense on Windows, use non-locked version for now... */
Wait();
}

bool JackWinProcessSync::TimedWait(long usec)
{
ReleaseMutex(fMutex);
DWORD res = WaitForSingleObject(fEvent, usec / 1000);
return (res == WAIT_OBJECT_0);
}

bool JackWinProcessSync::LockedTimedWait(long usec)
{
/* Does it make sense on Windows, use non-locked version for now...*/
return TimedWait(usec);
}

/*
Code from CAGuard.cpp : does ot sees to work as expected..

void JackWinProcessSync::Wait()
{
ReleaseMutex(fMutex);
HANDLE handles[] = { fMutex, fEvent };
DWORD res = WaitForMultipleObjects(2, handles, true, INFINITE);
if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
jack_error("Wait error err = %d", GetLastError());
ResetEvent(fEvent);
}

void JackWinProcessSync::LockedWait()
{
WaitForSingleObject(fMutex, INFINITE);
ReleaseMutex(fMutex);
HANDLE handles[] = { fMutex, fEvent };
DWORD res = WaitForMultipleObjects(2, handles, true, INFINITE);
if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
jack_error("LockedWait error err = %d", GetLastError());
ResetEvent(fEvent);
ResetEvent(fEvent);
}
bool JackWinProcessSync::TimedWait(long usec)
{
ReleaseMutex(fMutex);
HANDLE handles[] = { fMutex, fEvent };
DWORD res = WaitForMultipleObjects(2, handles, true, usec / 1000);
if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
jack_error("Wait error err = %d", GetLastError());
ResetEvent(fEvent);
bool JackWinProcessSync::TimedWait(long usec)
{
ReleaseMutex(fMutex);
HANDLE handles[] = { fMutex, fEvent };
DWORD res = WaitForMultipleObjects(2, handles, true, usec / 1000);
if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
jack_error("Wait error err = %d", GetLastError());
ResetEvent(fEvent);
}

bool JackWinProcessSync::LockedTimedWait(long usec)
{
WaitForSingleObject(fMutex, INFINITE);
{
WaitForSingleObject(fMutex, INFINITE);
ReleaseMutex(fMutex);
HANDLE handles[] = { fMutex, fEvent };
DWORD res = WaitForMultipleObjects(2, handles, true, usec / 1000);


+ 1
- 1
windows/JackWinSemaphore.h View File

@@ -44,7 +44,7 @@ class JackWinSemaphore : public detail::JackSynchro

public:

JackWinSemaphore(): fSemaphore(NULL)
JackWinSemaphore():JackSynchro(), fSemaphore(NULL)
{}

bool Signal();


+ 26
- 26
windows/JackWinServerLaunch.cpp View File

@@ -1,26 +1,26 @@
/*
Copyright (C) 2001-2003 Paul Davis
Copyright (C) 2004-2008 Grame
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "JackServerLaunch.h"
int try_start_server(jack_varargs_t* va, jack_options_t options, jack_status_t* status)
{
return 0;
}
/*
Copyright (C) 2001-2003 Paul Davis
Copyright (C) 2004-2008 Grame
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "JackServerLaunch.h"
int try_start_server(jack_varargs_t* va, jack_options_t options, jack_status_t* status)
{
return 0;
}

BIN
windows/Setup/JackRouter.dll View File


+ 5
- 1
windows/Setup/README View File

@@ -1,7 +1,11 @@
This folder contains a script to create an installer for windows.
It uses 'CreateInstall Free'(http://www.createinstall.com), a little software allowing to make simple installers.
You can use the 'jack.ci' script to make the installer. For that, you need to build the Code::Blocks workspace in order to have '.exe' and libraries. You also need 'qjackctl' binaries and libraries ('qjackctl.exe', 'mingwm10.dll', 'QtCore4.dll', 'QtGui.dll' and 'QtXml4.dll'). You can recompile qjackctl with qt4 or directly get the binaries. The five files are expected in the 'qjackctl' folder.
You can use the 'jack.ci' script to make the installer. For that, you need to build the Code::Blocks workspace in order to have '.exe' and libraries.
You also need 'qjackctl' binaries and libraries ('qjackctl.exe', 'mingwm10.dll', 'QtCore4.dll', 'QtGui.dll' and 'QtXml4.dll').
You can recompile qjackctl with qt4 or directly get the binaries. The five files are expected in the 'qjackctl' folder.
You also need the Microsoft Visual C++ 2008 Redistributable Package (x86) (the vcrdist_x86.exe file) to be in src folder.
If you need libjack.lib and libjackserver.lib to link with in MS Visual Studio, you can use the MS Tool lib.exe to create the .lib file from de .def.
Just use : 'lib /DEF:libjackserver.def /OUT:libjackserver.lib' and 'lib /DEF:libjack.def /OUT:libjack.lib' to create the lib file.


+ 7
- 3
windows/Setup/jack.ci View File

@@ -1,5 +1,5 @@
<*project
version = 4 civer = "Free v4.14.3" winver = "2.6/5.1.2600" >
version = 4 civer = "Free v4.14.5" winver = "2.6/5.1.2600" >
<output> .</>
<exename> Jack_v1.9.3_setup.exe</>
<digitsign> </>
@@ -38,7 +38,7 @@
<srcfolder> </>
<ifexist> over</>
<runafter> </>
<runconfirm> 0</>
<runconfirm> 1</>
<uninclude> 1</>
<unicon> Uninstall - 2</>
<unshortcut> 1</>
@@ -54,6 +54,7 @@
<bgback> </>
<files listview >
<_><src>..\Release\bin\libjack.a</><dest>inst</><custom>lib</><ifexist>overnewer</><recurs>0</></>
<_><src>.\src\vcredist_x86.exe</><dest>inst</><custom></><ifexist>overnewer</><recurs>0</></>
<_><src>..\Release\bin\libjack.lib</><dest>inst</><custom>lib</><ifexist>overnewer</><recurs>0</></>
<_><src>..\Release\bin\libjack.def</><dest>inst</><custom>lib</><ifexist>overnewer</><recurs>0</></>
<_><src>..\Release\bin\libjackserver.a</><dest>inst</><custom>lib</><ifexist>overnewer</><recurs>0</></>
@@ -72,6 +73,8 @@
<_><src>..\Release\bin\portaudio_x86.dll</><dest>inst</><custom></><ifexist>overnewer</><recurs>0</></>
<_><src>..\Release\bin\jack\jack_net.dll</><dest>inst</><custom>jack</><ifexist>overnewer</><recurs>0</></>
<_><src>..\Release\bin\jack\jack_dummy.dll</><dest>inst</><custom>jack</><ifexist>overnewer</><recurs>0</></>
<_><src>..\Release\bin\jack\jack_loopback.dll</><dest>inst</><custom>jack</><ifexist>overnewer</><recurs>0</></>
<_><src>..\Release\bin\jack\jack_winmme.dll</><dest>inst</><custom>jack</><ifexist>overnewer</><recurs>0</></>
<_><src>..\Release\bin\jack\jack_portaudio.dll</><dest>inst</><custom>jack</><ifexist>overnewer</><recurs>0</></>
<_><src>..\Release\bin\jack\netmanager.dll</><dest>inst</><custom>jack</><ifexist>overnewer</><recurs>0</></>
<_><src>..\Release\bin\jack\audioadapter.dll</><dest>inst</><custom>jack</><ifexist>overnewer</><recurs>0</></>
@@ -99,7 +102,8 @@
</files>
<runx listview >
<_><type>app</><path>inst</><file>vcredist_x86.exe</><cmdline></><wait>1</><workdir>inst</><custdir></><when>end</></>
</runx>
<registry listview >


+ 11
- 6
windows/Setup/src/README View File

@@ -4,11 +4,6 @@ JACK on Windows
This installer will install everything to use Jack Audio Connection Kit (JACK) (www.jackaudio.org) on Windows.
=============================================
Microsoft Runtime Libraries
=============================================
In order to use this software, you will need the Microsoft Visual C++ 2008 redistributable package. This package is freely available on the Microsoft download center. Please be sure you install the correct version (2008). This package is required by portaudio to run windows specific audio drivers (MME, DSound and ASIO).
=============================================
QJACKCTL on Windows
@@ -38,6 +33,16 @@ Then start jackd with the device you want, by using its name, for example:
- jackd -R -S -d portaudio -d "ASIO::MOTU Audio ASIO", then start qjackctl. qjackctl will see the jackd server already running and then can be used normally.
=============================================
Jack MIDI
=============================================
A first version of a JACK MIDI <==> Windows MIDI bridge (using Windows MME API) is available.
If can be activated using the -X parameter in jackd command line. So add "-X winmme" in QJACKCTL settings (something like "jackd -S -X winmme").
The WinMME driver will scan MIDI input/output ports, open corresponding JACK MIDI ports and convert MIDI in/out into JACK MIDI messages.
QJACKCTL MIDI connection windows can then be used.
=============================================
JackRouter JACK/ASIO driver
=============================================
@@ -53,7 +58,7 @@ JackRouter is an ASIO driver that allows any ASIO compatible application to beco
Known problems
=============================================
- starting/stopping the server several times in QJACKCTL does not work correctly. You'll have to quit qjackctl and launch it again.
- starting/stopping the server several times in QJACKCTL may not work correctly. You may have to quit QJACKCTL and launch it again.
=============================================


+ 95
- 0
windows/jack_loopback.cbp View File

@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="jack_loopback" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Win32 Release">
<Option output="Release\bin\jack\jack_loopback" prefix_auto="1" extension_auto="1" />
<Option object_output="Release\" />
<Option type="3" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
<Add option="-Wall" />
<Add option="-DBUILD_DLL" />
<Add option="-DSERVER_SIDE" />
<Add directory="..\windows" />
<Add directory="..\common\jack" />
<Add directory="..\common" />
</Compiler>
<Linker>
<Add directory="Release\bin" />
</Linker>
</Target>
<Target title="Win32 Debug">
<Option output="Debug\bin\jack\jack_loopback" prefix_auto="1" extension_auto="1" />
<Option object_output="Debug\" />
<Option type="3" />
<Option compiler="gcc" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
<Add option="-DBUILD_DLL" />
<Add option="-DSERVER_SIDE" />
<Add directory="..\windows" />
<Add directory="..\common\jack" />
<Add directory="..\common" />
</Compiler>
<Linker>
<Add directory="Debug\bin" />
</Linker>
</Target>
<Target title="Win32 Profiling">
<Option output="Release\bin\jack\jack_loopback" prefix_auto="1" extension_auto="1" />
<Option object_output="Release\" />
<Option type="3" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
<Add option="-Wall" />
<Add option="-DBUILD_DLL" />
<Add option="-DJACK_MONITOR" />
<Add option="-DSERVER_SIDE" />
<Add directory="..\windows" />
<Add directory="..\common\jack" />
<Add directory="..\common" />
</Compiler>
<Linker>
<Add directory="Release\bin" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Linker>
<Add library="kernel32" />
<Add library="user32" />
<Add library="gdi32" />
<Add library="winspool" />
<Add library="comdlg32" />
<Add library="advapi32" />
<Add library="shell32" />
<Add library="ole32" />
<Add library="oleaut32" />
<Add library="uuid" />
<Add library="odbc32" />
<Add library="odbccp32" />
<Add library="libjackserver" />
</Linker>
<Unit filename="..\common\JackLoopbackDriver.cpp" />
<Extensions>
<AutoVersioning>
<Scheme minor_max="10" build_max="0" rev_max="0" rev_rand_max="10" build_times_to_increment_minor="100" />
<Settings autoincrement="1" date_declarations="1" do_auto_increment="0" ask_to_increment="0" language="C++" svn="0" svn_directory="" header_path="version.h" />
<Changes_Log show_changes_editor="0" app_title="released version %M.%m.%b of %p" changeslog_path="ChangesLog.txt" />
</AutoVersioning>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

+ 1
- 0
windows/jackd.workspace View File

@@ -48,5 +48,6 @@
</Project>
<Project filename="jack_winmme.cbp" />
<Project filename="libjacknet.cbp" active="1" />
<Project filename="jack_loopback.cbp" active="1" />
</Workspace>
</CodeBlocks_workspace_file>

+ 2
- 2
windows/portaudio/JackPortAudioDevices.cpp View File

@@ -43,9 +43,9 @@ PortAudioDevices::PortAudioDevices()
}

PortAudioDevices::~PortAudioDevices()
{
{
// Desactivate for now: crash the server..
//Pa_Terminate();
//Pa_Terminate();

delete[] fDeviceInfo;
delete[] fHostName;


+ 59
- 59
windows/portaudio/JackPortAudioDevices.h View File

@@ -1,59 +1,59 @@
/*
Copyright (C) 2008 Romain Moret at Grame
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __PortAudioDevices__
#define __PortAudioDevices__
#include <cstdio>
#include <string>
#include "portaudio.h"
#include "pa_asio.h"
/*!
\brief A PortAudio Devices manager.
*/
class PortAudioDevices
{
private:
PaHostApiIndex fNumHostApi; //number of hosts
PaDeviceIndex fNumDevice; //number of devices
PaDeviceInfo** fDeviceInfo; //array of device info
std::string* fHostName; //array of host names (matched with host id's)
public:
PortAudioDevices();
~PortAudioDevices();
PaDeviceIndex GetNumDevice();
PaDeviceInfo* GetDeviceInfo(PaDeviceIndex id);
std::string GetDeviceName(PaDeviceIndex id);
std::string GetHostFromDevice(PaDeviceInfo* device);
std::string GetHostFromDevice(PaDeviceIndex id);
std::string GetFullName(PaDeviceIndex id);
std::string GetFullName(std::string hostname, std::string devicename);
PaDeviceInfo* GetDeviceFromFullName(std::string fullname, PaDeviceIndex& id, bool isInput );
void PrintSupportedStandardSampleRates(const PaStreamParameters* inputParameters, const PaStreamParameters* outputParameters);
int GetInputDeviceFromName(const char* name, PaDeviceIndex& device, int& in_max);
int GetOutputDeviceFromName(const char* name, PaDeviceIndex& device, int& out_max);
void DisplayDevicesNames();
bool IsDuplex ( PaDeviceIndex id );
};
#endif
/*
Copyright (C) 2008 Romain Moret at Grame
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __PortAudioDevices__
#define __PortAudioDevices__
#include <cstdio>
#include <string>
#include "portaudio.h"
#include "pa_asio.h"
/*!
\brief A PortAudio Devices manager.
*/
class PortAudioDevices
{
private:
PaHostApiIndex fNumHostApi; //number of hosts
PaDeviceIndex fNumDevice; //number of devices
PaDeviceInfo** fDeviceInfo; //array of device info
std::string* fHostName; //array of host names (matched with host id's)
public:
PortAudioDevices();
~PortAudioDevices();
PaDeviceIndex GetNumDevice();
PaDeviceInfo* GetDeviceInfo(PaDeviceIndex id);
std::string GetDeviceName(PaDeviceIndex id);
std::string GetHostFromDevice(PaDeviceInfo* device);
std::string GetHostFromDevice(PaDeviceIndex id);
std::string GetFullName(PaDeviceIndex id);
std::string GetFullName(std::string hostname, std::string devicename);
PaDeviceInfo* GetDeviceFromFullName(std::string fullname, PaDeviceIndex& id, bool isInput );
void PrintSupportedStandardSampleRates(const PaStreamParameters* inputParameters, const PaStreamParameters* outputParameters);
int GetInputDeviceFromName(const char* name, PaDeviceIndex& device, int& in_max);
int GetOutputDeviceFromName(const char* name, PaDeviceIndex& device, int& out_max);
void DisplayDevicesNames();
bool IsDuplex ( PaDeviceIndex id );
};
#endif

+ 15
- 15
windows/resource_vc.h View File

@@ -1,15 +1,15 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by resource.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by resource.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

+ 506
- 501
windows/winmme/JackWinMMEDriver.cpp
File diff suppressed because it is too large
View File


+ 24
- 3
wscript View File

@@ -61,6 +61,7 @@ def set_options(opt):
opt.tool_options('compiler_cc')

opt.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
opt.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
opt.add_option('--classic', action='store_true', default=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
@@ -68,6 +69,7 @@ def set_options(opt):
opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
opt.add_option('--ports', default=1024, type="int", dest="ports", help='Maximum number of ports')
opt.add_option('--ports-per-application', default=512, type="int", dest="application_ports", help='Maximum number of ports per application')
opt.sub_options('dbus')

def configure(conf):
@@ -130,12 +132,13 @@ def configure(conf):
conf.env['BUILD_JACKD'] = True

if Options.options.libdir:
conf.env['LIBDIR'] = Options.options.libdir
conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir
else:
conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib/'
conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'

conf.define('CLIENT_NUM', Options.options.clients)
conf.define('PORT_NUM', Options.options. ports)
conf.define('PORT_NUM', Options.options.ports)
conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)

conf.define('ADDON_DIR', os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')))
conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
@@ -143,6 +146,8 @@ def configure(conf):
conf.define('JACKMP', 1)
if conf.env['BUILD_JACKDBUS'] == True:
conf.define('JACK_DBUS', 1)
if conf.env['BUILD_JACKD'] == False:
conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
if conf.env['BUILD_WITH_PROFILE'] == True:
conf.define('JACK_MONITOR', 1)
if conf.env['BUILD_WITH_32_64'] == True:
@@ -167,6 +172,7 @@ def configure(conf):

print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
print "Build with a maximum of %d ports" % conf.env['PORT_NUM']
print "Build with a maximum of %d ports per application" % conf.env['PORT_NUM_FOR_CLIENT']
display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
@@ -204,7 +210,22 @@ def configure(conf):
print Logs.colors.NORMAL,
print

if Options.options.mixed == True:
env_variant2 = conf.env.copy()
conf.set_env_name('lib32', env_variant2)
env_variant2.set_variant('lib32')
conf.setenv('lib32')
conf.env.append_unique('CXXFLAGS', '-m32')
conf.env.append_unique('CCFLAGS', '-m32')
conf.env.append_unique('LINKFLAGS', '-m32')
conf.write_config_header('config.h')
if Options.options.libdir32:
conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir32
else:
conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'

def build(bld):
print ("make[1]: Entering directory `" + os.getcwd() + "/" + blddir + "'" )
if not os.access('svnversion.h', os.R_OK):
create_svnversion_task(bld)



Loading…
Cancel
Save