CLAM-Development
1.1
|
00001 /* 00002 * Copyright (c) 2001-2007 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 00023 #ifndef _PORTAUDIO_NETWORK_PLAYER_HXX_ 00024 #define _PORTAUDIO_NETWORK_PLAYER_HXX_ 00025 00026 #include <iostream> 00027 #include <string> 00028 #include "NetworkPlayer.hxx" 00029 #include <portaudio.h> 00030 00031 namespace CLAM 00032 { 00033 00034 00035 class PANetworkPlayer : public NetworkPlayer 00036 { 00037 int mPreferredBufferSize; 00038 int mSamplingRate; 00039 00040 PaStream * mPortAudioStream; 00041 PaError mError; 00042 std::string mErrorMessage; 00043 bool mNeedsPriority; 00044 00045 public: 00046 //When created in the prototyper 00047 PANetworkPlayer(const std::string & networkFile); 00048 //When created in neteditor 00049 PANetworkPlayer(); 00050 virtual ~PANetworkPlayer(); 00051 00052 // base class (virtual) interface: 00053 bool IsWorking() const; 00054 std::string NonWorkingReason() const; 00055 virtual void Start(); 00056 virtual void Stop(); 00057 00058 private: 00059 static int ProcessCallback ( 00060 const void *inputBuffers, 00061 void *outputBuffers, 00062 unsigned long framesPerBuffer, 00063 const PaStreamCallbackTimeInfo* timeInfo, 00064 PaStreamCallbackFlags statusFlags, 00065 void *userData); 00066 inline bool CheckPaError(PaError result); 00067 //Buffer copying methods 00068 void Do(const void *inputBuffers, void *outputBuffers, unsigned long framesPerBuffer); 00069 void DoInPorts(float** input, unsigned long nframes); 00070 void DoOutPorts(float** output, unsigned long nframes); 00071 }; 00072 00073 } //end namespace CLAM 00074 00075 #endif 00076