]> git.sesse.net Git - vlc/commitdiff
* Avoid overflowing the message queue with "audio output is starving"
authorChristophe Massiot <massiot@videolan.org>
Mon, 21 Oct 2002 20:00:10 +0000 (20:00 +0000)
committerChristophe Massiot <massiot@videolan.org>
Mon, 21 Oct 2002 20:00:10 +0000 (20:00 +0000)
  messages,
* Updated BeOS and QNX outputs with respect to i_channels policy.

include/aout_internal.h
modules/gui/beos/AudioOutput.cpp
modules/gui/macosx/aout.m
modules/gui/qnx/aout.c
src/audio_output/common.c
src/audio_output/output.c

index 4dbb532479c5129f79a3dea01f3eb7ef0eb33da6..b758cfa861b062afa14121bf946e0723d6ad5437 100644 (file)
@@ -2,7 +2,7 @@
  * aout_internal.h : internal defines for audio output
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: aout_internal.h,v 1.23 2002/10/20 12:23:47 massiot Exp $
+ * $Id: aout_internal.h,v 1.24 2002/10/21 20:00:09 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -165,6 +165,9 @@ struct aout_input_t
 typedef struct aout_output_t
 {
     audio_sample_format_t   output;
+    /* Indicates whether the audio output is currently starving, to avoid
+     * printing a 1,000 "output is starving" messages. */
+    vlc_bool_t              b_starving;
 
     /* post-filters */
     aout_filter_t *         pp_filters[AOUT_MAX_FILTERS];
index d35b7b64955c7e8478df8dc60aeefe89cad470de..25d095b632360f674395fc149ef3c1e8f311f690 100644 (file)
@@ -2,7 +2,7 @@
  * aout.cpp: BeOS audio output
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: AudioOutput.cpp,v 1.12 2002/10/14 23:11:52 titer Exp $
+ * $Id: AudioOutput.cpp,v 1.13 2002/10/21 20:00:09 massiot Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -62,10 +62,11 @@ static void DoNothing    ( aout_instance_t *p_aout );
  *****************************************************************************/
 int E_(OpenAudio) ( vlc_object_t * p_this )
 {
-       aout_instance_t *p_aout = (aout_instance_t*) p_this;
-       p_aout->output.p_sys = (aout_sys_t *) malloc( sizeof( aout_sys_t ) );
-       
-       aout_sys_t *p_sys = p_aout->output.p_sys;
+    int i_nb_channels;
+    aout_instance_t *p_aout = (aout_instance_t*) p_this;
+    p_aout->output.p_sys = (aout_sys_t *) malloc( sizeof( aout_sys_t ) );
+
+    aout_sys_t *p_sys = p_aout->output.p_sys;
 
     aout_VolumeSoftInit( p_aout );
     
@@ -74,12 +75,25 @@ int E_(OpenAudio) ( vlc_object_t * p_this )
         malloc( sizeof( media_raw_audio_format ) );
     
     p_format->frame_rate = p_aout->output.output.i_rate;
-    p_format->channel_count = p_aout->output.output.i_channels;
+
+    i_nb_channels = aout_FormatNbChannels( &p_aout->output.output );
+    if ( i_nb_channels > 2 )
+    {
+        /* I don't know if BeOS supports more than two channels. --Meuuh */
+        i_nb_channels = 2;
+        p_aout->output.output.i_channels = AOUT_CHAN_STEREO;
+    }
+    p_format->channel_count = i_nb_channels;
+
     p_format->format = media_raw_audio_format::B_AUDIO_FLOAT;
+#ifdef WORDS_BIGENDIAN
+    p_format->byte_order = B_MEDIA_BIG_ENDIAN;
+#else
     p_format->byte_order = B_MEDIA_LITTLE_ENDIAN;
-    p_format->buffer_size = 16384;
-    
+#endif
     p_aout->output.output.i_format = VLC_FOURCC('f','l','3','2');
+
+    p_format->buffer_size = 16384;
     p_aout->output.i_nb_samples = FRAME_SIZE;
     p_aout->output.pf_play = DoNothing;
     
index 93bd0e502c240fdd87dc41551e5bc2969ee714ff..2d00a7a124f521552616183b57c21b23c9fe13f8 100644 (file)
@@ -2,11 +2,12 @@
  * aout.m: CoreAudio output plugin
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: aout.m,v 1.12 2002/10/02 22:56:53 massiot Exp $
+ * $Id: aout.m,v 1.13 2002/10/21 20:00:09 massiot Exp $
  *
  * Authors: Colin Delacroix <colin@zoy.org>
  *          Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
+ *          Heiko Panther <heiko.panther@web.de>
  *
  * 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
index 6198c24806a9480399149f3654ca8d61cd48e406..1e1684aa2c824606221088528549d022a76ac7b6 100644 (file)
@@ -70,6 +70,7 @@ int E_(OpenAudio)( vlc_object_t *p_this )
     aout_instance_t *p_aout = (aout_instance_t *)p_this;
     int i_ret;
     int i_bytes_per_sample;
+    int i_nb_channels;
     snd_pcm_channel_info_t pi;
     snd_pcm_channel_params_t pp;
     aout_instance_t *p_aout = (aout_instance_t *)p_this;
@@ -117,6 +118,8 @@ int E_(OpenAudio)( vlc_object_t *p_this )
     {
         msg_Err( p_aout, "unable to get plugin info (%s)",
                          snd_strerror( i_ret ) );
+        E_(CloseAudio)( p_this );
+        free( p_aout->output.p_sys );
         return -1;
     }
 
@@ -130,23 +133,20 @@ int E_(OpenAudio)( vlc_object_t *p_this )
 
     pp.format.interleave     = 1;
     pp.format.rate           = p_aout->output.output.i_rate;
-    pp.format.voices         = p_aout->output.output.i_channels;
-
-    p_aout->output.output.i_format = AOUT_FMT_S16_NE;
-    p_aout->output.i_nb_samples = DEFAULT_FRAME_SIZE;
 
-    switch( p_aout->output.output.i_format )
+    i_nb_channels = aout_FormatNbChannels( &p_aout->output.output );
+    if ( i_nb_channels > 2 )
     {
-        case AOUT_FMT_S16_LE:
-            pp.format.format = SND_PCM_SFMT_S16_LE;
-            i_bytes_per_sample = 2;
-            break;
-
-        default:
-            pp.format.format = SND_PCM_SFMT_S16_BE;
-            i_bytes_per_sample = 2;
-            break;
+        /* I don't know if QNX supports more than two channels. */
+        i_nb_channels = 2;
+        p_aout->output.output.i_channels = AOUT_CHAN_STEREO;
     }
+    pp.format.voices         = i_nb_channels;
+
+    p_aout->output.output.i_format = AOUT_FMT_S16_NE;
+    p_aout->output.i_nb_samples = DEFAULT_FRAME_SIZE;
+    pp.format.format = SND_PCM_SFMT_S16;
+    i_bytes_per_sample = 2;
 
     pp.buf.block.frag_size = p_aout->output.i_nb_samples *
                             p_aout->output.output.i_channels *
@@ -157,6 +157,8 @@ int E_(OpenAudio)( vlc_object_t *p_this )
                                          &pp ) ) < 0 )
     {
         msg_Err( p_aout, "unable to set parameters (%s)", snd_strerror(i_ret) );
+        E_(CloseAudio)( p_this );
+        free( p_aout->output.p_sys );
         return -1;
     }
 
