Changeset 1219
- Timestamp:
- 05/25/08 08:59:41 (16 years ago)
- Files:
-
- branches/libffado-2.0/src/bebob/focusrite/focusrite_generic.cpp (modified) (4 diffs)
- branches/libffado-2.0/src/bebob/focusrite/focusrite_saffire.cpp (modified) (1 diff)
- branches/libffado-2.0/src/bebob/focusrite/focusrite_saffirepro.cpp (modified) (1 diff)
- branches/libffado-2.0/src/libavc/general/avc_generic.cpp (modified) (1 diff)
- branches/libffado-2.0/src/libieee1394/ieee1394service.cpp (modified) (1 diff)
- branches/libffado-2.0/support/dbus/ffado-dbus-server.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libffado-2.0/src/bebob/focusrite/focusrite_generic.cpp
r1184 r1219 26 26 27 27 #include "libutil/ByteSwap.h" 28 #include "libutil/SystemTimeSource.h" 28 29 29 30 namespace BeBoB { … … 142 143 if(!get1394Service().write_quadlet( nodeId, addr, CondSwapToBus32(data) ) ) { 143 144 debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 144 return false; 145 } 145 Util::SystemTimeSource::SleepUsecRelative(AVC::AVCCommand::getSleepAfterAVCCommand()); 146 return false; 147 } 148 Util::SystemTimeSource::SleepUsecRelative(AVC::AVCCommand::getSleepAfterAVCCommand()); 146 149 return true; 147 150 } … … 158 161 if(!get1394Service().read_quadlet( nodeId, addr, &result ) ) { 159 162 debugError("Could not read from node 0x%04llX addr 0x%012llX\n", nodeId, addr); 163 Util::SystemTimeSource::SleepUsecRelative(AVC::AVCCommand::getSleepAfterAVCCommand()); 160 164 return false; 161 165 } … … 165 169 166 170 *v = result; 171 Util::SystemTimeSource::SleepUsecRelative(AVC::AVCCommand::getSleepAfterAVCCommand()); 167 172 return true; 168 173 } branches/libffado-2.0/src/bebob/focusrite/focusrite_saffire.cpp
r1181 r1219 36 36 37 37 // the saffire doesn't seem to like it if the commands are too fast 38 if (AVC::AVCCommand::getSleepAfterAVCCommand() < 1000) {39 AVC::AVCCommand::setSleepAfterAVCCommand( 1000 );38 if (AVC::AVCCommand::getSleepAfterAVCCommand() < 4000) { 39 AVC::AVCCommand::setSleepAfterAVCCommand( 4000 ); 40 40 } 41 41 branches/libffado-2.0/src/bebob/focusrite/focusrite_saffirepro.cpp
r1184 r1219 44 44 addOption(Util::OptionContainer::Option("rebootOnSamplerateChange", true)); 45 45 // the saffire pro doesn't seem to like it if the commands are too fast 46 if (AVC::AVCCommand::getSleepAfterAVCCommand() < 500) {47 AVC::AVCCommand::setSleepAfterAVCCommand( 500 );46 if (AVC::AVCCommand::getSleepAfterAVCCommand() < 1000) { 47 AVC::AVCCommand::setSleepAfterAVCCommand( 1000 ); 48 48 } 49 49 } branches/libffado-2.0/src/libavc/general/avc_generic.cpp
r1135 r1219 210 210 } 211 211 212 unsigned int resp_len; 213 quadlet_t* resp = m_p1394Service->transactionBlock( m_nodeId, 214 (quadlet_t*)m_fcpFrame, 215 ( fcpFrameSize+3 ) / 4, 216 &resp_len ); 212 int ntries = 10; 217 213 bool result = false; 218 if ( resp ) { 219 resp_len *= 4; 220 unsigned char* buf = ( unsigned char* ) resp; 221 222 m_eResponse = ( EResponse )( *buf ); 223 switch ( m_eResponse ) 224 { 225 case eR_Accepted: 226 case eR_Implemented: 227 case eR_Rejected: 228 case eR_NotImplemented: 229 { 230 Util::Cmd::BufferDeserialize de( buf, resp_len ); 231 result = deserialize( de ); 232 233 debugOutputShort( DEBUG_LEVEL_VERY_VERBOSE," Response:\n"); 234 showFcpFrame( buf, de.getNrOfConsumedBytes() ); 235 236 Util::Cmd::StringSerializer se_dbg; 237 serialize( se_dbg ); 238 239 // output the debug message in smaller chunks to avoid problems 240 // with a max message size 241 unsigned int chars_to_write=se_dbg.getString().size(); 242 unsigned int chars_written=0; 243 while (chars_written<chars_to_write) { 244 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%s\n", 245 se_dbg.getString().substr(chars_written, DEBUG_MAX_MESSAGE_LENGTH).c_str()); 246 chars_written += DEBUG_MAX_MESSAGE_LENGTH-1; 214 while(ntries--) { 215 unsigned int resp_len; 216 quadlet_t* resp = m_p1394Service->transactionBlock( m_nodeId, 217 (quadlet_t*)m_fcpFrame, 218 ( fcpFrameSize+3 ) / 4, 219 &resp_len ); 220 if ( resp ) { 221 resp_len *= 4; 222 unsigned char* buf = ( unsigned char* ) resp; 223 224 m_eResponse = ( EResponse )( *buf ); 225 switch ( m_eResponse ) 226 { 227 case eR_Accepted: 228 case eR_Implemented: 229 case eR_Rejected: 230 case eR_NotImplemented: 231 { 232 Util::Cmd::BufferDeserialize de( buf, resp_len ); 233 result = deserialize( de ); 234 235 debugOutputShort( DEBUG_LEVEL_VERY_VERBOSE," Response:\n"); 236 showFcpFrame( buf, de.getNrOfConsumedBytes() ); 237 238 Util::Cmd::StringSerializer se_dbg; 239 serialize( se_dbg ); 240 241 // output the debug message in smaller chunks to avoid problems 242 // with a max message size 243 unsigned int chars_to_write=se_dbg.getString().size(); 244 unsigned int chars_written=0; 245 while (chars_written<chars_to_write) { 246 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%s\n", 247 se_dbg.getString().substr(chars_written, DEBUG_MAX_MESSAGE_LENGTH).c_str()); 248 chars_written += DEBUG_MAX_MESSAGE_LENGTH-1; 249 } 250 } 251 break; 252 default: 253 debugWarning( "unexpected response received (0x%x)\n", m_eResponse ); 254 debugOutputShort( DEBUG_LEVEL_VERY_VERBOSE," Response:\n"); 255 256 Util::Cmd::BufferDeserialize de( buf, resp_len ); 257 deserialize( de ); 258 259 showFcpFrame( buf, de.getNrOfConsumedBytes() ); 260 247 261 } 248 262 debugOutputShort( DEBUG_LEVEL_VERY_VERBOSE, "\n" ); 263 m_p1394Service->transactionBlockClose(); 264 break; // response received 265 } else { 266 debugOutput( DEBUG_LEVEL_VERBOSE, "no response (ntries: %d)\n", ntries ); 267 m_p1394Service->transactionBlockClose(); 268 SleepRelativeUsec( m_time * 10 ); 249 269 } 250 break; 251 default: 252 debugWarning( "unexpected response received (0x%x)\n", m_eResponse ); 253 debugOutputShort( DEBUG_LEVEL_VERY_VERBOSE," Response:\n"); 254 255 Util::Cmd::BufferDeserialize de( buf, resp_len ); 256 deserialize( de ); 257 258 showFcpFrame( buf, de.getNrOfConsumedBytes() ); 259 260 } 261 } else { 262 debugWarning( "no response\n" ); 263 } 264 265 debugOutputShort( DEBUG_LEVEL_VERY_VERBOSE, "\n" ); 266 267 m_p1394Service->transactionBlockClose(); 270 } 271 272 if (!ntries) { 273 debugWarning( "transaction failed\n" ); 274 } 268 275 269 276 SleepRelativeUsec( m_time ); branches/libffado-2.0/src/libieee1394/ieee1394service.cpp
r1190 r1219 539 539 len, 540 540 resp_len, 541 1 0);541 1 ); 542 542 543 543 for ( unsigned int i = 0; i < *resp_len; ++i ) { branches/libffado-2.0/support/dbus/ffado-dbus-server.cpp
r1201 r1219 246 246 return exitfunction(-1); 247 247 } 248 printMessage("FFADO Control DBUS service\n"); 248 249 249 250 debugOutput( DEBUG_LEVEL_NORMAL, "verbose level = %d\n", arguments.verbose); 250 251 debugOutput( DEBUG_LEVEL_NORMAL, "Using ffado library version: %s\n\n", ffado_get_version() ); 251 252 252 m_deviceManager = new DeviceManager(); 253 if ( !m_deviceManager ) { 254 debugError("Could not allocate device manager\n" ); 255 return exitfunction(-1); 256 } 257 if ( !m_deviceManager->initialize() ) { 258 debugError("Could not initialize device manager\n" ); 259 delete m_deviceManager; 260 return exitfunction(-1); 261 } 262 if ( arguments.verbose ) { 263 m_deviceManager->setVerboseLevel(arguments.verbose); 264 } 265 if ( !m_deviceManager->discover(arguments.use_cache) ) { 266 debugError("Could not discover devices\n" ); 267 delete m_deviceManager; 268 return exitfunction(-1); 269 } 270 271 // add pre-update handler 272 Util::Functor* preupdate_functor = new Util::CallbackFunctor0< void (*)() > 273 ( &preUpdateHandler, false ); 274 if ( !preupdate_functor ) { 275 debugFatal( "Could not create pre-update handler\n" ); 276 return false; 277 } 278 if(!m_deviceManager->registerPreUpdateNotification(preupdate_functor)) { 279 debugError("could not register pre-update notifier"); 280 } 281 // add post-update handler 282 Util::Functor* postupdate_functor = new Util::CallbackFunctor0< void (*)() > 283 ( &postUpdateHandler, false ); 284 if ( !postupdate_functor ) { 285 debugFatal( "Could not create post-update handler\n" ); 286 return false; 287 } 288 if(!m_deviceManager->registerPostUpdateNotification(postupdate_functor)) { 289 debugError("could not register post-update notifier"); 290 } 291 292 signal (SIGINT, sighandler); 293 294 DBus::_init_threading(); 253 254 printMessage(" Discovering devices...\n"); 255 m_deviceManager = new DeviceManager(); 256 if ( !m_deviceManager ) { 257 debugError("Could not allocate device manager\n" ); 258 return exitfunction(-1); 259 } 260 if ( !m_deviceManager->initialize() ) { 261 debugError("Could not initialize device manager\n" ); 262 delete m_deviceManager; 263 return exitfunction(-1); 264 } 265 if ( arguments.verbose ) { 266 m_deviceManager->setVerboseLevel(arguments.verbose); 267 } 268 if ( !m_deviceManager->discover(arguments.use_cache) ) { 269 debugError("Could not discover devices\n" ); 270 delete m_deviceManager; 271 return exitfunction(-1); 272 } 273 274 // add pre-update handler 275 Util::Functor* preupdate_functor = new Util::CallbackFunctor0< void (*)() > 276 ( &preUpdateHandler, false ); 277 if ( !preupdate_functor ) { 278 debugFatal( "Could not create pre-update handler\n" ); 279 return false; 280 } 281 if(!m_deviceManager->registerPreUpdateNotification(preupdate_functor)) { 282 debugError("could not register pre-update notifier"); 283 } 284 // add post-update handler 285 Util::Functor* postupdate_functor = new Util::CallbackFunctor0< void (*)() > 286 ( &postUpdateHandler, false ); 287 if ( !postupdate_functor ) { 288 debugFatal( "Could not create post-update handler\n" ); 289 return false; 290 } 291 if(!m_deviceManager->registerPostUpdateNotification(postupdate_functor)) { 292 debugError("could not register post-update notifier"); 293 } 294 295 signal (SIGINT, sighandler); 296 297 printMessage(" Starting DBUS service...\n"); 298 DBus::_init_threading(); 299 300 // test DBUS stuff 301 DBus::default_dispatcher = &dispatcher; 302 DBus::Connection conn = DBus::Connection::SessionBus(); 303 global_conn = &conn; 304 conn.request_name("org.ffado.Control"); 305 306 // lock the control tree such that it does not get modified while we build our view 307 m_deviceManager->lockControl(); 308 container = new DBusControl::Container(conn, "/org/ffado/Control/DeviceManager", 309 NULL, *m_deviceManager); 310 // unlock the control tree since the tree is built 311 m_deviceManager->unlockControl(); 312 313 printMessage(" Running... (press ctrl-c to stop & exit)\n"); 295 314 296 // test DBUS stuff 297 DBus::default_dispatcher = &dispatcher; 298 DBus::Connection conn = DBus::Connection::SessionBus(); 299 global_conn = &conn; 300 conn.request_name("org.ffado.Control"); 301 302 // lock the control tree such that it does not get modified while we build our view 303 m_deviceManager->lockControl(); 304 container = new DBusControl::Container(conn, "/org/ffado/Control/DeviceManager", 305 NULL, *m_deviceManager); 306 // unlock the control tree since the tree is built 307 m_deviceManager->unlockControl(); 308 309 printMessage("DBUS test service running\n"); 310 printMessage("press ctrl-c to stop it & exit\n"); 311 312 while(run) { 313 debugOutput( DEBUG_LEVEL_NORMAL, "dispatching...\n"); 314 dispatcher.enter(); 315 316 debugOutput( DEBUG_LEVEL_NORMAL, " dispatcher exited...\n"); 317 sem_wait(&run_sem); 318 debugOutput( DEBUG_LEVEL_NORMAL, " activity handled...\n"); 319 } 320 321 if(!m_deviceManager->unregisterPreUpdateNotification(preupdate_functor)) { 322 debugError("could not unregister pre update notifier"); 323 } 324 delete preupdate_functor; 325 if(!m_deviceManager->unregisterPostUpdateNotification(postupdate_functor)) { 326 debugError("could not unregister post update notifier"); 327 } 328 delete postupdate_functor; 329 delete container; 330 331 signal (SIGINT, SIG_DFL); 332 333 printMessage("server stopped\n"); 334 delete m_deviceManager; 335 return exitfunction(0); 336 } 315 while(run) { 316 debugOutput( DEBUG_LEVEL_NORMAL, "dispatching...\n"); 317 dispatcher.enter(); 318 319 debugOutput( DEBUG_LEVEL_NORMAL, " dispatcher exited...\n"); 320 sem_wait(&run_sem); 321 debugOutput( DEBUG_LEVEL_NORMAL, " activity handled...\n"); 322 } 323 324 printMessage(" Stopping...\n"); 325 if(!m_deviceManager->unregisterPreUpdateNotification(preupdate_functor)) { 326 debugError("could not unregister pre update notifier"); 327 } 328 delete preupdate_functor; 329 if(!m_deviceManager->unregisterPostUpdateNotification(postupdate_functor)) { 330 debugError("could not unregister post update notifier"); 331 } 332 delete postupdate_functor; 333 delete container; 334 335 signal (SIGINT, SIG_DFL); 336 delete m_deviceManager; 337 338 printMessage(" Bye.\n"); 339 return exitfunction(0); 340 }