CLAM-Development  1.4.0
PANetworkPlayer.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2007 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 
23 #ifndef _PORTAUDIO_NETWORK_PLAYER_HXX_
24 #define _PORTAUDIO_NETWORK_PLAYER_HXX_
25 
26 #include <iostream>
27 #include <string>
28 #include "NetworkPlayer.hxx"
29 #include <portaudio.h>
30 
31 namespace CLAM
32 {
33 
35 {
36  int mPreferredBufferSize;
37  int mSamplingRate;
38 
39  PaStream * mPortAudioStream;
40  PaError mError;
41  std::string mErrorMessage;
42  bool mNeedsPriority;
43 
44 public:
45  //When created in the prototyper
46  PANetworkPlayer(const std::string & networkFile);
47  //When created in neteditor
49  virtual ~PANetworkPlayer();
50 
51  // base class (virtual) interface:
52  bool IsWorking();
53  std::string NonWorkingReason();
54  virtual bool IsRealTime() const { return true; }
55  virtual void Start();
56  virtual void Stop();
57 
58 private:
59  static int ProcessCallback (
60  const void *inputBuffers,
61  void *outputBuffers,
62  unsigned long framesPerBuffer,
63  const PaStreamCallbackTimeInfo* timeInfo,
64  PaStreamCallbackFlags statusFlags,
65  void *userData);
66  inline bool CheckPaError(PaError result);
67  //Buffer copying methods
68  void Do(const void *inputBuffers, void *outputBuffers, unsigned long framesPerBuffer);
69  void DoInPorts(float** input, unsigned long nframes);
70  void DoOutPorts(float** output, unsigned long nframes);
71  void MuteOutBuffers(float** output, unsigned long nframes);
72 };
73 
74 } //end namespace CLAM
75 
76 #endif
77