Ejemplo n.º 1
0
XineEngine::~XineEngine()
{
    // Wait until the fader thread is done
    if( s_fader ) {
        m_stopFader = true;
        s_fader->resume(); // safety call if the engine is in the pause state
        s_fader->wait();
    }

    delete s_fader;
    delete s_outfader;

    if( PanaConfig::fadeoutOnExit() ) {
        bool terminateFader = false;
        fadeOut( PanaConfig::fadeoutLength(), &terminateFader, true ); // true == exiting
    }

    if( m_xine )       xine_config_save( m_xine, configPath() );

    if( m_stream )     xine_close( m_stream );
    if( m_eventQueue ) xine_event_dispose_queue( m_eventQueue );
    if( m_stream )     xine_dispose( m_stream );
    if( m_audioPort )  xine_close_audio_driver( m_xine, m_audioPort );
    if( m_post )       xine_post_dispose( m_xine, m_post );
    if( m_xine )       xine_exit( m_xine );

    debug() << "xine closed\n";

    debug() << "Scope statistics:\n"
            << "  Average list size: " << Log::bufferCount / Log::scopeCallCount << endl
            << "  Buffer failure:    " << double(Log::noSuitableBuffer*100) / Log::scopeCallCount << "%\n";
}
static void
IDirectFBVideoProvider_Xine_Destruct( IDirectFBVideoProvider *thiz )
{
     IDirectFBVideoProvider_Xine_data *data = thiz->priv;

     if (data->xine) {
          if (data->stream) {              
               xine_stop( data->stream );

               xine_close( data->stream );

               if (data->queue)
                    xine_event_dispose_queue( data->queue );
               
               xine_dispose( data->stream );
          }

          if (data->post)
               xine_post_dispose( data->xine, data->post );

          if (data->vo)
               xine_close_video_driver( data->xine, data->vo );

          if (data->ao)
               xine_close_audio_driver( data->xine, data->ao );

          if (data->cfg) {
               xine_config_save( data->xine, data->cfg );
               D_FREE( data->cfg );
          }

          xine_exit( data->xine );
     }

     if (data->buffer_thread) {
          direct_thread_cancel( data->buffer_thread );
          direct_thread_join( data->buffer_thread );
          direct_thread_destroy( data->buffer_thread );
     }
 
     if (data->buffer)
          data->buffer->Release( data->buffer );

     if (data->pipe) {
          unlink( data->pipe );
          D_FREE( data->pipe );
     }

     if (data->events)
          data->events->Release( data->events );

     D_FREE( data->mrl );

     pthread_mutex_destroy( &data->lock );
     
     DIRECT_DEALLOCATE_INTERFACE( thiz );
}
Ejemplo n.º 3
0
XineEngine::~XineEngine()
{
    // Wait until the fader thread is done
    if( s_fader ) {
        m_stopFader = true;
        s_fader->wait();
        delete s_fader;
    }

    // NOTE The fadeout gets stuck when the EQ is active, so we skip it then
    if( !m_equalizerEnabled && m_stream && state() == Engine::Playing )
    {
        const int volume = xine_get_param( m_stream, XINE_PARAM_AUDIO_AMP_LEVEL );
        const double D = 300000 * std::pow( (double)volume, -0.4951 );

        debug() << "Sleeping: " << D << ", " << volume << endl;

        for( int v = volume - 1; v >= 1; v-- ) {
            xine_set_param( m_stream, XINE_PARAM_AUDIO_AMP_LEVEL, v );

            const int sleep = int(D * (-log10( v + 1 ) + 2));

            ::usleep( sleep );
        }
        xine_stop( m_stream );
    }

    if( m_xine )       xine_config_save( m_xine, configPath() );

    if( m_stream )     xine_close( m_stream );
    if( m_eventQueue ) xine_event_dispose_queue( m_eventQueue );
    if( m_stream )     xine_dispose( m_stream );
    if( m_audioPort )  xine_close_audio_driver( m_xine, m_audioPort );
    if( m_post )       xine_post_dispose( m_xine, m_post );
    if( m_xine )       xine_exit( m_xine );

    debug() << "xine closed\n";

    debug() << "Scope statistics:\n"
            << "  Average list size: " << Log::bufferCount / Log::scopeCallCount << endl
            << "  Buffer failure:    " << double(Log::noSuitableBuffer*100) / Log::scopeCallCount << "%\n";
}