Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members
IO.cpp
00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: IO.cpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 /*********************************************************************** 00037 * * 00038 * REVISION HISTORY: * 00039 * * 00040 * * 00041 * * 00042 ***********************************************************************/ 00043 00044 #include "IO.hpp" 00045 char* sRTXState[]={"none","ack","nack","all"}; 00046 00047 IO::IO() { 00048 mutexStateChanged.initialize("mutexStateChanged"); 00049 // pthread_cond_init(&condStateChanged,NULL); 00050 state=CLOSED; 00051 framesSeen=0; 00052 currentFrameNumber=0; 00053 endFrameNumber=0; 00054 } 00055 00056 00057 IO::~IO() { 00058 mutexStateChanged.destroy(); 00059 // pthread_cond_destroy(&condStateChanged); 00060 } 00061 00062 00063 IO::State IO::setState(IO::State s) { 00064 mutexStateChanged.lock(); 00065 state=s; 00066 // pthread_cond_signal(&condStateChanged); 00067 mutexStateChanged.release(); 00068 return state; 00069 } 00070 00071 IO::State IO::play(double prefetchTime) { 00072 00073 dprintf_full("IO::play prefetch %f (old state %i)\n",prefetchTime,state); 00074 00075 if (state==CLOSED) { 00076 open(); 00077 return state; 00078 } else 00079 if ( (state==PAUSED) || (state==MUTED) ) 00080 setState(OPEN); 00081 else { 00082 dprintf_err("IO::play tried to OPEN from state %i\n",state); 00083 return state; 00084 } 00085 return state; 00086 } 00087 00088 00089 IO::State IO::pause() { 00090 00091 dprintf_err("IO::pause (old state %i)\n",state); 00092 if (getState() == IO::OPEN || 00093 getState() == IO::OPENING || 00094 getState() == IO::CLOSING || 00095 getState() == IO::STREAMEOF || 00096 getState() == IO::MUTED) 00097 return setState(IO::PAUSED); 00098 else 00099 return getState(); 00100 // return (state==OPEN)?setState(PAUSED):state; 00101 } 00102 00103 00104 IO::State IO::mute() { 00105 dprintf_err("IO::mute (old state %i)\n",state); 00106 return (state==OPEN)?setState(MUTED):state; 00107 } 00108