]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/waveout.c
Replace argument = realloc( argument, size ); with realloc_or_free() in modules/...
[vlc] / modules / audio_output / waveout.c
index 6d022c6d5054c768dc70acb876d93a9b4f91eff3..71497d6368855a355a8971e5e29ebf3c62edb9b8 100644 (file)
@@ -1,10 +1,11 @@
 /*****************************************************************************
  * waveout.c : Windows waveOut plugin for vlc
  *****************************************************************************
- * Copyright (C) 2001 the VideoLAN team
+ * Copyright (C) 2001-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
+ *          AndrĂ© Weber
  *
  * 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
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <assert.h>
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_aout.h>
 #include <vlc_charset.h>
+#include <vlc_memory.h>
 
 #include <windows.h>
 #include <mmsystem.h>
@@ -124,14 +129,13 @@ static void Probe        ( aout_instance_t * );
 static int OpenWaveOut   ( aout_instance_t *, uint32_t,
                            int, int, int, int, bool );
 static int OpenWaveOutPCM( aout_instance_t *, uint32_t,
-                           int*, int, int, int, bool );
+                           vlc_fourcc_t*, int, int, int, bool );
 static int PlayWaveOut   ( aout_instance_t *, HWAVEOUT, WAVEHDR *,
                            aout_buffer_t *, bool );
 
 static void CALLBACK WaveOutCallback ( HWAVEOUT, UINT, DWORD, DWORD, DWORD );
-static void WaveOutThread( notification_thread_t * );
+static void* WaveOutThread( vlc_object_t * );
 
-static int VolumeInfos( aout_instance_t *, audio_volume_t * );
 static int VolumeGet( aout_instance_t *, audio_volume_t * );
 static int VolumeSet( aout_instance_t *, audio_volume_t );
 
@@ -143,8 +147,8 @@ static uint32_t findDeviceID(char *);
 
 static const char psz_device_name_fmt[] = "%s ($%x,$%x)";
 
-static const char *ppsz_adev[] = { "wavemapper", };
-static const char *ppsz_adev_text[] = { N_("Microsoft Soundmapper") };
+static const char *const ppsz_adev[] = { "wavemapper", };
+static const char *const ppsz_adev_text[] = { N_("Microsoft Soundmapper") };
 
 
 
@@ -161,23 +165,24 @@ static const char *ppsz_adev_text[] = { N_("Microsoft Soundmapper") };
                        "to apply.")
 #define DEFAULT_AUDIO_DEVICE N_("Default Audio Device")
 
-vlc_module_begin();
-    set_shortname( "WaveOut" );
-    set_description( _("Win32 waveOut extension output") );
-    set_capability( "audio output", 50 );
-    set_category( CAT_AUDIO );
-    set_subcategory( SUBCAT_AUDIO_AOUT );
-    add_bool( "waveout-float32", 1, 0, FLOAT_TEXT, FLOAT_LONGTEXT, true );
+vlc_module_begin ()
+    set_shortname( "WaveOut" )
+    set_description( N_("Win32 waveOut extension output") )
+    set_capability( "audio output", 50 )
+    set_category( CAT_AUDIO )
+    set_subcategory( SUBCAT_AUDIO_AOUT )
+    add_bool( "waveout-float32", true, NULL, FLOAT_TEXT, FLOAT_LONGTEXT, true )
 
-    add_string( "waveout-dev", "wavemapper", NULL,
-                 DEVICE_TEXT, DEVICE_LONG, false );
-       change_string_list( ppsz_adev, ppsz_adev_text, ReloadWaveoutDevices );
-       change_need_restart();
-       change_action_add( ReloadWaveoutDevices, N_("Refresh list") );
+    add_string( "waveout-audio-device", "wavemapper", NULL,
+                 DEVICE_TEXT, DEVICE_LONG, false )
+       add_deprecated_alias( "waveout-dev" )   /* deprecated since 0.9.3 */
+       change_string_list( ppsz_adev, ppsz_adev_text, ReloadWaveoutDevices )
+       change_need_restart ()
+       change_action_add( ReloadWaveoutDevices, N_("Refresh list") )
 
 
-    set_callbacks( Open, Close );
-vlc_module_end();
+    set_callbacks( Open, Close )
+vlc_module_end ()
 
 /*****************************************************************************
  * aout_sys_t: waveOut audio output method descriptor
@@ -216,17 +221,18 @@ struct aout_sys_t
 static const uint32_t pi_channels_src[] =
     { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,
       AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT,
-      AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
+      AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, AOUT_CHAN_REARCENTER,
       AOUT_CHAN_CENTER, AOUT_CHAN_LFE, 0 };
 static const uint32_t pi_channels_in[] =
     { SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT,
       SPEAKER_SIDE_LEFT, SPEAKER_SIDE_RIGHT,
-      SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT,
+      SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT, SPEAKER_BACK_CENTER,
       SPEAKER_FRONT_CENTER, SPEAKER_LOW_FREQUENCY, 0 };
 static const uint32_t pi_channels_out[] =
     { SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT,
       SPEAKER_FRONT_CENTER, SPEAKER_LOW_FREQUENCY,
       SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT,
+      SPEAKER_BACK_CENTER,
       SPEAKER_SIDE_LEFT, SPEAKER_SIDE_RIGHT, 0 };
 
 /*****************************************************************************
@@ -244,10 +250,7 @@ static int Open( vlc_object_t *p_this )
     p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
 
     if( p_aout->output.p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
-        return VLC_EGENERIC;
-    }
+        return VLC_ENOMEM;
 
     p_aout->output.pf_play = Play;
     p_aout->b_die = false;
@@ -256,13 +259,13 @@ static int Open( vlc_object_t *p_this )
     /*
      initialize/update Device selection List
     */
