Results 1 to 5 of 5

Thread: Phonon performance slow down

  1. #1
    Join Date
    Mar 2013
    Posts
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Phonon performance slow down

    Hi,

    i've a problem using the phonon video player. I play a video on loop, but after some hours the application slow down. The memory usage is stable.

    I use it in that way:
    Qt Code:
    1. guiMain::guiMain(QWidget *parent) :
    2. QWidget(parent),
    3. ui(new Ui::guiMain)
    4. {
    5. ...
    6.  
    7. //video
    8. video=0;
    9. QString videoFileName;
    10. videoFileName.append(conf::Instance()->systemVideoPath);
    11. videoFileName.append(conf::Instance()->adsVideoFileName);
    12. QFile videoFile(videoFileName);
    13. videoRestartTime=new QTimer(this);
    14. if (videoFile.exists()){
    15. ui->videoPlayer->show();
    16. video = new Phonon::MediaSource(videoFileName);
    17. ui->videoPlayer->play(*video);
    18. connect(ui->videoPlayer->mediaObject(),SIGNAL(finished()), this,SLOT(videoRestart()));
    19. pictureEnable=false;
    20. videoEnable=true;
    21. }else{
    22. ui->videoPlayer->hide();
    23. ui->lblAds->show();
    24. pictureEnable=true;
    25. videoEnable=false;
    26. video=0;
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void guiMain::videoRestart(){
    2. if(videoEnable){
    3. if (video!=0){
    4. ui->videoPlayer->stop();
    5. ui->videoPlayer->load(*video);
    6. ui->videoPlayer->play();
    7. }else
    8. pErrorMng->alarmPush(302,warning,tr("Main Gui"), tr("Ads video not found"));
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    the ui->videoPlayer is a Phonon::videoPlayer

    What is wrong?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Phonon performance slow down

    When are you deleting the video object?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2013
    Posts
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Phonon performance slow down

    Never, I create it at the constructor and destroy at the exit.

    I pass always the same object to the videoPlayer, do I have to create and destroy the mediaObject and the videoPlayer every time?

    The strange thing is that the memory occupancy doesn't increase and if I disable the video(stop and clear) the application return back to the same performance.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Phonon performance slow down

    Well... first of all you can create that object as a member variable so that you don't have to dereference it everytime you have to pass it to Phonon. Not that it is going to make your code significantly faster but then you didn't show us anything that could help pinpoint the problem so that's the only comment I can give looking at the code you posted.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2013
    Posts
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Phonon performance slow down

    thanks you for your help.

    I post all the class about the video so you can have a look:

    guiMain.h
    Qt Code:
    1. class guiMain : public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. explicit guiMain(QWidget *parent = 0);
    7. ~guiMain();
    8. ...
    9.  
    10. public slots:
    11.  
    12.  
    13. private slots:
    14.  
    15. ...
    16.  
    17. void updateAds();
    18. void videoRestart();
    19. void videoAutoRestart();
    20.  
    21. signals:
    22.  
    23. private:
    24.  
    25. ...
    26. //video
    27. Phonon::MediaSource video;
    28. QTimer * videoRestartTime;
    29. void startVideo();
    30. void stopVideo();
    31.  
    32. };
    To copy to clipboard, switch view to plain text mode 


    guiMain.cpp
    Qt Code:
    1. guiMain::guiMain(QWidget *parent) :
    2. QWidget(parent),
    3. ui(new Ui::guiMain)
    4. {
    5. ui->setupUi(this);
    6.  
    7. ...
    8. //video
    9. QString videoFileName;
    10. videoFileName.append(conf::Instance()->systemVideoPath);
    11. videoFileName.append(conf::Instance()->adsVideoFileName);
    12. QFile videoFile(videoFileName);
    13. videoRestartTime=new QTimer(this);
    14. if (videoFile.exists()){
    15. ui->videoPlayer->show();
    16. video=Phonon::MediaSource (videoFileName);
    17. ui->videoPlayer->load(video);
    18. ui->videoPlayer->play();
    19. connect(ui->videoPlayer->mediaObject(),SIGNAL(aboutToFinish()), this,SLOT(videoAutoRestart()));
    20. pictureEnable=false;
    21. videoEnable=true;
    22. }else{
    23. ui->videoPlayer->hide();
    24. ui->lblAds->show();
    25. pictureEnable=true;
    26. videoEnable=false;
    27. }
    28. ...
    29. }
    30.  
    31. void guiMain::videoRestart(){
    32. if(videoEnable && ui->stackedWidget->currentIndex()==nav["pMain"]){
    33. ui->lblAds->hide();
    34. ui->videoPlayer->show();
    35. ui->videoPlayer->load(video);
    36. ui->videoPlayer->play();
    37. }
    38. }
    39.  
    40. void guiMain::videoAutoRestart(){
    41. ui->videoPlayer->mediaObject()->enqueue(video);
    42. ui->videoPlayer->play();
    43. }
    44.  
    45. void guiMain::stopVideo(){
    46. ui->videoPlayer->mediaObject()->clearQueue();
    47. ui->videoPlayer->mediaObject()->clear();
    48. ui->videoPlayer->stop();
    49. }
    To copy to clipboard, switch view to plain text mode 

    The videoRestart is called when I get back to the main screen, the stopVideo is called when i get out of it.
    The videoAutoRestart is a slot connected to the aboutToFinish signal

Similar Threads

  1. Multiple QGLWidgets slow performance
    By seesomi in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2013, 09:20
  2. Slow SQLite performance
    By themagician in forum Newbie
    Replies: 0
    Last Post: 26th April 2012, 14:23
  3. QT App performance is too slow on OSX
    By joshhhab in forum Newbie
    Replies: 1
    Last Post: 28th May 2011, 08:30
  4. Slow performance of QGraphicsView - why?
    By zeldaknight in forum Newbie
    Replies: 2
    Last Post: 25th August 2010, 03:34
  5. Replies: 1
    Last Post: 8th August 2010, 20:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.