]> git.sesse.net Git - vlc/blobdiff - src/input/stream_memory.c
Implement access_GetParentInput and demux_GetParentInput and use.
[vlc] / src / input / stream_memory.c
index d9db249ed4bf0a1faf6f5c17f90df7089e641a48..7444fda2d044c7beb5186e55c67c3a5a6b38af17 100644 (file)
@@ -56,9 +56,16 @@ stream_t *__stream_MemoryNew( vlc_object_t *p_this, uint8_t *p_buffer,
     stream_t *s = stream_CommonNew( p_this );
     stream_sys_t *p_sys;
 
-    if( !s ) return NULL;
+    if( !s )
+        return NULL;
 
+    s->psz_path = strdup( "" ); /* N/A */
     s->p_sys = p_sys = malloc( sizeof( stream_sys_t ) );
+    if( !s->psz_path || !s->p_sys )
+    {
+        stream_CommonDelete( s );
+        return NULL;
+    }
     p_sys->i_pos = 0;
     p_sys->i_size = i_size;
     p_sys->p_buffer = p_buffer;
@@ -69,10 +76,14 @@ stream_t *__stream_MemoryNew( vlc_object_t *p_this, uint8_t *p_buffer,
     s->pf_control = Control;
     s->pf_destroy = Delete;
 
-    s->i_char_width = 1;
-    s->b_little_endian = false;
     vlc_object_attach( s, p_this );
 
+    /* Get a weak link to the parent input */
+    /* FIXME: The usage of vlc_object_find has to be removed. */
+    s->p_input = (input_thread_t *)vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );
+    if(s->p_input)
+        vlc_object_release((vlc_object_t*)s->p_input);
+
     return s;
 }
 
@@ -81,7 +92,7 @@ static void Delete( stream_t *s )
     if( !s->p_sys->i_preserve_memory ) free( s->p_sys->p_buffer );
     free( s->p_sys );
     vlc_object_detach( s );
-    vlc_object_release( s );
+    stream_CommonDelete( s );
 }
 
 /****************************************************************************
@@ -124,7 +135,6 @@ static int Control( stream_t *s, int i_query, va_list args )
             p_sys->i_pos = i_64;
             break;
 
-        case STREAM_GET_MTU:
         case STREAM_GET_CONTENT_TYPE:
             return VLC_EGENERIC;