@@ -166,6 +168,8 @@ int E_(OpenAudio)( vlc_object_t *p_this )
     {
         msg_Err( p_aout, "unable to prepare channel (%s)",
                          snd_strerror( i_ret ) );
+        E_(CloseAudio)( p_this );
+        free( p_aout->output.p_sys );
         return -1;
     }
 
index e3d8afef793e3bff41d579e518d9d5b3ac35a8ed..58838f33049b2cb546b72d21c04229cd6a43af95 100644 (file)
@@ -2,7 +2,7 @@
  * common.c : audio output management of common data structures
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: common.c,v 1.3 2002/10/20 12:23:48 massiot Exp $
+ * $Id: common.c,v 1.4 2002/10/21 20:00:10 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -58,6 +58,7 @@ aout_instance_t * __aout_New( vlc_object_t * p_parent )
     p_aout->i_nb_inputs = 0;
     p_aout->mixer.f_multiplier = 1.0;
     p_aout->mixer.b_error = 1;
+    p_aout->output.b_starving = 1;
 
     vlc_object_attach( p_aout, p_parent->p_vlc );
 
index 058aa503d04e04263e387529fd4f62aea8476177..4bcba4c61b504a6420e53df27aad960b45ff7186 100644 (file)
@@ -2,7 +2,7 @@
  * output.c : internal management of output streams for the audio output
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: output.c,v 1.18 2002/10/20 12:23:48 massiot Exp $
+ * $Id: output.c,v 1.19 2002/10/21 20:00:10 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -196,8 +196,10 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
         /* Set date to 0, to allow the mixer to send a new buffer ASAP */
         aout_FifoSet( p_aout, &p_aout->output.fifo, 0 );
         vlc_mutex_unlock( &p_aout->output_fifo_lock );
-        msg_Dbg( p_aout,
+        if ( !p_aout->output.b_starving )
+            msg_Dbg( p_aout,
                  "audio output is starving (no input), playing silence" );
+        p_aout->output.b_starving = 1;
         return NULL;
     }
 
@@ -207,11 +209,15 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
                          + (p_buffer->end_date - p_buffer->start_date) )
     {
         vlc_mutex_unlock( &p_aout->output_fifo_lock );
-        msg_Dbg( p_aout, "audio output is starving (%lld), playing silence",
+        if ( !p_aout->output.b_starving )
+            msg_Dbg( p_aout, "audio output is starving (%lld), playing silence",
                  p_buffer->start_date - start_date );
+        p_aout->output.b_starving = 1;
         return NULL;
     }
 
+    p_aout->output.b_starving = 0;
+
     if ( !b_can_sleek &&
           ( (p_buffer->start_date - start_date > AOUT_PTS_TOLERANCE)
              || (start_date - p_buffer->start_date > AOUT_PTS_TOLERANCE) ) )