Browse Source

Another Tim Blechmann cleanup patch + do no allocate JackClientControl in shared memory for server internal clients.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2520 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 17 years ago
parent
commit
318ecc889d
8 changed files with 57 additions and 53 deletions
  1. +1
    -0
      ChangeLog
  2. +2
    -2
      common/JackClientControl.h
  3. +2
    -21
      common/JackDriver.h
  4. +11
    -6
      common/JackExternalClient.cpp
  5. +3
    -5
      common/JackInternalClient.cpp
  6. +2
    -1
      common/JackInternalClient.h
  7. +5
    -0
      common/JackShmMem.cpp
  8. +31
    -18
      common/JackShmMem.h

+ 1
- 0
ChangeLog View File

@@ -24,6 +24,7 @@ Romain Moret
2008-06-13 Stephane Letz <letz@grame.fr>

* Correct JackPosixThread::ThreadHandler termination, do not set buffer size if same value is used.
* Another Tim Blechmann cleanup patch + do no allocate JackClientControl in shared memory for server internal clients.

2008-06-12 Stephane Letz <letz@grame.fr>



+ 2
- 2
common/JackClientControl.h View File

@@ -31,10 +31,10 @@ namespace Jack
{

/*!
\brief Client control in shared memory.
\brief Client control possibly in shared memory.
*/

struct JackClientControl : public JackShmMem
struct JackClientControl : public JackShmMemAble
{
char fName[JACK_CLIENT_NAME_SIZE + 1];
bool fCallback[kMaxNotification];


+ 2
- 21
common/JackDriver.h View File

@@ -85,25 +85,6 @@ class EXPORT JackDriverInterface
virtual bool IsRealTime() = 0;
};
/*
\brief The base interface for blocking drivers.
*/

class EXPORT JackBlockingInterface
{
public:
JackBlockingInterface()
{}
virtual ~JackBlockingInterface()
{}
virtual bool Init() = 0; /* To be called by the wrapping thread Init method when the driver is a "blocking" one */
};

/*!
\brief The base interface for drivers clients.
*/
@@ -115,7 +96,7 @@ class EXPORT JackDriverClientInterface : public JackDriverInterface, public Jack
\brief The base class for drivers clients.
*/

class EXPORT JackDriverClient : public JackDriverClientInterface, public JackBlockingInterface
class EXPORT JackDriverClient : public JackDriverClientInterface
{
private:
@@ -127,7 +108,7 @@ class EXPORT JackDriverClient : public JackDriverClientInterface, public JackBlo
bool fIsMaster;
public:
virtual bool Init() = 0; /* To be called by the wrapping thread Init method when the driver is a "blocking" one */
virtual void SetMaster(bool onoff);
virtual bool GetMaster();
virtual void AddSlave(JackDriverInterface* slave);


+ 11
- 6
common/JackExternalClient.cpp View File

@@ -53,15 +53,19 @@ int JackExternalClient::Open(const char* name, int pid, int refnum, int* shared_
jack_error("Cannot connect to client name = %s\n", name);
return -1;
}

fClientControl = new JackClientControl(name, pid, refnum);
// Use "placement new" to allocate object in shared memory
JackShmMemAble* shared_mem = static_cast<JackShmMemAble*>(JackShmMem::operator new(sizeof(JackClientControl)));
shared_mem->Init();
fClientControl = new(shared_mem) JackClientControl(name, pid, refnum);
if (!fClientControl) {
jack_error("Cannot allocate client shared memory segment");
return -1;
}
*shared_client = fClientControl->GetShmIndex();
jack_log("JackExternalClient::Open name = %s index = %ld base = %x", name, fClientControl->GetShmIndex(), fClientControl->GetShmAddress());
*shared_client = shared_mem->GetShmIndex();
jack_log("JackExternalClient::Open name = %s index = %ld base = %x", name, shared_mem->GetShmIndex(), shared_mem->GetShmAddress());
return 0;

} catch (std::exception e) {
@@ -72,7 +76,8 @@ int JackExternalClient::Open(const char* name, int pid, int refnum, int* shared_
int JackExternalClient::Close()
{
fChannel.Close();
delete fClientControl;
fClientControl->~JackClientControl();
JackShmMem::operator delete(fClientControl);
return 0;
}



+ 3
- 5
common/JackInternalClient.cpp View File

@@ -66,13 +66,11 @@ JackSynchro* GetSynchroTable()

JackInternalClient::JackInternalClient(JackServer* server, JackSynchro* table): JackClient(table)
{
fClientControl = new JackClientControl();
fChannel = new JackInternalClientChannel(server);
}

JackInternalClient::~JackInternalClient()
{
delete fClientControl;
delete fChannel;
}

@@ -94,10 +92,10 @@ int JackInternalClient::Open(const char* server_name, const char* name, jack_opt
goto error;
}

strcpy(fClientControl->fName, name_res);
strcpy(fClientControl.fName, name_res);

// Require new client
fChannel->ClientOpen(name_res, &fClientControl->fRefNum, &fEngineControl, &fGraphManager, this, &result);
fChannel->ClientOpen(name_res, &fClientControl.fRefNum, &fEngineControl, &fGraphManager, this, &result);
if (result < 0) {
jack_error("Cannot open client name = %s", name_res);
goto error;
@@ -126,7 +124,7 @@ JackEngineControl* JackInternalClient::GetEngineControl() const

JackClientControl* JackInternalClient::GetClientControl() const
{
return fClientControl;
return const_cast<JackClientControl*>(&fClientControl);
}

JackLoadableInternalClient::JackLoadableInternalClient(JackServer* server, JackSynchro* table, const char* so_name, const char* object_data)


+ 2
- 1
common/JackInternalClient.h View File

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

#include "JackClient.h"
#include "JackClientControl.h"

namespace Jack
{
@@ -37,7 +38,7 @@ class JackInternalClient : public JackClient

private:

JackClientControl* fClientControl; /*! Client control */
JackClientControl fClientControl; /*! Client control */

public:



+ 5
- 0
common/JackShmMem.cpp View File

@@ -34,6 +34,11 @@ static jack_shm_info_t gInfo;
size_t JackMem::gSize = 0;

JackShmMem::JackShmMem()
{
JackShmMemAble::Init();
}

void JackShmMemAble::Init()
{
fInfo.index = gInfo.index;
fInfo.attached_at = gInfo.attached_at;


+ 31
- 18
common/JackShmMem.h View File

@@ -61,7 +61,6 @@ class JackMem
JackMem(): fSize(gSize)
{}

~JackMem()
{}
@@ -91,31 +90,20 @@ class JackMem
};

/*!
\brief The base class for shared memory management.
\brief

A class which objects need to be allocated in shared memory derives from this class.
A class which objects possibly want to be allocated in shared memory derives from this class.
*/

class EXPORT JackShmMem
class JackShmMemAble
{

protected:
jack_shm_info_t fInfo;
protected:
JackShmMem();
~JackShmMem()
{}
public:

void* operator new(size_t size);
void* operator new(size_t size, void* memory);
void operator delete(void* p, size_t size);
void operator delete(void* p);
void Init();

int GetShmIndex()
{
@@ -139,6 +127,31 @@ class EXPORT JackShmMem

};

/*!
\brief The base class for shared memory management.

A class which objects need to be allocated in shared memory derives from this class.
*/

class EXPORT JackShmMem : public JackShmMemAble
{

protected:
JackShmMem();
~JackShmMem()
{}
public:
void* operator new(size_t size);
void* operator new(size_t size, void* memory);
void operator delete(void* p, size_t size);
void operator delete(void* p);
};

/*!
\brief Pointer on shared memory segment in the client side.
*/


Loading…
Cancel
Save