Bug 98223

Summary: JuK takes 100% of cpu while paused with aKode output
Product: akodelib Reporter: Hasso Tepper <hasso>
Component: generalAssignee: Allan Sandfeld <kde>
Status: RESOLVED FIXED    
Severity: normal CC: georgi.r.ivanov, mr_smith, uli.2001, vide80
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Hasso Tepper 2005-01-30 20:18:06 UTC
Version:           2.1.89 (using KDE 3.3.91 (beta1), compiled sources)
Compiler:          gcc version 3.3.5 (Debian 1:3.3.5-6)
OS:                Linux (i686) release 2.6.10-rc2-bk8

As short description says ... Although aKode output works like a charm mostly, JuK takes 100% of cpu if paused.
Comment 1 Scott Wheeler 2005-01-30 20:30:16 UTC
This was fixed a long time ago...actually about 2 days after the aKode backend came in.
Comment 2 Hasso Tepper 2005-01-30 20:46:58 UTC
Scott Wheeler wrote:
> This was fixed a long time ago...actually about 2 days after the aKode 
> backend came in. 

I recompiled whole kdemultimedia HEAD from scratch yesterday (make cvs-clean 
etc). And bug is there for me.

Comment 3 Scott Wheeler 2005-01-30 20:55:19 UTC
Hmm, ok -- I'll pass this on to aKode then.  I had this problem when the backend was new, but Allan quickly fixed it.

You'll probably want to follow the instructions here to get a backtrace:

http://developer.kde.org/~wheeler/freeze.html
Comment 4 Hasso Tepper 2005-02-02 12:51:34 UTC
#0  0x410ea4e7 in select () from /lib/tls/libc.so.6
#1  0xb671351a in QEventLoop::processEvents (this=0x81efca8, flags=4) at kernel/qeventloop_x11.cpp:287
#2  0xb67826e9 in QEventLoop::enterLoop (this=0x81efca8) at kernel/qeventloop.cpp:198
#3  0xb6782602 in QEventLoop::exec (this=0x81efca8) at kernel/qeventloop.cpp:145
#4  0xb676e1c1 in QApplication::exec (this=0xbffff6b0) at kernel/qapplication.cpp:2758
#5  0x080e0218 in main (argc=2, argv=0xbffff864) at main.cpp:93
Comment 5 Hasso Tepper 2005-02-02 12:53:17 UTC
Ah, forgot to mention that I upgraded to the latest qt-copy (3.3.4) as well. Maybe it's related.
Comment 6 Allan Sandfeld 2005-02-18 12:44:30 UTC
I need the other backtrace as well. Akode generates a new thread and the backtrace of the other thread is much more interesting.
Comment 7 Hasso Tepper 2005-02-19 14:33:40 UTC
Due to disk crashes I have no room to compile KDE with debug info at the moment. It might take some weeks.
Comment 8 Max Howell 2005-03-15 22:31:57 UTC
*** Bug 101433 has been marked as a duplicate of this bug. ***
Comment 9 Allan Sandfeld 2005-03-22 01:51:00 UTC
Using OSS output and the nvsound driver, I can now reproduce the bug as well.
Comment 10 Alexandre Oliveira 2005-04-15 23:37:08 UTC
*** Bug 103978 has been marked as a duplicate of this bug. ***
Comment 11 Luke Plant 2005-04-30 18:12:01 UTC
I'm seeing this too, and at other times:
 - after un-pausing, 95% CPU usage continues
 - if I close the window (as opposed to either minimising or quitting), CPU immediately goes to 95%
 - often, a minute or so into a track, it will just start happening, sometimes after much less time.


Comment 12 Allan Sandfeld 2005-05-07 18:28:04 UTC
SVN commit 410345 by carewolf:

Avoid looping while paused.
BUG:98223


 M  +4 -0      trunk/KDE/kdemultimedia/akode/lib/audiobuffer.cpp  
 M  +3 -0      trunk/KDE/kdemultimedia/akode/lib/player.cpp  
 M  +8 -2      trunk/KDE/kdemultimedia/akode/lib/streamtoframe_decoder.cpp  
 M  +2 -0      trunk/KDE/kdemultimedia/akode/lib/streamtoframe_decoder.h  


--- trunk/KDE/kdemultimedia/akode/lib/audiobuffer.cpp #410344:410345
@@ -116,7 +116,11 @@
 }
 
 void AudioBuffer::resume() {
+    pthread_mutex_lock(&mutex);
     paused = false;
+    if (!empty())
+        pthread_cond_signal(&not_empty);
+    pthread_mutex_unlock(&mutex);
 }
 
 } // namespace
--- trunk/KDE/kdemultimedia/akode/lib/player.cpp #410344:410345
@@ -108,6 +108,8 @@
             else
             if (m_data->in_decoder->eof())
                 goto eof;
+            else
+                std::cerr << "Blip?\n";
         }
         else {
             AudioFrame* out_frame = &frame;
@@ -336,6 +338,7 @@
     // connect the streams to play
     m_data->decoder = new FrameToStreamDecoder(m_data->frame_decoder);
     m_data->in_decoder = new StreamToFrameDecoder(m_data->decoder, m_data->buffer);
+    m_data->in_decoder->setBlocking(true);
 
     //m_data->player_thread = new pthread_t;
     if (pthread_create(&m_data->player_thread, 0, run_player, m_data) == 0) {
--- trunk/KDE/kdemultimedia/akode/lib/streamtoframe_decoder.cpp #410344:410345
@@ -34,13 +34,15 @@
                    , xfader(0)
                    , latestPos(-1)
                    , halted(false)
-                   , halting(false) {};
+                   , halting(false)
+                   , blocking(false) {};
     AudioBuffer *buffer;
     StreamDecoder *inDecoder;
     CrossFader *xfader;
     long latestPos;
     AudioConfiguration latest_config;
     bool halted, halting;
+    bool blocking;
 };
 
 StreamToFrameDecoder::StreamToFrameDecoder(StreamDecoder *inDecoder, AudioBuffer *buffer)
@@ -74,7 +76,7 @@
         return true;
     }
     // Get non-blocking
-    if (m_data->buffer->get(frame, false)) {
+    if (m_data->buffer->get(frame, m_data->blocking)) {
         m_data->latestPos = frame->pos;
         m_data->latest_config = *frame;
 
@@ -146,6 +148,10 @@
     }
 }
 
+void StreamToFrameDecoder::setBlocking(bool block) {
+    m_data->blocking = block;
+}
+
 const AudioConfiguration* StreamToFrameDecoder::audioConfiguration() {
     if (m_data->latest_config.channels > 0)
         return &m_data->latest_config;
--- trunk/KDE/kdemultimedia/akode/lib/streamtoframe_decoder.h #410344:410345
@@ -43,6 +43,8 @@
     virtual void stop();
     virtual void resume();
 
+    void setBlocking(bool block);
+
     virtual const AudioConfiguration* audioConfiguration();
 
     struct private_data;
Comment 13 Allan Sandfeld 2005-05-14 13:55:11 UTC
*** Bug 105651 has been marked as a duplicate of this bug. ***
Comment 14 Alexandre Oliveira 2005-05-16 21:29:48 UTC
*** Bug 105746 has been marked as a duplicate of this bug. ***