Michael Zenov | 14 Jun 2012 13:13
Picon

Windows C++ application crush

I made a simple demo program in C + + and run it in Linux and then Windows.
In Linux, everything is fine, but Windows program crashes. Video clip
= ~ 30 sec, audio clip = ~ 3.30 sec. Windows program crashes when the
video ends, the Linux program continues to play audio. The source code
below.

#include <Mlt.h>
using namespace Mlt;
using namespace std;

#include <iostream>
#include <stdlib.h>

#ifdef WIN32
extern "C" {
#include <SDL.h>
}

void eventHandling()
{
       SDL_Event event;
       while( SDL_PollEvent( &event ) ){
               switch( event.type ){
         case SDL_KEYDOWN:
                 if ( event.key.keysym.sym  = SDLK_q ) {
                         std::cout<< "Nice exit" << std::endl;
                         exit(0);
                 }
         default:
                 ;
               };
       }
}
#endif

Producer* createCustomProducer( Profile& profile, const std::string&
videoFile, const std::string& audioFile )
{
       Tractor *tractor = new Tractor();
       Producer video( profile, videoFile.c_str() );
       Producer audio( profile, audioFile.c_str() );
       //    Producer video( profile, "test.avi" );
       //    Producer audio( profile, "test.mp3" );

       tractor->set_track( video, 0 );
       tractor->set_track( audio, 1 );

       return tractor;

}

int main (int /*argc*/, char** /*argv*/)
{
   Factory::init( NULL );
   Profile profile;
   Consumer consumer( profile );
   consumer.set( "rescale", "none" );

   std::string videoFile = "test.avi";
   std::string audioFile = "test.mp3";

   Producer* producer = createCustomProducer(profile, videoFile, audioFile);

   consumer.connect( *producer );
   consumer.start();

   for(;;) {
#ifdef WIN32
       eventHandling();
#endif

       if ( (producer->frame() + 1) >= producer->get_length()) {
           break;
       } else {
           struct timespec tm = { 0, 40000 };
           nanosleep( &tm, NULL );
       }
   }
   delete producer;

}

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

Gmane