]> git.sesse.net Git - vlc/commitdiff
* ./src/misc/objects.c: two big changes in the object API: now objects can
authorSam Hocevar <sam@videolan.org>
Mon, 12 Aug 2002 09:34:15 +0000 (09:34 +0000)
committerSam Hocevar <sam@videolan.org>
Mon, 12 Aug 2002 09:34:15 +0000 (09:34 +0000)
    only have one parent, because I don't want to deal with cycles, and each
    created object is indexed in a global array. This feature is unused yet,
    but it will speed up vlc_object_find(FIND_ANYWHERE).
  * ./debian/rules: activated the faad codec.
  * ./doc/fortunes.txt: new fortune cookies.
  * ./modules/codec/mpeg_video/headers.c: reduced the use of attach/detach.
  * ./modules/audio_output/oss.c: fixed two compilation warnings.

33 files changed:
configure
configure.in
debian/rules
doc/fortunes.txt
doc/vlc-config.1 [new file with mode: 0644]
include/main.h
include/vlc_common.h
include/vlc_objects.h
include/vlc_symbols.h
modules/access/dvdplay/demux.c
modules/audio_output/oss.c
modules/codec/cinepak/cinepak.c
modules/codec/dv/dv.c
modules/codec/ffmpeg/ffmpeg.c
modules/codec/mpeg_video/headers.c
modules/codec/mpeg_video/parser.c
modules/codec/mpeg_video/pool.c
modules/gui/macosx/intf.m
modules/video_output/directx/aout.c
modules/video_output/directx/vout.c
modules/video_output/sdl/aout.c
modules/visualization/scope/scope.c
src/audio_output/aout_ext-dec.c
src/audio_output/audio_output.c
src/audio_output/filters.c
src/input/input_dec.c
src/libvlc.c
src/misc/beos_specific.cpp
src/misc/modules.c
src/misc/modules_plugin.h
src/misc/objects.c
src/playlist/playlist.c
src/video_output/video_output.c

index f5186b7e5447af514eb943e39a7ddcc42c832002..bd674bd6b321a811501dbbc59304afc2f00d978c 100755 (executable)
--- a/configure
+++ b/configure
@@ -7108,7 +7108,7 @@ echo "configure:7097: checking for libfaad.a in ${with_faad_tree}" >&5
       faad_CFLAGS="${faad_CFLAGS} -I${real_faad_tree}/include"
     else
             echo "$ac_t""no" 1>&6
-      { echo "configure: error: cannot find ${real_faad_tree}/.libs/libfaad.a, make sure you compiled libfaad in ${with_faad_tree}" 1>&2; exit 1; }
+      { echo "configure: error: cannot find ${real_faad_tree}/libfaad/.libs/libfaad.a, make sure you compiled libfaad in ${with_faad_tree}" 1>&2; exit 1; }
     fi
   else
     CFLAGS="${save_CFLAGS} ${faad_CFLAGS}"
index 8f2aceda557a507192063541a82adc592c5b5320..16da852d11e64655d471b125d9cd355d2caf89bd 100644 (file)
@@ -1095,7 +1095,7 @@ then
     else
       dnl  The given libfaad wasn't built
       AC_MSG_RESULT(no)
-      AC_MSG_ERROR([cannot find ${real_faad_tree}/.libs/libfaad.a, make sure you compiled libfaad in ${with_faad_tree}])
+      AC_MSG_ERROR([cannot find ${real_faad_tree}/libfaad/.libs/libfaad.a, make sure you compiled libfaad in ${with_faad_tree}])
     fi
   else
     CFLAGS="${save_CFLAGS} ${faad_CFLAGS}"
index 50a263a322d1eccc864185f1347bbd3c03f3a8be..1298d979cad9ca15ddd35286cf1d4c4e8fb76948 100755 (executable)
@@ -10,7 +10,8 @@ export DH_COMPAT=3
 
 # Compilation options
 export FFMPEG_VERSION=cvs
-export CONFIG_FLAGS="--enable-release --prefix=/usr --enable-gnome --enable-gtk --enable-fb --enable-ggi --enable-sdl --enable-esd --enable-qt --enable-mad --enable-arts --enable-alsa --enable-lirc --enable-a52 --enable-aa --enable-dvbpsi --enable-xosd --enable-mozilla --enable-kde --enable-ffmpeg --with-ffmpeg-tree=ffmpeg-$(FFMPEG_VERSION) --enable-mp4 --enable-dvb --enable-dv"
+export FAAD_VERSION=cvs
+export CONFIG_FLAGS="--enable-release --prefix=/usr --enable-gnome --enable-gtk --enable-fb --enable-ggi --enable-sdl --enable-esd --enable-qt --enable-mad --enable-arts --enable-alsa --enable-lirc --enable-a52 --enable-aa --enable-dvbpsi --enable-xosd --enable-mozilla --enable-kde --enable-ffmpeg --with-ffmpeg-tree=ffmpeg-$(FFMPEG_VERSION) --enable-mp4 --enable-dvb --enable-dv --enable-faad --with-faad-tree=faad-$(FAAD_VERSION)"
 # Remove --without-dvdcss here in non-totalitarian countries
 export DVDCSS_FLAGS="--enable-dvd --without-dvdcss"
 
index 323fb087d72a2401e04104319fd506270b8d7062..2098a9b73d1523413d2d9fe1b39a9be4f1e11379 100644 (file)
@@ -197,3 +197,20 @@ the Boston strangler is to the woman home alone.
 
   -- #videolan
 %
