]> git.sesse.net Git - vlc/blobdiff - src/control/vlm.c
modules: Make sure DupModule() work as expected. (Pointed by courmisch).
[vlc] / src / control / vlm.c
index 7ea608667be4f0ffcdec0a747b1b3d648a72ad96..aa6181cb50d38eb0ab26a152b085ac9b76ac4907 100644 (file)
@@ -91,10 +91,12 @@ char* libvlc_vlm_show_media( libvlc_instance_t *p_instance, char *psz_name,
     }
     free( psz_message );
     return(psz_response );
-#endif
+#else
+    libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
     return NULL;
-}
 #endif
+}
+#endif /* 0 */
 
 static int libvlc_vlm_init( libvlc_instance_t *p_instance,
                             libvlc_exception_t *p_exception )
@@ -102,12 +104,15 @@ static int libvlc_vlm_init( libvlc_instance_t *p_instance,
 #ifdef ENABLE_VLM
     if( !p_instance->p_vlm )
         p_instance->p_vlm = vlm_New( p_instance->p_libvlc_int );
+#else
+    libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
+    return VLC_EGENERIC;
 #endif
 
     if( !p_instance->p_vlm )
     {
         libvlc_exception_raise( p_exception,
-                                "Unable to create VLM. It might be disabled." );
+                                "Unable to create VLM." );
         return VLC_EGENERIC;
     }
     return VLC_SUCCESS;
@@ -118,6 +123,37 @@ static int libvlc_vlm_init( libvlc_instance_t *p_instance,
   } while(0)
 #define VLM(p) VLM_RET(p,)
 
+static vlm_media_instance_t *libvlc_vlm_get_media_instance( libvlc_instance_t *p_instance,
+                                                            char *psz_name, int i_minstance_idx,
+                                                            libvlc_exception_t *p_exception )
+{
+    vlm_t *p_vlm;
+    vlm_media_instance_t **pp_minstance;
+    vlm_media_instance_t *p_minstance;
+    int i_minstance;
+    int64_t id;
+
+    VLM_RET(p_vlm, NULL);
+
+    if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
+        vlm_Control( p_vlm, VLM_GET_MEDIA_INSTANCES, id, &pp_minstance, &i_minstance ) )
+    {
+        libvlc_exception_raise( p_exception, "Unable to get %s instances", psz_name );
+        return NULL;
+    }
+    p_minstance = NULL;
+    if( i_minstance_idx >= 0 && i_minstance_idx < i_minstance )
+    {
+        p_minstance = pp_minstance[i_minstance_idx];
+        TAB_REMOVE( i_minstance, pp_minstance, p_minstance );
+    }
+    while( i_minstance > 0 )
+        vlm_media_instance_Delete( pp_minstance[--i_minstance] );
+    TAB_CLEAN( i_minstance, pp_minstance );
+    return p_minstance;
+}
+
+
 void libvlc_vlm_release( libvlc_instance_t *p_instance, libvlc_exception_t *p_exception)
 {
     vlm_t *p_vlm;
@@ -143,7 +179,7 @@ void libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance, char *psz_name,
     vlm_media_Init( &m );
     m.psz_name = strdup( psz_name );
     m.b_enabled = b_enabled;
-    m.b_vod = VLC_FALSE;
+    m.b_vod = false;
     m.broadcast.b_loop = b_loop;
     if( psz_input )
         TAB_APPEND( m.i_input, m.ppsz_input, strdup(psz_input) );
@@ -325,36 +361,6 @@ void libvlc_vlm_seek_media( libvlc_instance_t *p_instance, char *psz_name,
     }
 }
 
-static vlm_media_instance_t *libvlc_vlm_get_media_instance( libvlc_instance_t *p_instance,
-                                                            char *psz_name, int i_minstance_idx,
-                                                            libvlc_exception_t *p_exception )
-{
-    vlm_t *p_vlm;
-    vlm_media_instance_t **pp_minstance;
-    vlm_media_instance_t *p_minstance;
-    int i_minstance;
-    int64_t id;
-
-    VLM_RET(p_vlm, NULL);
-
-    if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
-        vlm_Control( p_vlm, VLM_GET_MEDIA_INSTANCES, id, &pp_minstance, &i_minstance ) )
-    {
-        libvlc_exception_raise( p_exception, "Unable to get %s instances", psz_name );
-        return NULL;
-    }
-    p_minstance = NULL;
-    if( i_minstance_idx >= 0 && i_minstance_idx < i_minstance )
-    {
-        p_minstance = pp_minstance[i_minstance_idx];
-        TAB_REMOVE( i_minstance, pp_minstance, p_minstance );
-    }
-    while( i_minstance > 0 )
-        vlm_media_instance_Delete( pp_minstance[--i_minstance] );
-    TAB_CLEAN( i_minstance, pp_minstance );
-    return p_minstance;
-}
-
 #define LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( attr, returnType, getType, ret, code )\
 returnType libvlc_vlm_get_media_## attr( libvlc_instance_t *p_instance, \
                         char *psz_name, int i_instance, libvlc_exception_t *p_exception ) \
@@ -378,7 +384,7 @@ LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( rate,     int, Integer, -1, ret_value = p_mi->i_
 /* FIXME extend vlm_media_instance_t to be able to implement them */
 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( title,    int, Integer,  0, ret_value = 0 );
 LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( chapter,  int, Integer,  0, ret_value = 0 );
-LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( seekable, int, Bool,     0, ret_value = VLC_FALSE );
+LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( seekable, int, Bool,     0, ret_value = false );
 
 #undef LIBVLC_VLM_GET_MEDIA_ATTRIBUTE