Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with export of project with Sample Track #3344

Closed
zonkmachine opened this issue Feb 11, 2017 · 12 comments
Closed

Problems with export of project with Sample Track #3344

zonkmachine opened this issue Feb 11, 2017 · 12 comments
Assignees

Comments

@zonkmachine
Copy link
Member

zonkmachine commented Feb 11, 2017

As discussed in PR #3341 there is some issues with exporting projects containing a Sample Track. I've only seen this when using SDL. ALSA works fine and other sound engines I haven't tried.

The renderer process will simply hang and never return to main(). If you do a --rendertracks export it will stop on the first Sample Track it tries tor render.

I'm not done bisecting this but it may have happened around these commits 8497d39 e55ec80

@zonkmachine zonkmachine changed the title SDL - problems with export of project with Sample Track from the command line SDL - problems with export of project with Sample Track Feb 11, 2017
@zonkmachine
Copy link
Member Author

(gdb)   thread apply all bt full

Thread 2 (Thread 0x7fffdffc5700 (LWP 21314)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
No locals.
#1  0x00007ffff685a816 in wait (time=18446744073709551615, this=0xb84070) at thread/qwaitcondition_unix.cpp:86
        code = <optimized out>
#2  QWaitCondition::wait (this=<optimized out>, mutex=0x7fffdffc4e40, time=18446744073709551615) at thread/qwaitcondition_unix.cpp:158
No locals.
#3  0x0000000000535596 in MixerWorkerThread::run (this=0xa01840) at /home/zonkmachine/builds/lmms/lmms/src/core/MixerWorkerThread.cpp:162
        m = {d = 0x7fffd80013d0}
#4  0x00007ffff685a32f in QThreadPrivate::start (arg=0xa01840) at thread/qthread_unix.cpp:349
        __clframe = {__cancel_routine = 0x7ffff6859300 <QThreadPrivate::finish(void*)>, __cancel_arg = 0xa01840, __do_it = 1, 
          __cancel_type = <optimized out>}
        thr = 0xa01840
        data = <optimized out>
        objectName = {static null = {<No data fields>}, static shared_null = {ref = {_q_value = 1743}, alloc = 0, size = 0, 
            data = 0x7ffff6cc293a <QString::shared_null+26>, clean = 0, simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, 
            array = {0}}, static shared_empty = {ref = {_q_value = 2}, alloc = 0, size = 0, data = 0x7ffff6cc291a <QString::shared_empty+26>, clean = 0, 
            simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, d = 0x7ffff6cc2920 <QString::shared_null>, 
          static codecForCStrings = 0x0}
#5  0x00007ffff7bc4184 in start_thread (arg=0x7fffdffc5700) at pthread_create.c:312
        __res = <optimized out>
        pd = 0x7fffdffc5700
        now = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140736951244544, -2079227267844162622, 1, 0, 140736951245248, 140736951244544, 2079156870619577282, 
                2079245381250431938}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#6  0x00007ffff3f35ffd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
No locals.

Thread 1 (Thread 0x7ffff7fab7c0 (LWP 21310)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
No locals.
#1  0x00007ffff685a816 in wait (time=18446744073709551615, this=0xa01e60) at thread/qwaitcondition_unix.cpp:86
        code = <optimized out>
#2  QWaitCondition::wait (this=<optimized out>, mutex=0xb7bff8, time=18446744073709551615) at thread/qwaitcondition_unix.cpp:158
No locals.
#3  0x0000000000530ce0 in Mixer::requestChangeInModel (this=0xb7bec0) at /home/zonkmachine/builds/lmms/lmms/src/core/Mixer.cpp:773
No locals.
#4  0x0000000000530a58 in Mixer::removePlayHandlesOfTypes (this=0xb7bec0, _track=0x7fffeac2a420, types=4 '\004')
    at /home/zonkmachine/builds/lmms/lmms/src/core/Mixer.cpp:734
        it = {i = 0x1}
#5  0x000000000062f0e3 in SampleTCO::playbackPositionChanged (this=0x7fffeac2a820) at /home/zonkmachine/builds/lmms/lmms/src/tracks/SampleTrack.cpp:168
        st = 0x7ffff6962e09 <QMetaObject::cast(QObject*) const+25>
#6  0x00000000006402af in SampleTCO::qt_static_metacall (_o=0x7fffeac2a820, _c=QMetaObject::InvokeMetaMethod, _id=5, _a=0x7fffa4003270)
    at /home/zonkmachine/builds/lmms/lmms/build/src/moc_SampleTrack.cpp:65
        _t = 0x7fffeac2a820
#7  0x00007ffff6974c1e in QObject::event (this=0x7fffeac2a820, e=<optimized out>) at kernel/qobject.cpp:1194
---Type <return> to continue, or q <return> to quit---
        mce = <optimized out>
        currentSender = {sender = 0xb80160, signal = 9, ref = 1}
        previousSender = 0x0

@PhysSong
Copy link
Member

Reproduced with ALSA.

@musikBear
Copy link

@PhysSong can you elaborate
How long was the sample?
Where in the project was it placed?
Was there other tracks in the project (upload project on lsp
Was it a cmd-line export, and how did it go if the export was internal from menu?
Ogg or wave or both?

@PhysSong
Copy link
Member

@musikBear I can reproduce it for various samples. I used gui, and the exported file has .wav extension.
However, It seems to be a bug of LMMS core. I think it is from thread synchronization.

@PhysSong
Copy link
Member

I think 5606a04 may be related. @jasp00 may know what goes wrong.

@musikBear
Copy link

I used gui, : a bug of LMMS core. I think it is from thread synchronization.

Then its a critical :/

@PhysSong
Copy link
Member

PhysSong commented Jul 29, 2017

@PhysSong
Copy link
Member

After the exporting ends, ProjectRenderer::run() calls Song::stopExport(), it calls Song::stop(), and it emits playbackStateChanged(), so SampleTCO::playbackPositionChanged() receives the signal.

requestChangeInModel() waits for runChangesInModel(), which is called by AudioDevice::getNextBuffer() while exporting, or Mixer::fifoWriter::run() otherwise.
So, runChangesInModel() is never called between the end of export and the calling of restoreAudioDevice() in ~ProjectRenderer().

However, ~ProjectRenderer() isn't called until finished() signal is emitted by renderer. To be emitted finished(), event handling must be finished, but SampleTCO::playbackPositionChanged() is still waiting. Now there's a deadlock!

@zonkmachine
Copy link
Member Author

Easy to fix?

@PhysSong
Copy link
Member

I'm testing a simple fix: postpone the emitting of playbackStateChanged(). It looks fine, but I need more testings.

@musikBear
Copy link

but I need more testings.

I will install a test binary if you have any @PhysSong

@PhysSong
Copy link
Member

Actually I have some choices.
@musikBear I'll post the binary after I choose one of them.

@PhysSong PhysSong self-assigned this Aug 1, 2017
@zonkmachine zonkmachine changed the title SDL - problems with export of project with Sample Track Problems with export of project with Sample Track Aug 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants