]> git.sesse.net Git - vlc/blobdiff - src/audio_output/dec.c
Remove msg_Err about memory allocation.
[vlc] / src / audio_output / dec.c
index ded0a4936efcb9b23ca47557f5b7fef39af9be44..5c15891460cdad0edfba0cce46883589f9bc649b 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
 
 #ifdef HAVE_ALLOCA_H
 #   include <alloca.h>
@@ -47,7 +51,6 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
 {
     aout_input_t * p_input;
     input_thread_t * p_input_thread;
-    vlc_value_t val;
 
     /* Sanitize audio format */
     if( p_format->i_channels > 32 )
@@ -76,13 +79,10 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
 
     p_input = malloc(sizeof(aout_input_t));
     if ( p_input == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         goto error;
-    }
     memset( p_input, 0, sizeof(aout_input_t) );
 
-    vlc_mutex_init( p_aout, &p_input->lock );
+    vlc_mutex_init( &p_input->lock );
 
     p_input->b_changed = 0;
     p_input->b_error = 1;
@@ -140,9 +140,7 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
     aout_InputNew( p_aout, p_input );
 
     vlc_mutex_unlock( &p_aout->mixer_lock );
-    var_Create( p_this, "audio-desync", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Get( p_this, "audio-desync", &val );
-    p_input->i_desync = val.i_int * 1000;
+    p_input->i_desync = var_CreateGetInteger( p_this, "audio-desync" ) * 1000;
 
     p_input_thread = (input_thread_t *)vlc_object_find( p_this,
                                            VLC_OBJECT_INPUT, FIND_PARENT );
@@ -172,30 +170,21 @@ aout_input_t * __aout_DecNew( vlc_object_t * p_this,
                               audio_sample_format_t * p_format,
                               audio_replay_gain_t *p_replay_gain )
 {
-    if ( *pp_aout == NULL )
+    aout_instance_t *p_aout = *pp_aout;
+    if ( p_aout == NULL )
     {
-        /* Create an audio output if there is none. */
-        *pp_aout = vlc_object_find( p_this, VLC_OBJECT_AOUT, FIND_ANYWHERE );
+        msg_Dbg( p_this, "no aout present, spawning one" );
+        p_aout = aout_New( p_this );
 
-        if( *pp_aout == NULL )
-        {
-            msg_Dbg( p_this, "no aout present, spawning one" );
+        /* Everything failed, I'm a loser, I just wanna die */
+        if( p_aout == NULL )
+            return NULL;
 
-            *pp_aout = aout_New( p_this );
-            /* Everything failed, I'm a loser, I just wanna die */
-            if( *pp_aout == NULL )
-            {
-                return NULL;
-            }
-            vlc_object_attach( *pp_aout, p_this->p_libvlc );
-        }
-        else
-        {
-            vlc_object_release( *pp_aout );
-        }
+        vlc_object_attach( p_aout, p_this );
+        *pp_aout = p_aout;
     }
 
-    return DecNew( p_this, *pp_aout, p_format, p_replay_gain );
+    return DecNew( p_this, p_aout, p_format, p_replay_gain );
 }
 
 /*****************************************************************************
@@ -260,8 +249,7 @@ int aout_DecDelete( aout_instance_t * p_aout, aout_input_t * p_input )
 /*****************************************************************************
  * aout_DecNewBuffer : ask for a new empty buffer
  *****************************************************************************/
-aout_buffer_t * aout_DecNewBuffer( aout_instance_t * p_aout,
-                                   aout_input_t * p_input,
+aout_buffer_t * aout_DecNewBuffer( aout_input_t * p_input,
                                    size_t i_nb_samples )
 {
     aout_buffer_t * p_buffer;
@@ -333,7 +321,7 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
     if ( p_buffer->start_date > mdate() + p_input->i_pts_delay +
          AOUT_MAX_ADVANCE_TIME )
     {
-        msg_Warn( p_aout, "received buffer in the future ("I64Fd")",
+        msg_Warn( p_aout, "received buffer in the future (%"PRId64")",
                   p_buffer->start_date - mdate());
         if( p_input->p_input_thread )
         {
@@ -368,8 +356,8 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
                             / p_input->input.i_rate;
 
         aout_BufferAlloc( &p_input->input_alloc, duration, NULL, p_new_buffer );
-        p_aout->p_libvlc->pf_memcpy( p_new_buffer->p_buffer, p_buffer->p_buffer,
-                                  p_buffer->i_nb_bytes );
+        vlc_memcpy( p_new_buffer->p_buffer, p_buffer->p_buffer,
+                    p_buffer->i_nb_bytes );
         p_new_buffer->i_nb_samples = p_buffer->i_nb_samples;
         p_new_buffer->i_nb_bytes = p_buffer->i_nb_bytes;
         p_new_buffer->start_date = p_buffer->start_date;