Changeset 8837d3d6ac772535558a22e8cc750d2497f126d5

Show
Ignore:
Timestamp:
10/21/07 18:52:11 (11 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1192985531 +0000
git-parent:

[d95b7e67485fed8cd1db9b585300049325d5cd7c]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1192985531 +0000
Message:

Playlist delete support... sorta. LibVLC crashes internally.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bindings/cil/libvlc.cs

    r9c4f520 r8837d3d  
    2323 
    2424using System; 
     25using System.Collections.Generic; 
    2526using System.Runtime.InteropServices; 
    2627 
     
    7071    public class Instance : BaseObject<InstanceHandle> 
    7172    { 
     73        Dictionary<int, PlaylistItem> items; 
     74 
    7275        internal Instance (InstanceHandle self) : base (self) 
    7376        { 
     77            items = new Dictionary<int, PlaylistItem> (); 
    7478        } 
    7579 
     
    8286            return new MediaDescriptor (dh); 
    8387        } 
    84  
    8588 
    8689        [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_loop")] 
     
    170173            PlaylistClear (self, ex); 
    171174            ex.Raise (); 
     175 
     176            foreach (PlaylistItem item in items.Values) 
     177                item.Close (); 
     178            items.Clear (); 
    172179        } 
    173180 
    174181        [DllImport ("libvlc-control.dll", 
    175182                    EntryPoint="libvlc_playlist_add_extended")] 
    176         static extern void PlaylistAdd (InstanceHandle self, U8String uri, 
    177                                         U8String name, int optc, 
    178                                         U8String[] optv, NativeException e); 
     183        static extern int PlaylistAdd (InstanceHandle self, U8String uri, 
     184                                       U8String name, int optc, 
     185                                       U8String[] optv, NativeException e); 
    179186        /** Appends an item to the playlist with options */ 
    180         public void Add (string mrl, string name, string[] opts) 
     187        public PlaylistItem Add (string mrl, string name, string[] opts) 
    181188        { 
    182189            U8String umrl = new U8String (mrl); 
     
    186193                optv[i] = new U8String (opts[i]); 
    187194 
    188             PlaylistAdd (self, umrl, uname, optv.Length, optv, ex); 
    189             ex.Raise (); 
    190         } 
    191         public void Add (string mrl, string[] opts) 
    192         { 
    193             Add (mrl, null, opts); 
    194         } 
    195         public void Add (string mrl, string name) 
    196         { 
    197             Add (mrl, name, new string[0]); 
    198         } 
    199         public void Add (string mrl) 
    200         { 
    201             Add (mrl, null, new string[0]); 
     195            int id = PlaylistAdd (self, umrl, uname, optv.Length, optv, ex); 
     196            ex.Raise (); 
     197 
     198            PlaylistItem item = new PlaylistItem (id); 
     199            items.Add (id, item); 
     200            return item; 
     201        } 
     202        public PlaylistItem Add (string mrl, string[] opts) 
     203        { 
     204            return Add (mrl, null, opts); 
     205        } 
     206        public PlaylistItem Add (string mrl, string name) 
     207        { 
     208            return Add (mrl, name, new string[0]); 
     209        } 
     210        public PlaylistItem Add (string mrl) 
     211        { 
     212            return Add (mrl, null, new string[0]); 
     213        } 
     214 
     215        [DllImport ("libvlc-control.dll", 
     216                    EntryPoint="libvlc_playlist_delete_item")] 
     217        static extern int PlaylistDelete (InstanceHandle self, int id, 
     218                                          NativeException e); 
     219        public void Delete (PlaylistItem item) 
     220        { 
     221            int id = item.Id; 
     222            PlaylistDelete (self, id, ex); 
     223            ex.Raise (); 
     224 
     225            item.Close (); 
     226            items.Remove (id); 
     227        } 
     228    }; 
     229 
     230    public class PlaylistItem 
     231    { 
     232        int id; 
     233        bool deleted; 
     234 
     235        internal PlaylistItem (int id) 
     236        { 
     237            this.id = id; 
     238            this.deleted = false; 
     239        } 
     240 
     241        internal void Close () 
     242        { 
     243            deleted = true; 
     244        } 
     245 
     246        internal int Id 
     247        { 
     248            get 
     249            { 
     250                if (deleted) 
     251                    throw new ObjectDisposedException ("Playlist item deleted"); 
     252                return id; 
     253            } 
    202254        } 
    203255    }; 
  • bindings/cil/testvlc.cs

    r54f91fa r8837d3d  
    3737            md.Dispose (); 
    3838 
     39            PlaylistItem item = null; 
     40 
    3941            foreach (string s in args) 
    40                 vlc.Add (s); 
     42                item = vlc.Add (s); 
    4143 
    4244            vlc.Loop = false; 
    4345            vlc.TogglePause (); 
    4446            Console.ReadLine (); 
     47 
     48            if (item != null) 
     49                vlc.Delete (item); 
     50            vlc.Clear (); 
    4551            vlc.Dispose (); 
    4652            return 0;