-    ReloadWaveoutDevices( p_this, "waveout-dev", val, val, NULL);
+    ReloadWaveoutDevices( p_this, "waveout-audio-device", val, val, NULL);
 
 
     /*
       check for configured audio device!
     */
-    char *psz_waveout_dev = var_CreateGetString( p_aout, "waveout-dev");
+    char *psz_waveout_dev = var_CreateGetString( p_aout, "waveout-audio-device");
 
     p_aout->output.p_sys->i_wave_device_id =
          findDeviceID( psz_waveout_dev );
@@ -304,7 +307,7 @@ static int Open( vlc_object_t *p_this )
     if( var_Get( p_aout, "audio-device", &val ) < 0 )
     {
         /* Probe() has failed. */
-        var_Destroy( p_aout, "waveout-device");
+        var_Destroy( p_aout, "waveout-audio-device");
         free( p_aout->output.p_sys );
         return VLC_EGENERIC;
     }
@@ -313,11 +316,11 @@ static int Open( vlc_object_t *p_this )
     /* Open the device */
     if( val.i_int == AOUT_VAR_SPDIF )
     {
-        p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i');
+        p_aout->output.output.i_format = VLC_CODEC_SPDIFL;
 
         if( OpenWaveOut( p_aout,
                          p_aout->output.p_sys->i_wave_device_id,
-                         VLC_FOURCC('s','p','d','i'),
+                         VLC_CODEC_SPDIFL,
                          p_aout->output.output.i_physical_channels,
                          aout_FormatNbChannels( &p_aout->output.output ),
                          p_aout->output.output.i_rate, false )
@@ -341,27 +344,25 @@ static int Open( vlc_object_t *p_this )
     {
         WAVEOUTCAPS wocaps;
 
-        if( val.i_int == AOUT_VAR_5_1 )
+        switch( val.i_int )
         {
+        case AOUT_VAR_5_1:
             p_aout->output.output.i_physical_channels
-                = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
-                   | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
-                   | AOUT_CHAN_LFE;
-        }
-        else if( val.i_int == AOUT_VAR_2F2R )
-        {
+                    = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
+                      | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
+                      | AOUT_CHAN_LFE;
+            break;
+        case AOUT_VAR_2F2R:
             p_aout->output.output.i_physical_channels
-                = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
-                   | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
-        }
-        else if( val.i_int == AOUT_VAR_MONO )
-        {
+                    = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
+                      | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
+            break;
+        case AOUT_VAR_MONO:
             p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER;
-        }
-        else
-        {
+            break;
+        default:
             p_aout->output.output.i_physical_channels
-                = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
+                    = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
         }
 
         if( OpenWaveOutPCM( p_aout,
@@ -394,7 +395,6 @@ static int Open( vlc_object_t *p_this )
             if( waveOutGetVolume( p_aout->output.p_sys->h_waveout, &i_dummy )
                 == MMSYSERR_NOERROR )
             {
-                p_aout->output.pf_volume_infos = VolumeInfos;
                 p_aout->output.pf_volume_get = VolumeGet;
                 p_aout->output.pf_volume_set = VolumeSet;
             }
@@ -410,8 +410,7 @@ static int Open( vlc_object_t *p_this )
     if( p_aout->output.p_sys->p_silence_buffer == NULL )
     {
         free( p_aout->output.p_sys );
-        msg_Err( p_aout, "out of memory" );
-        return 1;
+        return VLC_ENOMEM;
     }
     p_aout->output.p_sys->i_repeat_counter = 0;
 
@@ -436,7 +435,7 @@ static int Open( vlc_object_t *p_this )
     /* Then launch the notification thread */
     if( vlc_thread_create( p_aout->output.p_sys->p_notif,
                            "waveOut Notification Thread", WaveOutThread,
-                           VLC_THREAD_PRIORITY_OUTPUT, false ) )
+                           VLC_THREAD_PRIORITY_OUTPUT ) )
     {
         msg_Err( p_aout, "cannot create WaveOutThread" );
     }
@@ -449,7 +448,7 @@ static int Open( vlc_object_t *p_this )
         p_aout->output.p_sys->waveheader[i].dwUser = 0;
     }
 
-    return 0;
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
@@ -458,7 +457,7 @@ static int Open( vlc_object_t *p_this )
 static void Probe( aout_instance_t * p_aout )
 {
     vlc_value_t val, text;
-    int i_format;
+    vlc_fourcc_t i_format;
     unsigned int i_physical_channels;
 
     var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
@@ -479,7 +478,7 @@ static void Probe( aout_instance_t * p_aout )
             == VLC_SUCCESS )
         {
             val.i_int = AOUT_VAR_5_1;
-            text.psz_string = (char *)N_("5.1");
+            text.psz_string = (char *)_("5.1");
             var_Change( p_aout, "audio-device",
                         VLC_VAR_ADDCHOICE, &val, &text );
             msg_Dbg( p_aout, "device supports 5.1 channels" );
@@ -500,7 +499,7 @@ static void Probe( aout_instance_t * p_aout )
             == VLC_SUCCESS )
         {
             val.i_int = AOUT_VAR_2F2R;
-            text.psz_string = (char *)N_("2 Front 2 Rear");
+            text.psz_string = (char *)_("2 Front 2 Rear");
             var_Change( p_aout, "audio-device",
                         VLC_VAR_ADDCHOICE, &val, &text );
             msg_Dbg( p_aout, "device supports 4 channels" );
@@ -517,7 +516,7 @@ static void Probe( aout_instance_t * p_aout )
         == VLC_SUCCESS )
     {
         val.i_int = AOUT_VAR_STEREO;
-        text.psz_string = (char *)N_("Stereo");
+        text.psz_string = (char *)_("Stereo");
         var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
         msg_Dbg( p_aout, "device supports 2 channels" );
     }
@@ -532,7 +531,7 @@ static void Probe( aout_instance_t * p_aout )
         == VLC_SUCCESS )
     {
         val.i_int = AOUT_VAR_MONO;
-        text.psz_string = (char *)N_("Mono");
+        text.psz_string = (char *)_("Mono");
         var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
         msg_Dbg( p_aout, "device supports 1 channel" );
     }
@@ -542,7 +541,7 @@ static void Probe( aout_instance_t * p_aout )
     {
         if( OpenWaveOut( p_aout,
                          p_aout->output.p_sys->i_wave_device_id,
-                         VLC_FOURCC('s','p','d','i'),
+                         VLC_CODEC_SPDIFL,
                          p_aout->output.output.i_physical_channels,
                          aout_FormatNbChannels( &p_aout->output.output ),
                          p_aout->output.output.i_rate, true )
@@ -550,7 +549,7 @@ static void Probe( aout_instance_t * p_aout )
         {
             msg_Dbg( p_aout, "device supports A/52 over S/PDIF" );
             val.i_int = AOUT_VAR_SPDIF;
-            text.psz_string = (char *)N_("A/52 over S/PDIF");
+            text.psz_string = (char *)_("A/52 over S/PDIF");
             var_Change( p_aout, "audio-device",
                         VLC_VAR_ADDCHOICE, &val, &text );
             if( config_GetInt( p_aout, "spdif" ) )
@@ -567,9 +566,7 @@ static void Probe( aout_instance_t * p_aout )
     }
 
     var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
-
-    val.b_bool = true;
-    var_Set( p_aout, "intf-change", val );
+    var_SetBool( p_aout, "intf-change", true );
 }
 
 /*****************************************************************************
@@ -697,7 +694,7 @@ static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_for
 
     switch( i_format )
     {
-    case VLC_FOURCC('s','p','d','i'):
+    case VLC_CODEC_SPDIFL:
         i_nb_channels = 2;
         /* To prevent channel re-ordering */
         waveformat.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
@@ -708,7 +705,7 @@ static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_for
         waveformat.SubFormat = __KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF;
         break;
 
-    case VLC_FOURCC('f','l','3','2'):
+    case VLC_CODEC_FL32:
         waveformat.Format.wBitsPerSample = sizeof(float) * 8;
         waveformat.Samples.wValidBitsPerSample =
             waveformat.Format.wBitsPerSample;
@@ -716,7 +713,7 @@ static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_for
         waveformat.SubFormat = __KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
         break;
 
-    case VLC_FOURCC('s','1','6','l'):
+    case VLC_CODEC_S16L:
         waveformat.Format.wBitsPerSample = 16;
         waveformat.Samples.wValidBitsPerSample =
             waveformat.Format.wBitsPerSample;
@@ -808,17 +805,18 @@ static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_for
 /*****************************************************************************
  * OpenWaveOutPCM: open a PCM waveout sound device
  ****************************************************************************/
-static int OpenWaveOutPCM( aout_instance_t *p_aout, uint32_t i_device_id, int *i_format,
+static int OpenWaveOutPCM( aout_instance_t *p_aout, uint32_t i_device_id,
+                           vlc_fourcc_t *i_format,
                            int i_channels, int i_nb_channels, int i_rate,
                            bool b_probe )
 {
     bool b_use_float32 = var_CreateGetBool( p_aout, "waveout-float32");
 
-    if( !b_use_float32 || OpenWaveOut( p_aout, i_device_id, VLC_FOURCC('f','l','3','2'),
+    if( !b_use_float32 || OpenWaveOut( p_aout, i_device_id, VLC_CODEC_FL32,
                                    i_channels, i_nb_channels, i_rate, b_probe )
         != VLC_SUCCESS )
     {
-        if ( OpenWaveOut( p_aout, i_device_id, VLC_FOURCC('s','1','6','l'),
+        if ( OpenWaveOut( p_aout, i_device_id, VLC_CODEC_S16L,
                           i_channels, i_nb_channels, i_rate, b_probe )
              != VLC_SUCCESS )
         {
@@ -826,13 +824,13 @@ static int OpenWaveOutPCM( aout_instance_t *p_aout, uint32_t i_device_id, int *i
         }
         else
         {
-            *i_format = VLC_FOURCC('s','1','6','l');
+            *i_format = VLC_CODEC_S16L;
             return VLC_SUCCESS;
         }
     }
     else
     {
-        *i_format = VLC_FOURCC('f','l','3','2');
+        *i_format = VLC_CODEC_FL32;
         return VLC_SUCCESS;
     }
 }
@@ -906,12 +904,13 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg,
                                       DWORD _p_aout,
                                       DWORD dwParam1, DWORD dwParam2 )
 {
+    (void)h_waveout;    (void)dwParam1;    (void)dwParam2;
     aout_instance_t *p_aout = (aout_instance_t *)_p_aout;
     int i, i_queued_frames = 0;
 
     if( uMsg != WOM_DONE ) return;
 
-    if( p_aout->b_die ) return;
+    if( !vlc_object_alive (p_aout) ) return;
 
     /* Find out the current latency */
     for( i = 0; i < FRAMES_NUM; i++ )
@@ -972,8 +971,9 @@ static int WaveOutClearDoneBuffers(aout_sys_t *p_sys)
  * we are not authorized to use waveOutWrite() directly in the waveout
  * callback.
  *****************************************************************************/
-static void WaveOutThread( notification_thread_t *p_notif )
+static void* WaveOutThread( vlc_object_t *p_this )
 {
+    notification_thread_t *p_notif = (notification_thread_t*)p_this;
     aout_instance_t *p_aout = p_notif->p_aout;
     aout_sys_t *p_sys = p_aout->output.p_sys;
     aout_buffer_t *p_buffer = NULL;
@@ -982,15 +982,16 @@ static void WaveOutThread( notification_thread_t *p_notif )
     bool b_sleek;
     mtime_t next_date;
     uint32_t i_buffer_length = 64;
+    int canc = vlc_savecancel ();
 
     /* We don't want any resampling when using S/PDIF */
-    b_sleek = p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i');
+    b_sleek = p_aout->output.output.i_format == VLC_CODEC_SPDIFL;
 
     // wait for first call to "play()"
-    while( !p_sys->start_date && !p_aout->b_die )
+    while( !p_sys->start_date && vlc_object_alive (p_aout) )
            WaitForSingleObject( p_sys->event, INFINITE );
-    if( p_aout->b_die )
-        return;
+    if( !vlc_object_alive (p_aout) )
+        return NULL;
 
     msg_Dbg( p_aout, "will start to play in %"PRId64" us",
              (p_sys->start_date - AOUT_PTS_TOLERANCE/4)-mdate());
@@ -1006,12 +1007,12 @@ static void WaveOutThread( notification_thread_t *p_notif )
                            p_aout->output.b_starving, msg);
     next_date = mdate();
 
-    while( !p_aout->b_die )
+    while( vlc_object_alive (p_aout) )
     {
         /* Cleanup and find out the current latency */
         i_queued_frames = WaveOutClearDoneBuffers( p_sys );
 
-        if( p_aout->b_die ) return;
+        if( !vlc_object_alive (p_aout) ) return NULL;
 
         /* Try to fill in as many frame buffers as possible */
         for( i = 0; i < FRAMES_NUM; i++ )
@@ -1064,8 +1065,7 @@ static void WaveOutThread( notification_thread_t *p_notif )
 
                 if( p_buffer )
                 {
-                    mtime_t buffer_length = (p_buffer->end_date
-                                             - p_buffer->start_date);
+                    mtime_t buffer_length = p_buffer->i_length;
                     next_date = next_date + buffer_length;
                     i_buffer_length = buffer_length/1000;
                 }
@@ -1074,7 +1074,7 @@ static void WaveOutThread( notification_thread_t *p_notif )
                 if( p_buffer && p_sys->b_chan_reorder )
                 {
                     aout_ChannelReorder( p_buffer->p_buffer,
-                        p_buffer->i_nb_bytes,
+                        p_buffer->i_buffer,
                         p_sys->waveformat.Format.nChannels,
                         p_sys->pi_chan_table,
                         p_sys->waveformat.Format.wBitsPerSample );
@@ -1087,7 +1087,7 @@ static void WaveOutThread( notification_thread_t *p_notif )
             }
         }
 
-        if( p_aout->b_die ) return;
+        if( !vlc_object_alive (p_aout) ) return NULL;
 
         /*
           deal with the case that the loop didn't fillup the buffer to the
@@ -1108,12 +1108,8 @@ static void WaveOutThread( notification_thread_t *p_notif )
     }
 
 #undef waveout_warn
-}
-
-static int VolumeInfos( aout_instance_t * p_aout, audio_volume_t * pi_soft )
-{
-    *pi_soft = AOUT_VOLUME_MAX / 2;
-    return 0;
+    vlc_restorecancel (canc);
+    return NULL;
 }
 
 static int VolumeGet( aout_instance_t * p_aout, audio_volume_t * pi_volume )
@@ -1154,7 +1150,7 @@ static int VolumeSet( aout_instance_t * p_aout, audio_volume_t i_volume )
 static int ReloadWaveoutDevices( vlc_object_t *p_this, char const *psz_name,
                                  vlc_value_t newval, vlc_value_t oldval, void *data )
 {
-    int i;
+    VLC_UNUSED( newval ); VLC_UNUSED( oldval ); VLC_UNUSED( data );
 
     module_config_t *p_item = config_FindConfig( p_this, psz_name );
     if( !p_item ) return VLC_SUCCESS;
@@ -1162,6 +1158,8 @@ static int ReloadWaveoutDevices( vlc_object_t *p_this, char const *psz_name,
     /* Clear-up the current list */
     if( p_item->i_list )
     {
+        int i;
+
         /* Keep the first entry */
         for( i = 1; i < p_item->i_list; i++ )
         {
@@ -1176,12 +1174,12 @@ static int ReloadWaveoutDevices( vlc_object_t *p_this, char const *psz_name,
 
     int wave_devices = waveOutGetNumDevs();
 
-    p_item->ppsz_list =
-        (char **)realloc( p_item->ppsz_list,
+    p_item->ppsz_list = realloc_or_free( p_item->ppsz_list,
                           (wave_devices+2) * sizeof(char *) );
-    p_item->ppsz_list_text =
-        (char **)realloc( p_item->ppsz_list_text,
+    assert( p_item->ppsz_list );
+    p_item->ppsz_list_text = realloc_or_free( p_item->ppsz_list_text,
                           (wave_devices+2) * sizeof(char *) );
+    assert( p_item->ppsz_list_text );
 
     WAVEOUTCAPS caps;
     char sz_dev_name[MAXPNAMELEN+32];