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"; }
virtual ~ReaderWriterXine() { OSG_INFO<<"~ReaderWriterXine()"<<std::endl; if (_xine) xine_exit(_xine); _xine = NULL; }
void SjPlayer::DoStop() { if( m_impl->m_currStream ) { m_impl->m_currStream->PlaybackDone(); delete m_impl->m_currStream; m_impl->m_currStream = NULL; } if( m_impl->m_ao_port ) { xine_close_audio_driver(m_impl->m_xine, m_impl->m_ao_port); m_impl->m_ao_port = NULL; } if( m_impl->m_xine ) { xine_exit(m_impl->m_xine); m_impl->m_xine = NULL; } // clear the extension list to allow changes of plugins m_impl->m_extListInitialized = false; m_impl->m_extList.Clear(); }
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 ); }
void music_destroy () { xine_event_dispose_queue (events); xine_dispose (stream); xine_close_video_driver (xine, vo); xine_close_audio_driver (xine, ao); xine_exit (xine); }
static void icvCloseAVI_XINE( CvCaptureAVI_XINE* capture ) { xine_free_video_frame( capture->vo_port, &capture->xine_frame ); if ( capture->yuv_frame ) cvReleaseImage( &capture->yuv_frame ); if ( capture->bgr_frame ) cvReleaseImage( &capture->bgr_frame ); xine_close( capture->stream ); // xine_dispose( capture->stream ); if ( capture->vo_port ) xine_close_video_driver( capture->xine, capture->vo_port ); xine_exit( capture->xine ); }
void Xine_PyObject__dealloc(Xine_PyObject *self) { printf("DEalloc Xine: %p\n", self->xine); Py_DECREF(self->wrapper); Py_DECREF(self->dependencies); Xine_PyObject__clear(self); xine_object_to_pyobject_unregister(self->xine); printf("XINE EXIT\n"); if (self->xine) { xine_exit(self->xine); } self->ob_type->tp_free((PyObject*)self); }
bool SjPlayerImpl::InitXine() { if( m_xine ) { return true; // success, already open } // load options from INI wxConfigBase* c = g_tools->m_config; m_iniDevice = c->Read(wxT("xine/device"), wxT("auto")); // TODO: XInitThreads may be needed (for videos only?), see hackersguide.html /* if (!XInitThreads()) { wxLogDebug(wxT("InitXine()/XInitThreads() failed")); return 1; } */ // preinit xine m_xine = xine_new(); if( m_xine == NULL ) { goto Cleanup; } // load xine config file and init xine // TODO: this may also be possible by //xine_config_load(m_xine, "$HOME/.xine/config"); // postinit xine xine_init(m_xine); // success, xine opened return true; Cleanup: // error if( m_xine ) { xine_exit(m_xine); m_xine = NULL; } return false; }
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"; }
void engine_shutdown ( void ) { // Stop playing and close down the stream xine_stop( stream ); xine_stop( meta_stream ); xine_event_dispose_queue(queue); xine_close(stream); xine_close(meta_stream); xine_dispose(stream); xine_dispose(meta_stream); // Now shut down cleanly xine_close_audio_driver ( engine, ap ); // Now shut down cleanly xine_exit ( engine ); }
Xine::~Xine(){ pthread_mutex_lock(&stream_mutex); quitting = true; pthread_cond_broadcast(&stream_switch); pthread_mutex_unlock(&stream_mutex); if (!initted) return; pthread_join(thread_loop, NULL); pthread_mutex_lock(&stream_mutex); if(stream){ xine_close(stream); xine_event_dispose_queue(event_queue); event_queue = NULL; xine_dispose(stream); stream = NULL; } if (ao_port) xine_close_audio_driver(xine, ao_port); ao_port = NULL; xine_exit(xine); /* booo bye */ }
~eXine() { if (xine) xine_exit(xine); }
/* this is a slave controller thread for the xine module - libxine loves * to deadlock, internally stall and otherwise have unpredictable behavior * if we use the main process thread for many things - so a lot will be * farmed off to this slave. its job is to handle opening, closing, file * opening, recoder init etc. and all sorts of things can that often block. * anything this thread needs to return, it will return via the event pipe. */ static void * _em_slave(void *par) { Emotion_Xine_Video *ev; void *buf[2]; int len; ev = (Emotion_Xine_Video *)par; while ((len = read(ev->fd_slave_read, buf, sizeof(buf))) > 0) { if (len == sizeof(buf)) { Emotion_Xine_Event *eev; ev = buf[0]; eev = buf[1]; switch (eev->mtype) { case 0: /* noop */ break; case 1: /* init */ { ev->decoder = xine_new(); xine_init(ev->decoder); xine_register_plugins(ev->decoder, emotion_xine_plugin_info); if (1) { xine_cfg_entry_t cf; if (xine_config_lookup_entry(ev->decoder, "input.dvd_use_readahead", &cf)) { cf.num_value = 1; // 0 or 1 xine_config_update_entry(ev->decoder, &cf); } } DBG("OPEN VIDEO PLUGIN..."); if (!ev->opt_no_video) ev->video = xine_open_video_driver(ev->decoder, "emotion", XINE_VISUAL_TYPE_NONE, ev); DBG("RESULT: xine_open_video_driver() = %p", ev->video); // Let xine autodetect the best audio output driver if (!ev->opt_no_audio) ev->audio = xine_open_audio_driver(ev->decoder, NULL, ev); // ev->audio = xine_open_audio_driver(ev->decoder, "oss", ev); // dont use alsa - alsa has oss emulation. // ev->audio = xine_open_audio_driver(ev->decoder, "alsa", ev); // ev->audio = xine_open_audio_driver(ev->decoder, "arts", ev); // ev->audio = xine_open_audio_driver(ev->decoder, "esd", ev); ev->stream = xine_stream_new(ev->decoder, ev->audio, ev->video); ev->queue = xine_event_new_queue(ev->stream); xine_event_create_listener_thread(ev->queue, _em_event, ev); ev->opening = 0; ev->play_ok = 1; _em_module_event(ev, 1); /* event - open done */ } break; case 3: /* shutdown */ { _em_module_event(ev, 3); DBG("shutdown stop"); xine_stop(ev->stream); // pthread_mutex_lock(&(ev->get_pos_len_mutex)); if (!ev->get_pos_thread_deleted) { DBG("closing get_pos thread, %p", ev); pthread_mutex_lock(&(ev->get_pos_len_mutex)); pthread_cond_broadcast(&(ev->get_pos_len_cond)); pthread_mutex_unlock(&(ev->get_pos_len_mutex)); while (ev->get_poslen); } DBG("dispose %p", ev); xine_dispose(ev->stream); DBG("dispose evq %p", ev); xine_event_dispose_queue(ev->queue); DBG("close video drv %p", ev); if (ev->video) xine_close_video_driver(ev->decoder, ev->video); DBG("wait for vo to go"); while (ev->have_vo); DBG("vo gone"); DBG("close audio drv %p", ev); if (ev->audio) xine_close_audio_driver(ev->decoder, ev->audio); DBG("xine exit %p", ev); xine_exit(ev->decoder); DBG("DONE %p", ev); close(ev->fd_write); close(ev->fd_read); close(ev->fd_ev_write); close(ev->fd_ev_read); close(ev->fd_slave_write); close(ev->fd_slave_read); ev->closing = 0; if (eev->xine_event) free(eev->xine_event); free(eev); free(ev); return NULL; } break; case 2: /* file open */ { int pos_stream = 0; int pos_time = 0; int length_time = 0; uint32_t v; char *file; file = eev->xine_event; DBG("OPEN STREAM %s", file); if (xine_open(ev->stream, file)) { if (xine_get_pos_length(ev->stream, &pos_stream, &pos_time, &length_time)) { if (length_time == 0) { ev->pos = (double)pos_stream / 65535; ev->len = 1.0; ev->no_time = 1; } else { ev->pos = 0.0; ev->len = (double)length_time / 1000.0; } } else { ev->pos = 0.0; ev->len = 1.0; } v = xine_get_stream_info(ev->stream, XINE_STREAM_INFO_FRAME_DURATION); if (v > 0) ev->fps = 90000.0 / (double)v; v = xine_get_stream_info(ev->stream, XINE_STREAM_INFO_VIDEO_WIDTH); ev->w = v; v = xine_get_stream_info(ev->stream, XINE_STREAM_INFO_VIDEO_HEIGHT); ev->h = v; v = xine_get_stream_info(ev->stream, XINE_STREAM_INFO_VIDEO_RATIO); ev->ratio = (double)v / 10000.0; ev->just_loaded = 1; ev->get_poslen = 0; xine_set_param(ev->stream, XINE_PARAM_AUDIO_VOLUME, ev->volume * 100); } _em_module_event(ev, 2); /* event - open done */ } break; case 11: /* file close */ { DBG("done %p", ev); em_frame_done(ev); DBG("stop %p", ev); xine_stop(ev->stream); DBG("close %p", ev); xine_close(ev->stream); DBG("close done %p", ev); _em_module_event(ev, 11); } break; case 4: /* play */ { double pos; int pos_stream, pos_time, length_time; pos = *((double *)eev->xine_event); if ((xine_get_param(ev->stream, XINE_PARAM_SPEED) == XINE_SPEED_PAUSE) && (pos == ev->pos) && (!ev->just_loaded)) { xine_set_param(ev->stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL); } else { if (ev->no_time) xine_play(ev->stream, pos * 65535, 0); else xine_play(ev->stream, 0, pos * 1000); } ev->just_loaded = 0; if (xine_get_pos_length(ev->stream, &pos_stream, &pos_time, &length_time)) { if (length_time == 0) { ev->pos = (double)pos_stream / 65535; ev->len = 1.0; ev->no_time = 1; } else { ev->pos = (double)pos_time / 1000.0; ev->len = (double)length_time / 1000.0; } } _em_module_event(ev, 4); } break; case 5: /* stop */ { xine_set_param(ev->stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE); _em_module_event(ev, 5); } break; case 6: /* seek */ { double pos; pos = *((double *)eev->xine_event); if (ev->no_time) xine_play(ev->stream, pos * 65535, 0); else xine_play(ev->stream, 0, pos * 1000); if (!ev->play) xine_set_param(ev->stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE); _em_module_event(ev, 6); } break; case 7: /* eject */ { xine_eject(ev->stream); _em_module_event(ev, 7); } break; case 8: /* spu mute */ { xine_set_param(ev->stream, XINE_PARAM_IGNORE_SPU, ev->spu_mute); _em_module_event(ev, 8); } break; case 9: /* channel */ { xine_set_param(ev->stream, XINE_PARAM_SPU_CHANNEL, ev->spu_channel); _em_module_event(ev, 9); } break; case 10: /* vol */ { xine_set_param(ev->stream, XINE_PARAM_AUDIO_VOLUME, ev->volume * 100); _em_module_event(ev, 10); } break; case 12: /* audio mute */ { xine_set_param(ev->stream, XINE_PARAM_AUDIO_MUTE, ev->audio_mute); } break; case 13: /* audio mute */ { xine_set_param(ev->stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL, ev->audio_channel); } break; case 14: /* audio mute */ { xine_set_param(ev->stream, XINE_PARAM_VIDEO_CHANNEL, ev->video_channel); } break; default: break; } if (eev->xine_event) free(eev->xine_event); free(eev); } } return NULL; }