[vlc-devel] [RFC PATCH 3/5] aout_filters: implement error signaling

Thomas Guillem thomas at gllm.fr
Thu Feb 28 16:59:52 CET 2019


TODO:
 - One commit per module ?
 - Do the same for video and spu filters.
---
 modules/audio_filter/channel_mixer/dolby.c    |  3 ++
 .../audio_filter/channel_mixer/headphone.c    |  1 +
 modules/audio_filter/channel_mixer/mono.c     |  2 ++
 modules/audio_filter/channel_mixer/remap.c    |  1 +
 modules/audio_filter/channel_mixer/simple.c   |  1 +
 .../channel_mixer/spatialaudio.cpp            |  1 +
 modules/audio_filter/channel_mixer/trivial.c  |  2 ++
 modules/audio_filter/converter/format.c       | 35 ++++++++++++++-----
 modules/audio_filter/converter/tospdif.c      |  1 +
 modules/audio_filter/normvol.c                |  4 +++
 modules/audio_filter/resampler/bandlimited.c  |  7 ++++
 modules/audio_filter/resampler/soxr.c         |  1 +
 modules/audio_filter/resampler/speex.c        |  6 ++--
 modules/audio_filter/resampler/src.c          |  6 ++--
 modules/audio_filter/resampler/ugly.c         |  3 ++
 modules/audio_filter/scaletempo.c             |  1 +
 16 files changed, 63 insertions(+), 12 deletions(-)

diff --git a/modules/audio_filter/channel_mixer/dolby.c b/modules/audio_filter/channel_mixer/dolby.c
index 8d5c63c256..5539892908 100644
--- a/modules/audio_filter/channel_mixer/dolby.c
+++ b/modules/audio_filter/channel_mixer/dolby.c
@@ -166,7 +166,10 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
     block_t *p_out_buf = block_Alloc(
                                 sizeof(float) * i_nb_samples * i_nb_channels );
     if( !p_out_buf )
+    {
+        p_filter->error = true;
         goto out;
+    }
 
     float * p_out = (float*) p_out_buf->p_buffer;
     p_out_buf->i_nb_samples = i_nb_samples;
diff --git a/modules/audio_filter/channel_mixer/headphone.c b/modules/audio_filter/channel_mixer/headphone.c
index 0c91a15892..b3fad8b970 100644
--- a/modules/audio_filter/channel_mixer/headphone.c
+++ b/modules/audio_filter/channel_mixer/headphone.c
@@ -517,6 +517,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
     {
         msg_Warn( p_filter, "can't get output buffer" );
         block_Release( p_block );
+        p_filter->error = true;
         return NULL;
     }
 
diff --git a/modules/audio_filter/channel_mixer/mono.c b/modules/audio_filter/channel_mixer/mono.c
index 0c383e761e..a333ca2ebe 100644
--- a/modules/audio_filter/channel_mixer/mono.c
+++ b/modules/audio_filter/channel_mixer/mono.c
@@ -427,6 +427,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
     {
         if( p_block )
             block_Release( p_block );
+        p_filter->error = true;
         return NULL;
     }
 
@@ -439,6 +440,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
     {
         msg_Warn( p_filter, "can't get output buffer" );
         block_Release( p_block );
+        p_filter->error = true;
         return NULL;
     }
     p_out->i_nb_samples =
diff --git a/modules/audio_filter/channel_mixer/remap.c b/modules/audio_filter/channel_mixer/remap.c
index b3d284a582..27cb8b7855 100644
--- a/modules/audio_filter/channel_mixer/remap.c
+++ b/modules/audio_filter/channel_mixer/remap.c
@@ -406,6 +406,7 @@ static block_t *Remap( filter_t *p_filter, block_t *p_block )
     {
         msg_Warn( p_filter, "can't get output buffer" );
         block_Release( p_block );
+        p_filter->error = true;
         return NULL;
     }
     p_out->i_nb_samples = p_block->i_nb_samples;
diff --git a/modules/audio_filter/channel_mixer/simple.c b/modules/audio_filter/channel_mixer/simple.c
index 8b3feb7a31..4bd05dd5cc 100644
--- a/modules/audio_filter/channel_mixer/simple.c
+++ b/modules/audio_filter/channel_mixer/simple.c
@@ -373,6 +373,7 @@ static block_t *Filter( filter_t *p_filter, block_t *p_block )
     {
         msg_Warn( p_filter, "can't get output buffer" );
         block_Release( p_block );
+        p_filter->error = true;
         return NULL;
     }
 
