internal Album(MtpDevice device, AlbumStruct album) : base(device, album.tracks, album.no_tracks) { // Once we've loaded the tracks, set the TracksPtr to NULL as it // will be freed when the Album constructor is finished. this.album = album; TracksPtr = IntPtr.Zero; }
public List <Album> GetAlbums() { List <Album> albums = new List <Album> (); IntPtr ptr = Album.LIBMTP_Get_Album_List(Handle); while (ptr != IntPtr.Zero) { AlbumStruct d = (AlbumStruct)Marshal.PtrToStructure(ptr, typeof(AlbumStruct)); albums.Add(new Album(this, d)); ptr = d.next; } return(albums); }
internal static List <Album> GetAlbums(MtpDevice device) { List <Album> albums = new List <Album> (); IntPtr ptr = LIBMTP_Get_Album_List(device.Handle); while (ptr != IntPtr.Zero) { // Destroy the struct *after* we use it to ensure we don't access freed memory // for the 'tracks' variable AlbumStruct d = (AlbumStruct)Marshal.PtrToStructure(ptr, typeof(AlbumStruct)); albums.Add(new Album(device, d)); LIBMTP_destroy_album_t(ptr); ptr = d.next; } return(albums); }
public static Album GetById(MtpDevice device, uint id) { IntPtr ptr = Album.LIBMTP_Get_Album(device.Handle, id); if (ptr == IntPtr.Zero) { return(null); } else { // Destroy the struct after we use it to prevent accessing freed memory // in the 'tracks' variable AlbumStruct album = (AlbumStruct)Marshal.PtrToStructure(ptr, typeof(AlbumStruct)); var ret = new Album(device, album); LIBMTP_destroy_album_t(ptr); return(ret); } }
static extern int LIBMTP_Update_Album(MtpDeviceHandle handle, ref AlbumStruct album);
internal static extern int LIBMTP_Create_New_Album(MtpDeviceHandle handle, ref AlbumStruct album);
static extern int LIBMTP_Update_Album (MtpDeviceHandle handle, ref AlbumStruct album);
internal static extern int LIBMTP_Create_New_Album (MtpDeviceHandle handle, ref AlbumStruct album, uint parentId);
internal Album(MtpDevice device, AlbumStruct album) : base(device, album.tracks, album.no_tracks) { this.album = album; }
internal static extern void LIBMTP_destroy_album_t(ref AlbumStruct album);
internal Album (MtpDevice device, AlbumStruct album) : base (device, album.tracks, album.no_tracks) { this.album = album; }