Exemplo n.º 1
0
/**
 * Destroy playlist.
 * This is not thread-safe. Any reference to the playlist is assumed gone.
 * (In particular, all interface and services threads must have been joined).
 *
 * \param p_playlist the playlist object
 */
void playlist_Destroy( playlist_t *p_playlist )
{
    playlist_private_t *p_sys = pl_priv(p_playlist);

    /* Remove all services discovery */
    playlist_ServicesDiscoveryKillAll( p_playlist );

    msg_Dbg( p_playlist, "destroying" );

    playlist_Deactivate( p_playlist );
    if( p_sys->p_preparser )
        playlist_preparser_Delete( p_sys->p_preparser );

    /* Release input resources */
    assert( p_sys->p_input == NULL );
    input_resource_Release( p_sys->p_input_resource );

    if( p_playlist->p_media_library != NULL )
        playlist_MLDump( p_playlist );

    PL_LOCK;
    /* Release the current node */
    set_current_status_node( p_playlist, NULL );
    /* Release the current item */
    set_current_status_item( p_playlist, NULL );
    PL_UNLOCK;

    vlc_cond_destroy( &p_sys->signal );
    vlc_mutex_destroy( &p_sys->lock );

    /* Remove all remaining items */
    FOREACH_ARRAY( playlist_item_t *p_del, p_playlist->all_items )
        free( p_del->pp_children );
        vlc_gc_decref( p_del->p_input );
        free( p_del );
    FOREACH_END();
    ARRAY_RESET( p_playlist->all_items );
    FOREACH_ARRAY( playlist_item_t *p_del, p_sys->items_to_delete )
        free( p_del->pp_children );
        vlc_gc_decref( p_del->p_input );
        free( p_del );
    FOREACH_END();
    ARRAY_RESET( p_sys->items_to_delete );

    ARRAY_RESET( p_playlist->items );
    ARRAY_RESET( p_playlist->current );

    vlc_http_cookie_jar_t *cookies = var_GetAddress( p_playlist, "http-cookies" );
    if ( cookies )
    {
        var_Destroy( p_playlist, "http-cookies" );
        vlc_http_cookies_destroy( cookies );
    }

    vlc_object_release( p_playlist );
}
Exemplo n.º 2
0
static void SysCleanup( stream_sys_t *p_sys )
{
    if ( p_sys->sms.i_size )
    {
        FOREACH_ARRAY( sms_stream_t *sms, p_sys->sms );
            sms_Free( sms );
        FOREACH_END();
        ARRAY_RESET( p_sys->sms );
    }
    ARRAY_RESET( p_sys->sms_selected );
    if ( p_sys->playback.init.p_datachunk )
        chunk_Free( p_sys->playback.init.p_datachunk );
    free( p_sys->download.base_url );
}
Exemplo n.º 3
0
static int Remove( addons_storage_t *p_storage, addon_entry_t *p_entry )
{
    vlc_mutex_lock( &p_entry->lock );
    FOREACH_ARRAY( addon_file_t *p_file, p_entry->files )
    switch( p_file->e_filetype )
    {
        case ADDON_EXTENSION:
        case ADDON_PLAYLIST_PARSER:
        case ADDON_SERVICE_DISCOVERY:
        case ADDON_INTERFACE:
        case ADDON_META:
        case ADDON_SKIN2:
        {
            char *psz_dest;

            char *psz_translated_filename = strdup( p_file->psz_filename );
            if ( !psz_translated_filename )
                return VLC_ENOMEM;
            char *tmp = psz_translated_filename;
            while (*tmp++) if ( *tmp == '/' ) *tmp = DIR_SEP_CHAR;

            char *psz_dir = getAddonInstallDir( p_file->e_filetype );
            if ( !psz_dir || asprintf( &psz_dest, "%s"DIR_SEP"%s", psz_dir,
                                       psz_translated_filename ) < 1 )
            {
                free( psz_dir );
                free( psz_translated_filename );
                return VLC_EGENERIC;
            }
            free( psz_dir );
            free( psz_translated_filename );

            vlc_unlink( psz_dest );
            msg_Dbg( p_storage, "removing %s", psz_dest );

            free( psz_dest );
            break;
        }
            /* Ignore all other unhandled files */
        case ADDON_UNKNOWN:
        case ADDON_PLUGIN:
        case ADDON_OTHER:
        default:
            break;
    }
    FOREACH_END()

    /* Remove file info on success */
    FOREACH_ARRAY( addon_file_t *p_file, p_entry->files )
    free( p_file->psz_filename );
    free( p_file->psz_download_uri );
    free( p_file );
    FOREACH_END()
    ARRAY_RESET( p_entry->files );

    vlc_mutex_unlock( &p_entry->lock );
    return VLC_SUCCESS;
}
Exemplo n.º 4
0
void ts_pat_Del( demux_t *p_demux, ts_pat_t *pat )
{
    if( dvbpsi_decoder_present( pat->handle ) )
        dvbpsi_pat_detach( pat->handle );
    dvbpsi_delete( pat->handle );
    for( int i=0; i<pat->programs.i_size; i++ )
        PIDRelease( p_demux, pat->programs.p_elems[i] );
    ARRAY_RESET( pat->programs );
    free( pat );
}
Exemplo n.º 5
0
void ts_pmt_Del( demux_t *p_demux, ts_pmt_t *pmt )
{
    if( dvbpsi_decoder_present( pmt->handle ) )
        dvbpsi_pmt_detach( pmt->handle );
    dvbpsi_delete( pmt->handle );
    for( int i=0; i<pmt->e_streams.i_size; i++ )
        PIDRelease( p_demux, pmt->e_streams.p_elems[i] );
    ARRAY_RESET( pmt->e_streams );
    if( pmt->p_mgt )
        PIDRelease( p_demux, pmt->p_mgt );
    if( pmt->iod )
        ODFree( pmt->iod );
    for( int i=0; i<pmt->od.objects.i_size; i++ )
        ODFree( pmt->od.objects.p_elems[i] );
    ARRAY_RESET( pmt->od.objects );
    if( pmt->i_number > -1 )
        es_out_Control( p_demux->out, ES_OUT_DEL_GROUP, pmt->i_number );
    free( pmt );
}
Exemplo n.º 6
0
void ql_Free( quality_level_t *qlevel )
{
    free( qlevel->CodecPrivateData );
    FOREACH_ARRAY( custom_attrs_t *p_attrs, qlevel->custom_attrs )
        free( p_attrs->psz_key );
        free( p_attrs->psz_value );
    FOREACH_END()
    ARRAY_RESET(qlevel->custom_attrs);
    free( qlevel );
    qlevel = NULL;
}
Exemplo n.º 7
0
Arquivo: ts_psip.c Projeto: RSATom/vlc
void ts_psip_context_Delete( ts_psip_context_t *p_ctx )
{
    assert( !p_ctx->p_mgt || !p_ctx->etts.i_size );
    assert( !p_ctx->p_vct || !p_ctx->eits.i_size );

    if( p_ctx->p_mgt )
        dvbpsi_atsc_DeleteMGT( p_ctx->p_mgt );
    if( p_ctx->p_stt )
        dvbpsi_atsc_DeleteSTT( p_ctx->p_stt );
    if ( p_ctx->p_vct )
        dvbpsi_atsc_DeleteVCT( p_ctx->p_vct );
    if( p_ctx->p_a65 )
        atsc_a65_handle_Release( p_ctx->p_a65 );
    /* Things only used for ETT/EIT */
    for( int i=0; i<p_ctx->etts.i_size; i++ )
        dvbpsi_atsc_DeleteETT( p_ctx->etts.p_elems[i] );
    for( int i=0; i<p_ctx->eits.i_size; i++ )
        dvbpsi_atsc_DeleteEIT( p_ctx->eits.p_elems[i] );
    ARRAY_RESET( p_ctx->etts );
    ARRAY_RESET( p_ctx->eits );
    free( p_ctx );
}
Exemplo n.º 8
0
Arquivo: vdr.c Projeto: Aakash-729/vlc
/*****************************************************************************
 * Close files and free resources
 *****************************************************************************/