diff --git a/modules/audio_filter/channel_mixer/spatialaudio.cpp b/modules/audio_filter/channel_mixer/spatialaudio.cpp
index 755f1422d5..9f7c31a8ef 100644
--- a/modules/audio_filter/channel_mixer/spatialaudio.cpp
+++ b/modules/audio_filter/channel_mixer/spatialaudio.cpp
@@ -187,6 +187,7 @@ static block_t *Mix( filter_t *p_filter, block_t *p_buf )
     if (unlikely(p_out_buf == NULL))
     {
         block_Release(p_buf);
+        p_filter->error = true;
         return NULL;
     }
 
diff --git a/modules/audio_filter/channel_mixer/trivial.c b/modules/audio_filter/channel_mixer/trivial.c
index 6b5b843c87..93c3710664 100644
--- a/modules/audio_filter/channel_mixer/trivial.c
+++ b/modules/audio_filter/channel_mixer/trivial.c
@@ -66,6 +66,7 @@ static block_t *Upmix( filter_t *p_filter, block_t *p_in_buf )
     if( unlikely(p_out_buf == NULL) )
     {
         block_Release( p_in_buf );
+        p_filter->error = true;
         return NULL;
     }
 
@@ -142,6 +143,7 @@ static block_t *Extract( filter_t *p_filter, block_t *p_in_buf )
     if( unlikely(p_out_buf == NULL) )
     {
         block_Release( p_in_buf );
+        p_filter->error = true;
         return NULL;
     }
 
diff --git a/modules/audio_filter/converter/format.c b/modules/audio_filter/converter/format.c
index 2178668b31..200308013c 100644
--- a/modules/audio_filter/converter/format.c
+++ b/modules/audio_filter/converter/format.c
@@ -87,7 +87,10 @@ static block_t *U8toS16(filter_t *filter, block_t *bsrc)
 {
     block_t *bdst = block_Alloc(bsrc->i_buffer * 2);
     if (unlikely(bdst == NULL))
+    {
+        filter->error = true;
         goto out;
+    }
 
     block_CopyProperties(bdst, bsrc);
     uint8_t *src = (uint8_t *)bsrc->p_buffer;
@@ -96,7 +99,6 @@ static block_t *U8toS16(filter_t *filter, block_t *bsrc)
         *dst++ = ((*src++) << 8) - 0x8000;
 out:
     block_Release(bsrc);
-    VLC_UNUSED(filter);
     return bdst;
 }
 
@@ -104,7 +106,10 @@ static block_t *U8toFl32(filter_t *filter, block_t *bsrc)
 {
     block_t *bdst = block_Alloc(bsrc->i_buffer * 4);
     if (unlikely(bdst == NULL))
+    {
+        filter->error = true;
         goto out;
+    }
 
     block_CopyProperties(bdst, bsrc);
     uint8_t *src = (uint8_t *)bsrc->p_buffer;
@@ -113,7 +118,6 @@ static block_t *U8toFl32(filter_t *filter, block_t *bsrc)
         *dst++ = ((float)((*src++) - 128)) / 128.f;
 out:
     block_Release(bsrc);
-    VLC_UNUSED(filter);
     return bdst;
 }
 
@@ -121,7 +125,10 @@ static block_t *U8toS32(filter_t *filter, block_t *bsrc)
 {
     block_t *bdst = block_Alloc(bsrc->i_buffer * 4);
     if (unlikely(bdst == NULL))
+    {
+        filter->error = true;
         goto out;
+    }
 
     block_CopyProperties(bdst, bsrc);
     uint8_t *src = (uint8_t *)bsrc->p_buffer;
@@ -130,7 +137,6 @@ static block_t *U8toS32(filter_t *filter, block_t *bsrc)
         *dst++ = ((*src++) << 24) - 0x80000000;
 out:
     block_Release(bsrc);
-    VLC_UNUSED(filter);
     return bdst;
 }
 
@@ -138,7 +144,10 @@ static block_t *U8toFl64(filter_t *filter, block_t *bsrc)
 {
     block_t *bdst = block_Alloc(bsrc->i_buffer * 8);
     if (unlikely(bdst == NULL))
+    {
+        filter->error = true;
         goto out;
+    }
 
     block_CopyProperties(bdst, bsrc);
     uint8_t *src = (uint8_t *)bsrc->p_buffer;
@@ -147,7 +156,6 @@ static block_t *U8toFl64(filter_t *filter, block_t *bsrc)
         *dst++ = ((double)((*src++) - 128)) / 128.;
 out:
     block_Release(bsrc);
-    VLC_UNUSED(filter);
     return bdst;
 }
 
