]> git.sesse.net Git - vlc/blobdiff - modules/codec/cmml/intf.c
Use pl_Locked and pl_Unlocked.
[vlc] / modules / codec / cmml / intf.c
index bb91c75b039198d70fdcfdb5acd28bceb75680c4..5f58b303d318a92b075c96c3d08d84d46f685ef6 100644 (file)
@@ -31,7 +31,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 
 #include <stdio.h>
 
@@ -79,8 +79,8 @@ struct navigation_history_t
  * Local prototypes.
  *****************************************************************************/
 
-int          E_(OpenIntf)               ( vlc_object_t * );
-void         E_(CloseIntf)              ( vlc_object_t * );
+int          OpenIntf               ( vlc_object_t * );
+void         CloseIntf              ( vlc_object_t * );
 
 static int   InitThread                 ( intf_thread_t * );
 static int   MouseEvent                 ( vlc_object_t *, char const *,
@@ -114,7 +114,7 @@ static void RunIntf        ( intf_thread_t *p_intf );
 /*****************************************************************************
  * OpenIntf: initialize CMML interface
  *****************************************************************************/
-int E_(OpenIntf) ( vlc_object_t *p_this )
+int OpenIntf ( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
 
@@ -146,7 +146,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
 /*****************************************************************************
  * CloseIntf: destroy dummy interface
  *****************************************************************************/
-void E_(CloseIntf) ( vlc_object_t *p_this )
+void CloseIntf ( vlc_object_t *p_this )
 {
     intf_thread_t * p_intf = (intf_thread_t *)p_this;
     vout_thread_t * p_vout;
@@ -188,17 +188,16 @@ static void RunIntf( intf_thread_t *p_intf )
     msg_Dbg( p_intf, "CMML intf initialized" );
 #endif
 
-    /* if video output is dying, disassociate ourselves from it */
-    if( p_vout && p_vout->b_die )
-    {
-        var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
-        vlc_object_release( p_vout );
-        p_vout = NULL;
-    }
-
     /* Main loop */
-    while( !p_intf->b_die )
+    while( vlc_object_alive (p_intf) )
     {
+        /* if video output is dying, disassociate ourselves from it */
+        if( p_vout && !vlc_object_alive (p_vout) )
+        {
+            var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
+            vlc_object_release( p_vout );
+            p_vout = NULL;
+        }
 
         /* find a video output if we currently don't have one */
         if( p_vout == NULL )
@@ -270,11 +269,11 @@ static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
     if( var_Get( p_cmml_decoder, "psz-current-anchor-description", &val )
             != VLC_SUCCESS )
     {
-        return VLC_TRUE;
+        return true;
     }
 
     if( !val.p_address )
-        return VLC_TRUE;
+        return true;
 
     psz_description = val.p_address;
 
@@ -295,10 +294,10 @@ static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
             if( var_Get( p_primary_intf, "intf-displays-cmml-description", &val )
                     == VLC_SUCCESS )
             {
-                if( val.b_bool == VLC_TRUE )
+                if( val.b_bool == true )
                 {
                     vlc_object_release( p_primary_intf );
-                    return VLC_TRUE;
+                    return true;
                 }
             }
 
@@ -310,7 +309,7 @@ static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
                 != VLC_SUCCESS )
         {
             /* text render unsuccessful: do nothing */
-            return VLC_FALSE;
+            return false;
         }
 
         /* text render successful: clear description */
@@ -325,7 +324,7 @@ static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
         psz_url = NULL;
     }
 
-    return VLC_TRUE;
+    return true;
 }
 
 
@@ -335,7 +334,7 @@ static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
 static int InitThread( intf_thread_t * p_intf )
 {
     /* We might need some locking here */
-    if( !p_intf->b_die )
+    if( vlc_object_alive (p_intf) )
     {
         input_thread_t * p_input;
         decoder_t *p_cmml_decoder;
@@ -436,13 +435,7 @@ static void FollowAnchor ( intf_thread_t *p_intf )
         mtime_t i_seconds;
         vlc_value_t time;
 
-        p_playlist = (playlist_t *) vlc_object_find( p_intf,
-                VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-        if ( !p_playlist )
-        {
-            msg_Warn( p_intf, "can't find playlist" );
-            return;
-        }
+        p_playlist = pl_Yield( p_intf );
 
         /* Get new URL */
         p_current_item = p_playlist->status.p_item;
@@ -517,7 +510,7 @@ static void FollowAnchor ( intf_thread_t *p_intf )
             msg_Dbg( p_intf, "calling browser_Open with \"%s\"", psz_url );
 #endif
             (void) browser_Open( psz_url );
-            playlist_Control( p_playlist, PLAYLIST_PAUSE, VLC_TRUE, 0 );
+            playlist_Control( p_playlist, PLAYLIST_PAUSE, pl_Unlocked, 0 );
         }
 
         free( psz_uri_to_load );
@@ -541,7 +534,7 @@ char *GetTimedURLFromPlaylistItem( intf_thread_t *p_intf,
     free( psz_uri );
 
     /* Get current time as a string */
-    if( XURL_IsFileURL( psz_url ) == VLC_TRUE )
+    if( XURL_IsFileURL( psz_url ) == true )
         psz_url = xstrcat( psz_url, "#" );
     else
         psz_url = xstrcat( psz_url, "?" );
@@ -645,13 +638,7 @@ void GoBack( intf_thread_t *p_intf )
 #endif
 
     /* Find the playlist */
-    p_playlist = (playlist_t *) vlc_object_find( p_intf,
-            VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if ( !p_playlist )
-    {
-        msg_Warn( p_intf, "can't find playlist" );
-        return;
-    }
+    p_playlist = pl_Yield( p_intf );
 
     /* Retrieve navigation history from playlist */
     if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS ||
@@ -671,7 +658,7 @@ void GoBack( intf_thread_t *p_intf )
 #endif
 
     /* Check whether we can go back in the history */
-    if( history_CanGoBack( p_history ) == VLC_FALSE )
+    if( history_CanGoBack( p_history ) == false )
     {
         msg_Warn( p_intf, "can't go back: already at beginning of history" );
         vlc_object_release( p_playlist );
@@ -723,13 +710,7 @@ void GoForward( intf_thread_t *p_intf )
 #endif
 
     /* Find the playlist */
-    p_playlist = (playlist_t *) vlc_object_find( p_intf,
-            VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if ( !p_playlist )
-    {
-        msg_Warn( p_intf, "can't find playlist" );
-        return;
-    }
+    p_playlist = pl_Yield( p_intf );
 
     /* Retrieve navigation history from playlist */
     if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS ||
@@ -749,7 +730,7 @@ void GoForward( intf_thread_t *p_intf )
 #endif
 
     /* Check whether we can go forward in the history */
-    if( history_CanGoForward( p_history ) == VLC_FALSE )
+    if( history_CanGoForward( p_history ) == false )
     {
         msg_Warn( p_intf, "can't go forward: already at end of history" );
         vlc_object_release( p_playlist );
@@ -789,8 +770,8 @@ static void ReplacePlaylistItem( playlist_t *p_playlist, char *psz_uri )
 {
     playlist_Stop( p_playlist );
     (void) playlist_Add( p_playlist, psz_uri, psz_uri,
-                         PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO, VLC_TRUE /* FIXME: p_playlist->status.i_index */,
-                         VLC_FALSE);
+                         PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO, true /* FIXME: p_playlist->status.i_index */,
+                         false);
 }
 
 /****************************************************************************