I add function that I have wrote
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1847 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
* @file MidiConsumer.cpp
|
* @file MidiConsumer.cpp
|
||||||
*
|
*
|
||||||
* @author Matthijs Hollemans
|
* @author Matthijs Hollemans
|
||||||
|
* @author Jerome Leveque
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@@ -12,8 +13,7 @@
|
|||||||
|
|
||||||
bigtime_t BMidiConsumer::Latency() const
|
bigtime_t BMidiConsumer::Latency() const
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
return fLatency;
|
||||||
return 0LL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -21,14 +21,15 @@ bigtime_t BMidiConsumer::Latency() const
|
|||||||
BMidiConsumer::BMidiConsumer(const char* name)
|
BMidiConsumer::BMidiConsumer(const char* name)
|
||||||
: BMidiEndpoint(name)
|
: BMidiEndpoint(name)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
fLatency = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
BMidiConsumer::~BMidiConsumer()
|
BMidiConsumer::~BMidiConsumer()
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
if (fEventPort != B_NO_MORE_PORTS)
|
||||||
|
delete_port(fEventPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* @file MidiEndpoint.cpp
|
* @file MidiEndpoint.cpp
|
||||||
*
|
*
|
||||||
* @author Matthijs Hollemans
|
* @author Matthijs Hollemans
|
||||||
|
* @author Jerome Leveque
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@@ -11,39 +12,37 @@
|
|||||||
|
|
||||||
const char* BMidiEndpoint::Name() const
|
const char* BMidiEndpoint::Name() const
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
return fName.String();
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void BMidiEndpoint::SetName(const char* name)
|
void BMidiEndpoint::SetName(const char* name)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
BMidiRoster *roster = BMidiRoster::MidiRoster();
|
||||||
|
roster->Rename(this, name);
|
||||||
|
fName.SetTo(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
int32 BMidiEndpoint::ID() const
|
int32 BMidiEndpoint::ID() const
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
return fID;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BMidiEndpoint::IsProducer() const
|
bool BMidiEndpoint::IsProducer() const
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
return (fFlags && 0x01) == 0x01;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BMidiEndpoint::IsConsumer() const
|
bool BMidiEndpoint::IsConsumer() const
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
return (fFlags && 0x01) == 0x01;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -82,16 +81,24 @@ bool BMidiEndpoint::IsValid() const
|
|||||||
|
|
||||||
status_t BMidiEndpoint::Release()
|
status_t BMidiEndpoint::Release()
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
if (1 == atomic_add(&fRefCount, -1))
|
||||||
return B_ERROR;
|
{
|
||||||
|
Unregister();
|
||||||
|
delete this;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
status_t BMidiEndpoint::Acquire()
|
status_t BMidiEndpoint::Acquire()
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
atomic_add(&fRefCount, 1);
|
||||||
return B_ERROR;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -130,7 +137,11 @@ status_t BMidiEndpoint::Unregister(void)
|
|||||||
|
|
||||||
BMidiEndpoint::BMidiEndpoint(const char* name)
|
BMidiEndpoint::BMidiEndpoint(const char* name)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
fName = BString(name);
|
||||||
|
fStatus = B_OK;
|
||||||
|
fFlags = 0;
|
||||||
|
fRefCount = 0;
|
||||||
|
// fID = MidiRosterApp::GetNextFreeID();
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* @file MidiLocalConsumer.cpp
|
* @file MidiLocalConsumer.cpp
|
||||||
*
|
*
|
||||||
* @author Matthijs Hollemans
|
* @author Matthijs Hollemans
|
||||||
|
* @author Jerome Leveque
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@@ -10,8 +11,9 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
BMidiLocalConsumer::BMidiLocalConsumer(const char* name)
|
BMidiLocalConsumer::BMidiLocalConsumer(const char* name)
|
||||||
|
: BMidiConsumer(name)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
fFlags |= 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -25,22 +27,22 @@ BMidiLocalConsumer::~BMidiLocalConsumer()
|
|||||||
|
|
||||||
void BMidiLocalConsumer::SetLatency(bigtime_t latency)
|
void BMidiLocalConsumer::SetLatency(bigtime_t latency)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
fLatency = latency;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
int32 BMidiLocalConsumer::GetProducerID(void)
|
int32 BMidiLocalConsumer::GetProducerID(void)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
return fCurrentProducer;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void BMidiLocalConsumer::SetTimeout(bigtime_t when, void* data)
|
void BMidiLocalConsumer::SetTimeout(bigtime_t when, void* data)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
fTimeout = when;
|
||||||
|
fTimeoutData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* @file MidiLocalProducer.cpp
|
* @file MidiLocalProducer.cpp
|
||||||
*
|
*
|
||||||
* @author Matthijs Hollemans
|
* @author Matthijs Hollemans
|
||||||
|
* @author Jerome Leveque
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@@ -10,8 +11,9 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
BMidiLocalProducer::BMidiLocalProducer(const char* name)
|
BMidiLocalProducer::BMidiLocalProducer(const char* name)
|
||||||
|
: BMidiProducer(name)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
fFlags |= 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* @file MidiProducer.cpp
|
* @file MidiProducer.cpp
|
||||||
*
|
*
|
||||||
* @author Matthijs Hollemans
|
* @author Matthijs Hollemans
|
||||||
|
* @author Jerome Leveque
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@@ -12,32 +13,39 @@
|
|||||||
|
|
||||||
status_t BMidiProducer::Connect(BMidiConsumer* toObject)
|
status_t BMidiProducer::Connect(BMidiConsumer* toObject)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
if (toObject != NULL)
|
||||||
return B_ERROR;
|
if (fConnections->Add(toObject) == true)
|
||||||
|
fConnectionCount++;
|
||||||
|
BMidiRoster *roster = BMidiRoster::MidiRoster();
|
||||||
|
return roster->Connect(this, toObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
status_t BMidiProducer::Disconnect(BMidiConsumer* toObject)
|
status_t BMidiProducer::Disconnect(BMidiConsumer* toObject)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
if (toObject != NULL)
|
||||||
return B_ERROR;
|
if (fConnections->Remove(toObject) == true)
|
||||||
|
{
|
||||||
|
fConnectionCount--;
|
||||||
|
BMidiRoster *roster = BMidiRoster::MidiRoster();
|
||||||
|
return roster->Disconnect(this, toObject);
|
||||||
|
}
|
||||||
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BMidiProducer::IsConnected(BMidiConsumer* toObject) const
|
bool BMidiProducer::IsConnected(BMidiConsumer* toObject) const
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
return fConnections->IsIn(toObject);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
BList* BMidiProducer::Connections() const
|
BList* BMidiProducer::Connections() const
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
return fConnections;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -45,7 +53,9 @@ BList* BMidiProducer::Connections() const
|
|||||||
BMidiProducer::BMidiProducer(const char* name)
|
BMidiProducer::BMidiProducer(const char* name)
|
||||||
: BMidiEndpoint(name)
|
: BMidiEndpoint(name)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
fConnections = new BMidiList();
|
||||||
|
fConnectionCount = 1;
|
||||||
|
fLock = BLocker("BMidiProducer Lock");
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* @file MidiRoster.cpp
|
* @file MidiRoster.cpp
|
||||||
*
|
*
|
||||||
* @author Matthijs Hollemans
|
* @author Matthijs Hollemans
|
||||||
|
* @author Jerome Leveque
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* @file MidiServerApp.cpp
|
* @file MidiServerApp.cpp
|
||||||
*
|
*
|
||||||
* @author Matthijs Hollemans
|
* @author Matthijs Hollemans
|
||||||
|
* @author Jerome Leveque
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
@@ -9,11 +10,18 @@
|
|||||||
#include "MidiServerApp.h"
|
#include "MidiServerApp.h"
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
//Constructor
|
||||||
MidiServerApp::MidiServerApp()
|
MidiServerApp::MidiServerApp()
|
||||||
: BApplication("application/x-vnd.be-midi-roster")
|
: BApplication("application/x-vnd.obos-midi-roster")
|
||||||
{
|
{
|
||||||
// Do nothing.
|
roster = new BMidiRoster();
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//Destructor
|
||||||
|
MidiRosterApp:: ~MidiRosterApp(void)
|
||||||
|
{//ToTest
|
||||||
|
delete EndPointList;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -28,6 +36,65 @@ void MidiServerApp::AboutRequested()
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void MidiServerApp::MessageReceived(BMessage *msg)
|
||||||
|
{//ToDo
|
||||||
|
switch (msg->what)
|
||||||
|
{
|
||||||
|
default : BApplication::MessageReceived(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int32 MidiServerApp::GetNextFreeID(void)
|
||||||
|
{//ToTest
|
||||||
|
return NextFreeID++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BMidiEndpoint *MidiServerApp::NextEndPoint(int32 *id)
|
||||||
|
{//ToTest
|
||||||
|
int32 item = 0;
|
||||||
|
BMidiEndpoint *endpoint;
|
||||||
|
while ((endpoint = (BMidiEndpoint*)EndPointList->ItemAt(item)) != NULL)
|
||||||
|
{
|
||||||
|
if (endpoint->ID() > *id)
|
||||||
|
{
|
||||||
|
endpoint->Acquire();
|
||||||
|
*id = endpoint->ID();
|
||||||
|
return endpoint;
|
||||||
|
}
|
||||||
|
item++;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BMidiRoster *MidiServerApp::GetRoster()
|
||||||
|
{
|
||||||
|
return roster;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
MidiServerApp app;
|
MidiServerApp app;
|
||||||
|
|||||||
@@ -17,6 +17,19 @@ class MidiServerApp : public BApplication
|
|||||||
public:
|
public:
|
||||||
MidiServerApp();
|
MidiServerApp();
|
||||||
virtual void AboutRequested();
|
virtual void AboutRequested();
|
||||||
|
|
||||||
|
int32 GetNextFreeID(void);
|
||||||
|
BMidiEndpoint *NextEndPoint(int32 *id);
|
||||||
|
BMidiRoster *GetRoster();
|
||||||
|
|
||||||
|
void MessageReceived(BMessage *msg);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
BList *EndPointList;
|
||||||
|
int32 NextFreeID;
|
||||||
|
BMidiRoster *roster;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MIDI_SERVER_APP_H
|
#endif // MIDI_SERVER_APP_H
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user