aRts audio server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
3.6KB

  1. /*
  2. Copyright (C) 2000 Stefan Westerfeld
  3. stefan@space.twc.de
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #ifndef ASYNCSCHEDULE_H
  18. #define ASYNCSCHEDULE_H
  19. #include "gslschedule.h"
  20. #include "datapacket.h"
  21. #include "weakreference.h"
  22. #include <queue>
  23. /*
  24. * BC - Status (2002-03-08): ASyncNetSend, ASyncNetReceive, ASyncPort.
  25. *
  26. * None of these classes is considered part of the public API. Do NOT use it
  27. * in your apps. These are part of the implementation of libartsflow's
  28. * StdFlowSystem, and subject to change with the needs of it.
  29. */
  30. namespace Arts {
  31. class ASyncPort;
  32. class ASyncNetSend : public FlowSystemSender_skel
  33. {
  34. protected:
  35. ASyncPort *ap;
  36. std::queue<GenericDataPacket *> pqueue;
  37. FlowSystemReceiver receiver;
  38. long receiveHandlerID;
  39. std::string _dest;
  40. public:
  41. ASyncNetSend(ASyncPort *ap, const std::string& dest);
  42. ~ASyncNetSend();
  43. long notifyID();
  44. std::string dest();
  45. /* this overwrites the Object::notify function */
  46. void notify(const Notification& notification);
  47. void processed();
  48. void setReceiver(FlowSystemReceiver receiver);
  49. void disconnect();
  50. };
  51. class ASyncNetReceive : public FlowSystemReceiver_skel,
  52. public GenericDataChannel
  53. {
  54. protected:
  55. GenericAsyncStream *stream;
  56. FlowSystemSender sender;
  57. Notification gotPacketNotification;
  58. std::list<GenericDataPacket *> sent;
  59. long _receiveHandlerID;
  60. public:
  61. ASyncNetReceive(ASyncPort *port, FlowSystemSender sender);
  62. ~ASyncNetReceive();
  63. // GenericDataChannel interface
  64. void processedPacket(GenericDataPacket *packet);
  65. void sendPacket(GenericDataPacket *packet);
  66. void setPull(int packets, int capacity);
  67. void endPull();
  68. // FlowSystemReceiver interface
  69. long receiveHandlerID();
  70. void disconnect();
  71. void receive(Buffer *buffer); // custom data receiver
  72. };
  73. class ASyncPort :public Port, public GenericDataChannel {
  74. protected:
  75. long notifyID;
  76. std::vector<Notification> subscribers;
  77. std::list<GenericDataPacket *> sent;
  78. std::list<ASyncNetSend *> netSenders;
  79. WeakReference<FlowSystemReceiver> netReceiver;
  80. GenericAsyncStream *stream;
  81. bool pull;
  82. Notification pullNotification;
  83. public:
  84. // GenericDataChannel interface
  85. void processedPacket(GenericDataPacket *packet);
  86. void sendPacket(GenericDataPacket *packet);
  87. void setPull(int packets, int capacity);
  88. void endPull();
  89. // Port interface
  90. ASyncPort(const std::string& name, void *ptr, long flags,
  91. StdScheduleNode* parent);
  92. ~ASyncPort();
  93. void connect(Port *port);
  94. void disconnect(Port *port);
  95. ASyncPort *asyncPort();
  96. // Network transparency
  97. void addSendNet(ASyncNetSend *netsend); // send
  98. void removeSendNet(ASyncNetSend *netsend);
  99. void disconnectRemote(const std::string& dest);
  100. long receiveNetNotifyID(); // receive
  101. GenericAsyncStream *receiveNetCreateStream();
  102. NotificationClient *receiveNetObject();
  103. void setNetReceiver(ASyncNetReceive *receiver);
  104. };
  105. }
  106. #endif /* ASYNCSCHEDULE_H */