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

shans at svn.annodex.net shans at svn.annodex.net
Tue Jun 26 22:22:03 PDT 2007


Author: shans
Date: 2007-06-26 22:22:03 -0700 (Tue, 26 Jun 2007)
New Revision: 3085

Modified:
   liboggplay/trunk/plugin/plugin_gui_linux.c
Log:
Added finished state to linux gui



Modified: liboggplay/trunk/plugin/plugin_gui_linux.c
===================================================================
--- liboggplay/trunk/plugin/plugin_gui_linux.c	2007-06-27 04:59:42 UTC (rev 3084)
+++ liboggplay/trunk/plugin/plugin_gui_linux.c	2007-06-27 05:22:03 UTC (rev 3085)
@@ -63,6 +63,7 @@
   semaphore             oggplay_replace_sem;
   semaphore             start_stop_sem;
   PluginPlaybackState   playback_state;
+  int                   playback_finished;
   void                * new_oggplay_handle;
   SAAudioHandle       * audio_handle;
   gboolean	            audio_opened;
@@ -97,6 +98,14 @@
   return;
 }
 
+void
+close_audio(PluginWindowInfo *info) {
+  if (info->audio_opened == TRUE)
+    sa_device_close(info->audio_handle);
+  info->audio_opened = FALSE;
+  info->tried_audio = FALSE;
+}
+
 int maybe_switch_oggplays(PluginWindowInfo *info) {
 
   void * old_ogg_handle;
@@ -107,12 +116,10 @@
     old_ogg_handle = info->ogg_handle;
     info->ogg_handle = (void *)info->new_oggplay_handle;
     info->new_oggplay_handle = NULL;
+    info->playback_finished = FALSE;
+    close_audio(info);
     SEM_SIGNAL(info->oggplay_replace_sem); 
     shut_oggplay(old_ogg_handle);
-    if (info->audio_opened == TRUE)
-      sa_device_close(info->audio_handle);
-    info->audio_opened = FALSE;
-    info->tried_audio = FALSE;
     return TRUE;
   }
   
@@ -156,21 +163,38 @@
   /*
    * if we are paused, then don't do anything
    */
-  if (info->playback_state == PAUSED) {
+  if (info->playback_state == PAUSED || info->playback_finished) {
     return TRUE;
   }
 
   get_oggplay_frame(info->ogg_handle, &frame_data);
 
+  switch (get_oggplay_stream_info(info->ogg_handle, &frame_data)) {
+    case OGGPLAY_STREAM_JUST_SEEKED:
+      close_audio(info);
+      break;
+
+    case OGGPLAY_STREAM_LAST_DATA:
+      info->playback_finished = TRUE;
+      return TRUE;
+
+    default:
+      break;
+  }
+
   if (frame_data.video_data != NULL) {    
     render_frame_to_screen(info, &frame_data);
   } else if (frame_data.samples == NULL) {
     return TRUE;
   }
 
-  if (info->tried_audio == FALSE && frame_data.samples != NULL) {
+  if (info->tried_audio == FALSE) {
     info->tried_audio = TRUE;
-    open_audio(info);
+    if (frame_data.samples != NULL) {
+      open_audio(info);
+    } else {
+      info->playback_target = oggplay_sys_time_in_ms() << 16; 
+    }
   }
 
   if (frame_data.cmml_strings != NULL) {      
@@ -315,6 +339,7 @@
   info->audio_opened = FALSE;
   // set depending on the plugin startup settings
   info->playback_state = PLAYING; 
+  info->playback_finished = FALSE;
   /*
    * create semaphore to lock replacement of oggplay object
    */
@@ -372,24 +397,17 @@
 
 short
 gui_get_current_state(void *handle) {
-  short state;
   PluginWindowInfo  * info = (PluginWindowInfo *)handle;
-  switch (info->playback_state) {
-    case PAUSED: 
-      state = 0;
-      break;
-    case PLAYING: 
-      state = 1;
-      break;
-    case FINISHED: 
-      state = 2;    
-      break;
-    default:
-      /* error state: should never be returned */
-      state = -1;
-      break;
+
+  if (info->playback_state == PAUSED) {
+    return 0;
+  } 
+  
+  if (info->playback_finished) {
+    return 2;
   }
-  return state;
+
+  return 1;
 }
 
 void



More information about the commits mailing list