static void Close( vlc_object_t * p_this )
{
    access_t *p_access = (access_t*)p_this;
    access_sys_t *p_sys = p_access->p_sys;

    if( p_sys->fd != -1 )
        close( p_sys->fd );
    ARRAY_RESET( p_sys->file_sizes );

    if( p_sys->p_meta )
        vlc_meta_Delete( p_sys->p_meta );

    vlc_input_title_Delete( p_sys->p_marks );
    free( p_sys );
}
Exemplo n.º 9
0
Arquivo: vdr.c Projeto: chouquette/vlc
/*****************************************************************************
 * Close files and free resources
 *****************************************************************************/
static void Close( vlc_object_t * p_this )
{
    access_t *p_access = (access_t*)p_this;
    access_sys_t *p_sys = p_access->p_sys;

    if( p_sys->fd != -1 )
        vlc_close( p_sys->fd );
    ARRAY_RESET( p_sys->file_sizes );

    if( p_sys->p_meta )
        vlc_meta_Delete( p_sys->p_meta );

    size_t count = p_sys->p_marks->i_seekpoint;
    TAB_CLEAN( count, p_sys->offsets );
    vlc_input_title_Delete( p_sys->p_marks );
}
Exemplo n.º 10
0
/**
 * Destroy the event manager
 */
