Thursday, February 08, 2007

Cinelerra hanging after I move audio on the timeline

This is a bit off topic, but is related to troubleshooting Cinelerra. I have been having a problem with Cinelerra hanging for three or four minutes after I zoom in and slide audio tracks around on the timeline. To replicate the problem, I grabbed and moved the audio track (a wav file) around quite a bit, perhaps 10 times. In order to find the hanging thread, I started gdb ("gdb cinelerra pid").
[root@localhost ~]# ps -ef | grep cin
root 3671 3571 90 20:05 pts/2 00:17:55 cinelerra
root 4263 4178 0 20:25 pts/4 00:00:00 grep cin
[root@localhost ~]# gdb cinelerra 3671


Scrolling through the thread list, I identified the offending thread:

> Thread 65 (Thread -1520473168 (LWP 5674)):
> #0 0x0813fceb in CacheBase::get_oldest (this=0x8c04068) at cachebase.C:106
> #1 0x081f00bb in MWindow::age_caches (this=0xbfc5a288) at
> mwindow.C:1569
> #2 0x081f5e7b in MWindow::move_edits (this=0xbfc5a288, edits=0x8539b70,
> track=0x920f238, position=49.724958333333333, behaviour=1) at
> mwindowedit.C:830
> #3 0x08289ed6 in TrackCanvas::drag_stop (this=0xa9e1e7e0) at
> trackcanvas.C:575
> #4 0x0828a13d in TrackCanvas::drag_stop_event (this=0xa9e1e7e0) at
> trackcanvas.C:325
> #5 0xb7b73029 in BC_WindowBase::dispatch_drag_stop (this=0xa9e1e7e0) at
> bcwindowbase.C:1316
> #6 0xb7b7300e in BC_WindowBase::dispatch_drag_stop (this=0x8c44da0) at
> bcwindowbase.C:1311
> #7 0xb7b73122 in BC_WindowBase::dispatch_button_release
> (this=0x8c44da0) at bcwindowbase.C:1162
> #8 0xb7b778b1 in BC_WindowBase::dispatch_event (this=0x8c44da0) at
> bcwindowbase.C:787
> #9 0xb7b78739 in BC_WindowBase::run_window (this=0x8c44da0) at
> bcwindowbase.C:614
> #10 0xb7b88bb8 in Thread::entrypoint (parameters=0xbfc5a288) at
> thread.C:48
> #11 0x00da0b80 in start_thread () from /lib/libpthread.so.0
> #12 0x00c11dee in clone () from /lib/libc.so.6


I then exited gdb and found that the process hang was still occurring.
In order to step through the program code, I use kdbg, a graphical debugger. I started up kdbg ("kdbg -p /usr/local/bin/cinelerra") and
selected "View -> Threads". I then used an alternating combination of
F8 and F10 to step in and out of the code. I found that kdbg hung at
this line of code: MWindow.C:1561. It took a while, maybe five minutes
for kdbg to free up. This indicates where the hang is occurring. After the release, I exited the debugger.

Here is the snippet of hvirtual/cinelerra/mwindow.C code starting at
line 1561:

> if(memory_usage > preferences->cache_size)
> {
> int target = 1;
> int oldest1 = audio_cache->get_oldest();
> int oldest2 = video_cache->get_oldest();
> if(oldest2 < target =" 2;"> int oldest3 = frame_cache->get_oldest();
> if(oldest3 <> target = 3;
> int oldest4 = wave_cache->get_oldest();
> if(oldest4 <> oldest4 < target =" 4;"> switch(target)
> {
> case 1: audio_cache->delete_oldest();
> break;
> case 2: video_cache->delete_oldest();
> break;
> case 3: frame_cache->delete_oldest();
> break;
> case 4: wave_cache->delete_oldest();
> break;
> }
> }

I'm not a very experienced C programmer, but inferring from the if statement, it looks like I only go into this control structure if cin's memory usage is
greater than the value stated in Preferences -> Cache Size. I have it
set to the default value of 10MB.

I have not yet found the cause of this particular hang, but I will update my blog once I have an answer.

No comments: