00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _MCOMDEVICE_HH_
00028 #define _MCOMDEVICE_HH_
00029
00030 #include <player.h>
00031 #include <driver.h>
00032 #include <drivertable.h>
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 class LifoMCom : public Driver
00052 {
00053 private:
00054
00055 class Buffer {
00056 private:
00057 player_mcom_data_t dat[MCOM_N_BUFS];
00058 int top;
00059 int capacity;
00060 public:
00061 int type;
00062 char channel[MCOM_CHANNEL_LEN];
00063 Buffer();
00064 ~Buffer();
00065 void Push(player_mcom_data_t newdat);
00066 player_mcom_data_t Pop();
00067 player_mcom_data_t Read();
00068 void Clear();
00069 void print();
00070 void SetCapacity(int cap);
00071 int GetCapacity() { return capacity; }
00072 };
00073
00074 struct Link{
00075 Buffer buf;
00076 Link* next;
00077 };
00078
00079 class LinkList {
00080 private:
00081 Link * top;
00082 public:
00083 LinkList();
00084 ~LinkList();
00085 void Push(player_mcom_data_t d,int type, char channel[MCOM_CHANNEL_LEN]);
00086 player_mcom_data_t Pop(int type, char channel[MCOM_CHANNEL_LEN]);
00087 player_mcom_data_t Read(int type,char channel[MCOM_CHANNEL_LEN]);
00088 void Clear(int type,char channel[MCOM_CHANNEL_LEN]);
00089 void SetCapacity(int type, char channel[MCOM_CHANNEL_LEN],
00090 unsigned char cap);
00091 Link * FindLink(int type, char channel[MCOM_CHANNEL_LEN]);
00092 };
00093
00094 LinkList Data;
00095
00096 public:
00097
00098
00099 LifoMCom(ConfigFile* cf, int section);
00100
00101
00102 virtual int PutConfig(player_device_id_t id, void *client,
00103 void* src, size_t len,
00104 struct timeval* timestamp);
00105
00106
00107 virtual int Setup() {
00108 printf("startup...\n");
00109 return 0;
00110 }
00111
00112 virtual int Shutdown() {
00113 printf("shutdown ...\n");
00114 return 0;
00115 }
00116 };
00117
00118
00119
00120
00121 Driver* LifoMCom_Init(char* interface, ConfigFile* cf, int section);
00122
00123
00124 void LifoMCom_Register(DriverTable* table);
00125
00126
00127
00128 #endif //ifdef _MCOMDEVICE_HH_
00129