@@ -169,7 +177,10 @@ static block_t *S16toFl32(filter_t *filter, block_t *bsrc)
 {
     block_t *bdst = block_Alloc(bsrc->i_buffer * 2);
     if (unlikely(bdst == NULL))
+    {
+        filter->error = true;
         goto out;
+    }
 
     block_CopyProperties(bdst, bsrc);
     int16_t *src = (int16_t *)bsrc->p_buffer;
@@ -189,7 +200,6 @@ static block_t *S16toFl32(filter_t *filter, block_t *bsrc)
 #endif
 out:
     block_Release(bsrc);
-    VLC_UNUSED(filter);
     return bdst;
 }
 
@@ -197,7 +207,10 @@ static block_t *S16toS32(filter_t *filter, block_t *bsrc)
 {
     block_t *bdst = block_Alloc(bsrc->i_buffer * 2);
     if (unlikely(bdst == NULL))
+    {
+        filter->error = true;
         goto out;
+    }
 
     block_CopyProperties(bdst, bsrc);
     int16_t *src = (int16_t *)bsrc->p_buffer;
@@ -206,7 +219,6 @@ static block_t *S16toS32(filter_t *filter, block_t *bsrc)
         *dst++ = *src++ << 16;
 out:
     block_Release(bsrc);
-    VLC_UNUSED(filter);
     return bdst;
 }
 
@@ -214,7 +226,10 @@ static block_t *S16toFl64(filter_t *filter, block_t *bsrc)
 {
     block_t *bdst = block_Alloc(bsrc->i_buffer * 4);
     if (unlikely(bdst == NULL))
+    {
+        filter->error = true;
         goto out;
+    }
 
     block_CopyProperties(bdst, bsrc);
     int16_t *src = (int16_t *)bsrc->p_buffer;
@@ -223,7 +238,6 @@ static block_t *S16toFl64(filter_t *filter, block_t *bsrc)
         *dst++ = (double)*src++ / 32768.;
 out:
     block_Release(bsrc);
-    VLC_UNUSED(filter);
     return bdst;
 }
 
@@ -300,7 +314,10 @@ static block_t *Fl32toFl64(filter_t *filter, block_t *bsrc)
 {
     block_t *bdst = block_Alloc(bsrc->i_buffer * 2);
     if (unlikely(bdst == NULL))
+    {
+        filter->error = true;
         goto out;
+    }
 
     block_CopyProperties(bdst, bsrc);
     float  *src = (float *)bsrc->p_buffer;
@@ -353,7 +370,10 @@ static block_t *S32toFl64(filter_t *filter, block_t *bsrc)
 {
     block_t *bdst = block_Alloc(bsrc->i_buffer * 2);
     if (unlikely(bdst == NULL))
+    {
+        filter->error = true;
         goto out;
+    }
 
     block_CopyProperties(bdst, bsrc);
     int32_t *src = (int32_t*)bsrc->p_buffer;
@@ -361,7 +381,6 @@ static block_t *S32toFl64(filter_t *filter, block_t *bsrc)
     for (size_t i = bsrc->i_buffer / 4; i--;)
         *dst++ = (double)(*src++) / 2147483648.;
 out:
-    VLC_UNUSED(filter);
     block_Release(bsrc);
     return bdst;
 }
diff --git a/modules/audio_filter/converter/tospdif.c b/modules/audio_filter/converter/tospdif.c
index 9e9213f660..ebbef9447b 100644
--- a/modules/audio_filter/converter/tospdif.c
+++ b/modules/audio_filter/converter/tospdif.c
@@ -592,6 +592,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
             break;
         case SPDIF_ERROR:
             Flush( p_filter );
+            p_filter->error = true;
             break;
     }
 
diff --git a/modules/audio_filter/normvol.c b/modules/audio_filter/normvol.c
index 653e3818bb..a7553e80ac 100644
--- a/modules/audio_filter/normvol.c
+++ b/modules/audio_filter/normvol.c
@@ -143,12 +143,16 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
 
     pf_sum = calloc( i_channels, sizeof(float) );
     if( !pf_sum )
+    {
+        p_filter->error = true;
         goto out;
+    }
 
     pf_gain = vlc_alloc( i_channels, sizeof(float) );
     if( !pf_gain )
     {
         free( pf_sum );
+        p_filter->error = true;
         goto out;
     }
 
diff --git a/modules/audio_filter/resampler/bandlimited.c b/modules/audio_filter/resampler/bandlimited.c
index 2d544315af..b9c0ca3d21 100644
--- a/modules/audio_filter/resampler/bandlimited.c
+++ b/modules/audio_filter/resampler/bandlimited.c
@@ -121,7 +121,10 @@ static block_t *Resample( filter_t * p_filter, block_t * p_in_buf )
                 p_sys->i_old_wing * p_filter->fmt_in.audio.i_bytes_per_frame,
                 p_in_buf->i_buffer );
             if( !p_in_buf )
