[vlc-devel] [PATCH 03/13] Replace aout_sys_t* by void*
Romain Vimont
rom1v at videolabs.io
Tue Apr 24 11:18:21 CEST 2018
See #17078
---
include/vlc_aout.h | 2 +-
modules/audio_output/alsa.c | 9 +++--
modules/audio_output/file.c | 70 +++++++++++++++++++-----------------
modules/audio_output/pulse.c | 3 +-
modules/audio_output/sndio.c | 3 +-
5 files changed, 48 insertions(+), 39 deletions(-)
diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index 9a888d54a2..e260209346 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -116,7 +116,7 @@ struct audio_output
{
struct vlc_common_members obj;
- struct aout_sys_t *sys; /**< Private data for callbacks */
+ void *sys; /**< Private data for callbacks */
int (*start)(audio_output_t *, audio_sample_format_t *fmt);
/**< Starts a new stream (mandatory, cannot be NULL).
diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index dd1889b41e..1e7889e6d8 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -694,7 +694,8 @@ static void Play (audio_output_t *aout, block_t *block)
*/
static void Pause (audio_output_t *aout, bool pause, mtime_t date)
{
- snd_pcm_t *pcm = aout->sys->pcm;
+ aout_sys_t *p_sys = aout->sys;
+ snd_pcm_t *pcm = p_sys->pcm;
int val = snd_pcm_pause (pcm, pause);
if (unlikely(val))
@@ -703,7 +704,8 @@ static void Pause (audio_output_t *aout, bool pause, mtime_t date)
static void PauseDummy (audio_output_t *aout, bool pause, mtime_t date)
{
- snd_pcm_t *pcm = aout->sys->pcm;
+ aout_sys_t *p_sys = aout->sys;
+ snd_pcm_t *pcm = p_sys->pcm;
/* Stupid device cannot pause. Discard samples. */
if (pause)
@@ -718,7 +720,8 @@ static void PauseDummy (audio_output_t *aout, bool pause, mtime_t date)
*/
static void Flush (audio_output_t *aout, bool wait)
{
- snd_pcm_t *pcm = aout->sys->pcm;
+ aout_sys_t *p_sys = aout->sys;
+ snd_pcm_t *pcm = p_sys->pcm;
if (wait)
snd_pcm_drain (pcm);
diff --git a/modules/audio_output/file.c b/modules/audio_output/file.c
index 6c6c59cfb4..e6c9552523 100644
--- a/modules/audio_output/file.c
+++ b/modules/audio_output/file.c
@@ -147,19 +147,20 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
}
/* Allocate structure */
- p_aout->sys = malloc( sizeof( aout_sys_t ) );
- if( p_aout->sys == NULL )
+ aout_sys_t *p_sys = malloc( sizeof( aout_sys_t ) );
+ if( p_sys == NULL )
return VLC_ENOMEM;
+ p_aout->sys = p_sys;
if( !strcmp( psz_name, "-" ) )
- p_aout->sys->p_file = stdout;
+ p_sys->p_file = stdout;
else
- p_aout->sys->p_file = vlc_fopen( psz_name, "wb" );
+ p_sys->p_file = vlc_fopen( psz_name, "wb" );
free( psz_name );
- if ( p_aout->sys->p_file == NULL )
+ if ( p_sys->p_file == NULL )
{
- free( p_aout->sys );
+ free( p_sys );
return VLC_EGENERIC;
}
@@ -172,9 +173,9 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
psz_format = var_InheritString( p_aout, "audiofile-format" );
if ( !psz_format ) /* FIXME */
{
- if( p_aout->sys->p_file != stdout )
- fclose( p_aout->sys->p_file );
- free( p_aout->sys );
+ if( p_sys->p_file != stdout )
+ fclose( p_sys->p_file );
+ free( p_sys );
return VLC_EGENERIC;
}
@@ -191,9 +192,9 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
{
msg_Err( p_aout, "cannot understand the format string (%s)",
psz_format );
- if( p_aout->sys->p_file != stdout )
- fclose( p_aout->sys->p_file );
- free( p_aout->sys );
+ if( p_sys->p_file != stdout )
+ fclose( p_sys->p_file );
+ free( p_sys );
free( psz_format );
return VLC_EGENERIC;
}
@@ -215,11 +216,11 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
fmt->channel_type = AUDIO_CHANNEL_TYPE_BITMAP;
/* WAV header */
- p_aout->sys->b_add_wav_header = var_InheritBool( p_aout, "audiofile-wav" );
- if( p_aout->sys->b_add_wav_header )
+ p_sys->b_add_wav_header = var_InheritBool( p_aout, "audiofile-wav" );
+ if( p_sys->b_add_wav_header )
{
/* Write wave header */
- WAVEHEADER *wh = &p_aout->sys->waveh;
+ WAVEHEADER *wh = &p_sys->waveh;
memset( wh, 0, sizeof(*wh) );
@@ -265,7 +266,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
SetDWLE( &wh->BytesPerSec, wh->BytesPerSec );
if( fwrite( wh, sizeof(WAVEHEADER), 1,
- p_aout->sys->p_file ) != 1 )
+ p_sys->p_file ) != 1 )
{
msg_Err( p_aout, "write error: %s", vlc_strerror_c(errno) );
}
@@ -280,35 +281,36 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
static void Stop( audio_output_t *p_aout )
{
msg_Dbg( p_aout, "closing audio file" );
+ aout_sys_t *p_sys = p_aout->sys;
- if( p_aout->sys->b_add_wav_header )
+ if( p_sys->b_add_wav_header )
{
/* Update Wave Header */
- p_aout->sys->waveh.Length =
- p_aout->sys->waveh.DataLength + sizeof(WAVEHEADER) - 4;
+ p_sys->waveh.Length =
+ p_sys->waveh.DataLength + sizeof(WAVEHEADER) - 4;
/* Write Wave Header */
- if( fseek( p_aout->sys->p_file, 0, SEEK_SET ) )
+ if( fseek( p_sys->p_file, 0, SEEK_SET ) )
{
msg_Err( p_aout, "seek error: %s", vlc_strerror_c(errno) );
}
/* Header -> little endian format */
- SetDWLE( &p_aout->sys->waveh.Length,
- p_aout->sys->waveh.Length );
- SetDWLE( &p_aout->sys->waveh.DataLength,
- p_aout->sys->waveh.DataLength );
+ SetDWLE( &p_sys->waveh.Length,
+ p_sys->waveh.Length );
+ SetDWLE( &p_sys->waveh.DataLength,
+ p_sys->waveh.DataLength );
- if( fwrite( &p_aout->sys->waveh, sizeof(WAVEHEADER), 1,
- p_aout->sys->p_file ) != 1 )
+ if( fwrite( &p_sys->waveh, sizeof(WAVEHEADER), 1,
+ p_sys->p_file ) != 1 )
{
msg_Err( p_aout, "write error: %s", vlc_strerror_c(errno) );
}
}
- if( p_aout->sys->p_file != stdout )
- fclose( p_aout->sys->p_file );
- free( p_aout->sys );
+ if( p_sys->p_file != stdout )
+ fclose( p_sys->p_file );
+ free( p_sys );
}
/*****************************************************************************
@@ -316,16 +318,17 @@ static void Stop( audio_output_t *p_aout )
*****************************************************************************/
static void Play( audio_output_t * p_aout, block_t *p_buffer )
{
+ aout_sys_t *p_sys = p_aout->sys;
if( fwrite( p_buffer->p_buffer, p_buffer->i_buffer, 1,
- p_aout->sys->p_file ) != 1 )
+ p_sys->p_file ) != 1 )
{
msg_Err( p_aout, "write error: %s", vlc_strerror_c(errno) );
}
- if( p_aout->sys->b_add_wav_header )
+ if( p_sys->b_add_wav_header )
{
/* Update Wave Header */
- p_aout->sys->waveh.DataLength += p_buffer->i_buffer;
+ p_sys->waveh.DataLength += p_buffer->i_buffer;
}
block_Release( p_buffer );
@@ -333,7 +336,8 @@ static void Play( audio_output_t * p_aout, block_t *p_buffer )
static void Flush( audio_output_t *aout, bool wait )
{
- if( fflush( aout->sys->p_file ) )
+ aout_sys_t *p_sys = aout->sys;
+ if( fflush( p_sys->p_file ) )
msg_Err( aout, "flush error: %s", vlc_strerror_c(errno) );
(void) wait;
}
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 1a36a7b647..d49dc2bea9 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -175,7 +175,8 @@ static void stream_start_now(pa_stream *s, audio_output_t *aout)
{
pa_operation *op;
- assert (aout->sys->trigger == NULL);
+ aout_sys_t *p_sys = aout->sys;
+ assert (p_sys->trigger == NULL);
op = pa_stream_cork(s, 0, NULL, NULL);
if (op != NULL)
diff --git a/modules/audio_output/sndio.c b/modules/audio_output/sndio.c
index 6ea78dd2fa..c5608b161d 100644
--- a/modules/audio_output/sndio.c
+++ b/modules/audio_output/sndio.c
@@ -253,12 +253,13 @@ static void Flush (audio_output_t *aout, bool wait)
static void VolumeChanged (void *arg, unsigned volume)
{
audio_output_t *aout = arg;
+ aout_sys_t *p_sys = aout->sys;
float fvol = (float)volume / (float)SIO_MAXVOL;
aout_VolumeReport (aout, fvol);
aout_MuteReport (aout, volume == 0);
if (volume) /* remember last non-zero volume to unmute later */
- aout->sys->volume = volume;
+ p_sys->volume = volume;
}
static int VolumeSet (audio_output_t *aout, float fvol)
--
2.17.0
More information about the vlc-devel
mailing list