[vlc-commits] macosx/info panel: replace use of private API for statistics

Felix Paul Kühne git at videolan.org
Sun Mar 10 19:56:08 CET 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Mar 10 19:54:04 2019 +0100| [61951b5c8467f7abdb0524d0549c9b35fe95a36b] | committer: Felix Paul Kühne

macosx/info panel: replace use of private API for statistics

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=61951b5c8467f7abdb0524d0549c9b35fe95a36b
---

 .../gui/macosx/coreinteraction/VLCInputManager.m   |  4 ---
 .../macosx/panels/VLCInformationWindowController.h |  2 --
 .../macosx/panels/VLCInformationWindowController.m | 42 ++++++++++++----------
 3 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/modules/gui/macosx/coreinteraction/VLCInputManager.m b/modules/gui/macosx/coreinteraction/VLCInputManager.m
index 8afa757964..7abe71ef9f 100644
--- a/modules/gui/macosx/coreinteraction/VLCInputManager.m
+++ b/modules/gui/macosx/coreinteraction/VLCInputManager.m
@@ -31,7 +31,6 @@
 #import "os-integration/VLCRemoteControlService.h"
 #import "os-integration/iTunes.h"
 #import "os-integration/Spotify.h"
-#import "panels/VLCInformationWindowController.h"
 #import "panels/VLCTrackSynchronizationWindowController.h"
 #import "panels/dialogs/VLCResumeDialogController.h"
 #import "windows/extensions/VLCExtensionsManager.h"
@@ -83,9 +82,6 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
                 [inputManager performSelectorOnMainThread:@selector(updateMainWindow) withObject:nil waitUntilDone:NO];
                 break;
             case INPUT_EVENT_STATISTICS:
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    [[[VLCMain sharedInstance] currentMediaInfoPanel] updateStatistics];
-                });
                 break;
             case INPUT_EVENT_ES:
                 break;
diff --git a/modules/gui/macosx/panels/VLCInformationWindowController.h b/modules/gui/macosx/panels/VLCInformationWindowController.h
index 1859eee02b..a87c992b4b 100644
--- a/modules/gui/macosx/panels/VLCInformationWindowController.h
+++ b/modules/gui/macosx/panels/VLCInformationWindowController.h
@@ -93,6 +93,4 @@
 
 - (void)updatePanelWithItem:(input_item_t *)newInputItem;
 
-- (void)updateStatistics;
-
 @end
diff --git a/modules/gui/macosx/panels/VLCInformationWindowController.m b/modules/gui/macosx/panels/VLCInformationWindowController.m
index bd72d10039..72e6f7499e 100644
--- a/modules/gui/macosx/panels/VLCInformationWindowController.m
+++ b/modules/gui/macosx/panels/VLCInformationWindowController.m
@@ -26,6 +26,7 @@
 #import "main/CompatibilityFixes.h"
 #import "main/VLCMain.h"
 #import "playlist/VLCPlaylistController.h"
+#import "playlist/VLCPlayerController.h"
 
 #import <vlc_url.h>
 
@@ -62,10 +63,15 @@
 {
     self = [super initWithWindowNibName:@"MediaInfo"];
     if (self) {
-        [[NSNotificationCenter defaultCenter] addObserver:self
+        NSNotificationCenter *defaultNotificationCenter = [NSNotificationCenter defaultCenter];
+        [defaultNotificationCenter addObserver:self
                                                  selector:@selector(currentPlaylistItemChanged:)
                                                      name:VLCPlaylistCurrentItemChanged
                                                    object:nil];
+        [defaultNotificationCenter addObserver:self
+                                      selector:@selector(updateStatistics:)
+                                          name:VLCPlayerStatisticsUpdated
+                                        object:nil];
     }
     return self;
 }
@@ -265,43 +271,41 @@ FREENULL( psz_##foo );
 
     /* reload the codec details table */
     [self updateStreamsList];
-
-    /* update the stats once to display p_item change faster */
-    [self updateStatistics];
 }
 
-- (void)updateStatistics
+- (void)updateStatistics:(NSNotification *)aNotification
 {
     if (!self.isWindowLoaded || !b_stats)
         return;
 
-    if (!_mediaItem || !_mediaItem->p_stats) {
-        [self initMediaPanelStats];
+    if (![self.window isVisible])
         return;
-    }
 
-    if (![self.window isVisible])
+    VLCInputStats *inputStats = aNotification.userInfo[VLCPlayerInputStats];
+    if (!inputStats) {
+        [self initMediaPanelStats];
         return;
+    }
 
     /* input */
     [_readBytesTextField setStringValue: [NSString stringWithFormat:
-                                          @"%8.0f KiB", (float)(_mediaItem->p_stats->i_read_bytes)/1024]];
+                                          @"%8.0f KiB", (float)(inputStats.inputReadBytes)/1024]];
     [_inputBitrateTextField setStringValue: [NSString stringWithFormat:
-                                             @"%6.0f kb/s", (float)(_mediaItem->p_stats->f_input_bitrate)*8000]];
+                                             @"%6.0f kb/s", (float)(inputStats.inputBitrate)*8000]];
     [_demuxBytesTextField setStringValue: [NSString stringWithFormat:
-                                           @"%8.0f KiB", (float)(_mediaItem->p_stats->i_demux_read_bytes)/1024]];
+                                           @"%8.0f KiB", (float)(inputStats.demuxReadBytes)/1024]];
     [_demuxBitrateTextField setStringValue: [NSString stringWithFormat:
-                                             @"%6.0f kb/s", (float)(_mediaItem->p_stats->f_demux_bitrate)*8000]];
+                                             @"%6.0f kb/s", (float)(inputStats.demuxBitrate)*8000]];
 
     /* Video */
-    [_videoDecodedTextField setIntegerValue: _mediaItem->p_stats->i_decoded_video];
-    [_displayedTextField setIntegerValue: _mediaItem->p_stats->i_displayed_pictures];
-    [_lostFramesTextField setIntegerValue: _mediaItem->p_stats->i_lost_pictures];
+    [_videoDecodedTextField setIntegerValue: inputStats.decodedVideo];
+    [_displayedTextField setIntegerValue: inputStats.displayedPictures];
+    [_lostFramesTextField setIntegerValue: inputStats.lostPictures];
 
     /* Audio */
-    [_audioDecodedTextField setIntegerValue: _mediaItem->p_stats->i_decoded_audio];
-    [_playedAudioBuffersTextField setIntegerValue: _mediaItem->p_stats->i_played_abuffers];
-    [_lostAudioBuffersTextField setIntegerValue: _mediaItem->p_stats->i_lost_abuffers];
+    [_audioDecodedTextField setIntegerValue: inputStats.decodedAudio];
+    [_playedAudioBuffersTextField setIntegerValue: inputStats.playedAudioBuffers];
+    [_lostAudioBuffersTextField setIntegerValue: inputStats.lostAudioBuffers];
 }
 
 - (void)updateStreamsList



More information about the vlc-commits mailing list