[vlc-devel] [PATCH V2 3/4] modules: audio_filter: return vlc_block_discontinuity when needed
Thomas Guillem
thomas at gllm.fr
Fri Mar 1 12:41:52 CET 2019
---
modules/audio_filter/channel_mixer/dolby.c | 3 +++
.../audio_filter/channel_mixer/headphone.c | 2 +-
modules/audio_filter/channel_mixer/mono.c | 4 +--
modules/audio_filter/channel_mixer/remap.c | 2 +-
modules/audio_filter/channel_mixer/simple.c | 2 +-
.../channel_mixer/spatialaudio.cpp | 2 +-
modules/audio_filter/channel_mixer/trivial.c | 4 +--
modules/audio_filter/converter/format.c | 27 +++++++++++++++++++
modules/audio_filter/converter/tospdif.c | 2 +-
modules/audio_filter/normvol.c | 2 +-
modules/audio_filter/resampler/bandlimited.c | 8 +++---
modules/audio_filter/resampler/soxr.c | 2 +-
modules/audio_filter/resampler/speex.c | 5 ++--
modules/audio_filter/resampler/src.c | 5 ++--
modules/audio_filter/resampler/ugly.c | 3 +++
modules/audio_filter/scaletempo.c | 4 ++-
16 files changed, 58 insertions(+), 19 deletions(-)
diff --git a/modules/audio_filter/channel_mixer/dolby.c b/modules/audio_filter/channel_mixer/dolby.c
index 8d5c63c256..573b2dfcac 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_out_buf = vlc_block_discontinuity;
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..4fcc00da1f 100644
--- a/modules/audio_filter/channel_mixer/headphone.c
+++ b/modules/audio_filter/channel_mixer/headphone.c
@@ -517,7 +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 );
- return NULL;
+ return vlc_block_discontinuity;
}
p_out->i_nb_samples = p_block->i_nb_samples;
diff --git a/modules/audio_filter/channel_mixer/mono.c b/modules/audio_filter/channel_mixer/mono.c
index 0c383e761e..a134d129dc 100644
--- a/modules/audio_filter/channel_mixer/mono.c
+++ b/modules/audio_filter/channel_mixer/mono.c
@@ -427,7 +427,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
{
if( p_block )
block_Release( p_block );
- return NULL;
+ return vlc_block_discontinuity;
}
filter_sys_t *p_sys = p_filter->p_sys;
@@ -439,7 +439,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 );
- return NULL;
+ return vlc_block_discontinuity;
}
p_out->i_nb_samples =
(p_block->i_nb_samples / p_sys->i_nb_channels) *
diff --git a/modules/audio_filter/channel_mixer/remap.c b/modules/audio_filter/channel_mixer/remap.c
index b3d284a582..50ded5aaf6 100644
--- a/modules/audio_filter/channel_mixer/remap.c
+++ b/modules/audio_filter/channel_mixer/remap.c
@@ -406,7 +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 );
- return NULL;
+ return vlc_block_discontinuity;
}
p_out->i_nb_samples = p_block->i_nb_samples;
p_out->i_dts = p_block->i_dts;
diff --git a/modules/audio_filter/channel_mixer/simple.c b/modules/audio_filter/channel_mixer/simple.c
index 8b3feb7a31..b1160d22dd 100644
--- a/modules/audio_filter/channel_mixer/simple.c
+++ b/modules/audio_filter/channel_mixer/simple.c
@@ -373,7 +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 );
- return NULL;
+ return vlc_block_discontinuity;
}
p_out->i_nb_samples = p_block->i_nb_samples;
diff --git a/modules/audio_filter/channel_mixer/spatialaudio.cpp b/modules/audio_filter/channel_mixer/spatialaudio.cpp
index 755f1422d5..5e17cea80f 100644
--- a/modules/audio_filter/channel_mixer/spatialaudio.cpp
+++ b/modules/audio_filter/channel_mixer/spatialaudio.cpp
@@ -187,7 +187,7 @@ static block_t *Mix( filter_t *p_filter, block_t *p_buf )
if (unlikely(p_out_buf == NULL))
{
block_Release(p_buf);
- return NULL;
+ return vlc_block_discontinuity;
}
p_out_buf->i_nb_samples = i_nbBlocks * AMB_BLOCK_TIME_LEN;
diff --git a/modules/audio_filter/channel_mixer/trivial.c b/modules/audio_filter/channel_mixer/trivial.c
index 6b5b843c87..f4f5df0d07 100644
--- a/modules/audio_filter/channel_mixer/trivial.c
+++ b/modules/audio_filter/channel_mixer/trivial.c
@@ -66,7 +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 );
- return NULL;
+ return vlc_block_discontinuity;
}
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
@@ -142,7 +142,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 );
- return NULL;
+ return vlc_block_discontinuity;
}
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
diff --git a/modules/audio_filter/converter/format.c b/modules/audio_filter/converter/format.c
index 2178668b31..1382dc30d6 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))
+ {
+ bdst = vlc_block_discontinuity;
goto out;
+ }
block_CopyProperties(bdst, bsrc);
uint8_t *src = (uint8_t *)bsrc->p_buffer;
@@ -104,7 +107,10 @@ static block_t *U8toFl32(filter_t *filter, block_t *bsrc)
{
block_t *bdst = block_Alloc(bsrc->i_buffer * 4);
if (unlikely(bdst == NULL))
+ {
+ bdst = vlc_block_discontinuity;
goto out;
+ }
block_CopyProperties(bdst, bsrc);
uint8_t *src = (uint8_t *)bsrc->p_buffer;
@@ -121,7 +127,10 @@ static block_t *U8toS32(filter_t *filter, block_t *bsrc)
{
block_t *bdst = block_Alloc(bsrc->i_buffer * 4);
if (unlikely(bdst == NULL))
+ {
+ bdst = vlc_block_discontinuity;
goto out;
+ }
block_CopyProperties(bdst, bsrc);
uint8_t *src = (uint8_t *)bsrc->p_buffer;
@@ -138,7 +147,10 @@ static block_t *U8toFl64(filter_t *filter, block_t *bsrc)
{
block_t *bdst = block_Alloc(bsrc->i_buffer * 8);
if (unlikely(bdst == NULL))
+ {
+ bdst = vlc_block_discontinuity;
goto out;
+ }
block_CopyProperties(bdst, bsrc);
uint8_t *src = (uint8_t *)bsrc->p_buffer;
@@ -169,7 +181,10 @@ static block_t *S16toFl32(filter_t *filter, block_t *bsrc)
{
block_t *bdst = block_Alloc(bsrc->i_buffer * 2);
if (unlikely(bdst == NULL))
+ {
+ bdst = vlc_block_discontinuity;
goto out;
+ }
block_CopyProperties(bdst, bsrc);
int16_t *src = (int16_t *)bsrc->p_buffer;
@@ -197,7 +212,10 @@ static block_t *S16toS32(filter_t *filter, block_t *bsrc)
{
block_t *bdst = block_Alloc(bsrc->i_buffer * 2);
if (unlikely(bdst == NULL))
+ {
+ bdst = vlc_block_discontinuity;
goto out;
+ }
block_CopyProperties(bdst, bsrc);
int16_t *src = (int16_t *)bsrc->p_buffer;
@@ -214,7 +232,10 @@ static block_t *S16toFl64(filter_t *filter, block_t *bsrc)
{
block_t *bdst = block_Alloc(bsrc->i_buffer * 4);
if (unlikely(bdst == NULL))
+ {
+ bdst = vlc_block_discontinuity;
goto out;
+ }
block_CopyProperties(bdst, bsrc);
int16_t *src = (int16_t *)bsrc->p_buffer;
@@ -300,7 +321,10 @@ static block_t *Fl32toFl64(filter_t *filter, block_t *bsrc)
{
block_t *bdst = block_Alloc(bsrc->i_buffer * 2);
if (unlikely(bdst == NULL))
+ {
+ bdst = vlc_block_discontinuity;
goto out;
+ }
block_CopyProperties(bdst, bsrc);
float *src = (float *)bsrc->p_buffer;
@@ -353,7 +377,10 @@ static block_t *S32toFl64(filter_t *filter, block_t *bsrc)
{
block_t *bdst = block_Alloc(bsrc->i_buffer * 2);
if (unlikely(bdst == NULL))
+ {
+ bdst = vlc_block_discontinuity;
goto out;
+ }
block_CopyProperties(bdst, bsrc);
int32_t *src = (int32_t*)bsrc->p_buffer;
diff --git a/modules/audio_filter/converter/tospdif.c b/modules/audio_filter/converter/tospdif.c
index 9e9213f660..98659a449e 100644
--- a/modules/audio_filter/converter/tospdif.c
+++ b/modules/audio_filter/converter/tospdif.c
@@ -591,7 +591,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
case SPDIF_MORE_DATA:
break;
case SPDIF_ERROR:
- Flush( p_filter );
+ p_out_buf = vlc_block_discontinuity;
break;
}
diff --git a/modules/audio_filter/normvol.c b/modules/audio_filter/normvol.c
index 653e3818bb..7c8b4cbe62 100644
--- a/modules/audio_filter/normvol.c
+++ b/modules/audio_filter/normvol.c
@@ -216,7 +216,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
return p_in_buf;
out:
block_Release( p_in_buf );
- return NULL;
+ return vlc_block_discontinuity;
}
/**********************************************************************
diff --git a/modules/audio_filter/resampler/bandlimited.c b/modules/audio_filter/resampler/bandlimited.c
index 2d544315af..b0d2ebc597 100644
--- a/modules/audio_filter/resampler/bandlimited.c
+++ b/modules/audio_filter/resampler/bandlimited.c
@@ -121,7 +121,9 @@ 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 )
- return NULL;
+ {
+ return vlc_block_discontinuity;
+ }
memcpy( p_in_buf->p_buffer, p_sys->p_buf +
i_nb_channels * p_sys->i_old_wing,
p_sys->i_old_wing *
@@ -148,7 +150,7 @@ static block_t *Resample( filter_t * p_filter, block_t * p_in_buf )
if( !p_out_buf )
{
block_Release( p_in_buf );
- return NULL;
+ return vlc_block_discontinuity;
}
if( (p_in_buf->i_flags & BLOCK_FLAG_DISCONTINUITY) || p_sys->b_first )
@@ -187,7 +189,7 @@ 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) )
- return NULL;
+ return vlc_block_discontinuity;
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..7b1b8eacbc 100644
--- a/modules/audio_filter/resampler/soxr.c
+++ b/modules/audio_filter/resampler/soxr.c
@@ -372,7 +372,7 @@ Resample( filter_t *p_filter, block_t *p_in )
}
error:
block_Release( p_in );
- return NULL;
+ return vlc_block_discontinuity;
}
static block_t *
diff --git a/modules/audio_filter/resampler/speex.c b/modules/audio_filter/resampler/speex.c
index eeefc4f4c4..1062a031bc 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,9 @@ 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);
+ return vlc_block_discontinuity;
}
diff --git a/modules/audio_filter/resampler/src.c b/modules/audio_filter/resampler/src.c
index 1254314b13..e32a17324c 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,9 @@ 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);
+ return vlc_block_discontinuity;
}
diff --git a/modules/audio_filter/resampler/ugly.c b/modules/audio_filter/resampler/ugly.c
index a802cc9ae3..a634384c77 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_out_buf = vlc_block_discontinuity;
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..9cbd16b6d4 100644
--- a/modules/audio_filter/scaletempo.c
+++ b/modules/audio_filter/scaletempo.c
@@ -588,7 +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 );
- return NULL;
+ return vlc_block_discontinuity;
}
size_t bytes_out = 0;
while( p->bytes_queued >= p->bytes_queue_max )
@@ -626,6 +626,8 @@ static block_t *DoPitchWork( filter_t * p_filter, block_t * p_in_buf )
/* Change rate, thus changing pitch */
p_in_buf = p->resampler->pf_audio_filter( p->resampler, p_in_buf );
+ if( p_in_buf == vlc_block_discontinuity )
+ return p_in_buf;
/* Change tempo while preserving shifted pitch */
return DoWork( p_filter, p_in_buf );
--
2.20.1
More information about the vlc-devel
mailing list