From 426564be5088fa07fada75d9fd0ed1cacbf8ea1f Mon Sep 17 00:00:00 2001 From: hsgwon Date: Mon, 15 Apr 2019 15:12:33 +0900 Subject: [PATCH] [MediaController] Remove useless method call and fix the bug of foreach method (#790) --- .../Interop/Interop.MediaControllerPlaylist.cs | 2 +- .../MediaController/MediaControlPlaylist.cs | 2 -- .../MediaController/MediaController.cs | 18 +++++++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Tizen.Multimedia.Remoting/Interop/Interop.MediaControllerPlaylist.cs b/src/Tizen.Multimedia.Remoting/Interop/Interop.MediaControllerPlaylist.cs index c20eb6f..0b05dee 100644 --- a/src/Tizen.Multimedia.Remoting/Interop/Interop.MediaControllerPlaylist.cs +++ b/src/Tizen.Multimedia.Remoting/Interop/Interop.MediaControllerPlaylist.cs @@ -31,7 +31,7 @@ internal static partial class Interop IntPtr handle, IntPtr userData); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - internal delegate void PlaylistCallback(IntPtr handle, IntPtr userData); + internal delegate bool PlaylistCallback(IntPtr handle, IntPtr userData); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate bool PlaylistItemCallback(string index, IntPtr handle, IntPtr userData); diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaControlPlaylist.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaControlPlaylist.cs index d5cecdc..e636e97 100644 --- a/src/Tizen.Multimedia.Remoting/MediaController/MediaControlPlaylist.cs +++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaControlPlaylist.cs @@ -190,8 +190,6 @@ namespace Tizen.Multimedia.Remoting { AddMetadata(data.Key, data.Value); } - - MediaControlServer.SavePlaylist(Handle); } /// diff --git a/src/Tizen.Multimedia.Remoting/MediaController/MediaController.cs b/src/Tizen.Multimedia.Remoting/MediaController/MediaController.cs index 3ca8b47..10b4682 100644 --- a/src/Tizen.Multimedia.Remoting/MediaController/MediaController.cs +++ b/src/Tizen.Multimedia.Remoting/MediaController/MediaController.cs @@ -189,13 +189,29 @@ namespace Tizen.Multimedia.Remoting var playlists = new List(); + Exception caught = null; + NativePlaylist.PlaylistCallback playlistCallback = (handle, _) => { - playlists.Add(new MediaControlPlaylist(handle)); + try + { + playlists.Add(new MediaControlPlaylist(handle)); + return true; + } + catch (Exception e) + { + caught = e; + return false; + } }; NativePlaylist.ForeachServerPlaylist(Manager.Handle, ServerAppId, playlistCallback, IntPtr.Zero) .ThrowIfError("Failed to get playlist."); + if (caught != null) + { + throw caught; + } + return playlists.AsReadOnly(); } -- 2.7.4