git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3438 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.9.2
@@ -219,11 +219,12 @@ extern "C" | |||||
thread_routine routine, | thread_routine routine, | ||||
void *arg); | void *arg); | ||||
EXPORT int jack_drop_real_time_scheduling (pthread_t thread); | EXPORT int jack_drop_real_time_scheduling (pthread_t thread); | ||||
EXPORT int jack_client_stop_thread (jack_client_t* client, pthread_t thread); | EXPORT int jack_client_stop_thread (jack_client_t* client, pthread_t thread); | ||||
EXPORT int jack_client_kill_thread (jack_client_t* client, pthread_t thread); | EXPORT int jack_client_kill_thread (jack_client_t* client, pthread_t thread); | ||||
#ifndef WIN32 | |||||
EXPORT void jack_set_thread_creator (jack_thread_creator_t jtc); | EXPORT void jack_set_thread_creator (jack_thread_creator_t jtc); | ||||
#endif | |||||
EXPORT char * jack_get_internal_client_name (jack_client_t *client, | EXPORT char * jack_get_internal_client_name (jack_client_t *client, | ||||
jack_intclient_t intclient); | jack_intclient_t intclient); | ||||
EXPORT jack_intclient_t jack_internal_client_handle (jack_client_t *client, | EXPORT jack_intclient_t jack_internal_client_handle (jack_client_t *client, | ||||
@@ -1760,8 +1761,8 @@ EXPORT int jack_client_max_real_time_priority(jack_client_t* ext_client) | |||||
JackEngineControl* control = GetEngineControl(); | JackEngineControl* control = GetEngineControl(); | ||||
return (control->fRealTime) ? control->fMaxClientPriority : -1; | return (control->fRealTime) ? control->fMaxClientPriority : -1; | ||||
} | } | ||||
} | |||||
} | |||||
EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority) | EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority) | ||||
{ | { | ||||
JackEngineControl* control = GetEngineControl(); | JackEngineControl* control = GetEngineControl(); | ||||
@@ -1793,10 +1794,12 @@ EXPORT int jack_client_kill_thread(jack_client_t* client, pthread_t thread) | |||||
return JackThread::KillImp(thread); | return JackThread::KillImp(thread); | ||||
} | } | ||||
#ifndef WIN32 | |||||
EXPORT void jack_set_thread_creator (jack_thread_creator_t jtc) | EXPORT void jack_set_thread_creator (jack_thread_creator_t jtc) | ||||
{ | { | ||||
JackGlobals::fJackThreadCreator = jtc; | JackGlobals::fJackThreadCreator = jtc; | ||||
} | } | ||||
#endif | |||||
// intclient.h | // intclient.h | ||||
EXPORT int jack_internal_client_new (const char *client_name, | EXPORT int jack_internal_client_new (const char *client_name, | ||||
@@ -38,20 +38,20 @@ namespace Jack | |||||
JackAudioAdapter* adapter = static_cast<JackAudioAdapter*>(arg); | JackAudioAdapter* adapter = static_cast<JackAudioAdapter*>(arg); | ||||
float* inputBuffer[adapter->fAudioAdapter->GetInputs()]; | float* inputBuffer[adapter->fAudioAdapter->GetInputs()]; | ||||
float* outputBuffer[adapter->fAudioAdapter->GetOutputs()]; | float* outputBuffer[adapter->fAudioAdapter->GetOutputs()]; | ||||
// Always clear output | |||||
// Always clear output | |||||
for (int i = 0; i < adapter->fAudioAdapter->GetInputs(); i++) { | for (int i = 0; i < adapter->fAudioAdapter->GetInputs(); i++) { | ||||
inputBuffer[i] = (float*)jack_port_get_buffer(adapter->fCapturePortList[i], frames); | inputBuffer[i] = (float*)jack_port_get_buffer(adapter->fCapturePortList[i], frames); | ||||
memset(inputBuffer[i], 0, frames * sizeof(float)); | memset(inputBuffer[i], 0, frames * sizeof(float)); | ||||
} | } | ||||
if (adapter->fAudioAdapter->IsRunning()) { | if (adapter->fAudioAdapter->IsRunning()) { | ||||
for (int i = 0; i < adapter->fAudioAdapter->GetOutputs(); i++) { | for (int i = 0; i < adapter->fAudioAdapter->GetOutputs(); i++) { | ||||
outputBuffer[i] = (float*)jack_port_get_buffer(adapter->fPlaybackPortList[i], frames); | outputBuffer[i] = (float*)jack_port_get_buffer(adapter->fPlaybackPortList[i], frames); | ||||
} | } | ||||
adapter->fAudioAdapter->PullAndPush(inputBuffer, outputBuffer, frames); | adapter->fAudioAdapter->PullAndPush(inputBuffer, outputBuffer, frames); | ||||
} | |||||
} | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -73,13 +73,13 @@ namespace Jack | |||||
//JackAudioAdapter ********************************************************* | //JackAudioAdapter ********************************************************* | ||||
JackAudioAdapter::JackAudioAdapter (jack_client_t* jack_client, JackAudioAdapterInterface* audio_io, const JSList* params, bool system) | |||||
JackAudioAdapter::JackAudioAdapter (jack_client_t* jack_client, JackAudioAdapterInterface* audio_io, const JSList* params, bool system) | |||||
:fJackClient(jack_client), fAudioAdapter(audio_io) | :fJackClient(jack_client), fAudioAdapter(audio_io) | ||||
{ | { | ||||
const JSList* node; | const JSList* node; | ||||
const jack_driver_param_t* param; | const jack_driver_param_t* param; | ||||
fAutoConnect = false; | fAutoConnect = false; | ||||
for (node = params; node; node = jack_slist_next(node)) { | for (node = params; node; node = jack_slist_next(node)) { | ||||
param = (const jack_driver_param_t*) node->data; | param = (const jack_driver_param_t*) node->data; | ||||
switch (param->character) { | switch (param->character) { | ||||
@@ -89,7 +89,7 @@ namespace Jack | |||||
} | } | ||||
} | } | ||||
} | } | ||||
JackAudioAdapter::~JackAudioAdapter() | JackAudioAdapter::~JackAudioAdapter() | ||||
{ | { | ||||
// When called, Close has already been used for the client, thus ports are already unregistered. | // When called, Close has already been used for the client, thus ports are already unregistered. | ||||
@@ -108,11 +108,11 @@ namespace Jack | |||||
delete[] fCapturePortList; | delete[] fCapturePortList; | ||||
delete[] fPlaybackPortList; | delete[] fPlaybackPortList; | ||||
} | } | ||||
void JackAudioAdapter::ConnectPorts() | void JackAudioAdapter::ConnectPorts() | ||||
{ | { | ||||
const char **ports; | const char **ports; | ||||
ports = jack_get_ports(fJackClient, NULL, NULL, JackPortIsPhysical | JackPortIsInput); | ports = jack_get_ports(fJackClient, NULL, NULL, JackPortIsPhysical | JackPortIsInput); | ||||
if (ports != NULL) { | if (ports != NULL) { | ||||
for (int i = 0; i < fAudioAdapter->GetInputs() && ports[i]; i++) { | for (int i = 0; i < fAudioAdapter->GetInputs() && ports[i]; i++) { | ||||
@@ -120,7 +120,7 @@ namespace Jack | |||||
} | } | ||||
free(ports); | free(ports); | ||||
} | } | ||||
ports = jack_get_ports(fJackClient, NULL, NULL, JackPortIsPhysical | JackPortIsOutput); | ports = jack_get_ports(fJackClient, NULL, NULL, JackPortIsPhysical | JackPortIsOutput); | ||||
if (ports != NULL) { | if (ports != NULL) { | ||||
for (int i = 0; i < fAudioAdapter->GetOutputs() && ports[i]; i++) { | for (int i = 0; i < fAudioAdapter->GetOutputs() && ports[i]; i++) { | ||||
@@ -140,7 +140,7 @@ namespace Jack | |||||
char name[32]; | char name[32]; | ||||
jack_log("JackAudioAdapter::Open fCaptureChannels %d fPlaybackChannels %d", fAudioAdapter->GetInputs(), fAudioAdapter->GetOutputs()); | jack_log("JackAudioAdapter::Open fCaptureChannels %d fPlaybackChannels %d", fAudioAdapter->GetInputs(), fAudioAdapter->GetOutputs()); | ||||
fAudioAdapter->Create(); | fAudioAdapter->Create(); | ||||
//jack ports | //jack ports | ||||
fCapturePortList = new jack_port_t*[fAudioAdapter->GetInputs()]; | fCapturePortList = new jack_port_t*[fAudioAdapter->GetInputs()]; | ||||
fPlaybackPortList = new jack_port_t*[fAudioAdapter->GetOutputs()]; | fPlaybackPortList = new jack_port_t*[fAudioAdapter->GetOutputs()]; | ||||
@@ -168,7 +168,7 @@ namespace Jack | |||||
goto fail; | goto fail; | ||||
if ( jack_activate ( fJackClient ) < 0 ) | if ( jack_activate ( fJackClient ) < 0 ) | ||||
goto fail; | goto fail; | ||||
if (fAutoConnect) | if (fAutoConnect) | ||||
ConnectPorts(); | ConnectPorts(); | ||||
@@ -12,7 +12,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -32,6 +32,8 @@ JackMutex* JackGlobals::fOpenMutex = new JackMutex(); | |||||
bool JackGlobals::fServerRunning = false; | bool JackGlobals::fServerRunning = false; | ||||
JackClient* JackGlobals::fClientTable[CLIENT_NUM] = {}; | JackClient* JackGlobals::fClientTable[CLIENT_NUM] = {}; | ||||
jack_thread_creator_t JackGlobals::fJackThreadCreator = pthread_create; | |||||
#ifndef WIN32 | |||||
jack_thread_creator_t JackGlobals::fJackThreadCreator = pthread_create; | |||||
#endif | |||||
} // end of namespace | } // end of namespace |
@@ -12,7 +12,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
along with this program; if not, write to the Free Software | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | */ | ||||
@@ -36,8 +36,10 @@ struct JackGlobals { | |||||
static JackMutex* fOpenMutex; | static JackMutex* fOpenMutex; | ||||
static bool fServerRunning; | static bool fServerRunning; | ||||
static JackClient* fClientTable[]; | static JackClient* fClientTable[]; | ||||
static jack_thread_creator_t fJackThreadCreator; | |||||
#ifndef WIN32 | |||||
static jack_thread_creator_t fJackThreadCreator; | |||||
#endif | |||||
}; | }; | ||||
} // end of namespace | } // end of namespace | ||||
@@ -33,15 +33,15 @@ extern "C" | |||||
* clients. These interfaces hide some system variations in the | * clients. These interfaces hide some system variations in the | ||||
* handling of realtime scheduling and associated privileges. | * handling of realtime scheduling and associated privileges. | ||||
*/ | */ | ||||
/** | /** | ||||
* @defgroup ClientThreads Creating and managing client threads | * @defgroup ClientThreads Creating and managing client threads | ||||
* @{ | * @{ | ||||
*/ | */ | ||||
/** | /** | ||||
* @returns if JACK is running with realtime scheduling, this returns | * @returns if JACK is running with realtime scheduling, this returns | ||||
* the priority that any JACK-created client threads will run at. | |||||
* the priority that any JACK-created client threads will run at. | |||||
* Otherwise returns -1. | * Otherwise returns -1. | ||||
*/ | */ | ||||
@@ -114,8 +114,10 @@ int jack_client_stop_thread(jack_client_t* client, pthread_t thread); | |||||
* @param thread POSIX thread ID. | * @param thread POSIX thread ID. | ||||
* | * | ||||
* @returns 0, if successful; otherwise an error number. | * @returns 0, if successful; otherwise an error number. | ||||
*/ | |||||
*/ | |||||
int jack_client_kill_thread(jack_client_t* client, pthread_t thread); | int jack_client_kill_thread(jack_client_t* client, pthread_t thread); | ||||
#ifndef WIN32 | |||||
typedef int (*jack_thread_creator_t)(pthread_t*, | typedef int (*jack_thread_creator_t)(pthread_t*, | ||||
const pthread_attr_t*, | const pthread_attr_t*, | ||||
@@ -127,18 +129,20 @@ int jack_client_stop_thread(jack_client_t* client, pthread_t thread); | |||||
* are created by something other than pthread_create(). After | * are created by something other than pthread_create(). After | ||||
* it is used, any threads that JACK needs for the client will | * it is used, any threads that JACK needs for the client will | ||||
* will be created by calling the function passed to this | * will be created by calling the function passed to this | ||||
* function. | |||||
* function. | |||||
* | * | ||||
* No normal application/client should consider calling this. | * No normal application/client should consider calling this. | ||||
* The specific case for which it was created involves running | * The specific case for which it was created involves running | ||||
* win32/x86 plugins under Wine on Linux, where it is necessary | * win32/x86 plugins under Wine on Linux, where it is necessary | ||||
* that all threads that might call win32 functions are known | * that all threads that might call win32 functions are known | ||||
* to Wine. | * to Wine. | ||||
* | |||||
* | |||||
* @param creator a function that creates a new thread | * @param creator a function that creates a new thread | ||||
* | |||||
* | |||||
*/ | */ | ||||
void jack_set_thread_creator (jack_thread_creator_t creator); | |||||
void jack_set_thread_creator (jack_thread_creator_t creator); | |||||
#endif | |||||
/* @} */ | /* @} */ | ||||