]> git.sesse.net Git - vlc/blobdiff - src/audio_output/dec.c
Don't clutter REGISTRY on windows...
[vlc] / src / audio_output / dec.c
index 694957e0b7ead9d68b20392923906e87aab54e2f..a9eb16ac117172f9050c36a25dd69513afe74856 100644 (file)
@@ -28,7 +28,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 
 #ifdef HAVE_ALLOCA_H
 #   include <alloca.h>
@@ -57,14 +57,25 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
     {
         msg_Err( p_aout, "too many audio channels (%u)",
                  p_format->i_channels );
-        goto error;
+        return NULL;
+    }
+    if( p_format->i_channels <= 0 )
+    {
+        msg_Err( p_aout, "no audio channels" );
+        return NULL;
     }
 
     if( p_format->i_rate > 192000 )
     {
         msg_Err( p_aout, "excessive audio sample frequency (%u)",
                  p_format->i_rate );
-        goto error;
+        return NULL;
+    }
+    if( p_format->i_rate < 4000 )
+    {
+        msg_Err( p_aout, "too low audio sample frequency (%u)",
+                 p_format->i_rate );
+        return NULL;
     }
 
     /* We can only be called by the decoder, so no need to lock
@@ -79,13 +90,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;
@@ -173,30 +181,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 );
 }
 
 /*****************************************************************************
@@ -319,6 +318,11 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
         return -1;
     }
 
+#ifndef FIXME
+    /* This hack for #transcode{acodec=...}:display to work -- Courmisch */
+    if( i_input_rate == 0 )
+        i_input_rate = INPUT_RATE_DEFAULT;
+#endif
     if( i_input_rate > INPUT_RATE_DEFAULT * AOUT_MAX_INPUT_RATE ||
         i_input_rate < INPUT_RATE_DEFAULT / AOUT_MAX_INPUT_RATE )
     {
@@ -333,7 +337,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 +372,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;