Changeset 545
- Timestamp:
- 08/21/07 08:19:33 (16 years ago)
- Files:
-
- branches/echoaudio/src/libstreaming/AmdtpPort.h (modified) (2 diffs)
- branches/echoaudio/src/libstreaming/AmdtpPortInfo.h (modified) (2 diffs)
- branches/echoaudio/src/libstreaming/MotuPort.h (modified) (2 diffs)
- branches/echoaudio/src/libstreaming/MotuPortInfo.h (modified) (2 diffs)
- branches/echoaudio/src/libstreaming/Port.cpp (modified) (15 diffs)
- branches/echoaudio/src/libstreaming/Port.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/echoaudio/src/libstreaming/AmdtpPort.h
r445 r545 53 53 enum E_Formats format) 54 54 : AudioPort(name, direction), 55 AmdtpPortInfo( name,position, location, format)55 AmdtpPortInfo(position, location, format) 56 56 {}; 57 57 … … 80 80 enum E_Formats format) 81 81 : MidiPort(name, direction), 82 AmdtpPortInfo( name,position, location, format)82 AmdtpPortInfo(position, location, format) 83 83 {}; 84 84 branches/echoaudio/src/libstreaming/AmdtpPortInfo.h
r445 r545 54 54 }; 55 55 56 AmdtpPortInfo( std::string name,int position, int location, enum E_Formats format)57 : m_ name(name), m_position(position), m_location(location), m_format(format)56 AmdtpPortInfo( int position, int location, enum E_Formats format) 57 : m_position(position), m_location(location), m_format(format) 58 58 {}; 59 59 virtual ~AmdtpPortInfo() {}; 60 60 61 61 62 std::string getName() {return m_name;};63 62 int getLocation() {return m_location;}; 64 63 int getPosition() {return m_position;}; … … 66 65 67 66 protected: 68 std::string m_name;69 70 67 int m_position; 71 68 int m_location; branches/echoaudio/src/libstreaming/MotuPort.h
r445 r545 52 52 int size) 53 53 : AudioPort(name, direction), 54 MotuPortInfo( name,position, size) // TODO: add more port information parameters here if nescessary54 MotuPortInfo( position, size) // TODO: add more port information parameters here if nescessary 55 55 {}; 56 56 … … 76 76 int position) 77 77 : MidiPort(name, direction), 78 MotuPortInfo( name,position, 0) // TODO: add more port information parameters here if nescessary78 MotuPortInfo(position, 0) // TODO: add more port information parameters here if nescessary 79 79 {}; 80 80 branches/echoaudio/src/libstreaming/MotuPortInfo.h
r445 r545 60 60 * the name parameter is mandatory 61 61 * 62 * @param name Port name63 62 * @param position Start position of port's data in iso event 64 63 * @param format Format of data in iso event … … 66 65 * @return 67 66 */ 68 MotuPortInfo( std::string name,int position, int size)69 : m_ name(name), m_position(position), m_size(size)67 MotuPortInfo( int position, int size) 68 : m_position(position), m_size(size) 70 69 {}; 71 70 virtual ~MotuPortInfo() {}; 72 71 73 72 74 std::string getName() {return m_name;};75 73 int getPosition() {return m_position;}; 76 74 int getSize() {return m_size;}; 77 75 78 76 protected: 79 std::string m_name;80 77 81 78 int m_position; branches/echoaudio/src/libstreaming/Port.cpp
r445 r545 35 35 m_BufferType(E_PointerBuffer), 36 36 m_disabled(true), 37 m_initialized(false),38 37 m_buffersize(0), 39 38 m_eventsize(0), … … 49 48 m_rate_counter(0), 50 49 m_rate_counter_minimum(0), 51 m_average_ratecontrol(false) 52 50 m_average_ratecontrol(false), 51 m_State(E_Created) 53 52 { 54 53 … … 63 62 */ 64 63 bool Port::init() { 65 if (m_ initialized) {66 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());64 if (m_State != E_Created) { 65 debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 67 66 return false; 68 67 } … … 98 97 } 99 98 100 m_initialized=true;101 102 99 m_eventsize=getEventSize(); // this won't change, so cache it 103 104 return m_initialized; 100 101 m_State = E_Initialized; 102 return true; 105 103 } 106 104 … … 112 110 }; 113 111 112 void Port::show() { 113 debugOutput(DEBUG_LEVEL_VERBOSE,"Name : %s\n", m_Name.c_str()); 114 debugOutput(DEBUG_LEVEL_VERBOSE,"Signal Type : %d\n", m_SignalType); 115 debugOutput(DEBUG_LEVEL_VERBOSE,"Buffer Type : %d\n", m_BufferType); 116 debugOutput(DEBUG_LEVEL_VERBOSE,"Enabled? : %d\n", m_disabled); 117 debugOutput(DEBUG_LEVEL_VERBOSE,"State? : %d\n", m_State); 118 debugOutput(DEBUG_LEVEL_VERBOSE,"Buffer Size : %d\n", m_buffersize); 119 debugOutput(DEBUG_LEVEL_VERBOSE,"Event Size : %d\n", m_eventsize); 120 debugOutput(DEBUG_LEVEL_VERBOSE,"Data Type : %d\n", m_DataType); 121 debugOutput(DEBUG_LEVEL_VERBOSE,"Port Type : %d\n", m_PortType); 122 debugOutput(DEBUG_LEVEL_VERBOSE,"Direction : %d\n", m_Direction); 123 debugOutput(DEBUG_LEVEL_VERBOSE,"Rate Control? : %d\n", m_do_ratecontrol); 124 } 114 125 115 126 void Port::setVerboseLevel(int l) { … … 120 131 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting name to %s for port %s\n",name.c_str(),m_Name.c_str()); 121 132 122 if (m_ initialized) {123 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());133 if (m_State != E_Created) { 134 debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 124 135 return false; 125 136 } … … 132 143 bool Port::setBufferSize(unsigned int newsize) { 133 144 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting buffersize to %d for port %s\n",newsize,m_Name.c_str()); 134 if (m_ initialized) {135 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());145 if (m_State != E_Created) { 146 debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 136 147 return false; 137 148 } … … 157 168 bool Port::setDataType(enum E_DataType d) { 158 169 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting datatype to %d for port %s\n",(int) d,m_Name.c_str()); 159 if (m_ initialized) {160 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());170 if (m_State != E_Created) { 171 debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 161 172 return false; 162 173 } … … 190 201 bool Port::setSignalType(enum E_SignalType s) { 191 202 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting signaltype to %d for port %s\n",(int)s,m_Name.c_str()); 192 if (m_ initialized) {193 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());203 if (m_State != E_Created) { 204 debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 194 205 return false; 195 206 } … … 223 234 bool Port::setBufferType(enum E_BufferType b) { 224 235 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting buffer type to %d for port %s\n",(int)b,m_Name.c_str()); 225 if (m_ initialized) {226 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());236 if (m_State != E_Created) { 237 debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 227 238 return false; 228 239 } … … 257 268 // If called on an initialised stream but the request isn't for a change silently 258 269 // allow it (relied on by C API as used by jack backend driver) 259 if (m_ initialized && m_use_external_buffer==b)270 if (m_State==E_Initialized && m_use_external_buffer==b) 260 271 return true; 261 272 262 273 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting external buffer use to %d for port %s\n",(int)b,m_Name.c_str()); 263 274 264 if (m_ initialized) {265 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());275 if (m_State != E_Created) { 276 debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 266 277 return false; 267 278 } … … 284 295 /** 285 296 * Set the external buffer address. 286 * only call this when specifying an external buffer before init() 297 * only call this when you have specified that you will use 298 * an external buffer before doing the init() 287 299 * 288 300 * @param buff … … 296 308 // buffer handling api's for ringbuffers 297 309 bool Port::writeEvent(void *event) { 298 assert(m_BufferType==E_RingBuffer); 310 311 #ifdef DEBUG 312 if (m_State != E_Initialized) { 313 debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 314 return false; 315 } 316 317 if(m_BufferType!=E_RingBuffer) { 318 debugError("operation not allowed on non E_RingBuffer ports\n"); 319 show(); 320 return false; 321 } 299 322 assert(m_ringbuffer); 323 #endif 300 324 301 325 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Writing event %08X with size %d to port %s\n",*((quadlet_t *)event),m_eventsize, m_Name.c_str()); … … 305 329 306 330 bool Port::readEvent(void *event) { 331 332 #ifdef DEBUG 333 if (m_State != E_Initialized) { 334 debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 335 return false; 336 } 337 338 if(m_BufferType!=E_RingBuffer) { 339 debugError("operation not allowed on non E_RingBuffer ports\n"); 340 show(); 341 return false; 342 } 307 343 assert(m_ringbuffer); 308 344 #endif 345 346 309 347 unsigned int read=ffado_ringbuffer_read(m_ringbuffer, (char *)event, m_eventsize); 310 348 311 349 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Reading event %X with size %d from port %s\n",*((quadlet_t *)event),m_eventsize,m_Name.c_str()); 350 351 312 352 return (read==m_eventsize); 313 353 } 314 354 315 355 int Port::writeEvents(void *event, unsigned int nevents) { 316 assert(m_BufferType==E_RingBuffer); 356 357 #ifdef DEBUG 358 if (m_State != E_Initialized) { 359 debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 360 return false; 361 } 362 363 if(m_BufferType!=E_RingBuffer) { 364 debugError("operation not allowed on non E_RingBuffer ports\n"); 365 show(); 366 return false; 367 } 317 368 assert(m_ringbuffer); 369 #endif 370 318 371 319 372 unsigned int bytes2write=m_eventsize*nevents; … … 338 391 339 392 int Port::readEvents(void *event, unsigned int nevents) { 393 394 #ifdef DEBUG 395 if (m_State != E_Initialized) { 396 debugFatal("Port (%s) not in E_Initialized state: %d\n",m_Name.c_str(),m_State); 397 return false; 398 } 399 if(m_BufferType!=E_RingBuffer) { 400 debugError("operation not allowed on non E_RingBuffer ports\n"); 401 show(); 402 return false; 403 } 340 404 assert(m_ringbuffer); 405 #endif 406 341 407 342 408 unsigned int bytes2read=m_eventsize*nevents; branches/echoaudio/src/libstreaming/Port.h
r445 r545 270 270 int readEvents(void *event, unsigned int nevents); ///< read multiple events 271 271 272 virtual void setVerboseLevel(int l); 273 272 virtual void setVerboseLevel(int l); 273 virtual void show(); 274 274 275 protected: 275 276 std::string m_Name; ///< Port name, [at construction] … … 279 280 280 281 bool m_disabled; ///< is the port disabled?, [anytime] 281 bool m_initialized; ///< is the port initialized? [after init()]282 282 283 283 unsigned int m_buffersize; … … 306 306 307 307 DECLARE_DEBUG_MODULE; 308 308 309 // the state machine 310 protected: 311 enum EStates { 312 E_Created, 313 E_Initialized, 314 E_Prepared, 315 E_Running, 316 E_Error 317 }; 318 319 enum EStates m_State; 309 320 }; 310 321