+<ali> by the way i've never learnt the way to make figlets lool ...
+<lool> /exec -o figlet -f small 'ali is so stupid !'
+<sam> I'm not absolutely positive it was a good idea to teach her
+<sam> it's like handing a rocket launcher to a 6yr old ...
+
+  -- #videolan
+%
+<|sF|Vengance|> do u have any videos of porn u can send me?
+
+  -- #videolan
+%
+-+- Ourumov [www-data@brahma.via.ecp.fr] has joined #videolan
+<Ourumov> hey anybody here know videolan ?
+-*- SignOff: Ourumov (Client Quit)
+
+  -- #videolan
+%
diff --git a/doc/vlc-config.1 b/doc/vlc-config.1
new file mode 100644 (file)
index 0000000..5eac422
--- /dev/null
@@ -0,0 +1,47 @@
+.TH LIBVLC 1 "8 August 2002" Version 0.5.0
+.SH NAME
+vlc-config - script to get information about the installed version of libvlc
+.SH SYNOPSIS
+.B vlc-config
+[\-\-prefix\fI[=DIR]\fP] [\-\-exec\-prefix\fI[=DIR]\fP] [\-\-version] [\-\-libs] [\-\-cflags]
+.SH DESCRIPTION
+.PP
+\fIvlc-config\fP is a tool that is used to configure to determine
+the compiler and linker flags that should be used to compile
+and link programs that use \fIlibvlc\fP.
+.
+.SH OPTIONS
+.l
+\fIvlc-config\fP accepts the following options:
+.TP 8
+.B  \-\-version
+Print the currently installed version of \fIlibvlc\fP on the standard output.
+.TP 8
+.B  \-\-libs
+Print the linker flags that are necessary to link a \fIlibvlc\fP program.
+.TP 8
+.B  \-\-cflags
+Print the compiler flags that are necessary to compile a \fIlibvlc\fP program.
+.TP 8
+.B  \-\-prefix=PREFIX
+If specified, use PREFIX instead of the installation prefix that \fIlibvlc\fP
+was built with when computing the output for the \-\-cflags and
+\-\-libs options. This option is also used for the exec prefix
+if \-\-exec\-prefix was not specified. This option must be specified
+before any \-\-libs or \-\-cflags options.
+.TP 8
+.B  \-\-exec\-prefix=PREFIX
+If specified, use PREFIX instead of the installation exec prefix that
+\fIlibvlc\fP was built with when computing the output for the \-\-cflags
+and \-\-libs options.  This option must be specified before any
+\-\-libs or \-\-cflags options.
+.SH SEE ALSO
+.BR vlc (1),
+.SH COPYRIGHT
+Copyright \(co  2002 Owen Taylor, modified by Sam Hocevar
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation.
index a68ac4c02f212ede4542a6087f7bd686fee7afd3..ea5fb9458d1f837467589ad77b06851f6f836b30 100644 (file)
@@ -3,7 +3,7 @@
  * Declaration and extern access to global program object.
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
- * $Id: main.h,v 1.43 2002/08/09 16:39:08 sam Exp $
+ * $Id: main.h,v 1.44 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *
@@ -58,21 +58,24 @@ struct vlc_t
     void* ( *pf_memset ) ( void *, int, size_t );
 
     /* The module bank */
-    module_bank_t * p_module_bank;
+    module_bank_t *        p_module_bank;
 
     /* The message bank */
-    msg_bank_t      msg_bank;
+    msg_bank_t             msg_bank;
 
     /* Shared data - these structures are accessed directly from p_vlc by
      * several modules */
-    intf_msg_t *           p_msg;                 /* messages interface data */
     input_channel_t *      p_channel;                /* channel library data */
 
     /* Locks */
     vlc_mutex_t            config_lock;          /* lock for the config file */
     vlc_mutex_t            structure_lock;        /* lock for the p_vlc tree */
+
+    /* Object structure data */
     int                    i_unique;                    /* p_vlc occurence # */
     int                    i_counter;                      /* object counter */
+    int                    i_objects;              /* Attached objects count */
+    vlc_object_t **        pp_objects;               /* Array of all objects */
 
     /* Pointer to the big, evil global lock */
     vlc_mutex_t *          p_global_lock;
index f6e73e055e9e7ff59a2eab696f402f253a7cc2bf..91af23ecaa61304930b52b9cabc2df0e56be761d 100644 (file)
@@ -3,7 +3,7 @@
  * Collection of useful common types and macros definitions
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: vlc_common.h,v 1.17 2002/08/10 19:23:06 sam Exp $
+ * $Id: vlc_common.h,v 1.18 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@via.ecp.fr>
  *          Vincent Seguin <seguin@via.ecp.fr>
@@ -245,12 +245,12 @@ typedef struct iso639_lang_t iso639_lang_t;
     volatile vlc_bool_t b_error;                    /* set by the object */ \
     volatile vlc_bool_t b_die;                     /* set by the outside */ \
     volatile vlc_bool_t b_dead;                     /* set by the object */ \
+    volatile vlc_bool_t b_attached;                 /* set by the object */ \
                                                                             \
     vlc_t *         p_vlc;                           /* root of all evil */ \
                                                                             \
-    volatile int    i_refcount;                                             \
-    vlc_object_t ** pp_parents;                           /* our parents */ \
-    volatile int    i_parents;                                              \
+    volatile int    i_refcount;                           /* usage count */ \
+    vlc_object_t *  p_parent;                              /* our parent */ \
     vlc_object_t ** pp_children;                         /* our children */ \
     volatile int    i_children;                                             \
                                                                             \
index 63c36046bec4db10705088ebde77ad2a3ddea53e..be7b5eb9245f36cd928f6c938f44ef24b7f6b83f 100644 (file)
@@ -2,7 +2,7 @@
  * vlc_objects.h: vlc_object_t definition.
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: vlc_objects.h,v 1.5 2002/07/31 20:56:50 sam Exp $
+ * $Id: vlc_objects.h,v 1.6 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -51,8 +51,7 @@ VLC_EXPORT( void, __vlc_object_destroy, ( vlc_object_t * ) );
 VLC_EXPORT( void *, __vlc_object_find, ( vlc_object_t *, int, int ) );
 VLC_EXPORT( void, __vlc_object_yield, ( vlc_object_t * ) );
 VLC_EXPORT( void, __vlc_object_release, ( vlc_object_t * ) );
-VLC_EXPORT( void, __vlc_object_detach, ( vlc_object_t *, vlc_object_t * ) );
-VLC_EXPORT( void, __vlc_object_detach_all, ( vlc_object_t * ) );
+VLC_EXPORT( void, __vlc_object_detach, ( vlc_object_t * ) );
 VLC_EXPORT( void, __vlc_object_attach, ( vlc_object_t *, vlc_object_t * ) );
 #if 0
 //VLC_EXPORT( void, __vlc_object_setchild, ( vlc_object_t *, vlc_object_t * ) );
@@ -76,11 +75,8 @@ VLC_EXPORT( void, __vlc_dumpstructure, ( vlc_object_t * ) );
 #define vlc_object_release(a) \
     __vlc_object_release( VLC_OBJECT(a) )
 
-#define vlc_object_detach(a,b) \
-    __vlc_object_detach( VLC_OBJECT(a), VLC_OBJECT(b) )
-
-#define vlc_object_detach_all(a) \
-    __vlc_object_detach_all( VLC_OBJECT(a) )
+#define vlc_object_detach(a) \
+    __vlc_object_detach( VLC_OBJECT(a) )
 
 #define vlc_object_attach(a,b) \
     __vlc_object_attach( VLC_OBJECT(a), VLC_OBJECT(b) )
index 0c6026ee59bd5c1d4bcdb99aa234832643bd3174..35c75e99ac0cda1be505539b8c433defe89169a7 100644 (file)
@@ -93,8 +93,7 @@ struct module_symbols_t
     void (* __vlc_dumpstructure_inner) ( vlc_object_t * ) ;
     void (* __vlc_object_attach_inner) ( vlc_object_t *, vlc_object_t * ) ;
     void (* __vlc_object_destroy_inner) ( vlc_object_t * ) ;
-    void (* __vlc_object_detach_all_inner) ( vlc_object_t * ) ;
-    void (* __vlc_object_detach_inner) ( vlc_object_t *, vlc_object_t * ) ;
+    void (* __vlc_object_detach_inner) ( vlc_object_t * ) ;
     void (* __vlc_object_release_inner) ( vlc_object_t * ) ;
     void (* __vlc_object_yield_inner) ( vlc_object_t * ) ;
     void (* __vlc_thread_join_inner) ( vlc_object_t *, char *, int ) ;
@@ -191,7 +190,6 @@ struct module_symbols_t
 #   define __vlc_object_create p_symbols->__vlc_object_create_inner
 #   define __vlc_object_destroy p_symbols->__vlc_object_destroy_inner
 #   define __vlc_object_detach p_symbols->__vlc_object_detach_inner
-#   define __vlc_object_detach_all p_symbols->__vlc_object_detach_all_inner
 #   define __vlc_object_find p_symbols->__vlc_object_find_inner
 #   define __vlc_object_release p_symbols->__vlc_object_release_inner
 #   define __vlc_object_yield p_symbols->__vlc_object_yield_inner
index db491a8d0c477c46d41764e02f9681f7d88ae863..0a36083643b43c6acf797e98b9f8ce5acf0c04d6 100644 (file)
@@ -2,7 +2,7 @@
  * demux.c: demux functions for dvdplay.
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: demux.c,v 1.2 2002/08/07 00:29:36 sam Exp $
+ * $Id: demux.c,v 1.3 2002/08/12 09:34:15 sam Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -132,7 +132,7 @@ void E_(EndDVD) ( vlc_object_t *p_this )
     if( p_intf != NULL )
     {
         intf_StopThread( p_intf );
-        vlc_object_detach_all( p_intf );
+        vlc_object_detach( p_intf );
         vlc_object_release( p_intf );
         intf_Destroy( p_intf );
     }
index 92c324e4b31761fc0e85031483f0f1d32b3ee48a..28189db1f67c1eded7d6ef019a53072b3a07e3af 100644 (file)
@@ -2,7 +2,7 @@
  * oss.c : OSS /dev/dsp module for vlc
  *****************************************************************************
  * Copyright (C) 2000-2002 VideoLAN
- * $Id: oss.c,v 1.6 2002/08/11 22:36:35 massiot Exp $
+ * $Id: oss.c,v 1.7 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -293,9 +293,8 @@ static int OSSThread( aout_instance_t * p_aout )
 
     while ( !p_sys->b_die )
     {
-        int i_bytes_per_sample;
         aout_buffer_t * p_buffer;
-        mtime_t next_date;
+        mtime_t next_date = 0;
         int i_tmp, i_size;
         byte_t * p_bytes;
 
index 964ec5f35d8826331a6f0b716d0ee13e42789204..ba3a12d668185926ff3987019a10dde7c932d887 100644 (file)
@@ -2,7 +2,7 @@
  * cinepak.c: cinepak video decoder 
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: cinepak.c,v 1.2 2002/08/04 18:39:41 sam Exp $
+ * $Id: cinepak.c,v 1.3 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -300,7 +300,7 @@ static vout_thread_t *cinepak_CreateVout( videodec_thread_t *p_vdec,
         if( !cinepak_CheckVout( p_vout, i_width, i_height ) )
         {
             /* We are not interested in this format, close this vout */
-            vlc_object_detach_all( p_vout );
+            vlc_object_detach( p_vout );
             vlc_object_release( p_vout );
             vout_DestroyThread( p_vout );
             p_vout = NULL;
@@ -308,7 +308,7 @@ static vout_thread_t *cinepak_CreateVout( videodec_thread_t *p_vdec,
         else
         {
             /* This video output is cool! Hijack it. */
-            vlc_object_detach_all( p_vout );
+            vlc_object_detach( p_vout );
             vlc_object_attach( p_vout, p_vdec->p_fifo );
             vlc_object_release( p_vout );
         }
@@ -955,7 +955,7 @@ static void EndThread( videodec_thread_t *p_vdec )
     if( p_vdec->p_vout != NULL )
     {
         /* We are about to die. Reattach video output to p_vlc. */
-        vlc_object_detach( p_vdec->p_vout, p_vdec->p_fifo );
+        vlc_object_detach( p_vdec->p_vout );
         vlc_object_attach( p_vdec->p_vout, p_vdec->p_fifo->p_vlc );
     }
     
index bdcffb5be59223223587c311cc56586650a58a1b..a982853d8339f90ceb8eaab1d1ecd692f6a935ee 100644 (file)
@@ -2,7 +2,7 @@
  * dv.c: a decoder for DV video
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: dv.c,v 1.1 2002/08/05 15:16:18 sam Exp $
+ * $Id: dv.c,v 1.2 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *      
@@ -162,7 +162,7 @@ static int RunDecoder ( decoder_fifo_t *p_fifo )
              || p_vout->render.i_aspect != i_aspect )
             {
                 /* We are not interested in this format, close this vout */
-                vlc_object_detach_all( p_vout );
+                vlc_object_detach( p_vout );
                 vlc_object_release( p_vout );
                 vout_DestroyThread( p_vout );
                 p_vout = NULL;
@@ -170,7 +170,7 @@ static int RunDecoder ( decoder_fifo_t *p_fifo )
             else
             {
                 /* This video output is cool! Hijack it. */
-                vlc_object_detach_all( p_vout );
+                vlc_object_detach( p_vout );
                 vlc_object_attach( p_vout, p_fifo );
                 vlc_object_release( p_vout );
             }
index ba037507413ce2fc466861e07a2f8730a55cb2a7..7ed922bfec17f2fdbc9a9f32dd5b7e8c107981fb 100644 (file)
@@ -2,7 +2,7 @@
  * ffmpeg.c: video decoder using ffmpeg library
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: ffmpeg.c,v 1.4 2002/08/10 20:05:21 fenrir Exp $
+ * $Id: ffmpeg.c,v 1.5 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -413,7 +413,7 @@ static vout_thread_t *ffmpeg_CreateVout( videodec_thread_t *p_vdec,
                                i_width, i_height, i_aspect,i_chroma ) )
         {
             /* We are not interested in this format, close this vout */
-            vlc_object_detach_all( p_vout );
+            vlc_object_detach( p_vout );
             vlc_object_release( p_vout );
             vout_DestroyThread( p_vout );
             p_vout = NULL;
@@ -421,7 +421,7 @@ static vout_thread_t *ffmpeg_CreateVout( videodec_thread_t *p_vdec,
         else
         {
             /* This video output is cool! Hijack it. */
-            vlc_object_detach_all( p_vout );
+            vlc_object_detach( p_vout );
             vlc_object_attach( p_vout, p_vdec->p_fifo );
             vlc_object_release( p_vout );
         }
@@ -971,7 +971,7 @@ static void EndThread( videodec_thread_t *p_vdec )
     if( p_vdec->p_vout != NULL )
     {
         /* We are about to die. Reattach video output to p_vlc. */
-        vlc_object_detach( p_vdec->p_vout, p_vdec->p_fifo );
+        vlc_object_detach( p_vdec->p_vout );
         vlc_object_attach( p_vdec->p_vout, p_vdec->p_fifo->p_vlc );
     }
 
index d5b02b167d2f3e0ebe5c725458050ed82e98a9e3..6e6cadd493f4d82e862f94990d6f1269ed5796c7 100644 (file)
@@ -2,7 +2,7 @@
  * vpar_headers.c : headers parsing
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: headers.c,v 1.2 2002/08/04 18:39:41 sam Exp $
+ * $Id: headers.c,v 1.3 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Stéphane Borel <stef@via.ecp.fr>
@@ -311,6 +311,8 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
 
     int i_height_save, i_width_save, i_aspect;
 
+    vout_thread_t *p_vout;
+
     i_height_save = p_vpar->sequence.i_height;
     i_width_save = p_vpar->sequence.i_width;
 
@@ -488,36 +490,40 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
 
     /* Spawn a video output if there is none. First we look for our children,
      * then we look for any other vout that might be available. */
-    p_vpar->p_vout = vlc_object_find( p_vpar->p_fifo, VLC_OBJECT_VOUT,
-                                                      FIND_CHILD );
-    if( p_vpar->p_vout == NULL )
+    p_vout = vlc_object_find( p_vpar->p_fifo, VLC_OBJECT_VOUT, FIND_CHILD );
+    if( p_vout == NULL )
     {
-        p_vpar->p_vout = vlc_object_find( p_vpar->p_fifo, VLC_OBJECT_VOUT,
-                                                          FIND_ANYWHERE );
+        p_vout = vlc_object_find( p_vpar->p_fifo, VLC_OBJECT_VOUT,
+                                                  FIND_ANYWHERE );
     }
     
-    if( p_vpar->p_vout )
+    if( p_vout )
     {
-        if( p_vpar->p_vout->render.i_width != p_vpar->sequence.i_width
-             || p_vpar->p_vout->render.i_height != p_vpar->sequence.i_height
-             || p_vpar->p_vout->render.i_chroma != ChromaToFourCC( p_vpar->sequence.i_chroma_format )
-             || p_vpar->p_vout->render.i_aspect != p_vpar->sequence.i_aspect )
+        if( p_vout->render.i_width != p_vpar->sequence.i_width
+             || p_vout->render.i_height != p_vpar->sequence.i_height
+             || p_vout->render.i_chroma != ChromaToFourCC( p_vpar->sequence.i_chroma_format )
+             || p_vout->render.i_aspect != p_vpar->sequence.i_aspect )
         {
             /* We are not interested in this format, close this vout */
-            vlc_object_detach_all( p_vpar->p_vout );
-            vlc_object_release( p_vpar->p_vout );
-            vout_DestroyThread( p_vpar->p_vout );
-            p_vpar->p_vout = NULL;
+            vlc_object_detachp_vout );
+            vlc_object_release( p_vout );
+            vout_DestroyThread( p_vout );
+            p_vout = NULL;
         }
         else
         {
             /* This video output is cool! Hijack it. */
-            vlc_object_detach_all( p_vpar->p_vout );
-            vlc_object_attach( p_vpar->p_vout, p_vpar->p_fifo );
-            vlc_object_release( p_vpar->p_vout );
+            if( p_vout != p_vpar->p_vout )
+            {
+                vlc_object_detach( p_vout );
+                vlc_object_attach( p_vout, p_vpar->p_fifo );
+            }
+            vlc_object_release( p_vout );
         }
     }
 
+    p_vpar->p_vout = p_vout;
+
     if( p_vpar->p_fifo->b_die || p_vpar->p_fifo->b_error )
     {
         return;
index 914671a322129ac6d7517f430f98029a8b605a9f..5c67865446a4a10c00a474fe314c9b8fd88d6f74 100644 (file)
@@ -2,7 +2,7 @@
  * video_parser.c : video parser thread
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: parser.c,v 1.3 2002/08/04 20:04:11 sam Exp $
+ * $Id: parser.c,v 1.4 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
@@ -315,7 +315,7 @@ static void EndThread( vpar_thread_t *p_vpar )
         }
 
         /* We are about to die. Reattach video output to p_vlc. */
-        vlc_object_detach( p_vpar->p_vout, p_vpar->p_fifo );
+        vlc_object_detach( p_vpar->p_vout );
         vlc_object_attach( p_vpar->p_vout, p_vpar->p_fifo->p_vlc );
     }
 
index 60a5e7f71ebccadea68a1929345f158b3a4c68ed..82a3422fed2db5f7b35a5357406b267cb2840abf 100644 (file)
@@ -2,7 +2,7 @@
  * vpar_pool.c : management of the pool of decoder threads
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: pool.c,v 1.2 2002/08/04 18:39:41 sam Exp $
+ * $Id: pool.c,v 1.3 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -125,7 +125,7 @@ void vpar_SpawnPool( vpar_thread_t * p_vpar )
             {
                 int j;
 
-                vlc_object_detach_all( p_vpar->pool.pp_vdec[i] );
+                vlc_object_detach( p_vpar->pool.pp_vdec[i] );
                 vdec_DestroyThread( p_vpar->pool.pp_vdec[i] );
 
                 for( j = 0; j < 12; j++ )
@@ -218,7 +218,7 @@ void vpar_EndPool( vpar_thread_t * p_vpar )
     {
         int j;
 
-        vlc_object_detach_all( p_vpar->pool.pp_vdec[i] );
+        vlc_object_detach( p_vpar->pool.pp_vdec[i] );
         vdec_DestroyThread( p_vpar->pool.pp_vdec[i] );
 
         for( j = 0; j < 12; j++ )
@@ -235,7 +235,7 @@ void vpar_EndPool( vpar_thread_t * p_vpar )
     }
 
     /* Free fake video decoder (used when parser == decoder). */
-    vlc_object_detach_all( p_vpar->pool.p_vdec );
+    vlc_object_detach( p_vpar->pool.p_vdec );
     vdec_EndThread( p_vpar->pool.p_vdec );
     vlc_object_destroy( p_vpar->pool.p_vdec );
 
index 774a5ac0a984e80e972a86f5f994d973d98e1dcc..e5f08eda5ae308b1c58a4918dd556086fdb23e13 100644 (file)
@@ -2,7 +2,7 @@
  * intf.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: intf.m,v 1.1 2002/08/04 17:23:43 sam Exp $
+ * $Id: intf.m,v 1.2 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -402,7 +402,7 @@ static void Run( intf_thread_t *p_intf )
     while( (p_playlist = vlc_object_find( p_intf->p_vlc, VLC_OBJECT_PLAYLIST,
                                           FIND_CHILD )) )
     {
-        vlc_object_detach_all( p_playlist );
+        vlc_object_detach( p_playlist );
         vlc_object_release( p_playlist );
         playlist_Destroy( p_playlist );
     }
@@ -414,7 +414,7 @@ static void Run( intf_thread_t *p_intf )
     while( (p_vout = vlc_object_find( p_intf->p_vlc, 
                                       VLC_OBJECT_VOUT, FIND_CHILD )) )
     {
-        vlc_object_detach_all( p_vout );
+        vlc_object_detach( p_vout );
         vlc_object_release( p_vout );
         vout_DestroyThread( p_vout );
     }
index dc6301f4ff15de19c96ba2576b6bb2a7dee061fe..1198e0216193b6c7fb425e0126dce8ac2142abf4 100644 (file)
@@ -2,7 +2,7 @@
  * aout.c: Windows DirectX audio output method
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: aout.c,v 1.2 2002/08/10 18:17:06 gbazin Exp $
+ * $Id: aout.c,v 1.3 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -265,7 +265,7 @@ void E_(CloseAudio) ( vlc_object_t *p_this )
     /* kill the position notification thread, if any */
     if( p_aout->output.p_sys->p_notif )
     {
-        vlc_object_detach_all( p_aout->output.p_sys->p_notif );
+        vlc_object_detach( p_aout->output.p_sys->p_notif );
         if( p_aout->output.p_sys->p_notif->b_thread )
         {
             p_aout->output.p_sys->p_notif->b_die = 1;
index a0d566da9128f54b09ae8fd890f107939c94b248..bd4608b1ab34f4bc14a080b8596169c9bc3f4307 100644 (file)
@@ -2,7 +2,7 @@
  * vout.c: Windows DirectX video output display method
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: vout.c,v 1.1 2002/08/04 17:23:43 sam Exp $
+ * $Id: vout.c,v 1.2 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -288,7 +288,7 @@ void E_(CloseVideo) ( vlc_object_t *p_this )
 
     if( p_vout->p_sys->p_event )
     {
-        vlc_object_detach_all( p_vout->p_sys->p_event );
+        vlc_object_detach( p_vout->p_sys->p_event );
 
         /* Kill DirectXEventThread */
         p_vout->p_sys->p_event->b_die = 1;
index 6b511a4f18eb0b73066f534456613b3489a2f030..bc21b82cf9960e08458cc8370938f9240158c6c4 100644 (file)
@@ -2,7 +2,7 @@
  * aout_sdl.c : audio sdl functions library
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: aout.c,v 1.2 2002/08/07 21:36:56 massiot Exp $
+ * $Id: aout.c,v 1.3 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -156,7 +156,7 @@ static void SDLCallback( void * _p_aout, byte_t * p_stream, int i_len )
     }
     else
     {
-        memset( p_stream, 0, i_len );
+        p_aout->p_vlc->pf_memset( p_stream, 0, i_len );
     }
 }
 
index 9a79c3b1bda28abc58ef339191230738dbd88ba2..811abe0ade4c8f1479860ab935bcd9a673947e26 100644 (file)
@@ -2,7 +2,7 @@
  * scope.c : Scope effect module
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: scope.c,v 1.1 2002/08/04 17:23:44 sam Exp $
+ * $Id: scope.c,v 1.2 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -288,7 +288,7 @@ static void Close( vlc_object_t *p_this )
 
     /* Kill audio output */
     module_Unneed( p_aout->p_sys->p_aout, p_aout->p_sys->p_aout->p_module );
-    vlc_object_detach_all( p_aout->p_sys->p_aout );
+    vlc_object_detach( p_aout->p_sys->p_aout );
     vlc_object_destroy( p_aout->p_sys->p_aout );
 
     /* Kill video output */
index cbdf1c5f58e2bb231d588d68ea48eae7f05e6d22..239ee03db111db6e0d1d332371986b3a58eab44d 100644 (file)
@@ -2,7 +2,7 @@
  * aout_ext-dec.c : exported fifo management functions
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: aout_ext-dec.c,v 1.20 2002/08/08 00:35:11 sam Exp $
+ * $Id: aout_ext-dec.c,v 1.21 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Cyril Deguet <asmax@via.ecp.fr>
@@ -51,7 +51,7 @@ aout_fifo_t * __aout_CreateFifo( vlc_object_t *p_this, int i_format,
         if( p_aout->fifo[0].i_format != i_format )
         {
             msg_Dbg( p_this, "changing aout type" );
-            vlc_object_detach_all( p_aout );
+            vlc_object_detach( p_aout );
             vlc_object_release( p_aout );
             aout_DestroyThread( p_aout );
             p_aout = NULL;
index 311583053e5354909828f43cd637d9339cca40c0..1bda239b78483b70a81732a5f95ab97a7bfc76b0 100644 (file)
@@ -2,7 +2,7 @@
  * audio_output.c : audio output instance
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: audio_output.c,v 1.93 2002/08/11 23:26:28 massiot Exp $
+ * $Id: audio_output.c,v 1.94 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -77,7 +77,6 @@ void aout_DeleteInstance( aout_instance_t * p_aout )
     vlc_cond_destroy( &p_aout->mixer_signal );
 
     /* Free structure. */
-    vlc_object_detach_all( p_aout );
     vlc_object_destroy( p_aout );
 }
 
index f21c4c70d90000581128f8377cd7f16dbc27eba0..5c4d340c51d572126bd09647de51ce7c8c4746b5 100644 (file)
@@ -2,7 +2,7 @@
  * filters.c : audio output filters management
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: filters.c,v 1.2 2002/08/09 23:47:23 massiot Exp $
+ * $Id: filters.c,v 1.3 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -91,7 +91,7 @@ int aout_FiltersCreatePipeline( aout_instance_t * p_aout,
         if ( pp_filters[0]->p_module == NULL )
         {
             msg_Err( p_aout, "couldn't find a filter for any conversion" );
-            vlc_object_detach_all( pp_filters[0] );
+            vlc_object_detach( pp_filters[0] );
             vlc_object_destroy( pp_filters[0] );
             return -1;
         }
@@ -101,7 +101,7 @@ int aout_FiltersCreatePipeline( aout_instance_t * p_aout,
     pp_filters[1] = vlc_object_create( p_aout, sizeof(aout_filter_t) );
     if ( pp_filters[1] == NULL )
     {
-        vlc_object_detach_all( pp_filters[0] );
+        vlc_object_detach( pp_filters[0] );
         vlc_object_destroy( pp_filters[0] );
         return -1;
     }
@@ -117,9 +117,9 @@ int aout_FiltersCreatePipeline( aout_instance_t * p_aout,
     {
         msg_Err( p_aout,
                  "couldn't find a filter for the 2nd part of the conversion" );
-        vlc_object_detach_all( pp_filters[0] );
+        vlc_object_detach( pp_filters[0] );
         vlc_object_destroy( pp_filters[0] );
-        vlc_object_detach_all( pp_filters[1] );
+        vlc_object_detach( pp_filters[1] );
         vlc_object_destroy( pp_filters[1] );
         return -1;
     }
@@ -142,7 +142,7 @@ void aout_FiltersDestroyPipeline( aout_instance_t * p_aout,
     for ( i = 0; i < i_nb_filters; i++ )
     {
         module_Unneed( pp_filters[i], pp_filters[i]->p_module );
-        vlc_object_detach_all( pp_filters[i] );
+        vlc_object_detach( pp_filters[i] );
         vlc_object_destroy( pp_filters[i] );
     }
 }
index 22844b093e18f7b1c75a077892146381df92eb61..b8f2000576558d2771c4ba0d990699065106e75c 100644 (file)
@@ -2,7 +2,7 @@
  * input_dec.c: Functions for the management of decoders
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: input_dec.c,v 1.43 2002/08/08 00:35:11 sam Exp $
+ * $Id: input_dec.c,v 1.44 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -245,7 +245,7 @@ static decoder_fifo_t * CreateDecoderFifo( input_thread_t * p_input,
  *****************************************************************************/
 static void DeleteDecoderFifo( decoder_fifo_t * p_fifo )
 {
-    vlc_object_detach_all( p_fifo );
+    vlc_object_detach( p_fifo );
 
     msg_Dbg( p_fifo, "killing decoder for 0x%x, fourcc `%4.4s', %d PES in FIFO",
                      p_fifo->i_id, (char*)&p_fifo->i_fourcc, p_fifo->i_depth );
index 16516a4388280b6222afe9b774ff074e3d668036..20c0a11e66d1890bb55e41263faeee32ada263ba 100644 (file)
@@ -2,7 +2,7 @@
  * libvlc.c: main libvlc source
  *****************************************************************************
  * Copyright (C) 1998-2002 VideoLAN
- * $Id: libvlc.c,v 1.24 2002/08/09 16:39:08 sam Exp $
+ * $Id: libvlc.c,v 1.25 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -589,7 +589,7 @@ vlc_error_t vlc_add_intf_r( vlc_t *p_vlc, const char *psz_module,
     err = intf_RunThread( p_intf );
     if( err )
     {
-        vlc_object_detach_all( p_intf );
+        vlc_object_detach( p_intf );
         intf_Destroy( p_intf );
         return err;
     }
@@ -629,7 +629,7 @@ vlc_error_t vlc_stop_r( vlc_t *p_vlc )
     while( (p_intf = vlc_object_find( p_vlc, VLC_OBJECT_INTF, FIND_CHILD )) )
     {
         intf_StopThread( p_intf );
-        vlc_object_detach_all( p_intf );
+        vlc_object_detach( p_intf );
         vlc_object_release( p_intf );
         intf_Destroy( p_intf );
     }
@@ -641,7 +641,7 @@ vlc_error_t vlc_stop_r( vlc_t *p_vlc )
     while( (p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST,
                                           FIND_CHILD )) )
     {
-        vlc_object_detach_all( p_playlist );
+        vlc_object_detach( p_playlist );
         vlc_object_release( p_playlist );
         playlist_Destroy( p_playlist );
     }
@@ -652,7 +652,7 @@ vlc_error_t vlc_stop_r( vlc_t *p_vlc )
     msg_Dbg( p_vlc, "removing all video outputs" );
     while( (p_vout = vlc_object_find( p_vlc, VLC_OBJECT_VOUT, FIND_CHILD )) )
     {
-        vlc_object_detach_all( p_vout );
+        vlc_object_detach( p_vout );
         vlc_object_release( p_vout );
         vout_DestroyThread( p_vout );
     }
@@ -663,7 +663,7 @@ vlc_error_t vlc_stop_r( vlc_t *p_vlc )
     msg_Dbg( p_vlc, "removing all audio outputs" );
     while( (p_aout = vlc_object_find( p_vlc, VLC_OBJECT_AOUT, FIND_CHILD )) )
     {
-        vlc_object_detach_all( (vlc_object_t *)p_aout );
+        vlc_object_detach( (vlc_object_t *)p_aout );
         vlc_object_release( (vlc_object_t *)p_aout );
         aout_DeleteInstance( p_aout );
     }
index e98dd891be09ced5f54a107f28d6caf7e0bb3499..d5fc5f4fa0d1c32d7df95d72e827dfefdb7c7fab 100644 (file)
@@ -2,7 +2,7 @@
  * beos_init.cpp: Initialization for BeOS specific features 
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: beos_specific.cpp,v 1.23 2002/06/02 14:26:15 gbazin Exp $
+ * $Id: beos_specific.cpp,v 1.24 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *
@@ -114,7 +114,7 @@ static void AppThread( vlc_object_t * p_this )
     vlc_object_attach( p_this, p_this->p_vlc );
     BeApp->p_this = p_this;
     BeApp->Run();
-    vlc_object_detach_all( p_this );
+    vlc_object_detach( p_this );
     delete BeApp;
 }
 
index 9ec6de2cb5a9878c9c5883397690b25363aa9e57..edf4ea5abfad9fc6a5a6d00e3bf175efbf7fc886 100644 (file)
@@ -2,7 +2,7 @@
  * modules.c : Builtin and plugin modules management functions
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: modules.c,v 1.82 2002/08/08 00:35:11 sam Exp $
+ * $Id: modules.c,v 1.83 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Ethan C. Baldridge <BaldridgeE@cadmus.com>
@@ -155,7 +155,7 @@ void __module_EndBank( vlc_object_t *p_this )
 {
     module_t * p_next;
 
-    vlc_object_detach_all( p_this->p_vlc->p_module_bank );
+    vlc_object_detach( p_this->p_vlc->p_module_bank );
 
     while( p_this->p_vlc->p_module_bank->first != NULL )
     {
@@ -938,7 +938,7 @@ static int DeleteModule( module_t * p_module )
     }
 #endif
 
-    vlc_object_detach_all( p_module );
+    vlc_object_detach( p_module );
 
     /* Unlink the module from the linked list. */
     if( p_module->prev != NULL )
@@ -971,7 +971,7 @@ static int DeleteModule( module_t * p_module )
     while( p_module->i_children )
     {
         vlc_object_t *p_this = p_module->pp_children[0];
-        vlc_object_detach_all( p_this );
+        vlc_object_detach( p_this );
         vlc_object_destroy( p_this );
     }
 
index 3e8bca04237836fabb23b4e9af49734f19ac90e8..2114ba5106b5849e953ed234245fee77170387c5 100644 (file)
@@ -300,7 +300,6 @@ static const char * module_error( char *psz_buffer )
     (p_symbols)->__vlc_object_yield_inner = __vlc_object_yield; \
     (p_symbols)->__vlc_object_release_inner = __vlc_object_release; \
     (p_symbols)->__vlc_object_detach_inner = __vlc_object_detach; \
-    (p_symbols)->__vlc_object_detach_all_inner = __vlc_object_detach_all; \
     (p_symbols)->__vlc_object_attach_inner = __vlc_object_attach; \
     (p_symbols)->__vlc_dumpstructure_inner = __vlc_dumpstructure; \
     (p_symbols)->playlist_Command_inner = playlist_Command; \
index bdfcd999c2359ea560e121e848f3a32765dbb4cd..5d5d725e4c9341175fcbc6a16a328ec69030396a 100644 (file)
@@ -2,7 +2,7 @@
  * objects.c: vlc_object_t handling
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: objects.c,v 1.15 2002/08/08 00:35:11 sam Exp $
+ * $Id: objects.c,v 1.16 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
  * Local prototypes
  *****************************************************************************/
 static vlc_object_t * vlc_object_find_inner( vlc_object_t *, int, int );
-static void vlc_object_detach_inner( vlc_object_t *, vlc_object_t * );
+static void vlc_object_detach_inner( vlc_object_t * );
 static void vlc_dumpstructure_inner( vlc_object_t *, int, char * );
+static int  find_index_inner( vlc_object_t *, vlc_object_t **, int );
+static void set_attachment_flag( vlc_object_t *, vlc_bool_t );
 
 /*****************************************************************************
  * vlc_object_create: initialize a vlc object
@@ -120,28 +122,46 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
     p_new->psz_object_name = NULL;
 
     p_new->i_refcount = 0;
-    p_new->b_die = 0;
-    p_new->b_error = 0;
+    p_new->b_die = VLC_FALSE;
+    p_new->b_error = VLC_FALSE;
+    p_new->b_dead = VLC_FALSE;
+    p_new->b_attached = VLC_FALSE;
 
     /* If i_type is root, then p_new is our own p_vlc */
     if( i_type == VLC_OBJECT_ROOT )
     {
+        /* We are the first object ... no need to lock. */
         p_new->p_vlc = (vlc_t*)p_new;
+
         p_new->p_vlc->i_counter = 0;
         p_new->i_object_id = 0;
+
+        p_new->p_vlc->i_objects = 1;
+        p_new->p_vlc->pp_objects = malloc( sizeof(vlc_object_t *) );
+        p_new->p_vlc->pp_objects[0] = p_new;
+        p_new->b_attached = VLC_TRUE;
     }
     else
     {
         p_new->p_vlc = p_this->p_vlc;
 
         vlc_mutex_lock( &p_this->p_vlc->structure_lock );
+
         p_new->p_vlc->i_counter++;
         p_new->i_object_id = p_new->p_vlc->i_counter;
+
+        /* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's
+         * useless to try and recover anything if pp_objects gets smashed. */
+        p_new->p_vlc->i_objects++;
+        p_new->p_vlc->pp_objects =
+                  realloc( p_new->p_vlc->pp_objects,
+                           p_new->p_vlc->i_objects * sizeof(vlc_object_t *) );
+        p_new->p_vlc->pp_objects[ p_new->p_vlc->i_objects - 1 ] = p_new;
+
         vlc_mutex_unlock( &p_this->p_vlc->structure_lock );
     }
 
-    p_new->pp_parents = NULL;
-    p_new->i_parents = 0;
+    p_new->p_parent = NULL;
     p_new->pp_children = NULL;
     p_new->i_children = 0;
 
@@ -171,9 +191,9 @@ void __vlc_object_destroy( vlc_object_t *p_this )
         return;
     }
 
-    if( p_this->i_parents )
+    if( p_this->p_parent )
     {
-        msg_Err( p_this, "cannot delete object with parents" );
+        msg_Err( p_this, "cannot delete object with a parent" );
         vlc_dumpstructure( p_this );
         return;
     }
@@ -202,12 +222,78 @@ void __vlc_object_destroy( vlc_object_t *p_this )
         msleep( 100000 );
     }
 
+    vlc_mutex_lock( &p_this->p_vlc->structure_lock );
+
+    /* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's
+     * useless to try and recover anything if pp_objects gets smashed. */
+    if( p_this->p_vlc->i_objects > 1 )
+    {
+        int i_index = find_index_inner( p_this, p_this->p_vlc->pp_objects,
+                                                p_this->p_vlc->i_objects );
+        memmove( p_this->p_vlc->pp_objects + i_index,
+                 p_this->p_vlc->pp_objects + i_index + 1,
+                 p_this->p_vlc->i_objects - i_index - 1 );
+
+        p_this->p_vlc->pp_objects =
+            realloc( p_this->p_vlc->pp_objects,
+                     (p_this->p_vlc->i_objects - 1) * sizeof(vlc_object_t *) );
+    }
+    else
+    {
+        free( p_this->p_vlc->pp_objects );
+        p_this->p_vlc->pp_objects = NULL;
+    }
+
+    p_this->p_vlc->i_objects--;
+
+    vlc_mutex_unlock( &p_this->p_vlc->structure_lock );
+
     vlc_mutex_destroy( &p_this->object_lock );
     vlc_cond_destroy( &p_this->object_wait );
 
     free( p_this );
 }
 
+/*****************************************************************************
+ * find_index_inner: find the index of an object in an array of objects
+ *****************************************************************************
+ * This function assumes that p_this can be found in pp_objects. It will not
+ * crash if p_this cannot be found, but will return a random value. It is your
+ * duty to check the return value if you are not certain that the object could
+ * be found for sure.
+ *****************************************************************************/
+static int find_index_inner( vlc_object_t *p_this,
+                             vlc_object_t **pp_objects, int i_count )
+{
+    int i_middle = i_count / 2;
+
+    if( i_count == 0 )
+    {
+        return 0;
+    }
+
+    if( pp_objects[i_middle] == p_this )
+    {
+        return i_middle;
+    }
+
+    if( i_count == 1 )
+    {
+        return 0;
+    }
+
+    /* We take advantage of the sorted array */
+    if( pp_objects[i_middle]->i_object_id < p_this->i_object_id )
+    {
+        return i_middle + find_index_inner( p_this, pp_objects + i_middle,
+                                                    i_count - i_middle );
+    }
+    else
+    {
+        return find_index_inner( p_this, pp_objects, i_middle );
+    }
+}
+
 /*****************************************************************************
  * vlc_object_find: find a typed object and increment its refcount
  *****************************************************************************
@@ -254,21 +340,17 @@ static vlc_object_t * vlc_object_find_inner( vlc_object_t *p_this,
     switch( i_mode & 0x000f )
     {
     case FIND_PARENT:
-        for( i = p_this->i_parents; i--; )
+        p_tmp = p_this->p_parent;
+        if( p_tmp )
         {
-            p_tmp = p_this->pp_parents[i];
             if( p_tmp->i_object_type == i_type )
             {
                 p_tmp->i_refcount++;
                 return p_tmp;
             }
-            else if( p_tmp->i_parents )
+            else
             {
-                p_tmp = vlc_object_find_inner( p_tmp, i_type, i_mode );
-                if( p_tmp )
-                {
-                    return p_tmp;
-                }
+                return vlc_object_find_inner( p_tmp, i_type, i_mode );
             }
         }
         break;
@@ -331,102 +413,56 @@ void __vlc_object_attach( vlc_object_t *p_this, vlc_object_t *p_parent )
 {
     vlc_mutex_lock( &p_this->p_vlc->structure_lock );
 
-    p_this->i_parents++;
-    p_this->pp_parents = (vlc_object_t **)realloc( p_this->pp_parents,
-                            p_this->i_parents * sizeof(vlc_object_t *) );
-    p_this->pp_parents[p_this->i_parents - 1] = p_parent;
+    /* Attach the parent to its child */
+    p_this->p_parent = p_parent;
 
+    /* Attach the child to its parent */
     p_parent->i_children++;
     p_parent->pp_children = (vlc_object_t **)realloc( p_parent->pp_children,
                                p_parent->i_children * sizeof(vlc_object_t *) );
     p_parent->pp_children[p_parent->i_children - 1] = p_this;
 
-    vlc_mutex_unlock( &p_this->p_vlc->structure_lock );
-}
-
-#if 0 /* UNUSED */
-/* vlc_object_setchild: attach a child object */
-void __vlc_object_setchild( vlc_object_t *p_this, vlc_object_t *p_child )
-{
-    vlc_mutex_lock( &p_this->p_vlc->structure_lock );
-
-    p_this->i_children++;
-    p_this->pp_children = (vlc_object_t **)realloc( p_this->pp_children,
-                             p_this->i_children * sizeof(vlc_object_t *) );
-    p_this->pp_children[p_this->i_children - 1] = p_child;
-
-    p_child->i_parents++;
-    p_child->pp_parents = (vlc_object_t **)realloc( p_child->pp_parents,
-                             p_child->i_parents * sizeof(vlc_object_t *) );
-    p_child->pp_parents[p_child->i_parents - 1] = p_this;
+    /* Climb up the tree to see whether we are connected with the root */
+    if( p_parent->b_attached )
+    {
+        set_attachment_flag( p_this, VLC_TRUE );
+    }
 
     vlc_mutex_unlock( &p_this->p_vlc->structure_lock );
 }
-#endif
 
 /*****************************************************************************
- * vlc_object_detach_all: detach object from its parents
+ * vlc_object_detach: detach object from its parent
  *****************************************************************************
- * This function unlinks an object from all its parents. It is up to the
- * object to get rid of its children, so this function doesn't do anything
- * with them.
+ * This function removes all links between an object and its parent.
  *****************************************************************************/
-void __vlc_object_detach_all( vlc_object_t *p_this )
+void __vlc_object_detach( vlc_object_t *p_this )
 {
     vlc_mutex_lock( &p_this->p_vlc->structure_lock );
-
-    /* FIXME: BORK ! BORK ! BORK !!! THIS STUFF IS BORKED !! FIXME */
-    while( p_this->i_parents )
+    if( !p_this->p_parent )
     {
-        /* Not very effective because we know the index, but we'd have to
-         * parse p_parent->pp_children anyway. Plus, we remove duplicates
-         * by not using the object's index */
-        vlc_object_detach_inner( p_this, p_this->pp_parents[0] );
+        msg_Err( p_this, "object is not attached" );
+        vlc_mutex_unlock( &p_this->p_vlc->structure_lock );
+        return;
     }
 
-    vlc_mutex_unlock( &p_this->p_vlc->structure_lock );
-}
+    /* Climb up the tree to see whether we are connected with the root */
+    if( p_this->p_parent->b_attached )
+    {
+        set_attachment_flag( p_this, VLC_FALSE );
+    }
 
-/*****************************************************************************
- * vlc_object_detach: remove a parent/child link
- *****************************************************************************
- * This function removes all links between an object and a given parent.
- *****************************************************************************/
-void __vlc_object_detach( vlc_object_t *p_this, vlc_object_t *p_parent )
-{
-    vlc_mutex_lock( &p_this->p_vlc->structure_lock );
-    vlc_object_detach_inner( p_this, p_parent );
+    vlc_object_detach_inner( p_this );
     vlc_mutex_unlock( &p_this->p_vlc->structure_lock );
 }
 
-static void vlc_object_detach_inner( vlc_object_t *p_this,
-                                     vlc_object_t *p_parent )
+static void vlc_object_detach_inner( vlc_object_t *p_this )
 {
+    vlc_object_t *p_parent = p_this->p_parent;
     int i_index, i;
 
-    /* Remove all of p_this's parents which are p_parent */
-    for( i_index = p_this->i_parents ; i_index-- ; )
-    {
-        if( p_this->pp_parents[i_index] == p_parent )
-        {
-            p_this->i_parents--;
-            for( i = i_index ; i < p_this->i_parents ; i++ )
-            {
-                p_this->pp_parents[i] = p_this->pp_parents[i+1];
-            }
-        }
-    }
-
-    if( p_this->i_parents )
-    {
-        p_this->pp_parents = (vlc_object_t **)realloc( p_this->pp_parents,
-                                p_this->i_parents * sizeof(vlc_object_t *) );
-    }
-    else
-    {
-        free( p_this->pp_parents );
-        p_this->pp_parents = NULL;
-    }
+    /* Remove p_this's parent */
+    p_this->p_parent = NULL;
 
     /* Remove all of p_parent's children which are p_this */
     for( i_index = p_parent->i_children ; i_index-- ; )
@@ -453,6 +489,24 @@ static void vlc_object_detach_inner( vlc_object_t *p_this,
     }
 }
 
+/*****************************************************************************
+ * set_attachment_flag: recursively set the b_attached flag of a subtree.
+ *****************************************************************************
+ * This function is used by the attach and detach functions to propagate
+ * the b_attached flag in a subtree.
+ *****************************************************************************/
+static void set_attachment_flag( vlc_object_t *p_this, vlc_bool_t b_attached )
+{
+    int i_index;
+
+    for( i_index = p_this->i_children ; i_index-- ; )
+    {
+        set_attachment_flag( p_this->pp_children[i_index], b_attached );
+    }
+
+    p_this->b_attached = b_attached;
+}
+
 /*****************************************************************************
  * vlc_dumpstructure: print the current vlc structure
  *****************************************************************************
index 40c7d3d21dd648c42130cf18d87d75cee797007c..b43ac5e8ef907945faa9b40458294b121f6e3018 100644 (file)
@@ -2,7 +2,7 @@
  * playlist.c : Playlist management functions
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: playlist.c,v 1.9 2002/06/07 23:53:44 sam Exp $
+ * $Id: playlist.c,v 1.10 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -329,7 +329,7 @@ static void RunThread ( playlist_t *p_playlist )
                 /* Unlink current input */
                 p_input = p_playlist->p_input;
                 p_playlist->p_input = NULL;
-                vlc_object_detach_all( p_input );
+                vlc_object_detach( p_input );
 
                 /* Release the playlist lock, because we may get stuck
                  * in input_DestroyThread() for some time. */
@@ -387,7 +387,7 @@ static void RunThread ( playlist_t *p_playlist )
             /* Unlink current input */
             p_input = p_playlist->p_input;
             p_playlist->p_input = NULL;
-            vlc_object_detach_all( p_input );
+            vlc_object_detach( p_input );
             vlc_mutex_unlock( &p_playlist->object_lock );
 
             /* Destroy input */
index f49e81d1ad19d3414d49bc05e12b361da51d7d92..b661c159491f1d50092e60fe535cf7a6c07603df 100644 (file)
@@ -5,7 +5,7 @@
  * thread, and destroy a previously oppened video output thread.
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: video_output.c,v 1.189 2002/08/08 00:35:11 sam Exp $
+ * $Id: video_output.c,v 1.190 2002/08/12 09:34:15 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *
@@ -223,9 +223,6 @@ vout_thread_t * __vout_CreateThread ( vlc_object_t *p_parent,
  *****************************************************************************/
 void vout_DestroyThread( vout_thread_t *p_vout )
 {
-    /* Unlink object */
-    vlc_object_detach_all( p_vout );
-
     /* Request thread destruction */
     p_vout->b_die = 1;
     vlc_thread_join( p_vout );