+            {
+                p_filter->error = true;
                 return NULL;
+            }
             memcpy( p_in_buf->p_buffer, p_sys->p_buf +
                     i_nb_channels * p_sys->i_old_wing,
                     p_sys->i_old_wing *
@@ -148,6 +151,7 @@ static block_t *Resample( filter_t * p_filter, block_t * p_in_buf )
     if( !p_out_buf )
     {
         block_Release( p_in_buf );
+        p_filter->error = true;
         return NULL;
     }
 
@@ -187,7 +191,10 @@ static block_t *Resample( filter_t * p_filter, block_t * p_in_buf )
                                   p_sys->i_old_wing * 2 * i_bytes_per_frame,
                                   p_in_buf->i_buffer );
         if( unlikely(p_in_buf == NULL) )
+        {
+            p_filter->error = true;
             return NULL;
+        }
         memcpy( p_in_buf->p_buffer, p_sys->p_buf,
                 p_sys->i_old_wing * 2 * i_bytes_per_frame );
     }
diff --git a/modules/audio_filter/resampler/soxr.c b/modules/audio_filter/resampler/soxr.c
index 196f935faa..118e8622f9 100644
--- a/modules/audio_filter/resampler/soxr.c
+++ b/modules/audio_filter/resampler/soxr.c
@@ -371,6 +371,7 @@ Resample( filter_t *p_filter, block_t *p_in )
         return p_out;
     }
 error:
+    p_filter->error = true;
     block_Release( p_in );
     return NULL;
 }
diff --git a/modules/audio_filter/resampler/speex.c b/modules/audio_filter/resampler/speex.c
index eeefc4f4c4..d3eaefaf02 100644
--- a/modules/audio_filter/resampler/speex.c
+++ b/modules/audio_filter/resampler/speex.c
@@ -145,7 +145,6 @@ static block_t *Resample (filter_t *filter, block_t *in)
         msg_Err (filter, "cannot resample: %s",
                  speex_resampler_strerror (err));
         block_Release (out);
-        out = NULL;
         goto error;
     }
 
@@ -157,7 +156,10 @@ static block_t *Resample (filter_t *filter, block_t *in)
     out->i_nb_samples = olen;
     out->i_pts = in->i_pts;
     out->i_length = vlc_tick_from_samples(olen, filter->fmt_out.audio.i_rate);
-error:
     block_Release (in);
     return out;
+error:
+    block_Release (in);
+    filter->error = true;
+    return NULL;
 }
diff --git a/modules/audio_filter/resampler/src.c b/modules/audio_filter/resampler/src.c
index 1254314b13..ec75ed9151 100644
--- a/modules/audio_filter/resampler/src.c
+++ b/modules/audio_filter/resampler/src.c
@@ -151,7 +151,6 @@ static block_t *Resample (filter_t *filter, block_t *in)
     {
         msg_Err (filter, "cannot resample: %s", src_strerror (err));
         block_Release (out);
-        out = NULL;
         goto error;
     }
 
@@ -163,7 +162,10 @@ static block_t *Resample (filter_t *filter, block_t *in)
     out->i_nb_samples = src.output_frames_gen;
     out->i_pts = in->i_pts;
     out->i_length = vlc_tick_from_samples(src.output_frames_gen, filter->fmt_out.audio.i_rate);
-error:
     block_Release (in);
     return out;
+error:
+    block_Release (in);
+    filter->error = true;
+    return NULL;
 }
diff --git a/modules/audio_filter/resampler/ugly.c b/modules/audio_filter/resampler/ugly.c
index a802cc9ae3..1f5ef83e6c 100644
--- a/modules/audio_filter/resampler/ugly.c
+++ b/modules/audio_filter/resampler/ugly.c
@@ -100,7 +100,10 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
     {
         p_out_buf = block_Alloc( i_out_nb * framesize );
         if( !p_out_buf )
+        {
+            p_filter->error = true;
             goto out;
+        }
     }
 
     unsigned char *p_out = p_out_buf->p_buffer;
diff --git a/modules/audio_filter/scaletempo.c b/modules/audio_filter/scaletempo.c
index c7fc621796..b6fd29911b 100644
--- a/modules/audio_filter/scaletempo.c
+++ b/modules/audio_filter/scaletempo.c
@@ -588,6 +588,7 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
         if( p_out_buf == NULL )
         {
             block_Release( p_in_buf );
+            p_filter->error = true;
             return NULL;
         }
         size_t bytes_out = 0;
-- 
2.20.1



More information about the vlc-devel mailing list