1 #ifndef INCLUDED_AUDIOIO_DB_CLIENT_H
2 #define INCLUDED_AUDIOIO_DB_CLIENT_H
3 
4 #include <string>
5 #include <iostream>
6 
7 #include "audioio-proxy.h"
8 #include "audioio-db-server.h"
9 
10 class SAMPLE_BUFFER;
11 
12 /**
13  * Client class for double-buffering providing
14  * additional layer of buffering for objects
15  * derived from AUDIO_IO.
16  *
17  * The buffering subsystem has been optimized for
18  * reliable streaming performance. Because of this some
19  * operations like random seeks are considerably slower
20  * than with direct access.
21  *
22  * Related design patterns:
23  *     - Proxy (GoF207)
24  *
25  * @author Kai Vehmanen
26  */
27 class AUDIO_IO_DB_CLIENT : public AUDIO_IO_PROXY {
28 
29  public:
30 
31   /** @name Public functions */
32   /*@{*/
33 
34   AUDIO_IO_DB_CLIENT (AUDIO_IO_DB_SERVER *pserver, AUDIO_IO* aobject, bool transfer_ownership);
35   virtual ~AUDIO_IO_DB_CLIENT(void);
36 
37   /*@}*/
38 
39   /** @name Reimplemented functions from ECA_OBJECT */
40   /*@{*/
41 
name(void)42   virtual std::string name(void) const { return(string("DB => ") + child()->name()); }
description(void)43   virtual std::string description(void) const { return(child()->description()); }
44 
45   /*@}*/
46 
47   /** @name Reimplemented functions from DYNAMIC_PARAMETERS<string> */
48   /*@{*/
49 
50   /* none */
51 
52   /*@}*/
53 
54   /** @name Reimplemented functions from DYNAMIC_OBJECT<string> */
55   /*@{*/
56 
clone(void)57   AUDIO_IO_DB_CLIENT* clone(void) const { std::cerr << __FILE__ << ": Not implemented!" << std::endl; return 0; }
new_expr(void)58   AUDIO_IO_DB_CLIENT* new_expr(void) const  { std::cerr << __FILE__ << ": Not implemented!" << std::endl; return 0; }
59 
60   /*@}*/
61 
62   /** @name Reimplemented functions from ECA_AUDIO_POSITION */
63   /*@{*/
64 
65   virtual SAMPLE_SPECS::sample_pos_t seek_position(SAMPLE_SPECS::sample_pos_t pos);
66 
67   /*@}*/
68 
69   /** @name Reimplemented functions from AUDIO_IO_BARRIER */
70   /*@{*/
71 
72   virtual void start_io(void);
73   virtual void stop_io(void);
74 
75   /*@}*/
76 
77   /** @name Reimplemented functions from AUDIO_IO */
78   /*@{*/
79 
80   virtual void read_buffer(SAMPLE_BUFFER* sbuf);
81   virtual void write_buffer(SAMPLE_BUFFER* sbuf);
82 
83   virtual void open(void) throw(AUDIO_IO::SETUP_ERROR&);
84   virtual void close(void);
85 
86   virtual bool finished(void) const;
87 
88   /*@}*/
89 
90   private:
91 
92   AUDIO_IO_DB_SERVER* pserver_repp;
93   AUDIO_IO_DB_BUFFER* pbuffer_repp;
94 
95   AUDIO_IO_DB_CLIENT& operator=(const AUDIO_IO_DB_CLIENT& x) { return *this; }
AUDIO_IO_DB_CLIENT(const AUDIO_IO_DB_CLIENT & x)96   AUDIO_IO_DB_CLIENT (const AUDIO_IO_DB_CLIENT& x) { }
97 
98   int xruns_rep;
99   bool finished_rep;
100   bool free_child_rep;
101   bool recursing_rep;
102 
103   void fetch_initial_child_data(void);
104 
105   bool pause_db_server_if_running(void);
106   void restore_db_server_state(bool was_running);
107 };
108 
109 #endif
110