]> git.sesse.net Git - vlc/blobdiff - src/input/vlm.c
Replace remaining call sites of aout_BufferFree()
[vlc] / src / input / vlm.c
index ee7539d3bcb2e4419e14f2537caab216e5131dd0..6813591d2154b6592128a2b0bd7675f3238f6dd3 100644 (file)
@@ -1,26 +1,26 @@
 /*****************************************************************************
  * vlm.c: VLM interface plugin
  *****************************************************************************
- * Copyright (C) 2000-2005 the VideoLAN team
+ * Copyright (C) 2000-2005 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Simon Latapie <garf@videolan.org>
  *          Laurent Aimar <fenrir@videolan.org>
  *          Gildas Bazin <gbazin@videolan.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -131,7 +131,6 @@ vlm_t *vlm_New ( vlc_object_t *p_this )
 {
     vlm_t *p_vlm = NULL, **pp_vlm = &(libvlc_priv (p_this->p_libvlc)->p_vlm);
     char *psz_vlmconf;
-    static const char vlm_object_name[] = "vlm daemon";
 
     /* Avoid multiple creation */
     vlc_mutex_lock( &vlm_mutex );
@@ -150,7 +149,7 @@ vlm_t *vlm_New ( vlc_object_t *p_this )
     msg_Dbg( p_this, "creating VLM" );
 
     p_vlm = vlc_custom_create( p_this->p_libvlc, sizeof( *p_vlm ),
-                               VLC_OBJECT_GENERIC, vlm_object_name );
+                               "vlm daemon" );
     if( !p_vlm )
     {
         vlc_mutex_unlock( &vlm_mutex );
@@ -215,16 +214,15 @@ void vlm_Delete( vlm_t *p_vlm )
     vlc_mutex_lock( &vlm_mutex );
     assert( p_vlm->users > 0 );
     if( --p_vlm->users == 0 )
-    {
-        assert( libvlc_priv(p_vlm->p_libvlc)->p_vlm = p_vlm );
-        libvlc_priv(p_vlm->p_libvlc)->p_vlm = NULL;
-    }
+        assert( libvlc_priv(p_vlm->p_libvlc)->p_vlm == p_vlm );
     else
         p_vlm = NULL;
-    vlc_mutex_unlock( &vlm_mutex );
 
     if( p_vlm == NULL )
+    {
+        vlc_mutex_unlock( &vlm_mutex );
         return;
+    }
 
     /* Destroy and release VLM */
     vlc_mutex_lock( &p_vlm->lock );
@@ -243,6 +241,9 @@ void vlm_Delete( vlm_t *p_vlm )
         vlc_object_release( p_vlm->p_vod );
     }
 
+    libvlc_priv(p_vlm->p_libvlc)->p_vlm = NULL;
+    vlc_mutex_unlock( &vlm_mutex );
+
     vlc_mutex_lock( &p_vlm->lock_manage );
     p_vlm->input_state_changed = true;
     vlc_cond_signal( &p_vlm->wait_manage );
@@ -420,7 +421,7 @@ static void* Manage( void* p_object )
     int canc = vlc_savecancel ();
     i_lastcheck = vlm_Date();
 
-    while( !vlm->b_die )
+    while( vlc_object_alive( vlm ) )
     {
         char **ppsz_scheduled_commands = NULL;
         int    i_scheduled_commands = 0;
@@ -628,8 +629,7 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
             vlc_gc_decref( p_media->vod.p_item );
 
             char *psz_uri = make_URI( p_cfg->ppsz_input[0], NULL );
-            p_media->vod.p_item = input_item_New( p_vlm, psz_uri,
-                p_cfg->psz_name );
+            p_media->vod.p_item = input_item_New( psz_uri, p_cfg->psz_name );
             free( psz_uri );
 
             if( p_cfg->psz_output )
@@ -697,13 +697,15 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
                     psz_mux = p_cfg->vod.psz_mux;
 
                 es_format_t es, *p_es = &es;
-                union { char text[5]; uint32_t value; } fourcc;
+                union {
+                    char text[5];
+                    unsigned char utext[5];
+                    uint32_t value;
+                } fourcc;
 
                 sprintf( fourcc.text, "%4.4s", psz_mux );
-                fourcc.text[0] = tolower(fourcc.text[0]);
-                fourcc.text[1] = tolower(fourcc.text[1]);
-                fourcc.text[2] = tolower(fourcc.text[2]);
-                fourcc.text[3] = tolower(fourcc.text[3]);
+                for( int i = 0; i < 4; i++ )
+                    fourcc.utext[i] = tolower(fourcc.utext[i]);
 
                 item.i_es = 1;
                 item.es = &p_es;
@@ -766,7 +768,7 @@ static int vlm_ControlMediaAdd( vlm_t *p_vlm, vlm_media_t *p_cfg, int64_t *p_id
     if( p_cfg->b_vod && !p_vlm->p_vod )
     {
         p_vlm->p_vod = vlc_custom_create( VLC_OBJECT(p_vlm), sizeof( vod_t ),
-                                          VLC_OBJECT_GENERIC, "vod server" );
+                                          "vod server" );
         p_vlm->p_vod->p_module = module_need( p_vlm->p_vod, "vod server", "$vod-server", false );
         if( !p_vlm->p_vod->p_module )
         {
@@ -788,7 +790,7 @@ static int vlm_ControlMediaAdd( vlm_t *p_vlm, vlm_media_t *p_cfg, int64_t *p_id
     p_media->cfg.id = p_vlm->i_id++;
     /* FIXME do we do something here if enabled is true ? */
 
-    p_media->vod.p_item = input_item_New( p_vlm, NULL, NULL );
+    p_media->vod.p_item = input_item_New( NULL, NULL );
 
     p_media->vod.p_media = NULL;
     TAB_INIT( p_media->i_instance, p_media->instance );
@@ -903,7 +905,7 @@ static vlm_media_instance_sys_t *vlm_MediaInstanceNew( vlm_t *p_vlm, const char
     if( psz_name )
         p_instance->psz_name = strdup( psz_name );
 
-    p_instance->p_item = input_item_New( p_vlm, NULL, NULL );
+    p_instance->p_item = input_item_New( NULL, NULL );
 
     p_instance->i_index = 0;
     p_instance->b_sout_keep = false;