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:
parent
df1cbf3cc4
commit
96462df1ad
@ -2,6 +2,7 @@
|
||||
* @file MidiConsumer.cpp
|
||||
*
|
||||
* @author Matthijs Hollemans
|
||||
* @author Jerome Leveque
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
@ -12,8 +13,7 @@
|
||||
|
||||
bigtime_t BMidiConsumer::Latency() const
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return 0LL;
|
||||
return fLatency;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -21,14 +21,15 @@ bigtime_t BMidiConsumer::Latency() const
|
||||
BMidiConsumer::BMidiConsumer(const char* name)
|
||||
: BMidiEndpoint(name)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
fLatency = 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BMidiConsumer::~BMidiConsumer()
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
if (fEventPort != B_NO_MORE_PORTS)
|
||||
delete_port(fEventPort);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -2,6 +2,7 @@
|
||||
* @file MidiEndpoint.cpp
|
||||
*
|
||||
* @author Matthijs Hollemans
|
||||
* @author Jerome Leveque
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
@ -11,39 +12,37 @@
|
||||
|
||||
const char* BMidiEndpoint::Name() const
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return NULL;
|
||||
return fName.String();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiEndpoint::SetName(const char* name)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
BMidiRoster *roster = BMidiRoster::MidiRoster();
|
||||
roster->Rename(this, name);
|
||||
fName.SetTo(name);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
int32 BMidiEndpoint::ID() const
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return 0;
|
||||
return fID;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
bool BMidiEndpoint::IsProducer() const
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return false;
|
||||
return (fFlags && 0x01) == 0x01;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
bool BMidiEndpoint::IsConsumer() const
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return false;
|
||||
return (fFlags && 0x01) == 0x01;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -82,16 +81,24 @@ bool BMidiEndpoint::IsValid() const
|
||||
|
||||
status_t BMidiEndpoint::Release()
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return B_ERROR;
|
||||
if (1 == atomic_add(&fRefCount, -1))
|
||||
{
|
||||
Unregister();
|
||||
delete this;
|
||||
return B_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
status_t BMidiEndpoint::Acquire()
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return B_ERROR;
|
||||
atomic_add(&fRefCount, 1);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -130,7 +137,11 @@ status_t BMidiEndpoint::Unregister(void)
|
||||
|
||||
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
|
||||
*
|
||||
* @author Matthijs Hollemans
|
||||
* @author Jerome Leveque
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
@ -10,8 +11,9 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BMidiLocalConsumer::BMidiLocalConsumer(const char* name)
|
||||
: BMidiConsumer(name)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
fFlags |= 0x10;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -25,22 +27,22 @@ BMidiLocalConsumer::~BMidiLocalConsumer()
|
||||
|
||||
void BMidiLocalConsumer::SetLatency(bigtime_t latency)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
fLatency = latency;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
int32 BMidiLocalConsumer::GetProducerID(void)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return 0;
|
||||
return fCurrentProducer;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiLocalConsumer::SetTimeout(bigtime_t when, void* data)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
fTimeout = when;
|
||||
fTimeoutData = data;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -2,6 +2,7 @@
|
||||
* @file MidiLocalProducer.cpp
|
||||
*
|
||||
* @author Matthijs Hollemans
|
||||
* @author Jerome Leveque
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
@ -10,8 +11,9 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BMidiLocalProducer::BMidiLocalProducer(const char* name)
|
||||
: BMidiProducer(name)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
fFlags |= 0x10;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -2,6 +2,7 @@
|
||||
* @file MidiProducer.cpp
|
||||
*
|
||||
* @author Matthijs Hollemans
|
||||
* @author Jerome Leveque
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
@ -12,32 +13,39 @@
|
||||
|
||||
status_t BMidiProducer::Connect(BMidiConsumer* toObject)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return B_ERROR;
|
||||
if (toObject != NULL)
|
||||
if (fConnections->Add(toObject) == true)
|
||||
fConnectionCount++;
|
||||
BMidiRoster *roster = BMidiRoster::MidiRoster();
|
||||
return roster->Connect(this, toObject);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
status_t BMidiProducer::Disconnect(BMidiConsumer* toObject)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return B_ERROR;
|
||||
if (toObject != NULL)
|
||||
if (fConnections->Remove(toObject) == true)
|
||||
{
|
||||
fConnectionCount--;
|
||||
BMidiRoster *roster = BMidiRoster::MidiRoster();
|
||||
return roster->Disconnect(this, toObject);
|
||||
}
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
bool BMidiProducer::IsConnected(BMidiConsumer* toObject) const
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return false;
|
||||
return fConnections->IsIn(toObject);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BList* BMidiProducer::Connections() const
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
return NULL;
|
||||
return fConnections;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -45,7 +53,9 @@ BList* BMidiProducer::Connections() const
|
||||
BMidiProducer::BMidiProducer(const char* name)
|
||||
: BMidiEndpoint(name)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
fConnections = new BMidiList();
|
||||
fConnectionCount = 1;
|
||||
fLock = BLocker("BMidiProducer Lock");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -2,6 +2,7 @@
|
||||
* @file MidiRoster.cpp
|
||||
*
|
||||
* @author Matthijs Hollemans
|
||||
* @author Jerome Leveque
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
|
@ -2,6 +2,7 @@
|
||||
* @file MidiServerApp.cpp
|
||||
*
|
||||
* @author Matthijs Hollemans
|
||||
* @author Jerome Leveque
|
||||
*/
|
||||
|
||||
#include <Alert.h>
|
||||
@ -9,11 +10,18 @@
|
||||
#include "MidiServerApp.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//Constructor
|
||||
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()
|
||||
{
|
||||
MidiServerApp app;
|
||||
|
@ -17,6 +17,19 @@ class MidiServerApp : public BApplication
|
||||
public:
|
||||
MidiServerApp();
|
||||
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
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user