Changeset 767
- Timestamp:
- 12/23/07 07:21:18 (16 years ago)
- Files:
-
- trunk/libffado/src/libieee1394/CycleTimerHelper.cpp (modified) (10 diffs)
- trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (modified) (2 diffs)
- trunk/libffado/src/libieee1394/IsoHandlerManager.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/libieee1394/CycleTimerHelper.cpp
r764 r767 32 32 #define DLL_COEFF_B (DLL_SQRT2 * DLL_OMEGA) 33 33 #define DLL_COEFF_C (DLL_OMEGA * DLL_OMEGA) 34 35 /* 36 #define ENTER_CRITICAL_SECTION { \ 37 if (pthread_mutex_trylock(&m_compute_vars_lock) == EBUSY) { \ 38 debugWarning(" (%p) lock clash\n", this); \ 39 ENTER_CRITICAL_SECTION; \ 40 } \ 41 } 42 */ 43 #define ENTER_CRITICAL_SECTION { \ 44 ENTER_CRITICAL_SECTION; \ 45 } 46 #define EXIT_CRITICAL_SECTION { \ 47 EXIT_CRITICAL_SECTION; \ 48 } 49 34 50 35 51 IMPL_DEBUG_MODULE( CycleTimerHelper, CycleTimerHelper, DEBUG_LEVEL_NORMAL ); … … 168 184 CycleTimerHelper::Execute() 169 185 { 170 debugOutput( DEBUG_LEVEL_ ULTRA_VERBOSE, "Execute %p...\n", this);186 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Execute %p...\n", this); 171 187 uint32_t cycle_timer; 172 188 uint64_t local_time; … … 175 191 return false; 176 192 } 177 debugOutput( DEBUG_LEVEL_ ULTRA_VERBOSE, " read : CTR: %11lu, local: %17llu\n",193 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " read : CTR: %11lu, local: %17llu\n", 178 194 cycle_timer, local_time); 179 195 … … 195 211 196 212 double diff = m_next_time_usecs - m_current_time_usecs; 197 debugOutput( DEBUG_LEVEL_ ULTRA_VERBOSE, " usecs: local: %11llu current: %f next: %f, diff: %f\n",213 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " usecs: local: %11llu current: %f next: %f, diff: %f\n", 198 214 local_time, m_current_time_usecs, m_next_time_usecs, diff); 199 215 … … 204 220 m_current_time_usecs = m_next_time_usecs; 205 221 m_next_time_usecs = (local_time - usecs_late) + m_usecs_per_update; 206 debugOutput( DEBUG_LEVEL_ ULTRA_VERBOSE, " usecs: current: %f next: %f usecs_late=%f\n",222 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " usecs: current: %f next: %f usecs_late=%f\n", 207 223 m_current_time_usecs, m_next_time_usecs, usecs_late); 208 224 … … 213 229 (uint64_t)((DLL_COEFF_B * diff_ticks) + m_dll_e2)); 214 230 m_dll_e2 += DLL_COEFF_C * diff_ticks; 215 debugOutput( DEBUG_LEVEL_ ULTRA_VERBOSE, " ticks: current: %f next: %f diff=%f\n",231 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " ticks: current: %f next: %f diff=%f\n", 216 232 m_current_time_ticks, m_next_time_ticks, diff_ticks); 217 233 218 debugOutput( DEBUG_LEVEL_ ULTRA_VERBOSE, " state: local: %11llu, dll_e2: %f, rate: %f\n",234 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " state: local: %11llu, dll_e2: %f, rate: %f\n", 219 235 local_time, m_dll_e2, getRate()); 220 236 } … … 224 240 225 241 // FIXME: priority inversion! 226 pthread_mutex_lock(&m_compute_vars_lock);242 ENTER_CRITICAL_SECTION; 227 243 m_current_vars.ticks = m_current_time_ticks; 228 244 m_current_vars.usecs = m_current_time_usecs; 229 245 m_current_vars.rate = getRate(); 230 pthread_mutex_unlock(&m_compute_vars_lock);246 EXIT_CRITICAL_SECTION; 231 247 232 248 // wait for the next update period … … 235 251 //int64_t time_to_sleep = m_usecs_per_update; 236 252 if (time_to_sleep > 0) { 237 debugOutput( DEBUG_LEVEL_ ULTRA_VERBOSE, " sleeping %lld usecs (avg delay: %f)\n", time_to_sleep, m_avg_wakeup_delay);253 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " sleeping %lld usecs (avg delay: %f)\n", time_to_sleep, m_avg_wakeup_delay); 238 254 usleep(time_to_sleep); 239 255 } … … 255 271 256 272 // reduce lock contention 257 pthread_mutex_lock(&m_compute_vars_lock);273 ENTER_CRITICAL_SECTION; 258 274 my_vars = m_current_vars; 259 pthread_mutex_unlock(&m_compute_vars_lock);275 EXIT_CRITICAL_SECTION; 260 276 261 277 double time_diff = now - my_vars.usecs; … … 266 282 if (y_step_in_ticks_int > 0) { 267 283 retval = addTicks(offset_in_ticks_int, y_step_in_ticks_int); 284 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "y_step_in_ticks_int > 0: %lld, time_diff: %f, rate: %f, retval: %lu\n", 285 y_step_in_ticks_int, time_diff, my_vars.rate, retval); 268 286 } else { 287 retval = substractTicks(offset_in_ticks_int, -y_step_in_ticks_int); 288 269 289 // this can happen if the update thread was woken up earlier than it should have been 270 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "y_step_in_ticks_int <= 0: %lld, time_diff: %f, rate: %f\n", 271 y_step_in_ticks_int, time_diff, my_vars.rate); 272 retval = substractTicks(offset_in_ticks_int, -y_step_in_ticks_int); 290 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "y_step_in_ticks_int <= 0: %lld, time_diff: %f, rate: %f, retval: %lu\n", 291 y_step_in_ticks_int, time_diff, my_vars.rate, retval); 273 292 } 274 293 trunk/libffado/src/libieee1394/IsoHandlerManager.cpp
r759 r767 356 356 if(irq_interval <= 0) irq_interval=1; 357 357 // FIXME: test 358 //irq_interval=1;358 irq_interval=1; 359 359 360 360 #else … … 440 440 debugError("Max packet size too large! (%d)\n", stream->getMaxPacketSize()); 441 441 } 442 442 irq_interval=2; 443 443 #endif 444 444 // the SP specifies how many packets to buffer trunk/libffado/src/libieee1394/IsoHandlerManager.h
r760 r767 34 34 #include <vector> 35 35 36 // #define THREAD_PER_ISOHANDLER36 // #define THREAD_PER_ISOHANDLER 37 37 38 38 #define FFADO_MAX_ISO_HANDLERS_PER_PORT 16