void vlc_event_manager_fini( vlc_event_manager_t * p_em )
{
    struct vlc_event_listener_t * listener;

    vlc_mutex_destroy( &p_em->lock );

    for( size_t i = 0; i < ARRAY_SIZE(p_em->events); i++ )
    {
        struct vlc_event_listeners_group_t *slot = p_em->events + i;

        ARRAY_FOREACH( listener, slot->listeners )
            free( listener );

        ARRAY_RESET( slot->listeners );
    }
}
Exemplo n.º 11
0
static void ResetCurrentlyPlaying( playlist_t *p_playlist,
                                   playlist_item_t *p_cur )
{
    playlist_private_t *p_sys = pl_priv(p_playlist);

    stats_TimerStart( p_playlist, "Items array build",
                      STATS_TIMER_PLAYLIST_BUILD );
    PL_DEBUG( "rebuilding array of current - root %s",
              PLI_NAME( p_sys->status.p_node ) );
    ARRAY_RESET( p_playlist->current );
    p_playlist->i_current_index = -1;
    for( playlist_item_t *p_next = NULL; ; )
    {
        /** FIXME: this is *slow* */
        p_next = playlist_GetNextLeaf( p_playlist,
                                       p_sys->status.p_node,
                                       p_next, true, false );
        if( !p_next )
            break;

        if( p_next == p_cur )
            p_playlist->i_current_index = p_playlist->current.i_size;
        ARRAY_APPEND( p_playlist->current, p_next);
    }
    PL_DEBUG("rebuild done - %i items, index %i", p_playlist->current.i_size,
                                                  p_playlist->i_current_index);

    if( var_GetBool( p_playlist, "random" ) && ( p_playlist->current.i_size > 0 ) )
    {
        /* Shuffle the array */
        for( unsigned j = p_playlist->current.i_size - 1; j > 0; j-- )
        {
            unsigned i = vlc_lrand48() % (j+1); /* between 0 and j */
            playlist_item_t *p_tmp;
            /* swap the two items */
            p_tmp = ARRAY_VAL(p_playlist->current, i);
            ARRAY_VAL(p_playlist->current,i) = ARRAY_VAL(p_playlist->current,j);
            ARRAY_VAL(p_playlist->current,j) = p_tmp;
        }
    }
    p_sys->b_reset_currently_playing = false;
    stats_TimerStop( p_playlist, STATS_TIMER_PLAYLIST_BUILD );
}
Exemplo n.º 12
0
void ts_psip_Del( demux_t *p_demux, ts_psip_t *psip )
{
    if( psip->p_ctx )
        ts_psip_context_Delete( psip->p_ctx );

    ts_pes_ChainDelete_es( p_demux, psip->p_eas_es );

    if( psip->handle )
    {
        ATSC_Detach_Dvbpsi_Decoders( psip->handle );
        dvbpsi_delete( psip->handle );
    }

    for( int i=0; i<psip->eit.i_size; i++ )
        PIDRelease( p_demux, psip->eit.p_elems[i] );
    ARRAY_RESET( psip->eit );

    free( psip );
}
Exemplo n.º 13
0
void sms_Free( sms_stream_t *sms )
{
    if ( !sms )
        return;
    FOREACH_ARRAY( quality_level_t *qlevel, sms->qlevels );
    if( qlevel )
        ql_Free( qlevel );
    FOREACH_END();
    ARRAY_RESET( sms->qlevels );

    vlc_mutex_lock( &sms->chunks_lock );
    while( sms->p_chunks )
    {
        chunk_t *p_chunk = sms->p_chunks;
        sms->p_chunks = sms->p_chunks->p_next;
        chunk_Free( p_chunk );
    }
    vlc_mutex_unlock( &sms->chunks_lock );

    vlc_mutex_destroy( &sms->chunks_lock );
    free( sms->name );
    free( sms->url_template );
    free( sms );
}
Exemplo n.º 14
0
Arquivo: reader.c Projeto: mortehu/bra
static void
read_file (struct buffer *buffer)
{
  int fd;
  void *map = MAP_FAILED;

  struct line line_buffer;
  size_t line_length;

  const char *line_begin, *line_end, *end;

  char newline[8];
  size_t newline_length = 0;

  off_t size = 0;
  uint32_t digest = 0;

  if (-1 == (fd = open (buffer->path + 7, O_RDONLY)))
    {
      if (errno != ENOENT)
        {
          set_error (_("Failed to open '%s' for reading: %s"),
                     buffer->path, strerror (errno));

          goto failed;
        }

      buffer->charset = CHARSET_UTF8;
      buffer->line_ending = LINE_ENDING_LF;

      buffer->log = log_open (buffer->undo_path, buffer, 0);

      if (!buffer->log)
        goto failed;

      return;
    }

  if (-1 == (size = lseek (fd, 0, SEEK_END)))
    {
      static const size_t readbuf_size = 65536;
      char *readbuf;
      const char *begin, *end;
      int ret;

      struct line encoded_buffer;

      readbuf = malloc (readbuf_size);

      ARRAY_INIT (&encoded_buffer);

      while (0 < (ret = read (fd, readbuf, readbuf_size)))
        {
          digest = crc32 (digest, readbuf, ret);

          if (!buffer->charset)
            {
              charset_detect (&buffer->charset, &buffer->line_ending, readbuf, ret);

              newline_length = charset_encode_line_ending (newline, buffer->charset, buffer->line_ending);
            }

          begin = readbuf;
          end = readbuf + ret;

          while (begin != end)
            {
              line_end = memmem (begin, end - begin, newline, newline_length);

              if (!line_end)
                {
                  ARRAY_ADD_SEVERAL (&encoded_buffer, begin, end - begin);

                  break;
                }

              ARRAY_ADD_SEVERAL (&encoded_buffer, begin, line_end - begin);

              begin = line_end + newline_length;

              line_length = charset_decode (0, buffer->charset,
                                            &ARRAY_GET (&encoded_buffer, 0),
                                            ARRAY_COUNT (&encoded_buffer));

              ARRAY_INIT (&line_buffer);
              ARRAY_RESERVE (&line_buffer, line_length);

              charset_decode (&ARRAY_GET (&line_buffer, 0), buffer->charset,
                              &ARRAY_GET (&encoded_buffer, 0),
                              ARRAY_COUNT (&encoded_buffer));

              ARRAY_COUNT (&line_buffer) = line_length;

              pthread_mutex_lock (&buffer->lock);

              ARRAY_ADD (&buffer->lines, line_buffer);

              pthread_mutex_unlock (&buffer->lock);

              ARRAY_RESET (&encoded_buffer);
            }
        }
    }
  else if (size > 0)
    {
      if (MAP_FAILED == (map = mmap (0, size, PROT_READ, MAP_SHARED, fd, 0)))
        {
          set_error (_("Failed to mmap '%s': %s"), buffer->path, strerror (errno));

          goto failed;
        }

      digest = crc32 (0, map, size);

      charset_detect (&buffer->charset, &buffer->line_ending, map, size);

      newline_length = charset_encode_line_ending (newline, buffer->charset, buffer->line_ending);

      end = (char *) map + size;

      for (line_begin = map; line_begin < end; line_begin = line_end + newline_length)
        {
          line_end = memmem (line_begin, end - line_begin,
                             newline, newline_length);

          if (!line_end)
            line_end = end;

          line_length = charset_decode (0, buffer->charset, line_begin,
                                        line_end - line_begin);

          ARRAY_INIT (&line_buffer);
          ARRAY_RESERVE (&line_buffer, line_length);

          charset_decode (&ARRAY_GET (&line_buffer, 0), buffer->charset,
                          line_begin, line_end - line_begin);

          ARRAY_COUNT (&line_buffer) = line_length;

          pthread_mutex_lock (&buffer->lock);

          ARRAY_ADD (&buffer->lines, line_buffer);

          pthread_mutex_unlock (&buffer->lock);

          /* XXX: Avoid issuing full repaints when nothing really happens onscreen */

          gui_repaint ();
        }
    }
  else
    {
      buffer->charset = CHARSET_UTF8;
      buffer->line_ending = LINE_ENDING_LF;
    }

  buffer->log = log_open (buffer->undo_path, buffer, digest);

failed:

  if (fd != -1)
    close (fd);

  if (map != MAP_FAILED)
    munmap (map, size);
}