Commit c4dc4e69 authored by sletz's avatar sletz
Browse files

Merge branch 'port_register_notification_defer'

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3903 0c269be4-1314-0410-8aa9-9f06e86f4224
parents d060e55d 1d5712a5
......@@ -101,7 +101,6 @@ int JackAudioDriver::Attach()
jack_port_id_t port_index;
char name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
char alias[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
unsigned long port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
int i;
jack_log("JackAudioDriver::Attach fBufferSize = %ld fSampleRate = %ld", fEngineControl->fBufferSize, fEngineControl->fSampleRate);
......@@ -109,7 +108,7 @@ int JackAudioDriver::Attach()
for (i = 0; i < fCaptureChannels; i++) {
snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fAliasName, fCaptureDriverName, i + 1);
snprintf(name, sizeof(name) - 1, "%s:capture_%d", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, CaptureDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", name);
return -1;
}
......@@ -120,12 +119,10 @@ int JackAudioDriver::Attach()
jack_log("JackAudioDriver::Attach fCapturePortList[i] port_index = %ld", port_index);
}
port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
for (i = 0; i < fPlaybackChannels; i++) {
snprintf(alias, sizeof(alias) - 1, "%s:%s:in%d", fAliasName, fPlaybackDriverName, i + 1);
snprintf(name, sizeof(name) - 1, "%s:playback_%d", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, PlaybackDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", name);
return -1;
}
......
......@@ -109,6 +109,10 @@ class SERVER_EXPORT JackDriverClientInterface : public JackDriverInterface, publ
/*!
\brief The base class for drivers.
*/
#define CaptureDriverFlags static_cast<JackPortFlags>(JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal | JackPortIsActive)
#define PlaybackDriverFlags static_cast<JackPortFlags>(JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal | JackPortIsActive)
#define MonitorDriverFlags static_cast<JackPortFlags>(JackPortIsOutput | JackPortIsActive)
class SERVER_EXPORT JackDriver : public JackDriverClientInterface
{
......
......@@ -651,7 +651,30 @@ int JackEngine::ClientActivate(int refnum, bool is_real_time)
jack_error("JackEngine::ClientActivate wait error ref = %ld name = %s", refnum, client->GetClientControl()->fName);
return -1;
} else {
jack_int_t input_ports[PORT_NUM_FOR_CLIENT];
jack_int_t output_ports[PORT_NUM_FOR_CLIENT];
fGraphManager->GetInputPorts(refnum, input_ports);
fGraphManager->GetOutputPorts(refnum, output_ports);
// First add port state to JackPortIsActive
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (input_ports[i] != EMPTY); i++) {
fGraphManager->ActivatePort(input_ports[i]);
}
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (output_ports[i] != EMPTY); i++) {
fGraphManager->ActivatePort(output_ports[i]);
}
// Notify client
NotifyActivate(refnum);
// Then issue port registration notification
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (input_ports[i] != EMPTY); i++) {
NotifyPortRegistation(input_ports[i], true);
}
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (output_ports[i] != EMPTY); i++) {
NotifyPortRegistation(output_ports[i], true);
}
return 0;
}
}
......@@ -662,18 +685,27 @@ int JackEngine::ClientDeactivate(int refnum)
JackClientInterface* client = fClientTable[refnum];
jack_log("JackEngine::ClientDeactivate ref = %ld name = %s", refnum, client->GetClientControl()->fName);
// Disconnect all ports ==> notifications are sent
jack_int_t ports[PORT_NUM_FOR_CLIENT];
int i;
jack_int_t input_ports[PORT_NUM_FOR_CLIENT];
jack_int_t output_ports[PORT_NUM_FOR_CLIENT];
fGraphManager->GetInputPorts(refnum, input_ports);
fGraphManager->GetOutputPorts(refnum, output_ports);
fGraphManager->GetInputPorts(refnum, ports);
for (i = 0; (i < PORT_NUM_FOR_CLIENT) && (ports[i] != EMPTY) ; i++) {
PortDisconnect(refnum, ports[i], ALL_PORTS);
// First disconnect all ports and remove their JackPortIsActive state
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (input_ports[i] != EMPTY); i++) {
PortDisconnect(refnum, input_ports[i], ALL_PORTS);
fGraphManager->DeactivatePort(input_ports[i]);
}
fGraphManager->GetOutputPorts(refnum, ports);
for (i = 0; (i < PORT_NUM_FOR_CLIENT) && (ports[i] != EMPTY) ; i++) {
PortDisconnect(refnum, ports[i], ALL_PORTS);
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (output_ports[i] != EMPTY); i++) {
PortDisconnect(refnum, output_ports[i], ALL_PORTS);
fGraphManager->DeactivatePort(output_ports[i]);
}
// Then issue port registration notification
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (input_ports[i] != EMPTY); i++) {
NotifyPortRegistation(input_ports[i], false);
}
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (output_ports[i] != EMPTY); i++) {
NotifyPortRegistation(output_ports[i], false);
}
fGraphManager->Deactivate(refnum);
......@@ -695,7 +727,8 @@ int JackEngine::ClientDeactivate(int refnum)
int JackEngine::PortRegister(int refnum, const char* name, const char *type, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port_index)
{
jack_log("JackEngine::PortRegister ref = %ld name = %s type = %s flags = %d buffer_size = %d", refnum, name, type, flags, buffer_size);
JackClientInterface* client = fClientTable[refnum];
// Check if port name already exists
if (fGraphManager->GetPort(name) != NO_PORT) {
jack_error("port_name \"%s\" already exists", name);
......@@ -704,7 +737,8 @@ int JackEngine::PortRegister(int refnum, const char* name, const char *type, uns
*port_index = fGraphManager->AllocatePort(refnum, name, type, (JackPortFlags)flags, fEngineControl->fBufferSize);
if (*port_index != NO_PORT) {
NotifyPortRegistation(*port_index, true);
if (client->GetClientControl()->fActive)
NotifyPortRegistation(*port_index, true);
return 0;
} else {
return -1;
......@@ -714,12 +748,14 @@ int JackEngine::PortRegister(int refnum, const char* name, const char *type, uns
int JackEngine::PortUnRegister(int refnum, jack_port_id_t port_index)
{
jack_log("JackEngine::PortUnRegister ref = %ld port_index = %ld", refnum, port_index);
JackClientInterface* client = fClientTable[refnum];
// Disconnect port ==> notification is sent
PortDisconnect(refnum, port_index, ALL_PORTS);
if (fGraphManager->ReleasePort(refnum, port_index) == 0) {
NotifyPortRegistation(port_index, false);
if (client->GetClientControl()->fActive)
NotifyPortRegistation(port_index, false);
return 0;
} else {
return -1;
......
......@@ -376,6 +376,18 @@ int JackGraphManager::ReleasePort(int refnum, jack_port_id_t port_index)
return res;
}
void JackGraphManager::ActivatePort(jack_port_id_t port_index)
{
JackPort* port = GetPort(port_index);
port->fFlags = (JackPortFlags)(port->fFlags | JackPortIsActive);
}
void JackGraphManager::DeactivatePort(jack_port_id_t port_index)
{
JackPort* port = GetPort(port_index);
port->fFlags = (JackPortFlags)(port->fFlags | ~JackPortIsActive);
}
void JackGraphManager::GetInputPorts(int refnum, jack_int_t* res)
{
JackConnectionManager* manager = WriteNextStateStart();
......
......@@ -65,6 +65,8 @@ class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState
// Ports management
jack_port_id_t AllocatePort(int refnum, const char* port_name, const char* port_type, JackPortFlags flags, jack_nframes_t buffer_size);
int ReleasePort(int refnum, jack_port_id_t port_index);
void ActivatePort(jack_port_id_t port_index);
void DeactivatePort(jack_port_id_t port_index);
void GetInputPorts(int refnum, jack_int_t* res);
void GetOutputPorts(int refnum, jack_int_t* res);
void RemoveAllPorts(int refnum);
......@@ -75,7 +77,7 @@ class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState
int ComputeTotalLatency(jack_port_id_t port_index);
int ComputeTotalLatencies();
int RequestMonitor(jack_port_id_t port_index, bool onoff);
// Connections management
int Connect(jack_port_id_t src_index, jack_port_id_t dst_index);
int Disconnect(jack_port_id_t src_index, jack_port_id_t dst_index);
......
......@@ -74,7 +74,6 @@ int JackMidiDriver::Attach()
jack_port_id_t port_index;
char name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
char alias[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
unsigned long port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
int i;
jack_log("JackMidiDriver::Attach fBufferSize = %ld fSampleRate = %ld", fEngineControl->fBufferSize, fEngineControl->fSampleRate);
......@@ -82,7 +81,7 @@ int JackMidiDriver::Attach()
for (i = 0; i < fCaptureChannels; i++) {
snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fAliasName, fCaptureDriverName, i + 1);
snprintf(name, sizeof(name) - 1, "%s:capture_%d", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, CaptureDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", name);
return -1;
}
......@@ -92,12 +91,10 @@ int JackMidiDriver::Attach()
jack_log("JackMidiDriver::Attach fCapturePortList[i] port_index = %ld", port_index);
}
port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
for (i = 0; i < fPlaybackChannels; i++) {
snprintf(alias, sizeof(alias) - 1, "%s:%s:in%d", fAliasName, fPlaybackDriverName, i + 1);
snprintf(name, sizeof(name) - 1, "%s:playback_%d", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, PlaybackDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", name);
return -1;
}
......
......@@ -138,19 +138,15 @@ namespace Jack
jack_port_id_t port_id;
char buf[64];
unsigned int chn;
int port_flags;
//if (netj.handle_transport_sync)
// jack_set_sync_callback(netj.client, (JackSyncCallback) net_driver_sync_cb, NULL);
port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
for (chn = 0; chn < netj.capture_channels_audio; chn++) {
snprintf (buf, sizeof(buf) - 1, "system:capture_%u", chn + 1);
if ( ( port_id = fGraphManager->AllocatePort ( fClientControl.fRefNum, buf, JACK_DEFAULT_AUDIO_TYPE,
static_cast<JackPortFlags> ( port_flags ), fEngineControl->fBufferSize ) ) == NO_PORT )
CaptureDriverFlags, fEngineControl->fBufferSize ) ) == NO_PORT )
{
jack_error ( "driver: cannot register port for %s", buf );
return -1;
......@@ -184,7 +180,7 @@ namespace Jack
snprintf (buf, sizeof(buf) - 1, "system:capture_%u", chn + 1);
if ( ( port_id = fGraphManager->AllocatePort ( fClientControl.fRefNum, buf, JACK_DEFAULT_MIDI_TYPE,
static_cast<JackPortFlags> ( port_flags ), fEngineControl->fBufferSize ) ) == NO_PORT )
CaptureDriverFlags, fEngineControl->fBufferSize ) ) == NO_PORT )
{
jack_error ( "driver: cannot register port for %s", buf );
return -1;
......@@ -195,13 +191,11 @@ namespace Jack
jack_slist_append (netj.capture_ports, (void *)(intptr_t)port_id);
}
port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
for (chn = 0; chn < netj.playback_channels_audio; chn++) {
snprintf (buf, sizeof(buf) - 1, "system:playback_%u", chn + 1);
if ( ( port_id = fGraphManager->AllocatePort ( fClientControl.fRefNum, buf, JACK_DEFAULT_AUDIO_TYPE,
static_cast<JackPortFlags> ( port_flags ), fEngineControl->fBufferSize ) ) == NO_PORT )
PlaybackDriverFlags, fEngineControl->fBufferSize ) ) == NO_PORT )
{
jack_error ( "driver: cannot register port for %s", buf );
return -1;
......@@ -231,7 +225,7 @@ namespace Jack
snprintf (buf, sizeof(buf) - 1, "system:playback_%u", chn + 1);
if ( ( port_id = fGraphManager->AllocatePort ( fClientControl.fRefNum, buf, JACK_DEFAULT_MIDI_TYPE,
static_cast<JackPortFlags> ( port_flags ), fEngineControl->fBufferSize ) ) == NO_PORT )
PlaybackDriverFlags, fEngineControl->fBufferSize ) ) == NO_PORT )
{
jack_error ( "driver: cannot register port for %s", buf );
return -1;
......
......@@ -295,7 +295,15 @@ enum JackPortFlags {
* systems are examples of clients that would set this flag for
* their ports.
*/
JackPortIsTerminal = 0x10
JackPortIsTerminal = 0x10,
/**
* JackPortIsActive means the port has been registered and the
* client is "active", that is jack_activate has been called
*
* JackPortIsActive is on between jack_activate and jack_deactivate.
*/
JackPortIsActive = 0x20
};
/**
......
......@@ -208,6 +208,12 @@ main (int argc, char *argv[])
if (flags & JackPortIsTerminal) {
fputs ("terminal,", stdout);
}
if (flags & JackPortIsActive) {
fputs ("active,", stdout);
} else {
fputs ("non-active,", stdout);
}
putc ('\n', stdout);
}
}
......
......@@ -2087,7 +2087,7 @@ int JackAlsaDriver::Attach()
assert(fCaptureChannels < DRIVER_PORT_NUM);
assert(fPlaybackChannels < DRIVER_PORT_NUM);
port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
port_flags = (unsigned long)CaptureDriverFlags;
alsa_driver_t* alsa_driver = (alsa_driver_t*)fDriver;
......@@ -2114,7 +2114,7 @@ int JackAlsaDriver::Attach()
jack_log("JackAudioDriver::Attach fCapturePortList[i] %ld ", port_index);
}
port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
port_flags = (unsigned long)PlaybackDriverFlags;
for (int i = 0; i < fPlaybackChannels; i++) {
snprintf(alias, sizeof(alias) - 1, "%s:playback_%u", fAliasName, i + 1);
......@@ -2135,7 +2135,7 @@ int JackAlsaDriver::Attach()
if (fWithMonitorPorts) {
jack_log("Create monitor port ");
snprintf(name, sizeof(name) - 1, "%s:monitor_%d", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, MonitorDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error ("ALSA: cannot register monitor port for %s", name);
} else {
port = fGraphManager->GetPort(port_index);
......
......@@ -432,7 +432,7 @@ inline int midi_port_open_jack(alsa_rawmidi_t *midi, midi_port_t *port, int type
snprintf(name, sizeof(name) - 1, "system:midi_playback_%d", ++midi->midi_out_cnt);
port->jack = jack_port_register(midi->client, name, JACK_DEFAULT_MIDI_TYPE,
type | JackPortIsPhysical|JackPortIsTerminal, 0);
type | JackPortIsPhysical | JackPortIsTerminal | JackPortIsActive, 0);
if (port->jack)
jack_port_set_alias(port->jack, alias);
......
......@@ -488,7 +488,7 @@ port_t* port_create(alsa_seqmidi_t *self, int type, snd_seq_addr_t addr, const s
/* mark anything that looks like a hardware port as physical&terminal */
if (snd_seq_port_info_get_type (info) & (SND_SEQ_PORT_TYPE_HARDWARE|SND_SEQ_PORT_TYPE_PORT|SND_SEQ_PORT_TYPE_SPECIFIC)) {
jack_caps |= (JackPortIsPhysical|JackPortIsTerminal);
jack_caps |= (JackPortIsPhysical | JackPortIsTerminal | JackPortIsActive);
}
if (jack_caps & JackPortIsOutput)
......
......@@ -359,8 +359,6 @@ int JackFFADODriver::Attach()
{
JackPort* port;
int port_index;
unsigned long port_flags;
char buf[JACK_PORT_NAME_SIZE];
char portname[JACK_PORT_NAME_SIZE];
......@@ -418,8 +416,6 @@ int JackFFADODriver::Attach()
/* ports */
// capture
port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
driver->capture_nchannels = ffado_streaming_get_nb_capture_streams(driver->dev);
driver->capture_channels = (ffado_capture_channel_t *)calloc(driver->capture_nchannels, sizeof(ffado_capture_channel_t));
if (driver->capture_channels == NULL) {
......@@ -437,7 +433,7 @@ int JackFFADODriver::Attach()
printMessage ("Registering audio capture port %s", buf);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf,
JACK_DEFAULT_AUDIO_TYPE,
(JackPortFlags)port_flags,
CaptureDriverFlags,
fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", buf);
return -1;
......@@ -460,7 +456,7 @@ int JackFFADODriver::Attach()
printMessage ("Registering midi capture port %s", buf);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf,
JACK_DEFAULT_MIDI_TYPE,
(JackPortFlags)port_flags,
CaptureDriverFlags,
fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", buf);
return -1;
......@@ -489,8 +485,6 @@ int JackFFADODriver::Attach()
}
// playback
port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
driver->playback_nchannels = ffado_streaming_get_nb_playback_streams(driver->dev);
driver->playback_channels = (ffado_playback_channel_t *)calloc(driver->playback_nchannels, sizeof(ffado_playback_channel_t));
if (driver->playback_channels == NULL) {
......@@ -509,7 +503,7 @@ int JackFFADODriver::Attach()
printMessage ("Registering audio playback port %s", buf);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf,
JACK_DEFAULT_AUDIO_TYPE,
(JackPortFlags)port_flags,
PlaybackDriverFlags,
fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", buf);
return -1;
......@@ -534,7 +528,7 @@ int JackFFADODriver::Attach()
printMessage ("Registering midi playback port %s", buf);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf,
JACK_DEFAULT_MIDI_TYPE,
(JackPortFlags)port_flags,
PlaybackDriverFlags,
fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", buf);
return -1;
......
......@@ -667,8 +667,7 @@ int JackFreebobDriver::Attach()
{
JackPort* port;
int port_index;
unsigned long port_flags;
char buf[JACK_PORT_NAME_SIZE];
char portname[JACK_PORT_NAME_SIZE];
......@@ -717,8 +716,6 @@ int JackFreebobDriver::Attach()
/* ports */
// capture
port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
driver->capture_nchannels = freebob_streaming_get_nb_capture_streams(driver->dev);
driver->capture_nchannels_audio = 0;
......@@ -734,7 +731,7 @@ int JackFreebobDriver::Attach()
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf,
JACK_DEFAULT_AUDIO_TYPE,
(JackPortFlags)port_flags,
CaptureDriverFlags,
fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", buf);
return -1;
......@@ -748,8 +745,6 @@ int JackFreebobDriver::Attach()
}
// playback
port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
driver->playback_nchannels = freebob_streaming_get_nb_playback_streams(driver->dev);
driver->playback_nchannels_audio = 0;
......@@ -764,7 +759,7 @@ int JackFreebobDriver::Attach()
printMessage ("Registering playback port %s", buf);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf,
JACK_DEFAULT_AUDIO_TYPE,
(JackPortFlags)port_flags,
PlaybackDriverFlags,
fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", buf);
return -1;
......
......@@ -1560,8 +1560,7 @@ int JackCoreAudioDriver::Attach()
char channel_name[64];
char name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
char alias[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
unsigned long port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
jack_log("JackCoreAudioDriver::Attach fBufferSize %ld fSampleRate %ld", fEngineControl->fBufferSize, fEngineControl->fSampleRate);
for (int i = 0; i < fCaptureChannels; i++) {
......@@ -1580,7 +1579,7 @@ int JackCoreAudioDriver::Attach()
snprintf(name, sizeof(name) - 1, "%s:capture_%d", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, CaptureDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("Cannot register port for %s", name);
return -1;
}
......@@ -1601,8 +1600,6 @@ int JackCoreAudioDriver::Attach()
fCapturePortList[i] = port_index;
}
port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
for (int i = 0; i < fPlaybackChannels; i++) {
err = AudioDeviceGetPropertyInfo(fDeviceID, i + 1, false, kAudioDevicePropertyChannelName, &size, &isWritable);
......@@ -1619,7 +1616,7 @@ int JackCoreAudioDriver::Attach()
snprintf(name, sizeof(name) - 1, "%s:playback_%d", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, PlaybackDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("Cannot register port for %s", name);
return -1;
}
......@@ -1644,7 +1641,7 @@ int JackCoreAudioDriver::Attach()
if (fWithMonitorPorts) {
jack_log("Create monitor port ");
snprintf(name, sizeof(name) - 1, "%s:monitor_%u", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, MonitorDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("Cannot register monitor port for %s", name);
return -1;
} else {
......
......@@ -222,7 +222,6 @@ int JackCoreMidiDriver::Attach()
char name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
char endpoint_name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
char alias[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
unsigned long port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
int i;
jack_log("JackCoreMidiDriver::Attach fBufferSize = %ld fSampleRate = %ld", fEngineControl->fBufferSize, fEngineControl->fSampleRate);
......@@ -239,7 +238,7 @@ int JackCoreMidiDriver::Attach()
}
snprintf(name, sizeof(name) - 1, "%s:capture_%d", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, CaptureDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", name);
return -1;
}
......@@ -249,8 +248,6 @@ int JackCoreMidiDriver::Attach()
jack_log("JackCoreMidiDriver::Attach fCapturePortList[i] port_index = %ld", port_index);
}
port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
for (i = 0; i < fPlaybackChannels; i++) {
err = MIDIObjectGetStringProperty(fMidiSource[i], kMIDIPropertyName, &pname);
......@@ -263,7 +260,7 @@ int JackCoreMidiDriver::Attach()
}
snprintf(name, sizeof(name) - 1, "%s:playback_%d", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, PlaybackDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", name);
return -1;
}
......
......@@ -822,6 +822,8 @@ int main (int argc, char *argv[])
printf("error : port_set_name function can't be tested...\n");
}
port_callback_reg = 0; // number of port registration received by the callback
/**
* Activate the client
*
......@@ -840,6 +842,20 @@ int main (int argc, char *argv[])
if (port_rename_clbk == 0)
printf("!!! ERROR !!! Jack_Port_Rename_Callback was not called !!.\n");
/**
* Test if portregistration callback have been called.
*
*/
jack_sleep(1 * 1000);
if (1 == port_callback_reg) {
Log("%i ports have been successfully created, and %i callback reg ports have been received... ok\n", 1, port_callback_reg);
} else {
printf("!!! ERROR !!! %i ports have been created, and %i callback reg ports have been received !\n", 1, port_callback_reg);
}
/**
* Test if init callback initThread have been called.
......@@ -1095,11 +1111,14 @@ int main (int argc, char *argv[])
}
jack_sleep(1 * 1000); // To hope all port registration and reorder callback have been received...
// Check port registration callback
if (j == port_callback_reg) {
Log("%i ports have been successfully created, and %i callback reg ports have been received... ok\n", j, port_callback_reg);
} else {
printf("!!! ERROR !!! %i ports have been created, and %i callback reg ports have been received !\n", j, k);
printf("!!! ERROR !!! %i ports have been created, and %i callback reg ports have been received !\n", j, port_callback_reg);
}
if (reorder == (2 * j)) {
Log("%i graph reorder callback have been received... ok\n", reorder);
} else {
......@@ -1147,6 +1166,7 @@ int main (int argc, char *argv[])
* Deregister all ports previously created.
*
*/
port_callback_reg = 0; // to check registration callback
Log("Deregistering all ports of the client...\n");
inports = jack_get_ports(client1, NULL, NULL, 0);
a = 0;
......@@ -1160,6 +1180,13 @@ int main (int argc, char *argv[])
}
a++;
}
// Check port registration callback again
if (j == port_callback_reg) {
Log("%i ports have been successfully created, and %i callback reg ports have been received... ok\n", j, port_callback_reg);
} else {