[xiph-commits] r3067 - liboggplay/trunk/plugin

tahn at svn.annodex.net tahn at svn.annodex.net
Tue Jun 26 05:47:13 PDT 2007


Author: tahn
Date: 2007-06-26 05:47:13 -0700 (Tue, 26 Jun 2007)
New Revision: 3067

Modified:
   liboggplay/trunk/plugin/plugin_gui_mac.c
Log:
Added 'finished' state handling.


Modified: liboggplay/trunk/plugin/plugin_gui_mac.c
===================================================================
--- liboggplay/trunk/plugin/plugin_gui_mac.c	2007-06-26 11:57:27 UTC (rev 3066)
+++ liboggplay/trunk/plugin/plugin_gui_mac.c	2007-06-26 12:47:13 UTC (rev 3067)
@@ -72,6 +72,7 @@
   semaphore               oggplay_replace_sem;
   PluginPlaybackState     playback_state;
   PluginStateChange       playback_state_change;
+  bool                    playback_finished;
   semaphore               playback_sem;
   nsPluginInstance      * plugin_instance;
 } PluginWindowInfo;
@@ -394,6 +395,7 @@
       info->new_oggplay_handle = NULL;
       shutdown_audio(info, &td);
       playback_target = 0;
+      info->playback_finished = FALSE;
       if (paused) {
         SEM_WAIT(info->playback_sem);
         paused = FALSE;
@@ -413,6 +415,22 @@
      */
     if (!paused) {
       get_oggplay_frame(info->oggplay_handle, &td.frame_data);
+
+      /*
+       * Retrieve the latest oggplay stream info and update accordingly.
+       */
+      switch (get_oggplay_stream_info(info->oggplay_handle, &td.frame_data)) {
+        case OGGPLAY_STREAM_JUST_SEEKED:
+          /*
+           * Flush the audio buffers when the user seeks.
+           */
+          shutdown_audio(info, &td);
+          playback_target = 0;
+          break;
+        case OGGPLAY_STREAM_LAST_DATA:
+          info->playback_finished = TRUE;
+          break;
+      }
     }
     if (!drop_video_frame) {
       convert_oggplay_frame(info->oggplay_handle, &td.frame_data, RGB);
@@ -420,17 +438,6 @@
     }
 
     /*
-     * If the user seeks in the oggplay stream, we need to flush the audio
-     * buffers.
-     */
-    switch (get_oggplay_stream_info(info->oggplay_handle, &td.frame_data)) {
-      case OGGPLAY_STREAM_JUST_SEEKED:
-        shutdown_audio(info, &td);
-        playback_target = 0;
-        break;
-    }
-
-    /*
      * Notify the plugin class that we've got some CMML data.
      */
     if (td.frame_data.cmml_strings != NULL) {
@@ -605,6 +612,7 @@
   info->oggplay_handle        = oggplay_handle;
   info->new_oggplay_handle    = NULL;
   info->playback_state        = PLAYING;
+  info->playback_finished     = FALSE;
   info->playback_state_change = NO_CHANGE;
   info->plugin_instance       = plugin_instance;
 
@@ -714,16 +722,12 @@
 
   PluginWindowInfo  * info = gui_handle;
 
-  switch (info->playback_state) {
-    case PAUSED:
-      return 0;
-    case PLAYING:
-      return 1;
-    case FINISHED:
-      return 2;
-    default:
-      /* error state: should never be returned */
-      return -1;
+  if (info->playback_state == PAUSED) {
+    return 0;
+  } else if (info->playback_finished) {
+    return 2;
+  } else {
+    return 1;
   }
 }
 



More information about the commits mailing list