Commit 4f249a33 authored by sletz's avatar sletz
Browse files

Remove JackPortIsActive flag.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4120 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 5af8cff8
......@@ -34,6 +34,10 @@ Valerio Pilo
Jackdmp changes log
---------------------------
2011-02-09 Stephane Letz <letz@grame.fr>
* Remove JackPortIsActive flag.
2011-02-07 Stephane Letz <letz@grame.fr>
* Valerio Pilo second CAS for ARMv7 patch.
......
/*
Copyright (C) 2001 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 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 __JackDriver__
......@@ -30,27 +30,27 @@
namespace Jack
{
class JackLockedEngine;
class JackGraphManager;
struct JackEngineControl;
/*!
\brief The base interface for drivers.
*/
class SERVER_EXPORT JackDriverInterface
{
public:
JackDriverInterface()
{}
virtual ~JackDriverInterface()
{}
virtual int Open() = 0;
virtual int Open (bool capturing,
bool playing,
int inchannels,
......@@ -60,7 +60,7 @@ class SERVER_EXPORT JackDriverInterface
const char* playback_driver_name,
jack_nframes_t capture_latency,
jack_nframes_t playback_latency) = 0;
virtual int Open(jack_nframes_t buffer_size,
jack_nframes_t samplerate,
bool capturing,
......@@ -72,30 +72,30 @@ class SERVER_EXPORT JackDriverInterface
const char* playback_driver_name,
jack_nframes_t capture_latency,
jack_nframes_t playback_latency) = 0;
virtual int Attach() = 0;
virtual int Detach() = 0;
virtual int Read() = 0;
virtual int Write() = 0;
virtual int Start() = 0;
virtual int Stop() = 0;
virtual bool IsFixedBufferSize() = 0;
virtual int SetBufferSize(jack_nframes_t buffer_size) = 0;
virtual int SetSampleRate(jack_nframes_t sample_rate) = 0;
virtual int Process() = 0;
virtual int ProcessNull() = 0;
virtual void SetMaster(bool onoff) = 0;
virtual bool GetMaster() = 0;
virtual void AddSlave(JackDriverInterface* slave) = 0;
virtual void RemoveSlave(JackDriverInterface* slave) = 0;
virtual std::list<JackDriverInterface*> GetSlaves() = 0;
virtual int ProcessSlaves() = 0;
virtual bool IsRealTime() const = 0;
};
......@@ -109,16 +109,16 @@ 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)
#define CaptureDriverFlags static_cast<JackPortFlags>(JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal)
#define PlaybackDriverFlags static_cast<JackPortFlags>(JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal)
#define MonitorDriverFlags static_cast<JackPortFlags>(JackPortIsOutput)
class SERVER_EXPORT JackDriver : public JackDriverClientInterface
{
protected:
char fCaptureDriverName[JACK_CLIENT_NAME_SIZE + 1];
char fPlaybackDriverName[JACK_CLIENT_NAME_SIZE + 1];
char fAliasName[JACK_CLIENT_NAME_SIZE + 1];
......@@ -134,27 +134,27 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
JackClientControl fClientControl;
std::list<JackDriverInterface*> fSlaveList;
bool fIsMaster;
void CycleIncTime();
void CycleTakeBeginTime();
void CycleTakeEndTime();
void SetupDriverSync(int ref, bool freewheel);
void NotifyXRun(jack_time_t callback_usecs, float delayed_usecs); // XRun notification sent by the driver
void NotifyBufferSize(jack_nframes_t buffer_size); // BufferSize notification sent by the driver
void NotifySampleRate(jack_nframes_t sample_rate); // SampleRate notification sent by the driver
void NotifyFailure(int code, const char* reason); // Failure notification sent by the driver
public:
JackDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table);
JackDriver();
virtual ~JackDriver();
void SetMaster(bool onoff);
bool GetMaster();
void AddSlave(JackDriverInterface* slave);
void RemoveSlave(JackDriverInterface* slave);
std::list<JackDriverInterface*> GetSlaves()
......@@ -162,9 +162,9 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
return fSlaveList;
}
int ProcessSlaves();
virtual int Open();
virtual int Open (bool capturing,
bool playing,
int inchannels,
......@@ -174,7 +174,7 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
const char* playback_driver_name,
jack_nframes_t capture_latency,
jack_nframes_t playback_latency);
virtual int Open(jack_nframes_t buffer_size,
jack_nframes_t samplerate,
bool capturing,
......@@ -187,31 +187,31 @@ class SERVER_EXPORT JackDriver : public JackDriverClientInterface
jack_nframes_t capture_latency,
jack_nframes_t playback_latency);
virtual int Close();
virtual int Process();
virtual int ProcessNull();
virtual int Attach();
virtual int Detach();
virtual int Read();
virtual int Write();
virtual int Start();
virtual int Stop();
virtual bool IsFixedBufferSize();
virtual int SetBufferSize(jack_nframes_t buffer_size);
virtual int SetSampleRate(jack_nframes_t sample_rate);
virtual int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2);
virtual JackClientControl* GetClientControl() const;
virtual bool IsRealTime() const;
virtual bool Initialize(); // 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
};
} // end of namespace
#endif
......@@ -708,14 +708,6 @@ int JackEngine::ClientActivate(int refnum, bool is_real_time)
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);
......@@ -745,11 +737,9 @@ int JackEngine::ClientDeactivate(int refnum)
// 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]);
}
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
......
......@@ -13,7 +13,7 @@ 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
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
......@@ -37,7 +37,7 @@ static void AssertBufferSize(jack_nframes_t buffer_size)
assert(buffer_size <= BUFFER_SIZE_MAX);
}
}
void JackGraphManager::AssertPort(jack_port_id_t port_index)
{
if (port_index >= fPortMax) {
......@@ -45,7 +45,7 @@ void JackGraphManager::AssertPort(jack_port_id_t port_index)
assert(port_index < fPortMax);
}
}
JackGraphManager* JackGraphManager::Allocate(int port_max)
{
// Using "Placement" new
......@@ -59,18 +59,18 @@ void JackGraphManager::Destroy(JackGraphManager* manager)
manager->~JackGraphManager();
JackShmMem::operator delete(manager);
}
JackGraphManager::JackGraphManager(int port_max)
JackGraphManager::JackGraphManager(int port_max)
{
assert(port_max <= PORT_NUM_MAX);
for (int i = 0; i < port_max; i++) {
fPortArray[i].Release();
}
fPortMax = port_max;
}
JackPort* JackGraphManager::GetPort(jack_port_id_t port_index)
{
AssertPort(port_index);
......@@ -176,14 +176,14 @@ void* JackGraphManager::GetBuffer(jack_port_id_t port_index, jack_nframes_t buff
jack_int_t len = manager->Connections(port_index);
// No connections : return a zero-filled buffer
if (len == 0) {
if (len == 0) {
port->ClearBuffer(buffer_size);
return port->GetBuffer();
// One connection
} else if (len == 1) {
} else if (len == 1) {
jack_port_id_t src_index = manager->GetPort(port_index, 0);
// Ports in same client : copy the buffer
if (GetPort(src_index)->GetRefNum() == port->GetRefNum()) {
void* buffers[1];
......@@ -194,10 +194,10 @@ void* JackGraphManager::GetBuffer(jack_port_id_t port_index, jack_nframes_t buff
} else {
return GetBuffer(src_index, buffer_size);
}
// Multiple connections : mix all buffers
} else {
} else {
const jack_int_t* connections = manager->GetConnections(port_index);
void* buffers[CONNECTION_NUM_FOR_PORT];
jack_port_id_t src_index;
......@@ -220,10 +220,10 @@ int JackGraphManager::RequestMonitor(jack_port_id_t port_index, bool onoff) // C
JackPort* port = GetPort(port_index);
/**
jackd.h
jackd.h
* If @ref JackPortCanMonitor is set for this @a port, turn input
* monitoring on or off. Otherwise, do nothing.
if (!(fFlags & JackPortCanMonitor))
return -1;
*/
......@@ -376,18 +376,6 @@ 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();
......@@ -430,7 +418,7 @@ void JackGraphManager::RemoveAllPorts(int refnum)
jack_error("JackGraphManager::RemoveAllPorts failure ref = %ld port_index = %ld", refnum, port_index);
assert(true);
break;
}
}
}
WriteNextStateStop();
......@@ -717,7 +705,7 @@ void JackGraphManager::GetConnectionsAux(JackConnectionManager* manager, const c
const jack_int_t* connections = manager->GetConnections(port_index);
jack_int_t index;
int i;
// Cleanup connection array
memset(res, 0, sizeof(char*) * CONNECTION_NUM_FOR_PORT);
......@@ -740,7 +728,7 @@ const char** JackGraphManager::GetConnections(jack_port_id_t port_index)
{
const char** res = (const char**)malloc(sizeof(char*) * CONNECTION_NUM_FOR_PORT);
UInt16 cur_index, next_index;
if (!res)
return NULL;
......@@ -763,7 +751,7 @@ void JackGraphManager::GetPortsAux(const char** matching_ports, const char* port
{
int match_cnt = 0;
regex_t port_regex, type_regex;
if (port_name_pattern && port_name_pattern[0]) {
regcomp(&port_regex, port_name_pattern, REG_EXTENDED | REG_NOSUB);
}
......@@ -823,15 +811,15 @@ const char** JackGraphManager::GetPorts(const char* port_name_pattern, const cha
{
const char** res = (const char**)malloc(sizeof(char*) * fPortMax);
UInt16 cur_index, next_index;
if (!res)
return NULL;
do {
cur_index = GetCurrentIndex();
GetPortsAux(res, port_name_pattern, type_name_pattern, flags);
next_index = GetCurrentIndex();
} while (cur_index != next_index); // Until a coherent state has been read
} while (cur_index != next_index); // Until a coherent state has been read
if (res[0]) { // at least one port
return res;
......
......@@ -13,7 +13,7 @@ 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
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
......@@ -36,7 +36,7 @@ namespace Jack
/*!
\brief Graph manager: contains the connection manager and the port array.
*/
class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState<JackConnectionManager>
{
......@@ -65,8 +65,6 @@ 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);
......@@ -77,7 +75,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);
......@@ -130,7 +128,7 @@ class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState
void Save(JackConnectionManager* dst);
void Restore(JackConnectionManager* src);
static JackGraphManager* Allocate(int port_max);
static void Destroy(JackGraphManager* manager);
......
......@@ -214,7 +214,7 @@ typedef void (*JackFreewheelCallback)(int starting, void *arg);
/**
* Prototype for the client supplied function that is called
* whenever jackd is shutdown. Note that after server shutdown,
* whenever jackd is shutdown. Note that after server shutdown,
* the client pointer is *not* deallocated by libjack,
* the application is responsible to properly use jack_client_close()
* to release client ressources. Warning: jack_client_close() cannot be
......@@ -295,14 +295,7 @@ enum JackPortFlags {
* their ports.
*/
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
};
/**
......@@ -432,12 +425,12 @@ enum JackStatus {
* Client's protocol version does not match
*/
JackVersionError = 0x400,
/**
* Backend error
*/
JackBackendError = 0x800,
/**
* Client zombified failure
*/
......@@ -476,7 +469,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 */
......@@ -668,13 +661,13 @@ typedef struct {
/**
* Prototype for the client supplied function that is called
* whenever jackd is shutdown. Note that after server shutdown,
* whenever jackd is shutdown. Note that after server shutdown,
* the client pointer is *not* deallocated by libjack,
* the application is responsible to properly use jack_client_close()
* to release client ressources. Warning: jack_client_close() cannot be
* safely used inside the shutdown callback and has to be called outside of
* the callback context.
* @param code a status word, formed by OR-ing together the relevant @ref JackStatus bits.
* @param reason a string describing the shutdown reason (backend failure, server crash... etc...)
* @param arg pointer to a client supplied structure
......
......@@ -72,7 +72,7 @@ main (int argc, char *argv[])
char* aliases[2];
char *server_name = NULL;
jack_port_t *port;
struct option long_options[] = {
{ "server", 1, 0, 's' },
{ "aliases", 0, 0, 'A' },
......@@ -152,7 +152,7 @@ main (int argc, char *argv[])
}
ports = jack_get_ports (client, NULL, NULL, 0);
if (!ports)
if (!ports)
goto error;
for (i = 0; ports && ports[i]; ++i) {
......@@ -177,14 +177,14 @@ main (int argc, char *argv[])
printf (" %s\n", aliases[i]);
}
}
if (show_con) {
if ((connections = jack_port_get_all_connections (client, jack_port_by_name(client, ports[i]))) != 0) {
for (j = 0; connections[j]; j++) {
printf (" %s\n", connections[j]);
}
free (connections);
}
}
}
if (show_port_latency) {
if (port) {
......@@ -217,12 +217,7 @@ 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);
}
}
......@@ -234,7 +229,7 @@ main (int argc, char *argv[])
}
}
}
error:
if (ports)
jack_free (ports);
......
......@@ -104,7 +104,7 @@ typedef struct input_port_t {
// jack
midi_unpack_t unpack;
// midi
int overruns;
} input_port_t;
......@@ -114,7 +114,7 @@ typedef struct output_port_t {
// jack
midi_pack_t packer;
// midi
event_head_t next_event;
int todo;
......@@ -425,16 +425,16 @@ static
inline int midi_port_open_jack(alsa_rawmidi_t *midi, midi_port_t *port, int type, const char *alias)
{
char name[128];
if (type & JackPortIsOutput)
snprintf(name, sizeof(name) - 1, "system:midi_capture_%d", ++midi->midi_in_cnt);
else
else
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 | JackPortIsActive, 0);
if (port->jack)
type | JackPortIsPhysical | JackPortIsTerminal, 0);
if (port->jack)
jack_port_set_alias(port->jack, alias);
return port->jack == NULL;
}
......@@ -455,7 +455,7 @@ int midi_port_open(alsa_rawmidi_t *midi, midi_port_t *port)
out = &port->rawmidi;
type = JackPortIsInput;
}
if ((err = snd_rawmidi_open(in, out, port->dev, SND_RAWMIDI_NONBLOCK))<0)
return err;
......@@ -749,7 +749,7 @@ void* scan_thread(void *arg)