Commit d809a3fb authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Merge aout_output_t into aout_instance_t

This prepares for a possible cleanup of the audio output object,
especially hiding more stuff into the core.
parent 335bbdfe
...@@ -164,31 +164,9 @@ struct aout_fifo_t ...@@ -164,31 +164,9 @@ struct aout_fifo_t
/* FIXME to remove once aout.h is cleaned a bit more */ /* FIXME to remove once aout.h is cleaned a bit more */
#include <vlc_block.h> #include <vlc_block.h>
/** an output stream for the audio output */
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. */
bool b_starving;
/* post-filters */
filter_t * pp_filters[AOUT_MAX_FILTERS];
int i_nb_filters;
aout_fifo_t fifo;
struct module_t * p_module;
struct aout_sys_t * p_sys;
void (*pf_play)( aout_instance_t * );
void (* pf_pause)( aout_instance_t *, bool, mtime_t );
int (* pf_volume_set )( aout_instance_t *, float, bool );
int i_nb_samples;
} aout_output_t;
struct aout_mixer_t; struct aout_mixer_t;
/** audio output thread descriptor */ /** Audio output object */
struct aout_instance_t struct aout_instance_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
...@@ -205,8 +183,27 @@ struct aout_instance_t ...@@ -205,8 +183,27 @@ struct aout_instance_t
float mixer_multiplier; float mixer_multiplier;
struct aout_mixer_t *p_mixer; struct aout_mixer_t *p_mixer;
/* Output plug-in */ audio_sample_format_t format; /**< Output format (plugin can modify it
aout_output_t output; only when succesfully probed and not afterward) */
/* Indicates whether the audio output is currently starving, to avoid
* printing a 1,000 "output is starving" messages. */
bool b_starving;
/* post-filters */
filter_t * pp_filters[AOUT_MAX_FILTERS];
int i_nb_filters;
aout_fifo_t fifo;
struct module_t *module; /**< Output plugin */
struct aout_sys_t *sys; /**< Output plugin private data */
void (*pf_play)( aout_instance_t * ); /**< Audio buffer callback */
void (* pf_pause)( aout_instance_t *, bool, mtime_t ); /**< Pause/resume
callback (optional, may be NULL) */
int (* pf_volume_set )(aout_instance_t *, float, bool); /**< Volume setter
(optional, may be NULL) */
int i_nb_samples;
}; };
/** /**
......
...@@ -184,7 +184,7 @@ static int Open (vlc_object_t *obj) ...@@ -184,7 +184,7 @@ static int Open (vlc_object_t *obj)
return VLC_ENOMEM; return VLC_ENOMEM;
snd_pcm_format_t pcm_format; /* ALSA sample format */ snd_pcm_format_t pcm_format; /* ALSA sample format */
vlc_fourcc_t fourcc = p_aout->output.output.i_format; vlc_fourcc_t fourcc = p_aout->format.i_format;
bool spdif = false; bool spdif = false;
switch (fourcc) switch (fourcc)
...@@ -242,7 +242,7 @@ static int Open (vlc_object_t *obj) ...@@ -242,7 +242,7 @@ static int Open (vlc_object_t *obj)
pcm_format = SND_PCM_FORMAT_U8; pcm_format = SND_PCM_FORMAT_U8;
break; break;
default: default:
if (AOUT_FMT_NON_LINEAR(&p_aout->output.output)) if (AOUT_FMT_NON_LINEAR(&p_aout->format))
spdif = var_InheritBool (p_aout, "spdif"); spdif = var_InheritBool (p_aout, "spdif");
if (HAVE_FPU) if (HAVE_FPU)
{ {
...@@ -263,7 +263,7 @@ static int Open (vlc_object_t *obj) ...@@ -263,7 +263,7 @@ static int Open (vlc_object_t *obj)
{ {
unsigned aes3; unsigned aes3;
switch (p_aout->output.output.i_rate) switch (p_aout->format.i_rate)
{ {
#define FS(freq) \ #define FS(freq) \
case freq: aes3 = IEC958_AES3_CON_FS_ ## freq; break; case freq: aes3 = IEC958_AES3_CON_FS_ ## freq; break;
...@@ -293,7 +293,7 @@ static int Open (vlc_object_t *obj) ...@@ -293,7 +293,7 @@ static int Open (vlc_object_t *obj)
free (psz_device); free (psz_device);
return VLC_ENOMEM; return VLC_ENOMEM;
} }
p_aout->output.p_sys = p_sys; p_aout->sys = p_sys;
#ifdef ALSA_DEBUG #ifdef ALSA_DEBUG
snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 ); snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 );
...@@ -349,24 +349,24 @@ static int Open (vlc_object_t *obj) ...@@ -349,24 +349,24 @@ static int Open (vlc_object_t *obj)
pcm_format = SND_PCM_FORMAT_S16; pcm_format = SND_PCM_FORMAT_S16;
i_channels = 2; i_channels = 2;
p_aout->output.i_nb_samples = i_period_size = ALSA_SPDIF_PERIOD_SIZE; p_aout->i_nb_samples = i_period_size = ALSA_SPDIF_PERIOD_SIZE;
p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->output.output.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
aout_VolumeNoneInit( p_aout ); aout_VolumeNoneInit( p_aout );
} }
else else
{ {
i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE; i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE;
i_channels = aout_FormatNbChannels( &p_aout->output.output ); i_channels = aout_FormatNbChannels( &p_aout->format );
p_aout->output.i_nb_samples = i_period_size = ALSA_DEFAULT_PERIOD_SIZE; p_aout->i_nb_samples = i_period_size = ALSA_DEFAULT_PERIOD_SIZE;
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
} }
p_aout->output.pf_play = Play; p_aout->pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->pf_pause = NULL;
snd_pcm_hw_params_t *p_hw; snd_pcm_hw_params_t *p_hw;
snd_pcm_sw_params_t *p_sw; snd_pcm_sw_params_t *p_sw;
...@@ -391,7 +391,7 @@ static int Open (vlc_object_t *obj) ...@@ -391,7 +391,7 @@ static int Open (vlc_object_t *obj)
goto error; goto error;
} }
p_aout->output.output.i_format = fourcc; p_aout->format.i_format = fourcc;
val = snd_pcm_hw_params_set_access( p_sys->p_snd_pcm, p_hw, val = snd_pcm_hw_params_set_access( p_sys->p_snd_pcm, p_hw,
SND_PCM_ACCESS_RW_INTERLEAVED ); SND_PCM_ACCESS_RW_INTERLEAVED );
...@@ -412,9 +412,9 @@ static int Open (vlc_object_t *obj) ...@@ -412,9 +412,9 @@ static int Open (vlc_object_t *obj)
} }
/* Set rate. */ /* Set rate. */
unsigned old_rate = p_aout->output.output.i_rate; unsigned old_rate = p_aout->format.i_rate;
val = snd_pcm_hw_params_set_rate_near (p_sys->p_snd_pcm, p_hw, val = snd_pcm_hw_params_set_rate_near (p_sys->p_snd_pcm, p_hw,
&p_aout->output.output.i_rate, &p_aout->format.i_rate,
NULL); NULL);
if (val < 0) if (val < 0)
{ {
...@@ -422,9 +422,9 @@ static int Open (vlc_object_t *obj) ...@@ -422,9 +422,9 @@ static int Open (vlc_object_t *obj)
snd_strerror (val)); snd_strerror (val));
goto error; goto error;
} }
if (p_aout->output.output.i_rate != old_rate) if (p_aout->format.i_rate != old_rate)
msg_Warn (p_aout, "resampling from %d Hz to %d Hz", old_rate, msg_Warn (p_aout, "resampling from %d Hz to %d Hz", old_rate,
p_aout->output.output.i_rate); p_aout->format.i_rate);
/* Set period size. */ /* Set period size. */
val = snd_pcm_hw_params_set_period_size_near( p_sys->p_snd_pcm, p_hw, val = snd_pcm_hw_params_set_period_size_near( p_sys->p_snd_pcm, p_hw,
...@@ -435,7 +435,7 @@ static int Open (vlc_object_t *obj) ...@@ -435,7 +435,7 @@ static int Open (vlc_object_t *obj)
snd_strerror( val ) ); snd_strerror( val ) );
goto error; goto error;
} }
p_aout->output.i_nb_samples = i_period_size; p_aout->i_nb_samples = i_period_size;
/* Set buffer size. */ /* Set buffer size. */
val = snd_pcm_hw_params_set_buffer_size_near( p_sys->p_snd_pcm, p_hw, val = snd_pcm_hw_params_set_buffer_size_near( p_sys->p_snd_pcm, p_hw,
...@@ -469,7 +469,7 @@ static int Open (vlc_object_t *obj) ...@@ -469,7 +469,7 @@ static int Open (vlc_object_t *obj)
snd_pcm_sw_params_current( p_sys->p_snd_pcm, p_sw ); snd_pcm_sw_params_current( p_sys->p_snd_pcm, p_sw );
snd_pcm_sw_params_set_avail_min( p_sys->p_snd_pcm, p_sw, snd_pcm_sw_params_set_avail_min( p_sys->p_snd_pcm, p_sw,
p_aout->output.i_nb_samples ); p_aout->i_nb_samples );
/* start playing when one period has been written */ /* start playing when one period has been written */
val = snd_pcm_sw_params_set_start_threshold( p_sys->p_snd_pcm, p_sw, val = snd_pcm_sw_params_set_start_threshold( p_sys->p_snd_pcm, p_sw,
ALSA_DEFAULT_PERIOD_SIZE); ALSA_DEFAULT_PERIOD_SIZE);
...@@ -529,13 +529,13 @@ static void PlayIgnore( aout_instance_t *p_aout ) ...@@ -529,13 +529,13 @@ static void PlayIgnore( aout_instance_t *p_aout )
*****************************************************************************/ *****************************************************************************/
static void Play( aout_instance_t *p_aout ) static void Play( aout_instance_t *p_aout )
{ {
p_aout->output.pf_play = PlayIgnore; p_aout->pf_play = PlayIgnore;
/* get the playing date of the first aout buffer */ /* get the playing date of the first aout buffer */
p_aout->output.p_sys->start_date = aout_FifoFirstDate( &p_aout->output.fifo ); p_aout->sys->start_date = aout_FifoFirstDate( &p_aout->fifo );
/* wake up the audio output thread */ /* wake up the audio output thread */
sem_post( &p_aout->output.p_sys->wait ); sem_post( &p_aout->sys->wait );
} }
/***************************************************************************** /*****************************************************************************
...@@ -544,7 +544,7 @@ static void Play( aout_instance_t *p_aout ) ...@@ -544,7 +544,7 @@ static void Play( aout_instance_t *p_aout )
static void Close (vlc_object_t *obj) static void Close (vlc_object_t *obj)
{ {
aout_instance_t *p_aout = (aout_instance_t *)obj; aout_instance_t *p_aout = (aout_instance_t *)obj;
struct aout_sys_t * p_sys = p_aout->output.p_sys; struct aout_sys_t * p_sys = p_aout->sys;
/* Make sure that the thread will stop once it is waken up */ /* Make sure that the thread will stop once it is waken up */
vlc_cancel( p_sys->thread ); vlc_cancel( p_sys->thread );
...@@ -565,7 +565,7 @@ static void Close (vlc_object_t *obj) ...@@ -565,7 +565,7 @@ static void Close (vlc_object_t *obj)
static void* ALSAThread( void *data ) static void* ALSAThread( void *data )
{ {
aout_instance_t * p_aout = data; aout_instance_t * p_aout = data;
struct aout_sys_t * p_sys = p_aout->output.p_sys; struct aout_sys_t * p_sys = p_aout->sys;
/* Wait for the exact time to start playing (avoids resampling) */ /* Wait for the exact time to start playing (avoids resampling) */
vlc_sem_wait( &p_sys->wait ); vlc_sem_wait( &p_sys->wait );
...@@ -583,7 +583,7 @@ static void* ALSAThread( void *data ) ...@@ -583,7 +583,7 @@ static void* ALSAThread( void *data )
*****************************************************************************/ *****************************************************************************/
static void ALSAFill( aout_instance_t * p_aout ) static void ALSAFill( aout_instance_t * p_aout )
{ {
struct aout_sys_t * p_sys = p_aout->output.p_sys; struct aout_sys_t * p_sys = p_aout->sys;
snd_pcm_t *p_pcm = p_sys->p_snd_pcm; snd_pcm_t *p_pcm = p_sys->p_snd_pcm;
snd_pcm_status_t * p_status; snd_pcm_status_t * p_status;
int i_snd_rc; int i_snd_rc;
...@@ -635,9 +635,9 @@ static void ALSAFill( aout_instance_t * p_aout ) ...@@ -635,9 +635,9 @@ static void ALSAFill( aout_instance_t * p_aout )
size_t i_bytes = snd_pcm_frames_to_bytes( p_pcm, delay ); size_t i_bytes = snd_pcm_frames_to_bytes( p_pcm, delay );
mtime_t delay_us = CLOCK_FREQ * i_bytes mtime_t delay_us = CLOCK_FREQ * i_bytes
/ p_aout->output.output.i_bytes_per_frame / p_aout->format.i_bytes_per_frame
/ p_aout->output.output.i_rate / p_aout->format.i_rate
* p_aout->output.output.i_frame_length; * p_aout->format.i_frame_length;
#ifdef ALSA_DEBUG #ifdef ALSA_DEBUG
snd_pcm_state_t state = snd_pcm_status_get_state( p_status ); snd_pcm_state_t state = snd_pcm_status_get_state( p_status );
...@@ -646,16 +646,16 @@ static void ALSAFill( aout_instance_t * p_aout ) ...@@ -646,16 +646,16 @@ static void ALSAFill( aout_instance_t * p_aout )
msg_Dbg( p_aout, "Delay is %ld frames (%zu bytes)", delay, i_bytes ); msg_Dbg( p_aout, "Delay is %ld frames (%zu bytes)", delay, i_bytes );
msg_Dbg( p_aout, "Bytes per frame: %d", p_aout->output.output.i_bytes_per_frame ); msg_Dbg( p_aout, "Bytes per frame: %d", p_aout->format.i_bytes_per_frame );
msg_Dbg( p_aout, "Rate: %d", p_aout->output.output.i_rate ); msg_Dbg( p_aout, "Rate: %d", p_aout->format.i_rate );
msg_Dbg( p_aout, "Frame length: %d", p_aout->output.output.i_frame_length ); msg_Dbg( p_aout, "Frame length: %d", p_aout->format.i_frame_length );
msg_Dbg( p_aout, "Next date: in %"PRId64" microseconds", delay_us ); msg_Dbg( p_aout, "Next date: in %"PRId64" microseconds", delay_us );
#endif #endif
next_date = mdate() + delay_us; next_date = mdate() + delay_us;
} }
block_t *p_buffer = aout_OutputNextBuffer( p_aout, next_date, block_t *p_buffer = aout_OutputNextBuffer( p_aout, next_date,
(p_aout->output.output.i_format == VLC_CODEC_SPDIFL) ); (p_aout->format.i_format == VLC_CODEC_SPDIFL) );
/* Audio output buffer shortage -> stop the fill process and wait */ /* Audio output buffer shortage -> stop the fill process and wait */
if( p_buffer == NULL ) if( p_buffer == NULL )
......
...@@ -61,10 +61,10 @@ struct aout_sys_t ...@@ -61,10 +61,10 @@ struct aout_sys_t
static void Play (aout_instance_t *aout) static void Play (aout_instance_t *aout)
{ {
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
block_t *block; block_t *block;
while ((block = aout_FifoPop(&aout->output.fifo)) != NULL) while ((block = aout_FifoPop(&aout->fifo)) != NULL)
{ {
sys->play (sys->opaque, block->p_buffer, block->i_nb_samples, sys->play (sys->opaque, block->p_buffer, block->i_nb_samples,
block->i_pts); block->i_pts);
...@@ -74,7 +74,7 @@ static void Play (aout_instance_t *aout) ...@@ -74,7 +74,7 @@ static void Play (aout_instance_t *aout)
static int VolumeSet (aout_instance_t *aout, float vol, bool mute) static int VolumeSet (aout_instance_t *aout, float vol, bool mute)
{ {
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
return sys->set_volume (sys->opaque, vol, mute) ? -1 : 0; return sys->set_volume (sys->opaque, vol, mute) ? -1 : 0;
} }
...@@ -88,7 +88,7 @@ static int Open (vlc_object_t *obj) ...@@ -88,7 +88,7 @@ static int Open (vlc_object_t *obj)
if (unlikely(sys == NULL)) if (unlikely(sys == NULL))
return VLC_ENOMEM; return VLC_ENOMEM;
aout->output.p_sys = sys; aout->sys = sys;
sys->opaque = var_InheritAddress (obj, "amem-data"); sys->opaque = var_InheritAddress (obj, "amem-data");
sys->play = var_InheritAddress (obj, "amem-play"); sys->play = var_InheritAddress (obj, "amem-play");
sys->set_volume = var_InheritAddress (obj, "amem-set-volume"); sys->set_volume = var_InheritAddress (obj, "amem-set-volume");
...@@ -102,8 +102,8 @@ static int Open (vlc_object_t *obj) ...@@ -102,8 +102,8 @@ static int Open (vlc_object_t *obj)
if (setup != NULL) if (setup != NULL)
{ {
rate = aout->output.output.i_rate; rate = aout->format.i_rate;
channels = aout_FormatNbChannels(&aout->output.output); channels = aout_FormatNbChannels(&aout->format);
if (setup (&sys->opaque, format, &rate, &channels)) if (setup (&sys->opaque, format, &rate, &channels))
goto error; goto error;
...@@ -122,18 +122,18 @@ static int Open (vlc_object_t *obj) ...@@ -122,18 +122,18 @@ static int Open (vlc_object_t *obj)
/* TODO: amem-format */ /* TODO: amem-format */
/* FIXME/TODO channel mapping */ /* FIXME/TODO channel mapping */
if (strcmp(format, "S16N") || aout->output.output.i_channels != channels) if (strcmp(format, "S16N") || aout->format.i_channels != channels)
{ {
msg_Err (aout, "format not supported"); msg_Err (aout, "format not supported");
goto error; goto error;
} }
aout->output.output.i_format = VLC_CODEC_S16N; aout->format.i_format = VLC_CODEC_S16N;
aout->output.output.i_rate = rate; aout->format.i_rate = rate;
aout->output.pf_play = Play; aout->pf_play = Play;
aout->output.pf_pause = NULL; aout->pf_pause = NULL;
if (sys->set_volume != NULL) if (sys->set_volume != NULL)
aout->output.pf_volume_set = VolumeSet; aout->pf_volume_set = VolumeSet;
else else
aout_VolumeSoftInit (aout); aout_VolumeSoftInit (aout);
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -146,7 +146,7 @@ error: ...@@ -146,7 +146,7 @@ error:
static void Close (vlc_object_t *obj) static void Close (vlc_object_t *obj)
{ {
aout_instance_t *aout = (aout_instance_t *)obj; aout_instance_t *aout = (aout_instance_t *)obj;
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
if (sys->cleanup != NULL) if (sys->cleanup != NULL)
sys->cleanup (sys->opaque); sys->cleanup (sys->opaque);
......
...@@ -78,7 +78,7 @@ static int Open ( vlc_object_t *p_this ) ...@@ -78,7 +78,7 @@ static int Open ( vlc_object_t *p_this )
{ {
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
struct aout_sys_t *p_sys = malloc(sizeof(aout_sys_t)); struct aout_sys_t *p_sys = malloc(sizeof(aout_sys_t));
p_aout->output.p_sys = p_sys; p_aout->sys = p_sys;
OSStatus status = 0; OSStatus status = 0;
...@@ -118,12 +118,12 @@ static int Open ( vlc_object_t *p_this ) ...@@ -118,12 +118,12 @@ static int Open ( vlc_object_t *p_this )
/* Volume is entirely done in software. */ /* Volume is entirely done in software. */
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
p_aout->output.output.i_format = VLC_CODEC_S16L; p_aout->format.i_format = VLC_CODEC_S16L;
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
p_aout->output.output.i_rate = 44100; p_aout->format.i_rate = 44100;
p_aout->output.i_nb_samples = FRAME_SIZE; p_aout->format.i_nb_samples = FRAME_SIZE;
p_aout->output.pf_play = Play; p_aout->format.pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->format.pf_pause = NULL;
msg_Dbg(p_aout, "Starting AudioQueue (status = %i)", status); msg_Dbg(p_aout, "Starting AudioQueue (status = %i)", status);
status = AudioQueueStart(p_sys->audioQueue, NULL); status = AudioQueueStart(p_sys->audioQueue, NULL);
...@@ -145,7 +145,7 @@ static void Play( aout_instance_t * p_aout ) ...@@ -145,7 +145,7 @@ static void Play( aout_instance_t * p_aout )
static void Close ( vlc_object_t *p_this ) static void Close ( vlc_object_t *p_this )
{ {
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
struct aout_sys_t * p_sys = p_aout->output.p_sys; struct aout_sys_t * p_sys = p_aout->sys;
msg_Dbg(p_aout, "Stopping AudioQueue"); msg_Dbg(p_aout, "Stopping AudioQueue");
AudioQueueStop(p_sys->audioQueue, false); AudioQueueStop(p_sys->audioQueue, false);
...@@ -160,7 +160,7 @@ void AudioQueueCallback(void * inUserData, AudioQueueRef inAQ, AudioQueueBufferR ...@@ -160,7 +160,7 @@ void AudioQueueCallback(void * inUserData, AudioQueueRef inAQ, AudioQueueBufferR
if (p_aout) { if (p_aout) {
vlc_mutex_lock( &p_aout->lock ); vlc_mutex_lock( &p_aout->lock );
p_buffer = aout_FifoPop( &p_aout->output.fifo ); p_buffer = aout_FifoPop( &p_aout->fifo );
vlc_mutex_unlock( &p_aout->lock ); vlc_mutex_unlock( &p_aout->lock );
} }
......
...@@ -165,11 +165,11 @@ static int Open( vlc_object_t * p_this ) ...@@ -165,11 +165,11 @@ static int Open( vlc_object_t * p_this )
int b_alive = false; int b_alive = false;
/* Allocate structure */ /* Allocate structure */
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) ); p_aout->sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->output.p_sys == NULL ) if( p_aout->sys == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
p_sys = p_aout->output.p_sys; p_sys = p_aout->sys;
p_sys->i_default_dev = 0; p_sys->i_default_dev = 0;
p_sys->i_selected_dev = 0; p_sys->i_selected_dev = 0;
p_sys->i_devices = 0; p_sys->i_devices = 0;
...@@ -187,10 +187,10 @@ static int Open( vlc_object_t * p_this ) ...@@ -187,10 +187,10 @@ static int Open( vlc_object_t * p_this )
p_sys->b_changed_mixing = false; p_sys->b_changed_mixing = false;
memset( p_sys->p_remainder_buffer, 0, sizeof(uint8_t) * BUFSIZE ); memset( p_sys->p_remainder_buffer, 0, sizeof(uint8_t) * BUFSIZE );
p_aout->output.pf_play = Play; p_aout->pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->pf_pause = NULL;
aout_FormatPrint( p_aout, "VLC is looking for:", (audio_sample_format_t *)&p_aout->output.output ); aout_FormatPrint( p_aout, "VLC is looking for:", &p_aout->format );
/* Persistent device variable */ /* Persistent device variable */
if( var_Type( p_aout->p_libvlc, "macosx-audio-device" ) == 0 ) if( var_Type( p_aout->p_libvlc, "macosx-audio-device" ) == 0 )
...@@ -262,7 +262,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -262,7 +262,7 @@ static int Open( vlc_object_t * p_this )
} }
/* Check for Digital mode or Analog output mode */ /* Check for Digital mode or Analog output mode */
if( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) && p_sys->b_supports_digital ) if( AOUT_FMT_NON_LINEAR( &p_aout->format ) && p_sys->b_supports_digital )
{ {
if( OpenSPDIF( p_aout ) ) if( OpenSPDIF( p_aout ) )
{ {
...@@ -292,7 +292,7 @@ error: ...@@ -292,7 +292,7 @@ error:
*****************************************************************************/ *****************************************************************************/
static int OpenAnalog( aout_instance_t *p_aout ) static int OpenAnalog( aout_instance_t *p_aout )
{ {
struct aout_sys_t *p_sys = p_aout->output.p_sys; struct aout_sys_t *p_sys = p_aout->sys;
OSStatus err = noErr; OSStatus err = noErr;
UInt32 i_param_size = 0; UInt32 i_param_size = 0;
int i_original; int i_original;
...@@ -390,18 +390,18 @@ static int OpenAnalog( aout_instance_t *p_aout ) ...@@ -390,18 +390,18 @@ static int OpenAnalog( aout_instance_t *p_aout )
msg_Dbg( p_aout, "layout of AUHAL has %d channels" , (int)layout->mNumberChannelDescriptions ); msg_Dbg( p_aout, "layout of AUHAL has %d channels" , (int)layout->mNumberChannelDescriptions );
/* Initialize the VLC core channel count */ /* Initialize the VLC core channel count */
p_aout->output.output.i_physical_channels = 0; p_aout->format.i_physical_channels = 0;
i_original = p_aout->output.output.i_original_channels & AOUT_CHAN_PHYSMASK; i_original = p_aout->format.i_original_channels & AOUT_CHAN_PHYSMASK;
if( i_original == AOUT_CHAN_CENTER || layout->mNumberChannelDescriptions < 2 ) if( i_original == AOUT_CHAN_CENTER || layout->mNumberChannelDescriptions < 2 )
{ {
/* We only need Mono or cannot output more than 1 channel */ /* We only need Mono or cannot output more than 1 channel */
p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; p_aout->format.i_physical_channels = AOUT_CHAN_CENTER;
} }
else if( i_original == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) || layout->mNumberChannelDescriptions < 3 ) else if( i_original == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) || layout->mNumberChannelDescriptions < 3 )
{ {
/* We only need Stereo or cannot output more than 2 channels */ /* We only need Stereo or cannot output more than 2 channels */
p_aout->output.output.i_physical_channels = AOUT_CHAN_RIGHT | AOUT_CHAN_LEFT; p_aout->format.i_physical_channels = AOUT_CHAN_RIGHT | AOUT_CHAN_LEFT;
} }
else else
{ {
...@@ -413,39 +413,39 @@ static int OpenAnalog( aout_instance_t *p_aout ) ...@@ -413,39 +413,39 @@ static int OpenAnalog( aout_instance_t *p_aout )
switch( layout->mChannelDescriptions[i].mChannelLabel ) switch( layout->mChannelDescriptions[i].mChannelLabel )
{ {
case kAudioChannelLabel_Left: case kAudioChannelLabel_Left:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_LEFT; p_aout->format.i_physical_channels |= AOUT_CHAN_LEFT;
continue; continue;
case kAudioChannelLabel_Right: case kAudioChannelLabel_Right:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_RIGHT; p_aout->format.i_physical_channels |= AOUT_CHAN_RIGHT;
continue; continue;
case kAudioChannelLabel_Center: case kAudioChannelLabel_Center:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_CENTER; p_aout->format.i_physical_channels |= AOUT_CHAN_CENTER;
continue; continue;
case kAudioChannelLabel_LFEScreen: case kAudioChannelLabel_LFEScreen:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_LFE; p_aout->format.i_physical_channels |= AOUT_CHAN_LFE;
continue; continue;
case kAudioChannelLabel_LeftSurround: case kAudioChannelLabel_LeftSurround:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARLEFT; p_aout->format.i_physical_channels |= AOUT_CHAN_REARLEFT;
continue; continue;
case kAudioChannelLabel_RightSurround: case kAudioChannelLabel_RightSurround:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARRIGHT; p_aout->format.i_physical_channels |= AOUT_CHAN_REARRIGHT;
continue; continue;
case kAudioChannelLabel_RearSurroundLeft: case kAudioChannelLabel_RearSurroundLeft:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_MIDDLELEFT; p_aout->format.i_physical_channels |= AOUT_CHAN_MIDDLELEFT;
continue; continue;
case kAudioChannelLabel_RearSurroundRight: case kAudioChannelLabel_RearSurroundRight:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_MIDDLERIGHT; p_aout->format.i_physical_channels |= AOUT_CHAN_MIDDLERIGHT;
continue; continue;
case kAudioChannelLabel_CenterSurround: case kAudioChannelLabel_CenterSurround:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARCENTER; p_aout->format.i_physical_channels |= AOUT_CHAN_REARCENTER;
continue; continue;
default: default:
msg_Warn( p_aout, "unrecognized channel form provided by driver: %d", (int)layout->mChannelDescriptions[i].mChannelLabel ); msg_Warn( p_aout, "unrecognized channel form provided by driver: %d", (int)layout->mChannelDescriptions[i].mChannelLabel );
} }
} }
if( p_aout->output.output.i_physical_channels == 0 ) if( p_aout->format.i_physical_channels == 0 )
{ {
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
msg_Err( p_aout, "You should configure your speaker layout with Audio Midi Setup Utility in /Applications/Utilities. Now using Stereo mode." ); msg_Err( p_aout, "You should configure your speaker layout with Audio Midi Setup Utility in /Applications/Utilities. Now using Stereo mode." );
dialog_Fatal( p_aout, _("Audio device is not configured"), "%s", dialog_Fatal( p_aout, _("Audio device is not configured"), "%s",
_("You should configure your speaker layout with " _("You should configure your speaker layout with "
...@@ -458,14 +458,14 @@ static int OpenAnalog( aout_instance_t *p_aout ) ...@@ -458,14 +458,14 @@ static int OpenAnalog( aout_instance_t *p_aout )
else else
{ {
msg_Warn( p_aout, "this driver does not support kAudioDevicePropertyPreferredChannelLayout. BAD DRIVER AUTHOR !!!" ); msg_Warn( p_aout, "this driver does not support kAudioDevicePropertyPreferredChannelLayout. BAD DRIVER AUTHOR !!!" );
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
} }
msg_Dbg( p_aout, "selected %d physical channels for device output", aout_FormatNbChannels( &p_aout->output.output ) ); msg_Dbg( p_aout, "selected %d physical channels for device output", aout_FormatNbChannels( &p_aout->format ) );
msg_Dbg( p_aout, "VLC will output: %s", aout_FormatPrintChannels( &p_aout->output.output )); msg_Dbg( p_aout, "VLC will output: %s", aout_FormatPrintChannels( &p_aout->format ));
memset (&new_layout, 0, sizeof(new_layout)); memset (&new_layout, 0, sizeof(new_layout));
switch( aout_FormatNbChannels( &p_aout->output.output ) ) switch( aout_FormatNbChannels( &p_aout->format ) )
{ {
case 1: case 1:
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_Mono; new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_Mono;
...@@ -474,41 +474,41 @@ static int OpenAnalog( aout_instance_t *p_aout ) ...@@ -474,41 +474,41 @@ static int OpenAnalog( aout_instance_t *p_aout )
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo; new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo;
break; break;
case 3: case 3:
if( p_aout->output.output.i_physical_channels & AOUT_CHAN_CENTER ) if( p_aout->format.i_physical_channels & AOUT_CHAN_CENTER )
{ {
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_7; // L R C new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_7; // L R C
} }
else if( p_aout->output.output.i_physical_channels & AOUT_CHAN_LFE ) else if( p_aout->format.i_physical_channels & AOUT_CHAN_LFE )
{ {
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_4; // L R LFE new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_4; // L R LFE
} }
break; break;
case 4: case 4:
if( p_aout->output.output.i_physical_channels & ( AOUT_CHAN_CENTER | AOUT_CHAN_LFE ) ) if( p_aout->format.i_physical_channels & ( AOUT_CHAN_CENTER | AOUT_CHAN_LFE ) )
{ {
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_10; // L R C LFE new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_10; // L R C LFE
} }
else if( p_aout->output.output.i_physical_channels & ( AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT ) ) else if( p_aout->format.i_physical_channels & ( AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT ) )
{ {
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_3; // L R Ls Rs new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_3; // L R Ls Rs
} }
else if( p_aout->output.output.i_physical_channels & ( AOUT_CHAN_CENTER | AOUT_CHAN_REARCENTER ) ) else if( p_aout->format.i_physical_channels & ( AOUT_CHAN_CENTER | AOUT_CHAN_REARCENTER ) )
{ {
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_3; // L R C Cs new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_3; // L R C Cs
} }
break; break;
case 5: case 5:
if( p_aout->output.output.i_physical_channels & ( AOUT_CHAN_CENTER ) ) if( p_aout->format.i_physical_channels & ( AOUT_CHAN_CENTER ) )
{ {
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_19; // L R Ls Rs C new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_19; // L R Ls Rs C
} }
else if( p_aout->output.output.i_physical_channels & ( AOUT_CHAN_LFE ) ) else if( p_aout->format.i_physical_channels & ( AOUT_CHAN_LFE ) )
{ {
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_18; // L R Ls Rs LFE new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_18; // L R Ls Rs LFE
} }
break; break;
case 6: case 6:
if( p_aout->output.output.i_physical_channels & ( AOUT_CHAN_LFE ) ) if( p_aout->format.i_physical_channels & ( AOUT_CHAN_LFE ) )
{ {
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_20; // L R Ls Rs C LFE new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_20; // L R Ls Rs C LFE
} }
...@@ -528,14 +528,14 @@ static int OpenAnalog( aout_instance_t *p_aout ) ...@@ -528,14 +528,14 @@ static int OpenAnalog( aout_instance_t *p_aout )
} }
/* Set up the format to be used */ /* Set up the format to be used */
DeviceFormat.mSampleRate = p_aout->output.output.i_rate; DeviceFormat.mSampleRate = p_aout->format.i_rate;
DeviceFormat.mFormatID = kAudioFormatLinearPCM; DeviceFormat.mFormatID = kAudioFormatLinearPCM;
/* We use float 32. It's the best supported format by both VLC and Coreaudio */ /* We use float 32. It's the best supported format by both VLC and Coreaudio */
p_aout->output.output.i_format = VLC_CODEC_FL32; p_aout->format.i_format = VLC_CODEC_FL32;
DeviceFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked; DeviceFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
DeviceFormat.mBitsPerChannel = 32; DeviceFormat.mBitsPerChannel = 32;
DeviceFormat.mChannelsPerFrame = aout_FormatNbChannels( &p_aout->output.output ); DeviceFormat.mChannelsPerFrame = aout_FormatNbChannels( &p_aout->format );
/* Calculate framesizes and stuff */ /* Calculate framesizes and stuff */
DeviceFormat.mFramesPerPacket = 1; DeviceFormat.mFramesPerPacket = 1;
...@@ -564,8 +564,8 @@ static int OpenAnalog( aout_instance_t *p_aout ) ...@@ -564,8 +564,8 @@ static int OpenAnalog( aout_instance_t *p_aout )
msg_Dbg( p_aout, STREAM_FORMAT_MSG( "the actual set AU format is " , DeviceFormat ) ); msg_Dbg( p_aout, STREAM_FORMAT_MSG( "the actual set AU format is " , DeviceFormat ) );
/* Do the last VLC aout setups */ /* Do the last VLC aout setups */
aout_FormatPrepare( &p_aout->output.output ); aout_FormatPrepare( &p_aout->format );
p_aout->output.i_nb_samples = FRAMESIZE; p_aout->i_nb_samples = FRAMESIZE;
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
/* set the IOproc callback */ /* set the IOproc callback */
...@@ -608,7 +608,7 @@ static int OpenAnalog( aout_instance_t *p_aout ) ...@@ -608,7 +608,7 @@ static int OpenAnalog( aout_instance_t *p_aout )
*****************************************************************************/ *****************************************************************************/
static int OpenSPDIF( aout_instance_t * p_aout ) static int OpenSPDIF( aout_instance_t * p_aout )
{ {
struct aout_sys_t *p_sys = p_aout->output.p_sys; struct aout_sys_t *p_sys = p_aout->sys;
OSStatus err = noErr; OSStatus err = noErr;
UInt32 i_param_size = 0, b_mix = 0; UInt32 i_param_size = 0, b_mix = 0;
Boolean b_writeable = false; Boolean b_writeable = false;
...@@ -741,7 +741,7 @@ static int OpenSPDIF( aout_instance_t * p_aout ) ...@@ -741,7 +741,7 @@ static int OpenSPDIF( aout_instance_t * p_aout )
if( p_format_list[j].mFormatID == 'IAC3' || if( p_format_list[j].mFormatID == 'IAC3' ||
p_format_list[j].mFormatID == kAudioFormat60958AC3 ) p_format_list[j].mFormatID == kAudioFormat60958AC3 )
{ {
if( p_format_list[j].mSampleRate == p_aout->output.output.i_rate ) if( p_format_list[j].mSampleRate == p_aout->format.i_rate )
{ {
i_requested_rate_format = j; i_requested_rate_format = j;
break; break;
...@@ -776,14 +776,14 @@ static int OpenSPDIF( aout_instance_t * p_aout ) ...@@ -776,14 +776,14 @@ static int OpenSPDIF( aout_instance_t * p_aout )
/* Set the format flags */ /* Set the format flags */
if( p_sys->stream_format.mFormatFlags & kAudioFormatFlagIsBigEndian ) if( p_sys->stream_format.mFormatFlags & kAudioFormatFlagIsBigEndian )
p_aout->output.output.i_format = VLC_CODEC_SPDIFB; p_aout->format.i_format = VLC_CODEC_SPDIFB;
else else
p_aout->output.output.i_format = VLC_CODEC_SPDIFL; p_aout->format.i_format = VLC_CODEC_SPDIFL;
p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->output.output.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
p_aout->output.i_nb_samples = p_aout->output.output.i_frame_length; p_aout->format.i_nb_samples = p_aout->format.i_frame_length;
p_aout->output.output.i_rate = (unsigned int)p_sys->stream_format.mSampleRate; p_aout->format.i_rate = (unsigned int)p_sys->stream_format.mSampleRate;
aout_FormatPrepare( &p_aout->output.output ); aout_FormatPrepare( &p_aout->format );
aout_VolumeNoneInit( p_aout ); aout_VolumeNoneInit( p_aout );
/* Add IOProc callback */ /* Add IOProc callback */
...@@ -827,7 +827,7 @@ static int OpenSPDIF( aout_instance_t * p_aout ) ...@@ -827,7 +827,7 @@ static int OpenSPDIF( aout_instance_t * p_aout )
static void Close( vlc_object_t * p_this ) static void Close( vlc_object_t * p_this )
{ {
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
struct aout_sys_t *p_sys = p_aout->output.p_sys; struct aout_sys_t *p_sys = p_aout->sys;
OSStatus err = noErr; OSStatus err = noErr;
UInt32 i_param_size = 0; UInt32 i_param_size = 0;
...@@ -926,7 +926,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -926,7 +926,7 @@ static void Probe( aout_instance_t * p_aout )
AudioDeviceID *p_devices = NULL; AudioDeviceID *p_devices = NULL;
vlc_value_t val, text; vlc_value_t val, text;
struct aout_sys_t *p_sys = p_aout->output.p_sys; struct aout_sys_t *p_sys = p_aout->sys;
/* Get number of devices */ /* Get number of devices */
AudioObjectPropertyAddress audioDevicesAddress = { kAudioHardwarePropertyDevices, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; AudioObjectPropertyAddress audioDevicesAddress = { kAudioHardwarePropertyDevices, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
...@@ -1262,7 +1262,7 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout, ...@@ -1262,7 +1262,7 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout,
uint32_t i_mData_bytes = 0; uint32_t i_mData_bytes = 0;
aout_instance_t * p_aout = (aout_instance_t *)_p_aout; aout_instance_t * p_aout = (aout_instance_t *)_p_aout;
struct aout_sys_t * p_sys = p_aout->output.p_sys; struct aout_sys_t * p_sys = p_aout->sys;
VLC_UNUSED(ioActionFlags); VLC_UNUSED(ioActionFlags);
VLC_UNUSED(inBusNumber); VLC_UNUSED(inBusNumber);
...@@ -1278,7 +1278,7 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout, ...@@ -1278,7 +1278,7 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout,
current_date = p_sys->clock_diff + current_date = p_sys->clock_diff +
AudioConvertHostTimeToNanos( host_time.mHostTime ) / 1000; AudioConvertHostTimeToNanos( host_time.mHostTime ) / 1000;
//- ((mtime_t) 1000000 / p_aout->output.output.i_rate * 31 ); // 31 = Latency in Frames. retrieve somewhere //- ((mtime_t) 1000000 / p_aout->format.i_rate * 31 ); // 31 = Latency in Frames. retrieve somewhere
if( ioData == NULL && ioData->mNumberBuffers < 1 ) if( ioData == NULL && ioData->mNumberBuffers < 1 )
{ {
...@@ -1296,8 +1296,8 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout, ...@@ -1296,8 +1296,8 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout,
&p_sys->p_remainder_buffer[p_sys->i_read_bytes], &p_sys->p_remainder_buffer[p_sys->i_read_bytes],
i_mData_bytes ); i_mData_bytes );
p_sys->i_read_bytes += i_mData_bytes; p_sys->i_read_bytes += i_mData_bytes;
current_date += (mtime_t) ( (mtime_t) 1000000 / p_aout->output.output.i_rate ) * current_date += (mtime_t) ( (mtime_t) 1000000 / p_aout->format.i_rate ) *
( i_mData_bytes / 4 / aout_FormatNbChannels( &p_aout->output.output ) ); // 4 is fl32 specific ( i_mData_bytes / 4 / aout_FormatNbChannels( &p_aout->format ) ); // 4 is fl32 specific
if( p_sys->i_read_bytes >= p_sys->i_total_bytes ) if( p_sys->i_read_bytes >= p_sys->i_total_bytes )
p_sys->i_read_bytes = p_sys->i_total_bytes = 0; p_sys->i_read_bytes = p_sys->i_total_bytes = 0;
...@@ -1329,8 +1329,8 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout, ...@@ -1329,8 +1329,8 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout,
else else
{ {
/* update current_date */ /* update current_date */
current_date += (mtime_t) ( (mtime_t) 1000000 / p_aout->output.output.i_rate ) * current_date += (mtime_t) ( (mtime_t) 1000000 / p_aout->format.i_rate ) *
( i_second_mData_bytes / 4 / aout_FormatNbChannels( &p_aout->output.output ) ); // 4 is fl32 specific ( i_second_mData_bytes / 4 / aout_FormatNbChannels( &p_aout->format ) ); // 4 is fl32 specific
} }
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
} }
...@@ -1359,7 +1359,7 @@ static OSStatus RenderCallbackSPDIF( AudioDeviceID inDevice, ...@@ -1359,7 +1359,7 @@ static OSStatus RenderCallbackSPDIF( AudioDeviceID inDevice,
mtime_t current_date; mtime_t current_date;
aout_instance_t * p_aout = (aout_instance_t *)threadGlobals; aout_instance_t * p_aout = (aout_instance_t *)threadGlobals;
struct aout_sys_t * p_sys = p_aout->output.p_sys; struct aout_sys_t * p_sys = p_aout->sys;
VLC_UNUSED(inDevice); VLC_UNUSED(inDevice);
VLC_UNUSED(inInputData); VLC_UNUSED(inInputData);
...@@ -1372,7 +1372,7 @@ static OSStatus RenderCallbackSPDIF( AudioDeviceID inDevice, ...@@ -1372,7 +1372,7 @@ static OSStatus RenderCallbackSPDIF( AudioDeviceID inDevice,
current_date = p_sys->clock_diff + current_date = p_sys->clock_diff +
AudioConvertHostTimeToNanos( inOutputTime->mHostTime ) / 1000; AudioConvertHostTimeToNanos( inOutputTime->mHostTime ) / 1000;
//- ((mtime_t) 1000000 / p_aout->output.output.i_rate * 31 ); // 31 = Latency in Frames. retrieve somewhere //- ((mtime_t) 1000000 / p_aout->format.i_rate * 31 ); // 31 = Latency in Frames. retrieve somewhere
p_buffer = aout_OutputNextBuffer( p_aout, current_date, true ); p_buffer = aout_OutputNextBuffer( p_aout, current_date, true );
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "windows_audio_common.h" #include "windows_audio_common.h"
#define FRAME_SIZE ((int)p_aout->output.output.i_rate/20) /* Size in samples */ #define FRAME_SIZE ((int)p_aout->format.i_rate/20) /* Size in samples */
/***************************************************************************** /*****************************************************************************
* notification_thread_t: DirectX event thread * notification_thread_t: DirectX event thread
...@@ -163,18 +163,18 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -163,18 +163,18 @@ static int OpenAudio( vlc_object_t *p_this )
msg_Dbg( p_aout, "Opening DirectSound Audio Output" ); msg_Dbg( p_aout, "Opening DirectSound Audio Output" );
/* Allocate structure */ /* Allocate structure */
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) ); p_aout->sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->output.p_sys == NULL ) if( p_aout->sys == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
/* Initialize some variables */ /* Initialize some variables */
p_aout->output.p_sys->p_dsobject = NULL; p_aout->sys->p_dsobject = NULL;
p_aout->output.p_sys->p_dsbuffer = NULL; p_aout->sys->p_dsbuffer = NULL;
p_aout->output.p_sys->p_notif = NULL; p_aout->sys->p_notif = NULL;
p_aout->output.p_sys->b_playing = 0; p_aout->sys->b_playing = 0;
p_aout->output.pf_play = Play; p_aout->pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->pf_pause = NULL;
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
/* Retrieve config values */ /* Retrieve config values */
...@@ -198,9 +198,9 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -198,9 +198,9 @@ static int OpenAudio( vlc_object_t *p_this )
i = 0; i = 0;
} }
free( psz_speaker ); free( psz_speaker );
p_aout->output.p_sys->i_speaker_setup = i; p_aout->sys->i_speaker_setup = i;
p_aout->output.p_sys->p_device_guid = 0; p_aout->sys->p_device_guid = 0;
/* Initialise DirectSound */ /* Initialise DirectSound */
if( InitDirectSound( p_aout ) ) if( InitDirectSound( p_aout ) )
...@@ -223,24 +223,23 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -223,24 +223,23 @@ static int OpenAudio( vlc_object_t *p_this )
/* Open the device */ /* Open the device */
if( val.i_int == AOUT_VAR_SPDIF ) if( val.i_int == AOUT_VAR_SPDIF )
{ {
p_aout->output.output.i_format = VLC_CODEC_SPDIFL; p_aout->format.i_format = VLC_CODEC_SPDIFL;
/* Calculate the frame size in bytes */ /* Calculate the frame size in bytes */
p_aout->output.i_nb_samples = A52_FRAME_NB; p_aout->i_nb_samples = A52_FRAME_NB;
p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->output.output.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
p_aout->output.p_sys->i_frame_size = p_aout->sys->i_frame_size = p_aout->format.i_bytes_per_frame;
p_aout->output.output.i_bytes_per_frame;
if( CreateDSBuffer( p_aout, VLC_CODEC_SPDIFL, if( CreateDSBuffer( p_aout, VLC_CODEC_SPDIFL,
p_aout->output.output.i_physical_channels, p_aout->format.i_physical_channels,
aout_FormatNbChannels( &p_aout->output.output ), aout_FormatNbChannels( &p_aout->format ),
p_aout->output.output.i_rate, p_aout->format.i_rate,
p_aout->output.p_sys->i_frame_size, false ) p_aout->sys->i_frame_size, false )
!= VLC_SUCCESS ) != VLC_SUCCESS )
{ {
msg_Err( p_aout, "cannot open directx audio device" ); msg_Err( p_aout, "cannot open directx audio device" );
free( p_aout->output.p_sys ); free( p_aout->sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -250,14 +249,14 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -250,14 +249,14 @@ static int OpenAudio( vlc_object_t *p_this )
{ {
if( val.i_int == AOUT_VAR_5_1 ) if( val.i_int == AOUT_VAR_5_1 )
{ {
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_LFE; | AOUT_CHAN_LFE;
} }
else if( val.i_int == AOUT_VAR_7_1 ) else if( val.i_int == AOUT_VAR_7_1 )
{ {
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT | AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT
...@@ -265,62 +264,61 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -265,62 +264,61 @@ static int OpenAudio( vlc_object_t *p_this )
} }
else if( val.i_int == AOUT_VAR_3F2R ) else if( val.i_int == AOUT_VAR_3F2R )
{ {
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
} }
else if( val.i_int == AOUT_VAR_2F2R ) else if( val.i_int == AOUT_VAR_2F2R )
{ {
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
} }
else if( val.i_int == AOUT_VAR_MONO ) else if( val.i_int == AOUT_VAR_MONO )
{ {
p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; p_aout->format.i_physical_channels = AOUT_CHAN_CENTER;
} }
else else
{ {
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
} }
if( CreateDSBufferPCM( p_aout, &p_aout->output.output.i_format, if( CreateDSBufferPCM( p_aout, &p_aout->format.i_format,
p_aout->output.output.i_physical_channels, p_aout->format.i_physical_channels,
aout_FormatNbChannels( &p_aout->output.output ), aout_FormatNbChannels( &p_aout->format ),
p_aout->output.output.i_rate, false ) p_aout->format.i_rate, false )
!= VLC_SUCCESS ) != VLC_SUCCESS )
{ {
msg_Err( p_aout, "cannot open directx audio device" ); msg_Err( p_aout, "cannot open directx audio device" );
free( p_aout->output.p_sys ); free( p_aout->sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Calculate the frame size in bytes */ /* Calculate the frame size in bytes */
p_aout->output.i_nb_samples = FRAME_SIZE; p_aout->i_nb_samples = FRAME_SIZE;
aout_FormatPrepare( &p_aout->output.output ); aout_FormatPrepare( &p_aout->format );
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
} }
/* Now we need to setup our DirectSound play notification structure */ /* Now we need to setup our DirectSound play notification structure */
p_aout->output.p_sys->p_notif = calloc( 1, sizeof( *p_aout->output.p_sys->p_notif ) ); p_aout->sys->p_notif = calloc( 1, sizeof( *p_aout->sys->p_notif ) );
p_aout->output.p_sys->p_notif->p_aout = p_aout; p_aout->sys->p_notif->p_aout = p_aout;
vlc_atomic_set(&p_aout->output.p_sys->p_notif->abort, 0); vlc_atomic_set(&p_aout->sys->p_notif->abort, 0);
p_aout->output.p_sys->p_notif->event = CreateEvent( 0, FALSE, FALSE, 0 ); p_aout->sys->p_notif->event = CreateEvent( 0, FALSE, FALSE, 0 );
p_aout->output.p_sys->p_notif->i_frame_size = p_aout->sys->p_notif->i_frame_size = p_aout->sys->i_frame_size;
p_aout->output.p_sys->i_frame_size;
/* then launch the notification thread */ /* then launch the notification thread */
msg_Dbg( p_aout, "creating DirectSoundThread" ); msg_Dbg( p_aout, "creating DirectSoundThread" );
if( vlc_clone( &p_aout->output.p_sys->p_notif->thread, if( vlc_clone( &p_aout->sys->p_notif->thread,
DirectSoundThread, p_aout->output.p_sys->p_notif, DirectSoundThread, p_aout->sys->p_notif,
VLC_THREAD_PRIORITY_HIGHEST ) ) VLC_THREAD_PRIORITY_HIGHEST ) )
{ {
msg_Err( p_aout, "cannot create DirectSoundThread" ); msg_Err( p_aout, "cannot create DirectSoundThread" );
CloseHandle( p_aout->output.p_sys->p_notif->event ); CloseHandle( p_aout->sys->p_notif->event );
free( p_aout->output.p_sys->p_notif ); free( p_aout->sys->p_notif );
p_aout->output.p_sys->p_notif = NULL; p_aout->sys->p_notif = NULL;
goto error; goto error;
} }
...@@ -350,10 +348,10 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -350,10 +348,10 @@ static void Probe( aout_instance_t * p_aout )
i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT | AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT |
AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE; AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE;
if( p_aout->output.output.i_physical_channels == i_physical_channels ) if( p_aout->format.i_physical_channels == i_physical_channels )
{ {
if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 6, if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 6,
p_aout->output.output.i_rate, true ) p_aout->format.i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
val.i_int = AOUT_VAR_5_1; val.i_int = AOUT_VAR_5_1;
...@@ -371,10 +369,10 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -371,10 +369,10 @@ static void Probe( aout_instance_t * p_aout )
AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT | AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT |
AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT | AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT |
AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE; AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE;
if( p_aout->output.output.i_physical_channels == i_physical_channels ) if( p_aout->format.i_physical_channels == i_physical_channels )
{ {
if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 8, if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 8,
p_aout->output.output.i_rate, true ) p_aout->format.i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
val.i_int = AOUT_VAR_7_1; val.i_int = AOUT_VAR_7_1;
...@@ -391,10 +389,10 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -391,10 +389,10 @@ static void Probe( aout_instance_t * p_aout )
i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT | AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT |
AOUT_CHAN_REARRIGHT; AOUT_CHAN_REARRIGHT;
if( p_aout->output.output.i_physical_channels == i_physical_channels ) if( p_aout->format.i_physical_channels == i_physical_channels )
{ {
if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 5, if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 5,
p_aout->output.output.i_rate, true ) p_aout->format.i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
val.i_int = AOUT_VAR_3F2R; val.i_int = AOUT_VAR_3F2R;
...@@ -413,11 +411,11 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -413,11 +411,11 @@ static void Probe( aout_instance_t * p_aout )
/* Test for 2 Front 2 Rear support */ /* Test for 2 Front 2 Rear support */
i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
if( ( p_aout->output.output.i_physical_channels & i_physical_channels ) if( ( p_aout->format.i_physical_channels & i_physical_channels )
== i_physical_channels ) == i_physical_channels )
{ {
if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 4, if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 4,
p_aout->output.output.i_rate, true ) p_aout->format.i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
val.i_int = AOUT_VAR_2F2R; val.i_int = AOUT_VAR_2F2R;
...@@ -436,7 +434,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -436,7 +434,7 @@ static void Probe( aout_instance_t * p_aout )
/* Test for stereo support */ /* Test for stereo support */
i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 2, if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 2,
p_aout->output.output.i_rate, true ) p_aout->format.i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
val.i_int = AOUT_VAR_STEREO; val.i_int = AOUT_VAR_STEREO;
...@@ -454,7 +452,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -454,7 +452,7 @@ static void Probe( aout_instance_t * p_aout )
/* Test for mono support */ /* Test for mono support */
i_physical_channels = AOUT_CHAN_CENTER; i_physical_channels = AOUT_CHAN_CENTER;
if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 1, if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 1,
p_aout->output.output.i_rate, true ) p_aout->format.i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
val.i_int = AOUT_VAR_MONO; val.i_int = AOUT_VAR_MONO;
...@@ -465,7 +463,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -465,7 +463,7 @@ static void Probe( aout_instance_t * p_aout )
/* Check the speaker configuration to determine which channel config should /* Check the speaker configuration to determine which channel config should
* be the default */ * be the default */
if FAILED( IDirectSound_GetSpeakerConfig( p_aout->output.p_sys->p_dsobject, if FAILED( IDirectSound_GetSpeakerConfig( p_aout->sys->p_dsobject,
&ui_speaker_config ) ) &ui_speaker_config ) )
{ {
ui_speaker_config = DSSPEAKER_STEREO; ui_speaker_config = DSSPEAKER_STEREO;
...@@ -502,7 +500,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -502,7 +500,7 @@ static void Probe( aout_instance_t * p_aout )
} }
/* Check if we want to override speaker config */ /* Check if we want to override speaker config */
switch( p_aout->output.p_sys->i_speaker_setup ) switch( p_aout->sys->i_speaker_setup )
{ {
case 0: /* Default value aka Windows default speaker setup */ case 0: /* Default value aka Windows default speaker setup */
break; break;
...@@ -534,12 +532,12 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -534,12 +532,12 @@ static void Probe( aout_instance_t * p_aout )
var_Set( p_aout, "audio-device", val ); var_Set( p_aout, "audio-device", val );
/* Test for SPDIF support */ /* Test for SPDIF support */
if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) if ( AOUT_FMT_NON_LINEAR( &p_aout->format ) )
{ {
if( CreateDSBuffer( p_aout, VLC_CODEC_SPDIFL, if( CreateDSBuffer( p_aout, VLC_CODEC_SPDIFL,
p_aout->output.output.i_physical_channels, p_aout->format.i_physical_channels,
aout_FormatNbChannels( &p_aout->output.output ), aout_FormatNbChannels( &p_aout->format ),
p_aout->output.output.i_rate, p_aout->format.i_rate,
AOUT_SPDIF_SIZE, true ) AOUT_SPDIF_SIZE, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
...@@ -572,26 +570,26 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -572,26 +570,26 @@ static void Probe( aout_instance_t * p_aout )
*****************************************************************************/ *****************************************************************************/
static void Play( aout_instance_t *p_aout ) static void Play( aout_instance_t *p_aout )
{ {
if( !p_aout->output.p_sys->b_playing ) if( !p_aout->sys->b_playing )
{ {
aout_buffer_t *p_buffer; aout_buffer_t *p_buffer;
p_aout->output.p_sys->b_playing = 1; p_aout->sys->b_playing = 1;
/* get the playing date of the first aout buffer */ /* get the playing date of the first aout buffer */
p_aout->output.p_sys->p_notif->start_date = p_aout->sys->p_notif->start_date =
aout_FifoFirstDate( &p_aout->output.fifo ); aout_FifoFirstDate( &p_aout->fifo );
/* fill in the first samples */ /* fill in the first samples */
for( int i = 0; i < FRAMES_NUM; i++ ) for( int i = 0; i < FRAMES_NUM; i++ )
{ {
p_buffer = aout_FifoPop( &p_aout->output.fifo ); p_buffer = aout_FifoPop( &p_aout->fifo );
if( !p_buffer ) break; if( !p_buffer ) break;
FillBuffer( p_aout, i, p_buffer ); FillBuffer( p_aout, i, p_buffer );
} }
/* wake up the audio output thread */ /* wake up the audio output thread */
SetEvent( p_aout->output.p_sys->p_notif->event ); SetEvent( p_aout->sys->p_notif->event );
} }
} }
...@@ -601,14 +599,14 @@ static void Play( aout_instance_t *p_aout ) ...@@ -601,14 +599,14 @@ static void Play( aout_instance_t *p_aout )
static void CloseAudio( vlc_object_t *p_this ) static void CloseAudio( vlc_object_t *p_this )
{ {
aout_instance_t * p_aout = (aout_instance_t *)p_this; aout_instance_t * p_aout = (aout_instance_t *)p_this;
aout_sys_t *p_sys = p_aout->output.p_sys; aout_sys_t *p_sys = p_aout->sys;
msg_Dbg( p_aout, "closing audio device" ); msg_Dbg( p_aout, "closing audio device" );
/* kill the position notification thread, if any */ /* kill the position notification thread, if any */
if( p_sys->p_notif ) if( p_sys->p_notif )
{ {
vlc_atomic_set(&p_aout->output.p_sys->p_notif->abort, 1); vlc_atomic_set(&p_aout->sys->p_notif->abort, 1);
/* wake up the audio thread if needed */ /* wake up the audio thread if needed */
if( !p_sys->b_playing ) SetEvent( p_sys->p_notif->event ); if( !p_sys->b_playing ) SetEvent( p_sys->p_notif->event );
...@@ -625,7 +623,7 @@ static void CloseAudio( vlc_object_t *p_this ) ...@@ -625,7 +623,7 @@ static void CloseAudio( vlc_object_t *p_this )
/* free DSOUND.DLL */ /* free DSOUND.DLL */
if( p_sys->hdsound_dll ) FreeLibrary( p_sys->hdsound_dll ); if( p_sys->hdsound_dll ) FreeLibrary( p_sys->hdsound_dll );
free( p_aout->output.p_sys->p_device_guid ); free( p_aout->sys->p_device_guid );
free( p_sys ); free( p_sys );
} }
...@@ -642,22 +640,22 @@ static int CALLBACK CallBackDirectSoundEnum( LPGUID p_guid, LPCWSTR psz_desc, ...@@ -642,22 +640,22 @@ static int CALLBACK CallBackDirectSoundEnum( LPGUID p_guid, LPCWSTR psz_desc,
char *psz_device = FromWide( psz_desc ); char *psz_device = FromWide( psz_desc );
msg_Dbg( p_aout, "found device: %s", psz_device ); msg_Dbg( p_aout, "found device: %s", psz_device );
if( p_aout->output.p_sys->psz_device && if( p_aout->sys->psz_device &&
!strcmp(p_aout->output.p_sys->psz_device, psz_device) && p_guid ) !strcmp(p_aout->sys->psz_device, psz_device) && p_guid )
{ {
/* Use the device corresponding to psz_device */ /* Use the device corresponding to psz_device */
p_aout->output.p_sys->p_device_guid = malloc( sizeof( GUID ) ); p_aout->sys->p_device_guid = malloc( sizeof( GUID ) );
*p_aout->output.p_sys->p_device_guid = *p_guid; *p_aout->sys->p_device_guid = *p_guid;
msg_Dbg( p_aout, "using device: %s", psz_device ); msg_Dbg( p_aout, "using device: %s", psz_device );
} }
else else
{ {
/* If no default device has been selected, chose the first one */ /* If no default device has been selected, chose the first one */
if( !p_aout->output.p_sys->psz_device && p_guid ) if( !p_aout->sys->psz_device && p_guid )
{ {
p_aout->output.p_sys->psz_device = strdup( psz_device ); p_aout->sys->psz_device = strdup( psz_device );
p_aout->output.p_sys->p_device_guid = malloc( sizeof( GUID ) ); p_aout->sys->p_device_guid = malloc( sizeof( GUID ) );
*p_aout->output.p_sys->p_device_guid = *p_guid; *p_aout->sys->p_device_guid = *p_guid;
msg_Dbg( p_aout, "using device: %s", psz_device ); msg_Dbg( p_aout, "using device: %s", psz_device );
} }
} }
...@@ -674,15 +672,15 @@ static int InitDirectSound( aout_instance_t *p_aout ) ...@@ -674,15 +672,15 @@ static int InitDirectSound( aout_instance_t *p_aout )
HRESULT (WINAPI *OurDirectSoundCreate)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN); HRESULT (WINAPI *OurDirectSoundCreate)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
HRESULT (WINAPI *OurDirectSoundEnumerate)(LPDSENUMCALLBACKW, LPVOID); HRESULT (WINAPI *OurDirectSoundEnumerate)(LPDSENUMCALLBACKW, LPVOID);
p_aout->output.p_sys->hdsound_dll = LoadLibrary("DSOUND.DLL"); p_aout->sys->hdsound_dll = LoadLibrary("DSOUND.DLL");
if( p_aout->output.p_sys->hdsound_dll == NULL ) if( p_aout->sys->hdsound_dll == NULL )
{ {
msg_Warn( p_aout, "cannot open DSOUND.DLL" ); msg_Warn( p_aout, "cannot open DSOUND.DLL" );
goto error; goto error;
} }
OurDirectSoundCreate = (void *) OurDirectSoundCreate = (void *)
GetProcAddress( p_aout->output.p_sys->hdsound_dll, GetProcAddress( p_aout->sys->hdsound_dll,
"DirectSoundCreate" ); "DirectSoundCreate" );
if( OurDirectSoundCreate == NULL ) if( OurDirectSoundCreate == NULL )
{ {
...@@ -692,11 +690,11 @@ static int InitDirectSound( aout_instance_t *p_aout ) ...@@ -692,11 +690,11 @@ static int InitDirectSound( aout_instance_t *p_aout )
/* Get DirectSoundEnumerate */ /* Get DirectSoundEnumerate */
OurDirectSoundEnumerate = (void *) OurDirectSoundEnumerate = (void *)
GetProcAddress( p_aout->output.p_sys->hdsound_dll, GetProcAddress( p_aout->sys->hdsound_dll,
"DirectSoundEnumerateW" ); "DirectSoundEnumerateW" );
if( OurDirectSoundEnumerate ) if( OurDirectSoundEnumerate )
{ {
p_aout->output.p_sys->psz_device = var_InheritString(p_aout, "directx-audio-device-name"); p_aout->sys->psz_device = var_InheritString(p_aout, "directx-audio-device-name");
/* Attempt enumeration */ /* Attempt enumeration */
if( FAILED( OurDirectSoundEnumerate( CallBackDirectSoundEnum, if( FAILED( OurDirectSoundEnumerate( CallBackDirectSoundEnum,
p_aout ) ) ) p_aout ) ) )
...@@ -706,8 +704,8 @@ static int InitDirectSound( aout_instance_t *p_aout ) ...@@ -706,8 +704,8 @@ static int InitDirectSound( aout_instance_t *p_aout )
} }
/* Create the direct sound object */ /* Create the direct sound object */
if FAILED( OurDirectSoundCreate( p_aout->output.p_sys->p_device_guid, if FAILED( OurDirectSoundCreate( p_aout->sys->p_device_guid,
&p_aout->output.p_sys->p_dsobject, &p_aout->sys->p_dsobject,
NULL ) ) NULL ) )
{ {
msg_Warn( p_aout, "cannot create a direct sound device" ); msg_Warn( p_aout, "cannot create a direct sound device" );
...@@ -724,7 +722,7 @@ static int InitDirectSound( aout_instance_t *p_aout ) ...@@ -724,7 +722,7 @@ static int InitDirectSound( aout_instance_t *p_aout )
* sound without any video, and so what window handle should we use ??? * sound without any video, and so what window handle should we use ???
* The hack for now is to use the Desktop window handle - it seems to be * The hack for now is to use the Desktop window handle - it seems to be
* working */ * working */
if( IDirectSound_SetCooperativeLevel( p_aout->output.p_sys->p_dsobject, if( IDirectSound_SetCooperativeLevel( p_aout->sys->p_dsobject,
GetDesktopWindow(), GetDesktopWindow(),
DSSCL_EXCLUSIVE) ) DSSCL_EXCLUSIVE) )
{ {
...@@ -734,11 +732,11 @@ static int InitDirectSound( aout_instance_t *p_aout ) ...@@ -734,11 +732,11 @@ static int InitDirectSound( aout_instance_t *p_aout )
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
p_aout->output.p_sys->p_dsobject = NULL; p_aout->sys->p_dsobject = NULL;
if( p_aout->output.p_sys->hdsound_dll ) if( p_aout->sys->hdsound_dll )
{ {
FreeLibrary( p_aout->output.p_sys->hdsound_dll ); FreeLibrary( p_aout->sys->hdsound_dll );
p_aout->output.p_sys->hdsound_dll = NULL; p_aout->sys->hdsound_dll = NULL;
} }
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -809,8 +807,8 @@ static int CreateDSBuffer( aout_instance_t *p_aout, int i_format, ...@@ -809,8 +807,8 @@ static int CreateDSBuffer( aout_instance_t *p_aout, int i_format,
waveformat.Format.nAvgBytesPerSec = waveformat.Format.nAvgBytesPerSec =
waveformat.Format.nSamplesPerSec * waveformat.Format.nBlockAlign; waveformat.Format.nSamplesPerSec * waveformat.Format.nBlockAlign;
p_aout->output.p_sys->i_bits_per_sample = waveformat.Format.wBitsPerSample; p_aout->sys->i_bits_per_sample = waveformat.Format.wBitsPerSample;
p_aout->output.p_sys->i_channels = i_nb_channels; p_aout->sys->i_channels = i_nb_channels;
/* Then fill in the direct sound descriptor */ /* Then fill in the direct sound descriptor */
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
...@@ -837,16 +835,16 @@ static int CreateDSBuffer( aout_instance_t *p_aout, int i_format, ...@@ -837,16 +835,16 @@ static int CreateDSBuffer( aout_instance_t *p_aout, int i_format,
dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&waveformat; dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&waveformat;
if FAILED( IDirectSound_CreateSoundBuffer( if FAILED( IDirectSound_CreateSoundBuffer(
p_aout->output.p_sys->p_dsobject, &dsbdesc, p_aout->sys->p_dsobject, &dsbdesc,
&p_aout->output.p_sys->p_dsbuffer, NULL) ) &p_aout->sys->p_dsbuffer, NULL) )
{ {
if( dsbdesc.dwFlags & DSBCAPS_LOCHARDWARE ) if( dsbdesc.dwFlags & DSBCAPS_LOCHARDWARE )
{ {
/* Try without DSBCAPS_LOCHARDWARE */ /* Try without DSBCAPS_LOCHARDWARE */
dsbdesc.dwFlags &= ~DSBCAPS_LOCHARDWARE; dsbdesc.dwFlags &= ~DSBCAPS_LOCHARDWARE;
if FAILED( IDirectSound_CreateSoundBuffer( if FAILED( IDirectSound_CreateSoundBuffer(
p_aout->output.p_sys->p_dsobject, &dsbdesc, p_aout->sys->p_dsobject, &dsbdesc,
&p_aout->output.p_sys->p_dsbuffer, NULL) ) &p_aout->sys->p_dsbuffer, NULL) )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -862,19 +860,19 @@ static int CreateDSBuffer( aout_instance_t *p_aout, int i_format, ...@@ -862,19 +860,19 @@ static int CreateDSBuffer( aout_instance_t *p_aout, int i_format,
/* Stop here if we were just probing */ /* Stop here if we were just probing */
if( b_probe ) if( b_probe )
{ {
IDirectSoundBuffer_Release( p_aout->output.p_sys->p_dsbuffer ); IDirectSoundBuffer_Release( p_aout->sys->p_dsbuffer );
p_aout->output.p_sys->p_dsbuffer = NULL; p_aout->sys->p_dsbuffer = NULL;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
p_aout->output.p_sys->i_frame_size = i_bytes_per_frame; p_aout->sys->i_frame_size = i_bytes_per_frame;
p_aout->output.p_sys->i_channel_mask = waveformat.dwChannelMask; p_aout->sys->i_channel_mask = waveformat.dwChannelMask;
p_aout->output.p_sys->b_chan_reorder = p_aout->sys->b_chan_reorder =
aout_CheckChannelReorder( pi_channels_in, pi_channels_out, aout_CheckChannelReorder( pi_channels_in, pi_channels_out,
waveformat.dwChannelMask, i_nb_channels, waveformat.dwChannelMask, i_nb_channels,
p_aout->output.p_sys->pi_chan_table ); p_aout->sys->pi_chan_table );
if( p_aout->output.p_sys->b_chan_reorder ) if( p_aout->sys->b_chan_reorder )
{ {
msg_Dbg( p_aout, "channel reordering needed" ); msg_Dbg( p_aout, "channel reordering needed" );
} }
...@@ -927,10 +925,10 @@ static int CreateDSBufferPCM( aout_instance_t *p_aout, vlc_fourcc_t *i_format, ...@@ -927,10 +925,10 @@ static int CreateDSBufferPCM( aout_instance_t *p_aout, vlc_fourcc_t *i_format,
*****************************************************************************/ *****************************************************************************/
static void DestroyDSBuffer( aout_instance_t *p_aout ) static void DestroyDSBuffer( aout_instance_t *p_aout )
{ {
if( p_aout->output.p_sys->p_dsbuffer ) if( p_aout->sys->p_dsbuffer )
{ {
IDirectSoundBuffer_Release( p_aout->output.p_sys->p_dsbuffer ); IDirectSoundBuffer_Release( p_aout->sys->p_dsbuffer );
p_aout->output.p_sys->p_dsbuffer = NULL; p_aout->sys->p_dsbuffer = NULL;
} }
} }
...@@ -942,8 +940,8 @@ static void DestroyDSBuffer( aout_instance_t *p_aout ) ...@@ -942,8 +940,8 @@ static void DestroyDSBuffer( aout_instance_t *p_aout )
static int FillBuffer( aout_instance_t *p_aout, int i_frame, static int FillBuffer( aout_instance_t *p_aout, int i_frame,
aout_buffer_t *p_buffer ) aout_buffer_t *p_buffer )
{ {
notification_thread_t *p_notif = p_aout->output.p_sys->p_notif; notification_thread_t *p_notif = p_aout->sys->p_notif;
aout_sys_t *p_sys = p_aout->output.p_sys; aout_sys_t *p_sys = p_aout->sys;
void *p_write_position, *p_wrap_around; void *p_write_position, *p_wrap_around;
unsigned long l_bytes1, l_bytes2; unsigned long l_bytes1, l_bytes2;
HRESULT dsresult; HRESULT dsresult;
...@@ -1018,7 +1016,7 @@ static void* DirectSoundThread( void *data ) ...@@ -1018,7 +1016,7 @@ static void* DirectSoundThread( void *data )
int canc = vlc_savecancel (); int canc = vlc_savecancel ();
/* We don't want any resampling when using S/PDIF output */ /* We don't want any resampling when using S/PDIF output */
bool b_sleek = (p_aout->output.output.i_format == VLC_CODEC_SPDIFL); bool b_sleek = (p_aout->format.i_format == VLC_CODEC_SPDIFL);
msg_Dbg( p_aout, "DirectSoundThread ready" ); msg_Dbg( p_aout, "DirectSoundThread ready" );
...@@ -1031,15 +1029,15 @@ static void* DirectSoundThread( void *data ) ...@@ -1031,15 +1029,15 @@ static void* DirectSoundThread( void *data )
mwait( p_notif->start_date - AOUT_MAX_PTS_ADVANCE / 2 ); mwait( p_notif->start_date - AOUT_MAX_PTS_ADVANCE / 2 );
/* start playing the buffer */ /* start playing the buffer */
dsresult = IDirectSoundBuffer_Play( p_aout->output.p_sys->p_dsbuffer, dsresult = IDirectSoundBuffer_Play( p_aout->sys->p_dsbuffer,
0, /* Unused */ 0, /* Unused */
0, /* Unused */ 0, /* Unused */
DSBPLAY_LOOPING ); /* Flags */ DSBPLAY_LOOPING ); /* Flags */
if( dsresult == DSERR_BUFFERLOST ) if( dsresult == DSERR_BUFFERLOST )
{ {
IDirectSoundBuffer_Restore( p_aout->output.p_sys->p_dsbuffer ); IDirectSoundBuffer_Restore( p_aout->sys->p_dsbuffer );
dsresult = IDirectSoundBuffer_Play( dsresult = IDirectSoundBuffer_Play(
p_aout->output.p_sys->p_dsbuffer, p_aout->sys->p_dsbuffer,
0, /* Unused */ 0, /* Unused */
0, /* Unused */ 0, /* Unused */
DSBPLAY_LOOPING ); /* Flags */ DSBPLAY_LOOPING ); /* Flags */
...@@ -1055,7 +1053,7 @@ static void* DirectSoundThread( void *data ) ...@@ -1055,7 +1053,7 @@ static void* DirectSoundThread( void *data )
{ {
DWORD l_read; DWORD l_read;
int l_queued = 0, l_free_slots; int l_queued = 0, l_free_slots;
unsigned i_frame_siz = p_aout->output.i_nb_samples; unsigned i_frame_siz = p_aout->i_nb_samples;
mtime_t mtime = mdate(); mtime_t mtime = mdate();
int i; int i;
...@@ -1065,7 +1063,7 @@ static void* DirectSoundThread( void *data ) ...@@ -1065,7 +1063,7 @@ static void* DirectSoundThread( void *data )
/* Find out current play position */ /* Find out current play position */
if FAILED( IDirectSoundBuffer_GetCurrentPosition( if FAILED( IDirectSoundBuffer_GetCurrentPosition(
p_aout->output.p_sys->p_dsbuffer, &l_read, NULL ) ) p_aout->sys->p_dsbuffer, &l_read, NULL ) )
{ {
msg_Err( p_aout, "GetCurrentPosition() failed!" ); msg_Err( p_aout, "GetCurrentPosition() failed!" );
l_read = 0; l_read = 0;
...@@ -1073,15 +1071,15 @@ static void* DirectSoundThread( void *data ) ...@@ -1073,15 +1071,15 @@ static void* DirectSoundThread( void *data )
/* Detect underruns */ /* Detect underruns */
if( l_queued && mtime - last_time > if( l_queued && mtime - last_time >
INT64_C(1000000) * l_queued / p_aout->output.output.i_rate ) INT64_C(1000000) * l_queued / p_aout->format.i_rate )
{ {
msg_Dbg( p_aout, "detected underrun!" ); msg_Dbg( p_aout, "detected underrun!" );
} }
last_time = mtime; last_time = mtime;
/* Try to fill in as many frame buffers as possible */ /* Try to fill in as many frame buffers as possible */
l_read /= (p_aout->output.output.i_bytes_per_frame / l_read /= (p_aout->format.i_bytes_per_frame /
p_aout->output.output.i_frame_length); p_aout->format.i_frame_length);
l_queued = p_notif->i_write_slot * i_frame_siz - l_read; l_queued = p_notif->i_write_slot * i_frame_siz - l_read;
if( l_queued < 0 ) l_queued += (i_frame_siz * FRAMES_NUM); if( l_queued < 0 ) l_queued += (i_frame_siz * FRAMES_NUM);
l_free_slots = (FRAMES_NUM * i_frame_siz - l_queued) / i_frame_siz; l_free_slots = (FRAMES_NUM * i_frame_siz - l_queued) / i_frame_siz;
...@@ -1090,7 +1088,7 @@ static void* DirectSoundThread( void *data ) ...@@ -1090,7 +1088,7 @@ static void* DirectSoundThread( void *data )
{ {
aout_buffer_t *p_buffer = aout_OutputNextBuffer( p_aout, aout_buffer_t *p_buffer = aout_OutputNextBuffer( p_aout,
mtime + INT64_C(1000000) * (i * i_frame_siz + l_queued) / mtime + INT64_C(1000000) * (i * i_frame_siz + l_queued) /
p_aout->output.output.i_rate, b_sleek ); p_aout->format.i_rate, b_sleek );
/* If there is no audio data available and we have some buffered /* If there is no audio data available and we have some buffered
* already, then just wait for the next time */ * already, then just wait for the next time */
...@@ -1102,11 +1100,11 @@ static void* DirectSoundThread( void *data ) ...@@ -1102,11 +1100,11 @@ static void* DirectSoundThread( void *data )
/* Sleep a reasonable amount of time */ /* Sleep a reasonable amount of time */
l_queued += (i * i_frame_siz); l_queued += (i * i_frame_siz);
msleep( INT64_C(1000000) * l_queued / p_aout->output.output.i_rate / 2 ); msleep( INT64_C(1000000) * l_queued / p_aout->format.i_rate / 2 );
} }
/* make sure the buffer isn't playing */ /* make sure the buffer isn't playing */
IDirectSoundBuffer_Stop( p_aout->output.p_sys->p_dsbuffer ); IDirectSoundBuffer_Stop( p_aout->sys->p_dsbuffer );
/* free the event */ /* free the event */
CloseHandle( p_notif->event ); CloseHandle( p_notif->event );
......
...@@ -146,24 +146,24 @@ static int Open( vlc_object_t * p_this ) ...@@ -146,24 +146,24 @@ static int Open( vlc_object_t * p_this )
} }
/* Allocate structure */ /* Allocate structure */
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) ); p_aout->sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->output.p_sys == NULL ) if( p_aout->sys == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
if( !strcmp( psz_name, "-" ) ) if( !strcmp( psz_name, "-" ) )
p_aout->output.p_sys->p_file = stdout; p_aout->sys->p_file = stdout;
else else
p_aout->output.p_sys->p_file = vlc_fopen( psz_name, "wb" ); p_aout->sys->p_file = vlc_fopen( psz_name, "wb" );
free( psz_name ); free( psz_name );
if ( p_aout->output.p_sys->p_file == NULL ) if ( p_aout->sys->p_file == NULL )
{ {
free( p_aout->output.p_sys ); free( p_aout->sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_aout->output.pf_play = Play; p_aout->pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->pf_pause = NULL;
/* Audio format */ /* Audio format */
psz_format = var_CreateGetString( p_this, "audiofile-format" ); psz_format = var_CreateGetString( p_this, "audiofile-format" );
...@@ -181,25 +181,25 @@ static int Open( vlc_object_t * p_this ) ...@@ -181,25 +181,25 @@ static int Open( vlc_object_t * p_this )
{ {
msg_Err( p_aout, "cannot understand the format string (%s)", msg_Err( p_aout, "cannot understand the format string (%s)",
psz_format ); psz_format );
if( p_aout->output.p_sys->p_file != stdout ) if( p_aout->sys->p_file != stdout )
fclose( p_aout->output.p_sys->p_file ); fclose( p_aout->sys->p_file );
free( p_aout->output.p_sys ); free( p_aout->sys );
free( psz_format ); free( psz_format );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
free( psz_format ); free( psz_format );
p_aout->output.output.i_format = format_int[i]; p_aout->format.i_format = format_int[i];
if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) if ( AOUT_FMT_NON_LINEAR( &p_aout->format ) )
{ {
p_aout->output.i_nb_samples = A52_FRAME_NB; p_aout->i_nb_samples = A52_FRAME_NB;
p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->output.output.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
aout_VolumeNoneInit( p_aout ); aout_VolumeNoneInit( p_aout );
} }
else else
{ {
p_aout->output.i_nb_samples = FRAME_SIZE; p_aout->i_nb_samples = FRAME_SIZE;
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
} }
...@@ -208,22 +208,22 @@ static int Open( vlc_object_t * p_this ) ...@@ -208,22 +208,22 @@ static int Open( vlc_object_t * p_this )
if( i_channels > 0 && i_channels <= CHANNELS_MAX ) if( i_channels > 0 && i_channels <= CHANNELS_MAX )
{ {
p_aout->output.output.i_physical_channels = p_aout->format.i_physical_channels =
pi_channels_maps[i_channels]; pi_channels_maps[i_channels];
} }
/* WAV header */ /* WAV header */
p_aout->output.p_sys->b_add_wav_header = var_CreateGetBool( p_this, p_aout->sys->b_add_wav_header = var_CreateGetBool( p_this,
"audiofile-wav" ); "audiofile-wav" );
if( p_aout->output.p_sys->b_add_wav_header ) if( p_aout->sys->b_add_wav_header )
{ {
/* Write wave header */ /* Write wave header */
WAVEHEADER *wh = &p_aout->output.p_sys->waveh; WAVEHEADER *wh = &p_aout->sys->waveh;
memset( wh, 0, sizeof(*wh) ); memset( wh, 0, sizeof(*wh) );
switch( p_aout->output.output.i_format ) switch( p_aout->format.i_format )
{ {
case VLC_CODEC_FL32: case VLC_CODEC_FL32:
wh->Format = WAVE_FORMAT_IEEE_FLOAT; wh->Format = WAVE_FORMAT_IEEE_FLOAT;
...@@ -246,8 +246,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -246,8 +246,8 @@ static int Open( vlc_object_t * p_this )
wh->SubChunkID = VLC_FOURCC('f', 'm', 't', ' '); wh->SubChunkID = VLC_FOURCC('f', 'm', 't', ' ');
wh->SubChunkLength = 16; wh->SubChunkLength = 16;
wh->Modus = aout_FormatNbChannels( &p_aout->output.output ); wh->Modus = aout_FormatNbChannels( &p_aout->format );
wh->SampleFreq = p_aout->output.output.i_rate; wh->SampleFreq = p_aout->format.i_rate;
wh->BytesPerSample = wh->Modus * ( wh->BitsPerSample / 8 ); wh->BytesPerSample = wh->Modus * ( wh->BitsPerSample / 8 );
wh->BytesPerSec = wh->BytesPerSample * wh->SampleFreq; wh->BytesPerSec = wh->BytesPerSample * wh->SampleFreq;
...@@ -264,7 +264,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -264,7 +264,7 @@ static int Open( vlc_object_t * p_this )
SetDWLE( &wh->BytesPerSec, wh->BytesPerSec ); SetDWLE( &wh->BytesPerSec, wh->BytesPerSec );
if( fwrite( wh, sizeof(WAVEHEADER), 1, if( fwrite( wh, sizeof(WAVEHEADER), 1,
p_aout->output.p_sys->p_file ) != 1 ) p_aout->sys->p_file ) != 1 )
{ {
msg_Err( p_aout, "write error (%m)" ); msg_Err( p_aout, "write error (%m)" );
} }
...@@ -282,34 +282,34 @@ static void Close( vlc_object_t * p_this ) ...@@ -282,34 +282,34 @@ static void Close( vlc_object_t * p_this )
msg_Dbg( p_aout, "closing audio file" ); msg_Dbg( p_aout, "closing audio file" );
if( p_aout->output.p_sys->b_add_wav_header ) if( p_aout->sys->b_add_wav_header )
{ {
/* Update Wave Header */ /* Update Wave Header */
p_aout->output.p_sys->waveh.Length = p_aout->sys->waveh.Length =
p_aout->output.p_sys->waveh.DataLength + sizeof(WAVEHEADER) - 4; p_aout->sys->waveh.DataLength + sizeof(WAVEHEADER) - 4;
/* Write Wave Header */ /* Write Wave Header */
if( fseek( p_aout->output.p_sys->p_file, 0, SEEK_SET ) ) if( fseek( p_aout->sys->p_file, 0, SEEK_SET ) )
{ {
msg_Err( p_aout, "seek error (%m)" ); msg_Err( p_aout, "seek error (%m)" );
} }
/* Header -> little endian format */ /* Header -> little endian format */
SetDWLE( &p_aout->output.p_sys->waveh.Length, SetDWLE( &p_aout->sys->waveh.Length,
p_aout->output.p_sys->waveh.Length ); p_aout->sys->waveh.Length );
SetDWLE( &p_aout->output.p_sys->waveh.DataLength, SetDWLE( &p_aout->sys->waveh.DataLength,
p_aout->output.p_sys->waveh.DataLength ); p_aout->sys->waveh.DataLength );
if( fwrite( &p_aout->output.p_sys->waveh, sizeof(WAVEHEADER), 1, if( fwrite( &p_aout->sys->waveh, sizeof(WAVEHEADER), 1,
p_aout->output.p_sys->p_file ) != 1 ) p_aout->sys->p_file ) != 1 )
{ {
msg_Err( p_aout, "write error (%m)" ); msg_Err( p_aout, "write error (%m)" );
} }
} }
if( p_aout->output.p_sys->p_file != stdout ) if( p_aout->sys->p_file != stdout )
fclose( p_aout->output.p_sys->p_file ); fclose( p_aout->sys->p_file );
free( p_aout->output.p_sys ); free( p_aout->sys );
} }
/***************************************************************************** /*****************************************************************************
...@@ -319,18 +319,18 @@ static void Play( aout_instance_t * p_aout ) ...@@ -319,18 +319,18 @@ static void Play( aout_instance_t * p_aout )
{ {
aout_buffer_t * p_buffer; aout_buffer_t * p_buffer;
p_buffer = aout_FifoPop( &p_aout->output.fifo ); p_buffer = aout_FifoPop( &p_aout->fifo );
if( fwrite( p_buffer->p_buffer, p_buffer->i_buffer, 1, if( fwrite( p_buffer->p_buffer, p_buffer->i_buffer, 1,
p_aout->output.p_sys->p_file ) != 1 ) p_aout->sys->p_file ) != 1 )
{ {
msg_Err( p_aout, "write error (%m)" ); msg_Err( p_aout, "write error (%m)" );
} }
if( p_aout->output.p_sys->b_add_wav_header ) if( p_aout->sys->b_add_wav_header )
{ {
/* Update Wave Header */ /* Update Wave Header */
p_aout->output.p_sys->waveh.DataLength += p_buffer->i_buffer; p_aout->sys->waveh.DataLength += p_buffer->i_buffer;
} }
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
......
...@@ -113,7 +113,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -113,7 +113,7 @@ static int Open( vlc_object_t *p_this )
status = VLC_ENOMEM; status = VLC_ENOMEM;
goto error_out; goto error_out;
} }
p_aout->output.p_sys = p_sys; p_aout->sys = p_sys;
p_sys->latency = 0; p_sys->latency = 0;
/* Connect to the JACK server */ /* Connect to the JACK server */
...@@ -133,17 +133,17 @@ static int Open( vlc_object_t *p_this ) ...@@ -133,17 +133,17 @@ static int Open( vlc_object_t *p_this )
jack_set_process_callback( p_sys->p_jack_client, Process, p_aout ); jack_set_process_callback( p_sys->p_jack_client, Process, p_aout );
jack_set_graph_order_callback ( p_sys->p_jack_client, GraphChange, p_aout ); jack_set_graph_order_callback ( p_sys->p_jack_client, GraphChange, p_aout );
p_aout->output.pf_play = Play; p_aout->pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->pf_pause = NULL;
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
/* JACK only supports fl32 format */ /* JACK only supports fl32 format */
p_aout->output.output.i_format = VLC_CODEC_FL32; p_aout->format.i_format = VLC_CODEC_FL32;
// TODO add buffer size callback // TODO add buffer size callback
p_aout->output.i_nb_samples = jack_get_buffer_size( p_sys->p_jack_client ); p_aout->i_nb_samples = jack_get_buffer_size( p_sys->p_jack_client );
p_aout->output.output.i_rate = jack_get_sample_rate( p_sys->p_jack_client ); p_aout->format.i_rate = jack_get_sample_rate( p_sys->p_jack_client );
p_sys->i_channels = aout_FormatNbChannels( &p_aout->output.output ); p_sys->i_channels = aout_FormatNbChannels( &p_aout->format );
p_sys->p_jack_ports = malloc( p_sys->i_channels * p_sys->p_jack_ports = malloc( p_sys->i_channels *
sizeof(jack_port_t *) ); sizeof(jack_port_t *) );
...@@ -225,7 +225,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -225,7 +225,7 @@ static int Open( vlc_object_t *p_this )
msg_Dbg( p_aout, "JACK audio output initialized (%d channels, buffer " msg_Dbg( p_aout, "JACK audio output initialized (%d channels, buffer "
"size=%d, rate=%d)", p_sys->i_channels, "size=%d, rate=%d)", p_sys->i_channels,
p_aout->output.i_nb_samples, p_aout->output.output.i_rate ); p_aout->i_nb_samples, p_aout->format.i_rate );
error_out: error_out:
/* Clean up, if an error occurred */ /* Clean up, if an error occurred */
...@@ -251,7 +251,7 @@ int Process( jack_nframes_t i_frames, void *p_arg ) ...@@ -251,7 +251,7 @@ int Process( jack_nframes_t i_frames, void *p_arg )
{ {
unsigned int i, j, i_nb_samples = 0; unsigned int i, j, i_nb_samples = 0;
aout_instance_t *p_aout = (aout_instance_t*) p_arg; aout_instance_t *p_aout = (aout_instance_t*) p_arg;
struct aout_sys_t *p_sys = p_aout->output.p_sys; struct aout_sys_t *p_sys = p_aout->sys;
jack_sample_t *p_src = NULL; jack_sample_t *p_src = NULL;
jack_nframes_t dframes = p_sys->latency jack_nframes_t dframes = p_sys->latency
...@@ -312,7 +312,7 @@ int Process( jack_nframes_t i_frames, void *p_arg ) ...@@ -312,7 +312,7 @@ int Process( jack_nframes_t i_frames, void *p_arg )
static int GraphChange( void *p_arg ) static int GraphChange( void *p_arg )
{ {
aout_instance_t *p_aout = (aout_instance_t*) p_arg; aout_instance_t *p_aout = (aout_instance_t*) p_arg;
struct aout_sys_t *p_sys = p_aout->output.p_sys; struct aout_sys_t *p_sys = p_aout->sys;
unsigned int i; unsigned int i;
jack_nframes_t port_latency; jack_nframes_t port_latency;
...@@ -345,7 +345,7 @@ static void Close( vlc_object_t *p_this ) ...@@ -345,7 +345,7 @@ static void Close( vlc_object_t *p_this )
{ {
int i_error; int i_error;
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
struct aout_sys_t *p_sys = p_aout->output.p_sys; struct aout_sys_t *p_sys = p_aout->sys;
i_error = jack_deactivate( p_sys->p_jack_client ); i_error = jack_deactivate( p_sys->p_jack_client );
if( i_error ) if( i_error )
......
...@@ -139,11 +139,11 @@ static int Open( vlc_object_t * p_this ) ...@@ -139,11 +139,11 @@ static int Open( vlc_object_t * p_this )
SLresult result; SLresult result;
/* Allocate structure */ /* Allocate structure */
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) ); p_aout->sys = malloc( sizeof( aout_sys_t ) );
if( unlikely( p_aout->output.p_sys == NULL ) ) if( unlikely( p_aout->sys == NULL ) )
return VLC_ENOMEM; return VLC_ENOMEM;
aout_sys_t * p_sys = p_aout->output.p_sys; aout_sys_t * p_sys = p_aout->sys;
p_sys->playerObject = NULL; p_sys->playerObject = NULL;
p_sys->engineObject = NULL; p_sys->engineObject = NULL;
...@@ -204,7 +204,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -204,7 +204,7 @@ static int Open( vlc_object_t * p_this )
SLDataFormat_PCM format_pcm; SLDataFormat_PCM format_pcm;
format_pcm.formatType = SL_DATAFORMAT_PCM; format_pcm.formatType = SL_DATAFORMAT_PCM;
format_pcm.numChannels = 2; format_pcm.numChannels = 2;
format_pcm.samplesPerSec = ((SLuint32) p_aout->output.output.i_rate * 1000) ; format_pcm.samplesPerSec = ((SLuint32) p_aout->format.i_rate * 1000) ;
format_pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16; format_pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
format_pcm.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16; format_pcm.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16;
format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT; format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
...@@ -256,13 +256,13 @@ static int Open( vlc_object_t * p_this ) ...@@ -256,13 +256,13 @@ static int Open( vlc_object_t * p_this )
CHECK_OPENSL_ERROR( result, "Failed to switch to playing state" ); CHECK_OPENSL_ERROR( result, "Failed to switch to playing state" );
// we want 16bit signed data little endian. // we want 16bit signed data little endian.
p_aout->output.output.i_format = VLC_CODEC_S16L; p_aout->format.i_format = VLC_CODEC_S16L;
p_aout->output.i_nb_samples = 2048; p_aout->i_nb_samples = 2048;
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
p_aout->output.pf_play = Play; p_aout->pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->pf_pause = NULL;
aout_FormatPrepare( &p_aout->output.output ); aout_FormatPrepare( &p_aout->format );
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
...@@ -276,7 +276,7 @@ error: ...@@ -276,7 +276,7 @@ error:
static void Close( vlc_object_t * p_this ) static void Close( vlc_object_t * p_this )
{ {
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
aout_sys_t *p_sys = p_aout->output.p_sys; aout_sys_t *p_sys = p_aout->sys;
msg_Dbg( p_aout, "Closing OpenSLES" ); msg_Dbg( p_aout, "Closing OpenSLES" );
...@@ -292,12 +292,12 @@ static void Close( vlc_object_t * p_this ) ...@@ -292,12 +292,12 @@ static void Close( vlc_object_t * p_this )
*****************************************************************************/ *****************************************************************************/
static void Play( aout_instance_t * p_aout ) static void Play( aout_instance_t * p_aout )
{ {
aout_sys_t * p_sys = p_aout->output.p_sys; aout_sys_t * p_sys = p_aout->sys;
aout_buffer_t *p_buffer; aout_buffer_t *p_buffer;
SLresult result; SLresult result;
p_buffer = aout_FifoPop(&p_aout->output.fifo); p_buffer = aout_FifoPop(&p_aout->fifo);
if( p_buffer != NULL ) if( p_buffer != NULL )
{ {
for (;;) for (;;)
......
...@@ -114,7 +114,7 @@ vlc_module_end () ...@@ -114,7 +114,7 @@ vlc_module_end ()
*****************************************************************************/ *****************************************************************************/
static void Probe( aout_instance_t * p_aout ) static void Probe( aout_instance_t * p_aout )
{ {
struct aout_sys_t * p_sys = p_aout->output.p_sys; struct aout_sys_t * p_sys = p_aout->sys;
vlc_value_t val, text; vlc_value_t val, text;
int i_format, i_nb_channels; int i_format, i_nb_channels;
...@@ -124,7 +124,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -124,7 +124,7 @@ static void Probe( aout_instance_t * p_aout )
/* Test for multi-channel. */ /* Test for multi-channel. */
#ifdef SNDCTL_DSP_GETCHANNELMASK #ifdef SNDCTL_DSP_GETCHANNELMASK
if ( aout_FormatNbChannels( &p_aout->output.output ) > 2 ) if ( aout_FormatNbChannels( &p_aout->format ) > 2 )
{ {
/* Check that the device supports this. */ /* Check that the device supports this. */
...@@ -151,7 +151,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -151,7 +151,7 @@ static void Probe( aout_instance_t * p_aout )
} }
if ( (i_chanmask & (DSP_BIND_SURR | DSP_BIND_CENTER_LFE)) if ( (i_chanmask & (DSP_BIND_SURR | DSP_BIND_CENTER_LFE))
&& (p_aout->output.output.i_physical_channels == && (p_aout->format.i_physical_channels ==
(AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_LFE)) ) | AOUT_CHAN_LFE)) )
...@@ -163,7 +163,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -163,7 +163,7 @@ static void Probe( aout_instance_t * p_aout )
} }
if ( (i_chanmask & DSP_BIND_SURR) if ( (i_chanmask & DSP_BIND_SURR)
&& (p_aout->output.output.i_physical_channels & && (p_aout->format.i_physical_channels &
(AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT)) ) | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT)) )
{ {
...@@ -214,7 +214,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -214,7 +214,7 @@ static void Probe( aout_instance_t * p_aout )
val.i_int = AOUT_VAR_MONO; val.i_int = AOUT_VAR_MONO;
text.psz_string = _("Mono"); text.psz_string = _("Mono");
var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
if ( p_aout->output.output.i_physical_channels == AOUT_CHAN_CENTER ) if ( p_aout->format.i_physical_channels == AOUT_CHAN_CENTER )
{ {
var_Set( p_aout, "audio-device", val ); var_Set( p_aout, "audio-device", val );
} }
...@@ -228,7 +228,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -228,7 +228,7 @@ static void Probe( aout_instance_t * p_aout )
} }
/* Test for spdif. */ /* Test for spdif. */
if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) if ( AOUT_FMT_NON_LINEAR( &p_aout->format ) )
{ {
i_format = AFMT_AC3; i_format = AFMT_AC3;
...@@ -266,7 +266,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -266,7 +266,7 @@ static int Open( vlc_object_t *p_this )
vlc_value_t val; vlc_value_t val;
/* Allocate structure */ /* Allocate structure */
p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) ); p_aout->sys = p_sys = malloc( sizeof( aout_sys_t ) );
if( p_sys == NULL ) if( p_sys == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
...@@ -298,8 +298,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -298,8 +298,8 @@ static int Open( vlc_object_t *p_this )
free( psz_device ); free( psz_device );
p_aout->output.pf_play = Play; p_aout->pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->pf_pause = NULL;
if ( var_Type( p_aout, "audio-device" ) == 0 ) if ( var_Type( p_aout, "audio-device" ) == 0 )
{ {
...@@ -316,33 +316,33 @@ static int Open( vlc_object_t *p_this ) ...@@ -316,33 +316,33 @@ static int Open( vlc_object_t *p_this )
if ( val.i_int == AOUT_VAR_SPDIF ) if ( val.i_int == AOUT_VAR_SPDIF )
{ {
p_aout->output.output.i_format = VLC_CODEC_SPDIFL; p_aout->format.i_format = VLC_CODEC_SPDIFL;
} }
else if ( val.i_int == AOUT_VAR_5_1 ) else if ( val.i_int == AOUT_VAR_5_1 )
{ {
p_aout->output.output.i_format = VLC_CODEC_S16N; p_aout->format.i_format = VLC_CODEC_S16N;
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_LFE; | AOUT_CHAN_LFE;
} }
else if ( val.i_int == AOUT_VAR_2F2R ) else if ( val.i_int == AOUT_VAR_2F2R )
{ {
p_aout->output.output.i_format = VLC_CODEC_S16N; p_aout->format.i_format = VLC_CODEC_S16N;
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
} }
else if ( val.i_int == AOUT_VAR_STEREO ) else if ( val.i_int == AOUT_VAR_STEREO )
{ {
p_aout->output.output.i_format = VLC_CODEC_S16N; p_aout->format.i_format = VLC_CODEC_S16N;
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
} }
else if ( val.i_int == AOUT_VAR_MONO ) else if ( val.i_int == AOUT_VAR_MONO )
{ {
p_aout->output.output.i_format = VLC_CODEC_S16N; p_aout->format.i_format = VLC_CODEC_S16N;
p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; p_aout->format.i_physical_channels = AOUT_CHAN_CENTER;
} }
else else
{ {
...@@ -366,7 +366,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -366,7 +366,7 @@ static int Open( vlc_object_t *p_this )
} }
/* Set the output format */ /* Set the output format */
if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) if ( AOUT_FMT_NON_LINEAR( &p_aout->format ) )
{ {
int i_format = AFMT_AC3; int i_format = AFMT_AC3;
...@@ -379,15 +379,15 @@ static int Open( vlc_object_t *p_this ) ...@@ -379,15 +379,15 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_aout->output.output.i_format = VLC_CODEC_SPDIFL; p_aout->format.i_format = VLC_CODEC_SPDIFL;
p_aout->output.i_nb_samples = A52_FRAME_NB; p_aout->i_nb_samples = A52_FRAME_NB;
p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->output.output.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
aout_VolumeNoneInit( p_aout ); aout_VolumeNoneInit( p_aout );
} }
if ( !AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) if ( !AOUT_FMT_NON_LINEAR( &p_aout->format ) )
{ {
unsigned int i_format = AFMT_S16_NE; unsigned int i_format = AFMT_S16_NE;
unsigned int i_frame_size, i_fragments; unsigned int i_frame_size, i_fragments;
...@@ -406,22 +406,22 @@ static int Open( vlc_object_t *p_this ) ...@@ -406,22 +406,22 @@ static int Open( vlc_object_t *p_this )
switch ( i_format ) switch ( i_format )
{ {
case AFMT_U8: case AFMT_U8:
p_aout->output.output.i_format = VLC_CODEC_U8; p_aout->format.i_format = VLC_CODEC_U8;
break; break;
case AFMT_S8: case AFMT_S8:
p_aout->output.output.i_format = VLC_CODEC_S8; p_aout->format.i_format = VLC_CODEC_S8;
break; break;
case AFMT_U16_LE: case AFMT_U16_LE:
p_aout->output.output.i_format = VLC_CODEC_U16L; p_aout->format.i_format = VLC_CODEC_U16L;
break; break;
case AFMT_S16_LE: case AFMT_S16_LE:
p_aout->output.output.i_format = VLC_CODEC_S16L; p_aout->format.i_format = VLC_CODEC_S16L;
break; break;
case AFMT_U16_BE: case AFMT_U16_BE:
p_aout->output.output.i_format = VLC_CODEC_U16B; p_aout->format.i_format = VLC_CODEC_U16B;
break; break;
case AFMT_S16_BE: case AFMT_S16_BE:
p_aout->output.output.i_format = VLC_CODEC_S16B; p_aout->format.i_format = VLC_CODEC_S16B;
break; break;
default: default:
msg_Err( p_aout, "OSS fell back to an unknown format (%d)", msg_Err( p_aout, "OSS fell back to an unknown format (%d)",
...@@ -431,41 +431,41 @@ static int Open( vlc_object_t *p_this ) ...@@ -431,41 +431,41 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); i_nb_channels = aout_FormatNbChannels( &p_aout->format );
/* Set the number of channels */ /* Set the number of channels */
if( ioctl( p_sys->i_fd, SNDCTL_DSP_CHANNELS, &i_nb_channels ) < 0 || if( ioctl( p_sys->i_fd, SNDCTL_DSP_CHANNELS, &i_nb_channels ) < 0 ||
i_nb_channels != aout_FormatNbChannels( &p_aout->output.output ) ) i_nb_channels != aout_FormatNbChannels( &p_aout->format ) )
{ {
msg_Err( p_aout, "cannot set number of audio channels (%s)", msg_Err( p_aout, "cannot set number of audio channels (%s)",
aout_FormatPrintChannels( &p_aout->output.output) ); aout_FormatPrintChannels( &p_aout->format) );
close( p_sys->i_fd ); close( p_sys->i_fd );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Set the output rate */ /* Set the output rate */
i_rate = p_aout->output.output.i_rate; i_rate = p_aout->format.i_rate;
if( ioctl( p_sys->i_fd, SNDCTL_DSP_SPEED, &i_rate ) < 0 ) if( ioctl( p_sys->i_fd, SNDCTL_DSP_SPEED, &i_rate ) < 0 )
{ {
msg_Err( p_aout, "cannot set audio output rate (%i)", msg_Err( p_aout, "cannot set audio output rate (%i)",
p_aout->output.output.i_rate ); p_aout->format.i_rate );
close( p_sys->i_fd ); close( p_sys->i_fd );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
if( i_rate != p_aout->output.output.i_rate ) if( i_rate != p_aout->format.i_rate )
{ {
p_aout->output.output.i_rate = i_rate; p_aout->format.i_rate = i_rate;
} }
/* Set the fragment size */ /* Set the fragment size */
aout_FormatPrepare( &p_aout->output.output ); aout_FormatPrepare( &p_aout->format );
/* i_fragment = xxxxyyyy where: xxxx is fragtotal /* i_fragment = xxxxyyyy where: xxxx is fragtotal
* 1 << yyyy is fragsize */ * 1 << yyyy is fragsize */
i_frame_size = ((uint64_t)p_aout->output.output.i_bytes_per_frame * p_aout->output.output.i_rate * 65536) / (48000 * 2 * 2) / FRAME_COUNT; i_frame_size = ((uint64_t)p_aout->format.i_bytes_per_frame * p_aout->format.i_rate * 65536) / (48000 * 2 * 2) / FRAME_COUNT;
i_fragments = 4; i_fragments = 4;
while( i_fragments < 12 && (1U << i_fragments) < i_frame_size ) while( i_fragments < 12 && (1U << i_fragments) < i_frame_size )
{ {
...@@ -487,17 +487,17 @@ static int Open( vlc_object_t *p_this ) ...@@ -487,17 +487,17 @@ static int Open( vlc_object_t *p_this )
else else
{ {
/* Number of fragments actually allocated */ /* Number of fragments actually allocated */
p_aout->output.p_sys->i_fragstotal = audio_buf.fragstotal; p_aout->sys->i_fragstotal = audio_buf.fragstotal;
/* Maximum duration the soundcard's buffer can hold */ /* Maximum duration the soundcard's buffer can hold */
p_aout->output.p_sys->max_buffer_duration = p_aout->sys->max_buffer_duration =
(mtime_t)audio_buf.fragstotal * audio_buf.fragsize * 1000000 (mtime_t)audio_buf.fragstotal * audio_buf.fragsize * 1000000
/ p_aout->output.output.i_bytes_per_frame / p_aout->format.i_bytes_per_frame
/ p_aout->output.output.i_rate / p_aout->format.i_rate
* p_aout->output.output.i_frame_length; * p_aout->format.i_frame_length;
p_aout->output.i_nb_samples = audio_buf.fragsize / p_aout->i_nb_samples = audio_buf.fragsize /
p_aout->output.output.i_bytes_per_frame; p_aout->format.i_bytes_per_frame;
} }
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
...@@ -530,7 +530,7 @@ static void Play( aout_instance_t *p_aout ) ...@@ -530,7 +530,7 @@ static void Play( aout_instance_t *p_aout )
static void Close( vlc_object_t * p_this ) static void Close( vlc_object_t * p_this )
{ {
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
struct aout_sys_t * p_sys = p_aout->output.p_sys; struct aout_sys_t * p_sys = p_aout->sys;
vlc_cancel( p_sys->thread ); vlc_cancel( p_sys->thread );
vlc_join( p_sys->thread, NULL ); vlc_join( p_sys->thread, NULL );
...@@ -549,7 +549,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -549,7 +549,7 @@ static void Close( vlc_object_t * p_this )
*****************************************************************************/ *****************************************************************************/
static mtime_t BufferDuration( aout_instance_t * p_aout ) static mtime_t BufferDuration( aout_instance_t * p_aout )
{ {
struct aout_sys_t * p_sys = p_aout->output.p_sys; struct aout_sys_t * p_sys = p_aout->sys;
audio_buf_info audio_buf; audio_buf_info audio_buf;
int i_bytes; int i_bytes;
...@@ -565,9 +565,9 @@ static mtime_t BufferDuration( aout_instance_t * p_aout ) ...@@ -565,9 +565,9 @@ static mtime_t BufferDuration( aout_instance_t * p_aout )
/* Return the fragment duration */ /* Return the fragment duration */
return (mtime_t)i_bytes * 1000000 return (mtime_t)i_bytes * 1000000
/ p_aout->output.output.i_bytes_per_frame / p_aout->format.i_bytes_per_frame
/ p_aout->output.output.i_rate / p_aout->format.i_rate
* p_aout->output.output.i_frame_length; * p_aout->format.i_frame_length;
} }
typedef struct typedef struct
...@@ -591,7 +591,7 @@ static void OSSThreadCleanup( void *data ) ...@@ -591,7 +591,7 @@ static void OSSThreadCleanup( void *data )
static void* OSSThread( void *obj ) static void* OSSThread( void *obj )
{ {
aout_instance_t * p_aout = (aout_instance_t*)obj; aout_instance_t * p_aout = (aout_instance_t*)obj;
struct aout_sys_t * p_sys = p_aout->output.p_sys; struct aout_sys_t * p_sys = p_aout->sys;
mtime_t next_date = 0; mtime_t next_date = 0;
for( ;; ) for( ;; )
...@@ -599,7 +599,7 @@ static void* OSSThread( void *obj ) ...@@ -599,7 +599,7 @@ static void* OSSThread( void *obj )
aout_buffer_t * p_buffer = NULL; aout_buffer_t * p_buffer = NULL;
int canc = vlc_savecancel (); int canc = vlc_savecancel ();
if ( p_aout->output.output.i_format != VLC_CODEC_SPDIFL ) if ( p_aout->format.i_format != VLC_CODEC_SPDIFL )
{ {
mtime_t buffered = BufferDuration( p_aout ); mtime_t buffered = BufferDuration( p_aout );
...@@ -608,15 +608,15 @@ static void* OSSThread( void *obj ) ...@@ -608,15 +608,15 @@ static void* OSSThread( void *obj )
false ); false );
if( p_buffer == NULL && if( p_buffer == NULL &&
buffered > ( p_aout->output.p_sys->max_buffer_duration buffered > ( p_aout->sys->max_buffer_duration
/ p_aout->output.p_sys->i_fragstotal ) ) / p_aout->sys->i_fragstotal ) )
{ {
vlc_restorecancel (canc); vlc_restorecancel (canc);
/* If we have at least a fragment full, then we can wait a /* If we have at least a fragment full, then we can wait a
* little and retry to get a new audio buffer instead of * little and retry to get a new audio buffer instead of
* playing a blank sample */ * playing a blank sample */
msleep( ( p_aout->output.p_sys->max_buffer_duration msleep( ( p_aout->sys->max_buffer_duration
/ p_aout->output.p_sys->i_fragstotal / 2 ) ); / p_aout->sys->i_fragstotal / 2 ) );
continue; continue;
} }
} }
...@@ -664,8 +664,8 @@ static void* OSSThread( void *obj ) ...@@ -664,8 +664,8 @@ static void* OSSThread( void *obj )
} }
else else
{ {
i_size = FRAME_SIZE / p_aout->output.output.i_frame_length i_size = FRAME_SIZE / p_aout->format.i_frame_length
* p_aout->output.output.i_bytes_per_frame; * p_aout->format.i_bytes_per_frame;
p_bytes = malloc( i_size ); p_bytes = malloc( i_size );
memset( p_bytes, 0, i_size ); memset( p_bytes, 0, i_size );
next_date = 0; next_date = 0;
......
...@@ -181,9 +181,9 @@ static int Open( vlc_object_t * p_this ) ...@@ -181,9 +181,9 @@ static int Open( vlc_object_t * p_this )
return VLC_ENOMEM; return VLC_ENOMEM;
p_sys->p_aout = p_aout; p_sys->p_aout = p_aout;
p_sys->p_stream = 0; p_sys->p_stream = 0;
p_aout->output.p_sys = p_sys; p_aout->sys = p_sys;
p_aout->output.pf_play = Play; p_aout->pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->pf_pause = NULL;
/* Retrieve output device id from config */ /* Retrieve output device id from config */
p_sys->i_device_id = var_CreateGetInteger( p_aout, "portaudio-audio-device" ); p_sys->i_device_id = var_CreateGetInteger( p_aout, "portaudio-audio-device" );
...@@ -283,7 +283,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -283,7 +283,7 @@ static int Open( vlc_object_t * p_this )
static void Close ( vlc_object_t *p_this ) static void Close ( vlc_object_t *p_this )
{ {
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
aout_sys_t *p_sys = p_aout->output.p_sys; aout_sys_t *p_sys = p_aout->sys;
msg_Dbg( p_aout, "closing portaudio"); msg_Dbg( p_aout, "closing portaudio");
...@@ -332,7 +332,7 @@ static void Close ( vlc_object_t *p_this ) ...@@ -332,7 +332,7 @@ static void Close ( vlc_object_t *p_this )
static int PAOpenDevice( aout_instance_t *p_aout ) static int PAOpenDevice( aout_instance_t *p_aout )
{ {
aout_sys_t *p_sys = p_aout->output.p_sys; aout_sys_t *p_sys = p_aout->sys;
const PaDeviceInfo *p_pdi; const PaDeviceInfo *p_pdi;
PaError i_err; PaError i_err;
vlc_value_t val, text; vlc_value_t val, text;
...@@ -439,7 +439,7 @@ static int PAOpenDevice( aout_instance_t *p_aout ) ...@@ -439,7 +439,7 @@ static int PAOpenDevice( aout_instance_t *p_aout )
} }
/* Audio format is paFloat32 (always supported by portaudio v19) */ /* Audio format is paFloat32 (always supported by portaudio v19) */
p_aout->output.output.i_format = VLC_CODEC_FL32; p_aout->format.i_format = VLC_CODEC_FL32;
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -453,7 +453,7 @@ static int PAOpenDevice( aout_instance_t *p_aout ) ...@@ -453,7 +453,7 @@ static int PAOpenDevice( aout_instance_t *p_aout )
static int PAOpenStream( aout_instance_t *p_aout ) static int PAOpenStream( aout_instance_t *p_aout )
{ {
aout_sys_t *p_sys = p_aout->output.p_sys; aout_sys_t *p_sys = p_aout->sys;
const PaHostErrorInfo* paLastHostErrorInfo = Pa_GetLastHostErrorInfo(); const PaHostErrorInfo* paLastHostErrorInfo = Pa_GetLastHostErrorInfo();
PaStreamParameters paStreamParameters; PaStreamParameters paStreamParameters;
vlc_value_t val; vlc_value_t val;
...@@ -467,54 +467,54 @@ static int PAOpenStream( aout_instance_t *p_aout ) ...@@ -467,54 +467,54 @@ static int PAOpenStream( aout_instance_t *p_aout )
if( val.i_int == AOUT_VAR_5_1 ) if( val.i_int == AOUT_VAR_5_1 )
{ {
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_LFE; | AOUT_CHAN_LFE;
} }
else if( val.i_int == AOUT_VAR_3F2R ) else if( val.i_int == AOUT_VAR_3F2R )
{ {
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
} }
else if( val.i_int == AOUT_VAR_2F2R ) else if( val.i_int == AOUT_VAR_2F2R )
{ {
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
} }
else if( val.i_int == AOUT_VAR_MONO ) else if( val.i_int == AOUT_VAR_MONO )
{ {
p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; p_aout->format.i_physical_channels = AOUT_CHAN_CENTER;
} }
else else
{ {
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
} }
i_channels = aout_FormatNbChannels( &p_aout->output.output ); i_channels = aout_FormatNbChannels( &p_aout->format );
msg_Dbg( p_aout, "nb_channels requested = %d", i_channels ); msg_Dbg( p_aout, "nb_channels requested = %d", i_channels );
i_channel_mask = p_aout->output.output.i_physical_channels; i_channel_mask = p_aout->format.i_physical_channels;
/* Calculate the frame size in bytes */ /* Calculate the frame size in bytes */
p_sys->i_sample_size = 4 * i_channels; p_sys->i_sample_size = 4 * i_channels;
p_aout->output.i_nb_samples = FRAME_SIZE; p_aout->i_nb_samples = FRAME_SIZE;
aout_FormatPrepare( &p_aout->output.output ); aout_FormatPrepare( &p_aout->format );
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
/* Check for channel reordering */ /* Check for channel reordering */
p_aout->output.p_sys->i_channel_mask = i_channel_mask; p_aout->sys->i_channel_mask = i_channel_mask;
p_aout->output.p_sys->i_bits_per_sample = 32; /* forced to paFloat32 */ p_aout->sys->i_bits_per_sample = 32; /* forced to paFloat32 */
p_aout->output.p_sys->i_channels = i_channels; p_aout->sys->i_channels = i_channels;
p_aout->output.p_sys->b_chan_reorder = p_aout->sys->b_chan_reorder =
aout_CheckChannelReorder( NULL, pi_channels_out, aout_CheckChannelReorder( NULL, pi_channels_out,
i_channel_mask, i_channels, i_channel_mask, i_channels,
p_aout->output.p_sys->pi_chan_table ); p_aout->sys->pi_chan_table );
if( p_aout->output.p_sys->b_chan_reorder ) if( p_aout->sys->b_chan_reorder )
{ {
msg_Dbg( p_aout, "channel reordering needed" ); msg_Dbg( p_aout, "channel reordering needed" );
} }
...@@ -527,7 +527,7 @@ static int PAOpenStream( aout_instance_t *p_aout ) ...@@ -527,7 +527,7 @@ static int PAOpenStream( aout_instance_t *p_aout )
paStreamParameters.hostApiSpecificStreamInfo = NULL; paStreamParameters.hostApiSpecificStreamInfo = NULL;
i_err = Pa_OpenStream( &p_sys->p_stream, NULL /* no input */, i_err = Pa_OpenStream( &p_sys->p_stream, NULL /* no input */,
&paStreamParameters, (double)p_aout->output.output.i_rate, &paStreamParameters, (double)p_aout->format.i_rate,
FRAME_SIZE, paClipOff, paCallback, p_sys ); FRAME_SIZE, paClipOff, paCallback, p_sys );
if( i_err != paNoError ) if( i_err != paNoError )
{ {
...@@ -586,7 +586,7 @@ static void* PORTAUDIOThread( void *data ) ...@@ -586,7 +586,7 @@ static void* PORTAUDIOThread( void *data )
pa_thread->b_signal = false; pa_thread->b_signal = false;
p_aout = pa_thread->p_aout; p_aout = pa_thread->p_aout;
p_sys = p_aout->output.p_sys; p_sys = p_aout->sys;
if( PAOpenDevice( p_aout ) != VLC_SUCCESS ) if( PAOpenDevice( p_aout ) != VLC_SUCCESS )
{ {
......
...@@ -93,7 +93,7 @@ static void sink_info_cb(pa_context *c, const pa_sink_info *i, int eol, ...@@ -93,7 +93,7 @@ static void sink_info_cb(pa_context *c, const pa_sink_info *i, int eol,
void *userdata) void *userdata)
{ {
aout_instance_t *aout = userdata; aout_instance_t *aout = userdata;
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
if (eol) if (eol)
return; return;
...@@ -114,8 +114,8 @@ static void sink_info_cb(pa_context *c, const pa_sink_info *i, int eol, ...@@ -114,8 +114,8 @@ static void sink_info_cb(pa_context *c, const pa_sink_info *i, int eol,
/*** Stream helpers ***/ /*** Stream helpers ***/
static void stream_reset_sync(pa_stream *s, aout_instance_t *aout) static void stream_reset_sync(pa_stream *s, aout_instance_t *aout)
{ {
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
const unsigned rate = aout->output.output.i_rate; const unsigned rate = aout->format.i_rate;
sys->pts = VLC_TS_INVALID; sys->pts = VLC_TS_INVALID;
sys->desync = 0; sys->desync = 0;
...@@ -143,7 +143,7 @@ static void stream_state_cb(pa_stream *s, void *userdata) ...@@ -143,7 +143,7 @@ static void stream_state_cb(pa_stream *s, void *userdata)
static void stream_latency_cb(pa_stream *s, void *userdata) static void stream_latency_cb(pa_stream *s, void *userdata)
{ {
aout_instance_t *aout = userdata; aout_instance_t *aout = userdata;
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
mtime_t delta, change; mtime_t delta, change;
if (sys->pts == VLC_TS_INVALID) if (sys->pts == VLC_TS_INVALID)
...@@ -179,7 +179,7 @@ static void stream_latency_cb(pa_stream *s, void *userdata) ...@@ -179,7 +179,7 @@ static void stream_latency_cb(pa_stream *s, void *userdata)
msg_Warn(aout, "too early by %"PRId64" us", delta); msg_Warn(aout, "too early by %"PRId64" us", delta);
/* Compute playback sample rate */ /* Compute playback sample rate */
const unsigned inrate = aout->output.output.i_rate; const unsigned inrate = aout->format.i_rate;
#define ADJUST_FACTOR 4 #define ADJUST_FACTOR 4
#define ADJUST_MAX 1000 /* Hz (max rate variation per call) */ #define ADJUST_MAX 1000 /* Hz (max rate variation per call) */
...@@ -222,7 +222,7 @@ static void stream_latency_cb(pa_stream *s, void *userdata) ...@@ -222,7 +222,7 @@ static void stream_latency_cb(pa_stream *s, void *userdata)
static void stream_moved_cb(pa_stream *s, void *userdata) static void stream_moved_cb(pa_stream *s, void *userdata)
{ {
aout_instance_t *aout = userdata; aout_instance_t *aout = userdata;
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
pa_operation *op; pa_operation *op;
uint32_t idx = pa_stream_get_device_index(s); uint32_t idx = pa_stream_get_device_index(s);
...@@ -325,11 +325,11 @@ static void *data_convert(block_t **pp) ...@@ -325,11 +325,11 @@ static void *data_convert(block_t **pp)
*/ */
static void Play(aout_instance_t *aout) static void Play(aout_instance_t *aout)
{ {
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
pa_stream *s = sys->stream; pa_stream *s = sys->stream;
/* This function is called exactly once per block in the output FIFO. */ /* This function is called exactly once per block in the output FIFO. */
block_t *block = aout_FifoPop(&aout->output.fifo); block_t *block = aout_FifoPop(&aout->fifo);
assert (block != NULL); assert (block != NULL);
const void *ptr = data_convert(&block); const void *ptr = data_convert(&block);
...@@ -367,8 +367,8 @@ static void Play(aout_instance_t *aout) ...@@ -367,8 +367,8 @@ static void Play(aout_instance_t *aout)
advance -= latency; advance -= latency;
if (advance > 0) { if (advance > 0) {
size_t nb = (advance * aout->output.output.i_rate) / CLOCK_FREQ; size_t nb = (advance * aout->format.i_rate) / CLOCK_FREQ;
size_t size = aout->output.output.i_bytes_per_frame; size_t size = aout->format.i_bytes_per_frame;
float *zeroes = calloc (nb, size); float *zeroes = calloc (nb, size);
msg_Dbg(aout, "prepending %zu zeroes", nb); msg_Dbg(aout, "prepending %zu zeroes", nb);
...@@ -413,7 +413,7 @@ static void Play(aout_instance_t *aout) ...@@ -413,7 +413,7 @@ static void Play(aout_instance_t *aout)
*/ */
static void Pause(aout_instance_t *aout, bool b_paused, mtime_t i_date) static void Pause(aout_instance_t *aout, bool b_paused, mtime_t i_date)
{ {
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
pa_stream *s = sys->stream; pa_stream *s = sys->stream;
if (!b_paused) if (!b_paused)
...@@ -432,7 +432,7 @@ static void Pause(aout_instance_t *aout, bool b_paused, mtime_t i_date) ...@@ -432,7 +432,7 @@ static void Pause(aout_instance_t *aout, bool b_paused, mtime_t i_date)
static int VolumeSet(aout_instance_t *aout, float vol, bool mute) static int VolumeSet(aout_instance_t *aout, float vol, bool mute)
{ {
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
pa_operation *op; pa_operation *op;
uint32_t idx = pa_stream_get_index(sys->stream); uint32_t idx = pa_stream_get_index(sys->stream);
...@@ -461,7 +461,7 @@ static int StreamMove(vlc_object_t *obj, const char *varname, vlc_value_t old, ...@@ -461,7 +461,7 @@ static int StreamMove(vlc_object_t *obj, const char *varname, vlc_value_t old,
vlc_value_t val, void *userdata) vlc_value_t val, void *userdata)
{ {
aout_instance_t *aout = (aout_instance_t *)obj; aout_instance_t *aout = (aout_instance_t *)obj;
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
pa_stream *s = userdata; pa_stream *s = userdata;
pa_operation *op; pa_operation *op;
uint32_t idx = pa_stream_get_index(s); uint32_t idx = pa_stream_get_index(s);
...@@ -494,20 +494,20 @@ static int Open(vlc_object_t *obj) ...@@ -494,20 +494,20 @@ static int Open(vlc_object_t *obj)
/* Sample format specification */ /* Sample format specification */
struct pa_sample_spec ss; struct pa_sample_spec ss;
switch(aout->output.output.i_format) switch(aout->format.i_format)
{ {
case VLC_CODEC_F64B: case VLC_CODEC_F64B:
aout->output.output.i_format = VLC_CODEC_F32B; aout->format.i_format = VLC_CODEC_F32B;
case VLC_CODEC_F32B: case VLC_CODEC_F32B:
ss.format = PA_SAMPLE_FLOAT32BE; ss.format = PA_SAMPLE_FLOAT32BE;
break; break;
case VLC_CODEC_F64L: case VLC_CODEC_F64L:
aout->output.output.i_format = VLC_CODEC_F32L; aout->format.i_format = VLC_CODEC_F32L;
case VLC_CODEC_F32L: case VLC_CODEC_F32L:
ss.format = PA_SAMPLE_FLOAT32LE; ss.format = PA_SAMPLE_FLOAT32LE;
break; break;
case VLC_CODEC_FI32: case VLC_CODEC_FI32:
aout->output.output.i_format = VLC_CODEC_FL32; aout->format.i_format = VLC_CODEC_FL32;
ss.format = PA_SAMPLE_FLOAT32NE; ss.format = PA_SAMPLE_FLOAT32NE;
break; break;
case VLC_CODEC_S32B: case VLC_CODEC_S32B:
...@@ -529,26 +529,26 @@ static int Open(vlc_object_t *obj) ...@@ -529,26 +529,26 @@ static int Open(vlc_object_t *obj)
ss.format = PA_SAMPLE_S16LE; ss.format = PA_SAMPLE_S16LE;
break; break;
case VLC_CODEC_S8: case VLC_CODEC_S8:
aout->output.output.i_format = VLC_CODEC_U8; aout->format.i_format = VLC_CODEC_U8;
case VLC_CODEC_U8: case VLC_CODEC_U8:
ss.format = PA_SAMPLE_U8; ss.format = PA_SAMPLE_U8;
break; break;
default: default:
if (HAVE_FPU) if (HAVE_FPU)
{ {
aout->output.output.i_format = VLC_CODEC_FL32; aout->format.i_format = VLC_CODEC_FL32;
ss.format = PA_SAMPLE_FLOAT32NE; ss.format = PA_SAMPLE_FLOAT32NE;
} }
else else
{ {
aout->output.output.i_format = VLC_CODEC_S16N; aout->format.i_format = VLC_CODEC_S16N;
ss.format = PA_SAMPLE_S16NE; ss.format = PA_SAMPLE_S16NE;
} }
break; break;
} }
ss.rate = aout->output.output.i_rate; ss.rate = aout->format.i_rate;
ss.channels = aout_FormatNbChannels(&aout->output.output); ss.channels = aout_FormatNbChannels(&aout->format);
if (!pa_sample_spec_valid(&ss)) { if (!pa_sample_spec_valid(&ss)) {
msg_Err(aout, "unsupported sample specification"); msg_Err(aout, "unsupported sample specification");
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -558,28 +558,28 @@ static int Open(vlc_object_t *obj) ...@@ -558,28 +558,28 @@ static int Open(vlc_object_t *obj)
struct pa_channel_map map; struct pa_channel_map map;
map.channels = 0; map.channels = 0;
if (aout->output.output.i_physical_channels & AOUT_CHAN_LEFT) if (aout->format.i_physical_channels & AOUT_CHAN_LEFT)
map.map[map.channels++] = PA_CHANNEL_POSITION_FRONT_LEFT; map.map[map.channels++] = PA_CHANNEL_POSITION_FRONT_LEFT;
if (aout->output.output.i_physical_channels & AOUT_CHAN_RIGHT) if (aout->format.i_physical_channels & AOUT_CHAN_RIGHT)
map.map[map.channels++] = PA_CHANNEL_POSITION_FRONT_RIGHT; map.map[map.channels++] = PA_CHANNEL_POSITION_FRONT_RIGHT;
if (aout->output.output.i_physical_channels & AOUT_CHAN_MIDDLELEFT) if (aout->format.i_physical_channels & AOUT_CHAN_MIDDLELEFT)
map.map[map.channels++] = PA_CHANNEL_POSITION_SIDE_LEFT; map.map[map.channels++] = PA_CHANNEL_POSITION_SIDE_LEFT;
if (aout->output.output.i_physical_channels & AOUT_CHAN_MIDDLERIGHT) if (aout->format.i_physical_channels & AOUT_CHAN_MIDDLERIGHT)
map.map[map.channels++] = PA_CHANNEL_POSITION_SIDE_RIGHT; map.map[map.channels++] = PA_CHANNEL_POSITION_SIDE_RIGHT;
if (aout->output.output.i_physical_channels & AOUT_CHAN_REARLEFT) if (aout->format.i_physical_channels & AOUT_CHAN_REARLEFT)
map.map[map.channels++] = PA_CHANNEL_POSITION_REAR_LEFT; map.map[map.channels++] = PA_CHANNEL_POSITION_REAR_LEFT;
if (aout->output.output.i_physical_channels & AOUT_CHAN_REARRIGHT) if (aout->format.i_physical_channels & AOUT_CHAN_REARRIGHT)
map.map[map.channels++] = PA_CHANNEL_POSITION_REAR_RIGHT; map.map[map.channels++] = PA_CHANNEL_POSITION_REAR_RIGHT;
if (aout->output.output.i_physical_channels & AOUT_CHAN_REARCENTER) if (aout->format.i_physical_channels & AOUT_CHAN_REARCENTER)
map.map[map.channels++] = PA_CHANNEL_POSITION_REAR_CENTER; map.map[map.channels++] = PA_CHANNEL_POSITION_REAR_CENTER;
if (aout->output.output.i_physical_channels & AOUT_CHAN_CENTER) if (aout->format.i_physical_channels & AOUT_CHAN_CENTER)
{ {
if (ss.channels == 1) if (ss.channels == 1)
map.map[map.channels++] = PA_CHANNEL_POSITION_MONO; map.map[map.channels++] = PA_CHANNEL_POSITION_MONO;
else else
map.map[map.channels++] = PA_CHANNEL_POSITION_FRONT_CENTER; map.map[map.channels++] = PA_CHANNEL_POSITION_FRONT_CENTER;
} }
if (aout->output.output.i_physical_channels & AOUT_CHAN_LFE) if (aout->format.i_physical_channels & AOUT_CHAN_LFE)
map.map[map.channels++] = PA_CHANNEL_POSITION_LFE; map.map[map.channels++] = PA_CHANNEL_POSITION_LFE;
for (unsigned i = 0; map.channels < ss.channels; i++) { for (unsigned i = 0; map.channels < ss.channels; i++) {
...@@ -626,7 +626,7 @@ static int Open(vlc_object_t *obj) ...@@ -626,7 +626,7 @@ static int Open(vlc_object_t *obj)
return VLC_EGENERIC; return VLC_EGENERIC;
} }
aout->output.p_sys = sys; aout->sys = sys;
sys->stream = NULL; sys->stream = NULL;
sys->context = ctx; sys->context = ctx;
sys->pts = VLC_TS_INVALID; sys->pts = VLC_TS_INVALID;
...@@ -664,7 +664,7 @@ static int Open(vlc_object_t *obj) ...@@ -664,7 +664,7 @@ static int Open(vlc_object_t *obj)
"prebuf=%u, minreq=%u", "prebuf=%u, minreq=%u",
pba->maxlength, pba->tlength, pba->prebuf, pba->minreq); pba->maxlength, pba->tlength, pba->prebuf, pba->minreq);
aout->output.i_nb_samples = pba->minreq / pa_frame_size(&ss); aout->i_nb_samples = pba->minreq / pa_frame_size(&ss);
var_Create(aout, "audio-device", VLC_VAR_INTEGER|VLC_VAR_HASCHOICE); var_Create(aout, "audio-device", VLC_VAR_INTEGER|VLC_VAR_HASCHOICE);
var_Change(aout, "audio-device", VLC_VAR_SETTEXT, var_Change(aout, "audio-device", VLC_VAR_SETTEXT,
...@@ -678,9 +678,9 @@ static int Open(vlc_object_t *obj) ...@@ -678,9 +678,9 @@ static int Open(vlc_object_t *obj)
stream_moved_cb(s, aout); stream_moved_cb(s, aout);
vlc_pa_unlock(); vlc_pa_unlock();
aout->output.pf_play = Play; aout->pf_play = Play;
aout->output.pf_pause = Pause; aout->pf_pause = Pause;
aout->output.pf_volume_set = VolumeSet; aout->pf_volume_set = VolumeSet;
return VLC_SUCCESS; return VLC_SUCCESS;
fail: fail:
...@@ -695,7 +695,7 @@ fail: ...@@ -695,7 +695,7 @@ fail:
static void Close (vlc_object_t *obj) static void Close (vlc_object_t *obj)
{ {
aout_instance_t *aout = (aout_instance_t *)obj; aout_instance_t *aout = (aout_instance_t *)obj;
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->sys;
pa_context *ctx = sys->context; pa_context *ctx = sys->context;
pa_stream *s = sys->stream; pa_stream *s = sys->stream;
......
...@@ -110,24 +110,24 @@ static int Open ( vlc_object_t *p_this ) ...@@ -110,24 +110,24 @@ static int Open ( vlc_object_t *p_this )
/* The user has selected an audio device. */ /* The user has selected an audio device. */
if ( val.i_int == AOUT_VAR_STEREO ) if ( val.i_int == AOUT_VAR_STEREO )
{ {
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
} }
else if ( val.i_int == AOUT_VAR_MONO ) else if ( val.i_int == AOUT_VAR_MONO )
{ {
p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; p_aout->format.i_physical_channels = AOUT_CHAN_CENTER;
} }
} }
i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); i_nb_channels = aout_FormatNbChannels( &p_aout->format );
if ( i_nb_channels > 2 ) if ( i_nb_channels > 2 )
{ {
/* SDL doesn't support more than two channels. */ /* SDL doesn't support more than two channels. */
i_nb_channels = 2; i_nb_channels = 2;
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
} }
desired.freq = p_aout->output.output.i_rate; desired.freq = p_aout->format.i_rate;
desired.format = AUDIO_S16SYS; desired.format = AUDIO_S16SYS;
desired.channels = i_nb_channels; desired.channels = i_nb_channels;
desired.callback = SDLCallback; desired.callback = SDLCallback;
...@@ -146,24 +146,24 @@ static int Open ( vlc_object_t *p_this ) ...@@ -146,24 +146,24 @@ static int Open ( vlc_object_t *p_this )
switch ( obtained.format ) switch ( obtained.format )
{ {
case AUDIO_S16LSB: case AUDIO_S16LSB:
p_aout->output.output.i_format = VLC_CODEC_S16L; break; p_aout->format.i_format = VLC_CODEC_S16L; break;
case AUDIO_S16MSB: case AUDIO_S16MSB:
p_aout->output.output.i_format = VLC_CODEC_S16B; break; p_aout->format.i_format = VLC_CODEC_S16B; break;
case AUDIO_U16LSB: case AUDIO_U16LSB:
p_aout->output.output.i_format = VLC_CODEC_U16L; break; p_aout->format.i_format = VLC_CODEC_U16L; break;
case AUDIO_U16MSB: case AUDIO_U16MSB:
p_aout->output.output.i_format = VLC_CODEC_U16B; break; p_aout->format.i_format = VLC_CODEC_U16B; break;
case AUDIO_S8: case AUDIO_S8:
p_aout->output.output.i_format = VLC_CODEC_S8; break; p_aout->format.i_format = VLC_CODEC_S8; break;
case AUDIO_U8: case AUDIO_U8:
p_aout->output.output.i_format = VLC_CODEC_U8; break; p_aout->format.i_format = VLC_CODEC_U8; break;
} }
/* Volume is entirely done in software. */ /* Volume is entirely done in software. */
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
if ( obtained.channels != i_nb_channels ) if ( obtained.channels != i_nb_channels )
{ {
p_aout->output.output.i_physical_channels = (obtained.channels == 2 ? p_aout->format.i_physical_channels = (obtained.channels == 2 ?
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT : AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT :
AOUT_CHAN_CENTER); AOUT_CHAN_CENTER);
...@@ -212,10 +212,10 @@ static int Open ( vlc_object_t *p_this ) ...@@ -212,10 +212,10 @@ static int Open ( vlc_object_t *p_this )
var_TriggerCallback( p_aout, "intf-change" ); var_TriggerCallback( p_aout, "intf-change" );
p_aout->output.output.i_rate = obtained.freq; p_aout->format.i_rate = obtained.freq;
p_aout->output.i_nb_samples = obtained.samples; p_aout->i_nb_samples = obtained.samples;
p_aout->output.pf_play = Play; p_aout->pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->pf_pause = NULL;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -252,7 +252,7 @@ static void SDLCallback( void * _p_aout, uint8_t * p_stream, int i_len ) ...@@ -252,7 +252,7 @@ static void SDLCallback( void * _p_aout, uint8_t * p_stream, int i_len )
* it at SDL's face. Nah. */ * it at SDL's face. Nah. */
vlc_mutex_lock( &p_aout->lock ); vlc_mutex_lock( &p_aout->lock );
p_buffer = aout_FifoPop( &p_aout->output.fifo ); p_buffer = aout_FifoPop( &p_aout->fifo );
vlc_mutex_unlock( &p_aout->lock ); vlc_mutex_unlock( &p_aout->lock );
if ( p_buffer != NULL ) if ( p_buffer != NULL )
......
...@@ -148,13 +148,13 @@ static int Open( vlc_object_t *p_this ) ...@@ -148,13 +148,13 @@ static int Open( vlc_object_t *p_this )
vlc_value_t val; vlc_value_t val;
/* Allocate structure */ /* Allocate structure */
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) ); p_aout->sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->output.p_sys == NULL ) if( p_aout->sys == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
p_aout->output.pf_play = Play; p_aout->pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->pf_pause = NULL;
/* /*
initialize/update Device selection List initialize/update Device selection List
...@@ -167,10 +167,10 @@ static int Open( vlc_object_t *p_this ) ...@@ -167,10 +167,10 @@ static int Open( vlc_object_t *p_this )
*/ */
char *psz_waveout_dev = var_CreateGetString( p_aout, "waveout-audio-device"); char *psz_waveout_dev = var_CreateGetString( p_aout, "waveout-audio-device");
p_aout->output.p_sys->i_wave_device_id = p_aout->sys->i_wave_device_id =
findDeviceID( psz_waveout_dev ); findDeviceID( psz_waveout_dev );
if(p_aout->output.p_sys->i_wave_device_id == WAVE_MAPPER) if(p_aout->sys->i_wave_device_id == WAVE_MAPPER)
{ {
if(psz_waveout_dev && if(psz_waveout_dev &&
stricmp(psz_waveout_dev,"wavemapper")) stricmp(psz_waveout_dev,"wavemapper"))
...@@ -183,7 +183,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -183,7 +183,7 @@ static int Open( vlc_object_t *p_this )
WAVEOUTCAPS waveoutcaps; WAVEOUTCAPS waveoutcaps;
if(waveOutGetDevCaps( p_aout->output.p_sys->i_wave_device_id, if(waveOutGetDevCaps( p_aout->sys->i_wave_device_id,
&waveoutcaps, &waveoutcaps,
sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR) sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR)
{ {
...@@ -208,7 +208,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -208,7 +208,7 @@ static int Open( vlc_object_t *p_this )
{ {
/* Probe() has failed. */ /* Probe() has failed. */
var_Destroy( p_aout, "waveout-audio-device"); var_Destroy( p_aout, "waveout-audio-device");
free( p_aout->output.p_sys ); free( p_aout->sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -216,27 +216,27 @@ static int Open( vlc_object_t *p_this ) ...@@ -216,27 +216,27 @@ static int Open( vlc_object_t *p_this )
/* Open the device */ /* Open the device */
if( val.i_int == AOUT_VAR_SPDIF ) if( val.i_int == AOUT_VAR_SPDIF )
{ {
p_aout->output.output.i_format = VLC_CODEC_SPDIFL; p_aout->format.i_format = VLC_CODEC_SPDIFL;
if( OpenWaveOut( p_aout, if( OpenWaveOut( p_aout,
p_aout->output.p_sys->i_wave_device_id, p_aout->sys->i_wave_device_id,
VLC_CODEC_SPDIFL, VLC_CODEC_SPDIFL,
p_aout->output.output.i_physical_channels, p_aout->format.i_physical_channels,
aout_FormatNbChannels( &p_aout->output.output ), aout_FormatNbChannels( &p_aout->format ),
p_aout->output.output.i_rate, false ) p_aout->format.i_rate, false )
!= VLC_SUCCESS ) != VLC_SUCCESS )
{ {
msg_Err( p_aout, "cannot open waveout audio device" ); msg_Err( p_aout, "cannot open waveout audio device" );
free( p_aout->output.p_sys ); free( p_aout->sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Calculate the frame size in bytes */ /* Calculate the frame size in bytes */
p_aout->output.i_nb_samples = A52_FRAME_NB; p_aout->i_nb_samples = A52_FRAME_NB;
p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->output.output.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
p_aout->output.p_sys->i_buffer_size = p_aout->sys->i_buffer_size =
p_aout->output.output.i_bytes_per_frame; p_aout->format.i_bytes_per_frame;
aout_VolumeNoneInit( p_aout ); aout_VolumeNoneInit( p_aout );
} }
...@@ -247,90 +247,90 @@ static int Open( vlc_object_t *p_this ) ...@@ -247,90 +247,90 @@ static int Open( vlc_object_t *p_this )
switch( val.i_int ) switch( val.i_int )
{ {
case AOUT_VAR_5_1: case AOUT_VAR_5_1:
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_LFE; | AOUT_CHAN_LFE;
break; break;
case AOUT_VAR_2F2R: case AOUT_VAR_2F2R:
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
break; break;
case AOUT_VAR_MONO: case AOUT_VAR_MONO:
p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; p_aout->format.i_physical_channels = AOUT_CHAN_CENTER;
break; break;
default: default:
p_aout->output.output.i_physical_channels p_aout->format.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
} }
if( OpenWaveOutPCM( p_aout, if( OpenWaveOutPCM( p_aout,
p_aout->output.p_sys->i_wave_device_id, p_aout->sys->i_wave_device_id,
&p_aout->output.output.i_format, &p_aout->format.i_format,
p_aout->output.output.i_physical_channels, p_aout->format.i_physical_channels,
aout_FormatNbChannels( &p_aout->output.output ), aout_FormatNbChannels( &p_aout->format ),
p_aout->output.output.i_rate, false ) p_aout->format.i_rate, false )
!= VLC_SUCCESS ) != VLC_SUCCESS )
{ {
msg_Err( p_aout, "cannot open waveout audio device" ); msg_Err( p_aout, "cannot open waveout audio device" );
free( p_aout->output.p_sys ); free( p_aout->sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Calculate the frame size in bytes */ /* Calculate the frame size in bytes */
p_aout->output.i_nb_samples = FRAME_SIZE; p_aout->i_nb_samples = FRAME_SIZE;
aout_FormatPrepare( &p_aout->output.output ); aout_FormatPrepare( &p_aout->format );
p_aout->output.p_sys->i_buffer_size = FRAME_SIZE * p_aout->sys->i_buffer_size = FRAME_SIZE *
p_aout->output.output.i_bytes_per_frame; p_aout->format.i_bytes_per_frame;
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
/* Check for hardware volume support */ /* Check for hardware volume support */
if( waveOutGetDevCaps( (UINT_PTR)p_aout->output.p_sys->h_waveout, if( waveOutGetDevCaps( (UINT_PTR)p_aout->sys->h_waveout,
&wocaps, sizeof(wocaps) ) == MMSYSERR_NOERROR && &wocaps, sizeof(wocaps) ) == MMSYSERR_NOERROR &&
wocaps.dwSupport & WAVECAPS_VOLUME ) wocaps.dwSupport & WAVECAPS_VOLUME )
{ {
DWORD i_dummy; DWORD i_dummy;
if( waveOutGetVolume( p_aout->output.p_sys->h_waveout, &i_dummy ) if( waveOutGetVolume( p_aout->sys->h_waveout, &i_dummy )
== MMSYSERR_NOERROR ) == MMSYSERR_NOERROR )
{ {
p_aout->output.pf_volume_set = VolumeSet; p_aout->pf_volume_set = VolumeSet;
} }
} }
} }
waveOutReset( p_aout->output.p_sys->h_waveout ); waveOutReset( p_aout->sys->h_waveout );
/* Allocate silence buffer */ /* Allocate silence buffer */
p_aout->output.p_sys->p_silence_buffer = p_aout->sys->p_silence_buffer =
malloc( p_aout->output.p_sys->i_buffer_size ); malloc( p_aout->sys->i_buffer_size );
if( p_aout->output.p_sys->p_silence_buffer == NULL ) if( p_aout->sys->p_silence_buffer == NULL )
{ {
free( p_aout->output.p_sys ); free( p_aout->sys );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
p_aout->output.p_sys->i_repeat_counter = 0; p_aout->sys->i_repeat_counter = 0;
/* Zero the buffer. WinCE doesn't have calloc(). */ /* Zero the buffer. WinCE doesn't have calloc(). */
memset( p_aout->output.p_sys->p_silence_buffer, 0, memset( p_aout->sys->p_silence_buffer, 0,
p_aout->output.p_sys->i_buffer_size ); p_aout->sys->i_buffer_size );
/* Now we need to setup our waveOut play notification structure */ /* Now we need to setup our waveOut play notification structure */
p_aout->output.p_sys->event = CreateEvent( NULL, FALSE, FALSE, NULL ); p_aout->sys->event = CreateEvent( NULL, FALSE, FALSE, NULL );
p_aout->output.p_sys->new_buffer_event = CreateEvent( NULL, FALSE, FALSE, NULL ); p_aout->sys->new_buffer_event = CreateEvent( NULL, FALSE, FALSE, NULL );
/* define startpoint of playback on first call to play() /* define startpoint of playback on first call to play()
like alsa does (instead of playing a blank sample) */ like alsa does (instead of playing a blank sample) */
p_aout->output.p_sys->b_playing = 0; p_aout->sys->b_playing = 0;
p_aout->output.p_sys->start_date = 0; p_aout->sys->start_date = 0;
/* Then launch the notification thread */ /* Then launch the notification thread */
vlc_atomic_set( &p_aout->output.p_sys->abort, 0); vlc_atomic_set( &p_aout->sys->abort, 0);
if( vlc_clone( &p_aout->output.p_sys->thread, if( vlc_clone( &p_aout->sys->thread,
WaveOutThread, p_aout, VLC_THREAD_PRIORITY_OUTPUT ) ) WaveOutThread, p_aout, VLC_THREAD_PRIORITY_OUTPUT ) )
{ {
msg_Err( p_aout, "cannot create WaveOutThread" ); msg_Err( p_aout, "cannot create WaveOutThread" );
...@@ -340,8 +340,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -340,8 +340,8 @@ static int Open( vlc_object_t *p_this )
* working */ * working */
for( int i = 0; i < FRAMES_NUM; i++ ) for( int i = 0; i < FRAMES_NUM; i++ )
{ {
p_aout->output.p_sys->waveheader[i].dwFlags = WHDR_DONE; p_aout->sys->waveheader[i].dwFlags = WHDR_DONE;
p_aout->output.p_sys->waveheader[i].dwUser = 0; p_aout->sys->waveheader[i].dwUser = 0;
} }
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -364,13 +364,13 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -364,13 +364,13 @@ static void Probe( aout_instance_t * p_aout )
i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT | AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT |
AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE; AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE;
if( p_aout->output.output.i_physical_channels == i_physical_channels ) if( p_aout->format.i_physical_channels == i_physical_channels )
{ {
if( OpenWaveOutPCM( p_aout, if( OpenWaveOutPCM( p_aout,
p_aout->output.p_sys->i_wave_device_id, p_aout->sys->i_wave_device_id,
&i_format, &i_format,
i_physical_channels, 6, i_physical_channels, 6,
p_aout->output.output.i_rate, true ) p_aout->format.i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
val.i_int = AOUT_VAR_5_1; val.i_int = AOUT_VAR_5_1;
...@@ -384,14 +384,14 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -384,14 +384,14 @@ static void Probe( aout_instance_t * p_aout )
/* Test for 2 Front 2 Rear support */ /* Test for 2 Front 2 Rear support */
i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
if( ( p_aout->output.output.i_physical_channels & i_physical_channels ) if( ( p_aout->format.i_physical_channels & i_physical_channels )
== i_physical_channels ) == i_physical_channels )
{ {
if( OpenWaveOutPCM( p_aout, if( OpenWaveOutPCM( p_aout,
p_aout->output.p_sys->i_wave_device_id, p_aout->sys->i_wave_device_id,
&i_format, &i_format,
i_physical_channels, 4, i_physical_channels, 4,
p_aout->output.output.i_rate, true ) p_aout->format.i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
val.i_int = AOUT_VAR_2F2R; val.i_int = AOUT_VAR_2F2R;
...@@ -405,10 +405,10 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -405,10 +405,10 @@ static void Probe( aout_instance_t * p_aout )
/* Test for stereo support */ /* Test for stereo support */
i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
if( OpenWaveOutPCM( p_aout, if( OpenWaveOutPCM( p_aout,
p_aout->output.p_sys->i_wave_device_id, p_aout->sys->i_wave_device_id,
&i_format, &i_format,
i_physical_channels, 2, i_physical_channels, 2,
p_aout->output.output.i_rate, true ) p_aout->format.i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
val.i_int = AOUT_VAR_STEREO; val.i_int = AOUT_VAR_STEREO;
...@@ -420,10 +420,10 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -420,10 +420,10 @@ static void Probe( aout_instance_t * p_aout )
/* Test for mono support */ /* Test for mono support */
i_physical_channels = AOUT_CHAN_CENTER; i_physical_channels = AOUT_CHAN_CENTER;
if( OpenWaveOutPCM( p_aout, if( OpenWaveOutPCM( p_aout,
p_aout->output.p_sys->i_wave_device_id, p_aout->sys->i_wave_device_id,
&i_format, &i_format,
i_physical_channels, 1, i_physical_channels, 1,
p_aout->output.output.i_rate, true ) p_aout->format.i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
val.i_int = AOUT_VAR_MONO; val.i_int = AOUT_VAR_MONO;
...@@ -433,14 +433,14 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -433,14 +433,14 @@ static void Probe( aout_instance_t * p_aout )
} }
/* Test for SPDIF support */ /* Test for SPDIF support */
if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) if ( AOUT_FMT_NON_LINEAR( &p_aout->format ) )
{ {
if( OpenWaveOut( p_aout, if( OpenWaveOut( p_aout,
p_aout->output.p_sys->i_wave_device_id, p_aout->sys->i_wave_device_id,
VLC_CODEC_SPDIFL, VLC_CODEC_SPDIFL,
p_aout->output.output.i_physical_channels, p_aout->format.i_physical_channels,
aout_FormatNbChannels( &p_aout->output.output ), aout_FormatNbChannels( &p_aout->format ),
p_aout->output.output.i_rate, true ) p_aout->format.i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
msg_Dbg( p_aout, "device supports A/52 over S/PDIF" ); msg_Dbg( p_aout, "device supports A/52 over S/PDIF" );
...@@ -473,20 +473,20 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -473,20 +473,20 @@ static void Probe( aout_instance_t * p_aout )
*****************************************************************************/ *****************************************************************************/
static void Play( aout_instance_t *_p_aout ) static void Play( aout_instance_t *_p_aout )
{ {
if( !_p_aout->output.p_sys->b_playing ) if( !_p_aout->sys->b_playing )
{ {
_p_aout->output.p_sys->b_playing = 1; _p_aout->sys->b_playing = 1;
/* get the playing date of the first aout buffer */ /* get the playing date of the first aout buffer */
_p_aout->output.p_sys->start_date = _p_aout->sys->start_date =
aout_FifoFirstDate( &_p_aout->output.fifo ); aout_FifoFirstDate( &_p_aout->fifo );
msg_Dbg( _p_aout, "Wakeup sleeping output thread."); msg_Dbg( _p_aout, "Wakeup sleeping output thread.");
/* wake up the audio output thread */ /* wake up the audio output thread */
SetEvent( _p_aout->output.p_sys->event ); SetEvent( _p_aout->sys->event );
} else { } else {
SetEvent( _p_aout->output.p_sys->new_buffer_event ); SetEvent( _p_aout->sys->new_buffer_event );
} }
} }
...@@ -496,7 +496,7 @@ static void Play( aout_instance_t *_p_aout ) ...@@ -496,7 +496,7 @@ static void Play( aout_instance_t *_p_aout )
static void Close( vlc_object_t *p_this ) static void Close( vlc_object_t *p_this )
{ {
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
aout_sys_t *p_sys = p_aout->output.p_sys; aout_sys_t *p_sys = p_aout->sys;
/* Before calling waveOutClose we must reset the device */ /* Before calling waveOutClose we must reset the device */
vlc_atomic_set( &p_sys->abort, 1); vlc_atomic_set( &p_sys->abort, 1);
...@@ -577,7 +577,7 @@ static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_for ...@@ -577,7 +577,7 @@ static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_for
/* Set sound format */ /* Set sound format */
#define waveformat p_aout->output.p_sys->waveformat #define waveformat p_aout->sys->waveformat
waveformat.dwChannelMask = 0; waveformat.dwChannelMask = 0;
for( unsigned i = 0; i < sizeof(pi_channels_src)/sizeof(uint32_t); i++ ) for( unsigned i = 0; i < sizeof(pi_channels_src)/sizeof(uint32_t); i++ )
...@@ -660,7 +660,7 @@ static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_for ...@@ -660,7 +660,7 @@ static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_for
} }
/* Open the device */ /* Open the device */
result = waveOutOpen( &p_aout->output.p_sys->h_waveout, i_device_id, result = waveOutOpen( &p_aout->sys->h_waveout, i_device_id,
(WAVEFORMATEX *)&waveformat, (WAVEFORMATEX *)&waveformat,
(DWORD_PTR)WaveOutCallback, (DWORD_PTR)p_aout, (DWORD_PTR)WaveOutCallback, (DWORD_PTR)p_aout,
CALLBACK_FUNCTION | (b_probe?WAVE_FORMAT_QUERY:0) ); CALLBACK_FUNCTION | (b_probe?WAVE_FORMAT_QUERY:0) );
...@@ -680,12 +680,12 @@ static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_for ...@@ -680,12 +680,12 @@ static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_for
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_aout->output.p_sys->b_chan_reorder = p_aout->sys->b_chan_reorder =
aout_CheckChannelReorder( pi_channels_in, pi_channels_out, aout_CheckChannelReorder( pi_channels_in, pi_channels_out,
waveformat.dwChannelMask, i_nb_channels, waveformat.dwChannelMask, i_nb_channels,
p_aout->output.p_sys->pi_chan_table ); p_aout->sys->pi_chan_table );
if( p_aout->output.p_sys->b_chan_reorder ) if( p_aout->sys->b_chan_reorder )
{ {
msg_Dbg( p_aout, "channel reordering needed" ); msg_Dbg( p_aout, "channel reordering needed" );
} }
...@@ -750,27 +750,27 @@ static int PlayWaveOut( aout_instance_t *p_aout, HWAVEOUT h_waveout, ...@@ -750,27 +750,27 @@ static int PlayWaveOut( aout_instance_t *p_aout, HWAVEOUT h_waveout,
*/ */
if(b_spdif) if(b_spdif)
{ {
vlc_memcpy( p_aout->output.p_sys->p_silence_buffer, vlc_memcpy( p_aout->sys->p_silence_buffer,
p_buffer->p_buffer, p_buffer->p_buffer,
p_aout->output.p_sys->i_buffer_size ); p_aout->sys->i_buffer_size );
p_aout->output.p_sys->i_repeat_counter = 2; p_aout->sys->i_repeat_counter = 2;
} }
} else { } else {
/* Use silence buffer instead */ /* Use silence buffer instead */
if(p_aout->output.p_sys->i_repeat_counter) if(p_aout->sys->i_repeat_counter)
{ {
p_aout->output.p_sys->i_repeat_counter--; p_aout->sys->i_repeat_counter--;
if(!p_aout->output.p_sys->i_repeat_counter) if(!p_aout->sys->i_repeat_counter)
{ {
vlc_memset( p_aout->output.p_sys->p_silence_buffer, vlc_memset( p_aout->sys->p_silence_buffer,
0x00, p_aout->output.p_sys->i_buffer_size ); 0x00, p_aout->sys->i_buffer_size );
} }
} }
p_waveheader->lpData = (LPSTR)p_aout->output.p_sys->p_silence_buffer; p_waveheader->lpData = (LPSTR)p_aout->sys->p_silence_buffer;
} }
p_waveheader->dwUser = p_buffer ? (DWORD_PTR)p_buffer : (DWORD_PTR)1; p_waveheader->dwUser = p_buffer ? (DWORD_PTR)p_buffer : (DWORD_PTR)1;
p_waveheader->dwBufferLength = p_aout->output.p_sys->i_buffer_size; p_waveheader->dwBufferLength = p_aout->sys->i_buffer_size;
p_waveheader->dwFlags = 0; p_waveheader->dwFlags = 0;
result = waveOutPrepareHeader( h_waveout, p_waveheader, sizeof(WAVEHDR) ); result = waveOutPrepareHeader( h_waveout, p_waveheader, sizeof(WAVEHDR) );
...@@ -804,13 +804,13 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg, ...@@ -804,13 +804,13 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg,
if( uMsg != WOM_DONE ) return; if( uMsg != WOM_DONE ) return;
if( vlc_atomic_get(&p_aout->output.p_sys->abort) ) return; if( vlc_atomic_get(&p_aout->sys->abort) ) return;
/* Find out the current latency */ /* Find out the current latency */
for( int i = 0; i < FRAMES_NUM; i++ ) for( int i = 0; i < FRAMES_NUM; i++ )
{ {
/* Check if frame buf is available */ /* Check if frame buf is available */
if( !(p_aout->output.p_sys->waveheader[i].dwFlags & WHDR_DONE) ) if( !(p_aout->sys->waveheader[i].dwFlags & WHDR_DONE) )
{ {
i_queued_frames++; i_queued_frames++;
} }
...@@ -818,7 +818,7 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg, ...@@ -818,7 +818,7 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg,
/* Don't wake up the thread too much */ /* Don't wake up the thread too much */
if( i_queued_frames <= FRAMES_NUM/2 ) if( i_queued_frames <= FRAMES_NUM/2 )
SetEvent( p_aout->output.p_sys->event ); SetEvent( p_aout->sys->event );
} }
...@@ -868,7 +868,7 @@ static int WaveOutClearDoneBuffers(aout_sys_t *p_sys) ...@@ -868,7 +868,7 @@ static int WaveOutClearDoneBuffers(aout_sys_t *p_sys)
static void* WaveOutThread( void *data ) static void* WaveOutThread( void *data )
{ {
aout_instance_t *p_aout = data; aout_instance_t *p_aout = data;
aout_sys_t *p_sys = p_aout->output.p_sys; aout_sys_t *p_sys = p_aout->sys;
aout_buffer_t *p_buffer = NULL; aout_buffer_t *p_buffer = NULL;
WAVEHDR *p_waveheader = p_sys->waveheader; WAVEHDR *p_waveheader = p_sys->waveheader;
int i, i_queued_frames; int i, i_queued_frames;
...@@ -878,12 +878,12 @@ static void* WaveOutThread( void *data ) ...@@ -878,12 +878,12 @@ static void* WaveOutThread( void *data )
int canc = vlc_savecancel (); int canc = vlc_savecancel ();
/* We don't want any resampling when using S/PDIF */ /* We don't want any resampling when using S/PDIF */
b_sleek = p_aout->output.output.i_format == VLC_CODEC_SPDIFL; b_sleek = p_aout->format.i_format == VLC_CODEC_SPDIFL;
// wait for first call to "play()" // wait for first call to "play()"
while( !p_sys->start_date && !vlc_atomic_get(&p_aout->output.p_sys->abort) ) while( !p_sys->start_date && !vlc_atomic_get(&p_aout->sys->abort) )
WaitForSingleObject( p_sys->event, INFINITE ); WaitForSingleObject( p_sys->event, INFINITE );
if( vlc_atomic_get(&p_aout->output.p_sys->abort) ) if( vlc_atomic_get(&p_aout->sys->abort) )
return NULL; return NULL;
msg_Dbg( p_aout, "will start to play in %"PRId64" us", msg_Dbg( p_aout, "will start to play in %"PRId64" us",
...@@ -899,12 +899,12 @@ static void* WaveOutThread( void *data ) ...@@ -899,12 +899,12 @@ static void* WaveOutThread( void *data )
i_queued_frames, msg); i_queued_frames, msg);
next_date = mdate(); next_date = mdate();
while( !vlc_atomic_get(&p_aout->output.p_sys->abort) ) while( !vlc_atomic_get(&p_aout->sys->abort) )
{ {
/* Cleanup and find out the current latency */ /* Cleanup and find out the current latency */
i_queued_frames = WaveOutClearDoneBuffers( p_sys ); i_queued_frames = WaveOutClearDoneBuffers( p_sys );
if( vlc_atomic_get(&p_aout->output.p_sys->abort) ) return NULL; if( vlc_atomic_get(&p_aout->sys->abort) ) return NULL;
/* Try to fill in as many frame buffers as possible */ /* Try to fill in as many frame buffers as possible */
for( i = 0; i < FRAMES_NUM; i++ ) for( i = 0; i < FRAMES_NUM; i++ )
...@@ -913,7 +913,7 @@ static void* WaveOutThread( void *data ) ...@@ -913,7 +913,7 @@ static void* WaveOutThread( void *data )
if( p_waveheader[i].dwFlags & WHDR_DONE ) if( p_waveheader[i].dwFlags & WHDR_DONE )
{ {
// next_date = mdate() + 1000000 * i_queued_frames / // next_date = mdate() + 1000000 * i_queued_frames /
// p_aout->output.output.i_rate * p_aout->output.i_nb_samples; // p_aout->format.i_rate * p_aout->i_nb_samples;
// the realtime has got our back-site:) to come in sync // the realtime has got our back-site:) to come in sync
if(next_date < mdate()) if(next_date < mdate())
...@@ -936,7 +936,7 @@ static void* WaveOutThread( void *data ) ...@@ -936,7 +936,7 @@ static void* WaveOutThread( void *data )
#endif #endif
// means we are too early to request a new buffer? // means we are too early to request a new buffer?
waveout_warn("waiting...") waveout_warn("waiting...")
next_date = aout_FifoFirstDate( &p_aout->output.fifo ); next_date = aout_FifoFirstDate( &p_aout->fifo );
mwait( next_date - AOUT_MAX_PTS_ADVANCE/4 ); mwait( next_date - AOUT_MAX_PTS_ADVANCE/4 );
next_date = mdate(); next_date = mdate();
p_buffer = aout_OutputNextBuffer( p_aout, next_date, p_buffer = aout_OutputNextBuffer( p_aout, next_date,
...@@ -973,7 +973,7 @@ static void* WaveOutThread( void *data ) ...@@ -973,7 +973,7 @@ static void* WaveOutThread( void *data )
} }
} }
if( vlc_atomic_get(&p_aout->output.p_sys->abort) ) return NULL; if( vlc_atomic_get(&p_aout->sys->abort) ) return NULL;
/* /*
deal with the case that the loop didn't fillup the buffer to the deal with the case that the loop didn't fillup the buffer to the
...@@ -1009,7 +1009,7 @@ static int VolumeSet( aout_instance_t * p_aout, float volume, bool mute ) ...@@ -1009,7 +1009,7 @@ static int VolumeSet( aout_instance_t * p_aout, float volume, bool mute )
#ifdef UNDER_CE #ifdef UNDER_CE
waveOutSetVolume( 0, i_waveout_vol ); waveOutSetVolume( 0, i_waveout_vol );
#else #else
waveOutSetVolume( p_aout->output.p_sys->h_waveout, i_waveout_vol ); waveOutSetVolume( p_aout->sys->h_waveout, i_waveout_vol );
#endif #endif
return 0; return 0;
} }
......
...@@ -50,21 +50,20 @@ int OpenAudio ( vlc_object_t * p_this ) ...@@ -50,21 +50,20 @@ int OpenAudio ( vlc_object_t * p_this )
{ {
aout_instance_t * p_aout = (aout_instance_t *)p_this; aout_instance_t * p_aout = (aout_instance_t *)p_this;
p_aout->output.pf_play = Play; p_aout->pf_play = Play;
p_aout->output.pf_pause = NULL; p_aout->pf_pause = NULL;
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
if( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) if( AOUT_FMT_NON_LINEAR( &p_aout->format )
&& var_InheritBool( p_this, "spdif" ) ) && var_InheritBool( p_this, "spdif" ) )
{ {
p_aout->output.output.i_format = VLC_CODEC_SPDIFL; p_aout->format.i_format = VLC_CODEC_SPDIFL;
p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->output.output.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
} }
else else
p_aout->output.output.i_format = p_aout->format.i_format = HAVE_FPU ? VLC_CODEC_FL32 : VLC_CODEC_S16N;
HAVE_FPU ? VLC_CODEC_FL32 : VLC_CODEC_S16N; p_aout->i_nb_samples = A52_FRAME_NB;
p_aout->output.i_nb_samples = A52_FRAME_NB;
/* Create the variable for the audio-device */ /* Create the variable for the audio-device */
var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
...@@ -77,7 +76,7 @@ int OpenAudio ( vlc_object_t * p_this ) ...@@ -77,7 +76,7 @@ int OpenAudio ( vlc_object_t * p_this )
*****************************************************************************/ *****************************************************************************/
static void Play( aout_instance_t * p_aout ) static void Play( aout_instance_t * p_aout )
{ {
aout_buffer_t * p_buffer = aout_FifoPop( &p_aout->output.fifo ); aout_buffer_t * p_buffer = aout_FifoPop( &p_aout->fifo );
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
} }
...@@ -64,8 +64,8 @@ aout_instance_t *aout_New( vlc_object_t * p_parent ) ...@@ -64,8 +64,8 @@ aout_instance_t *aout_New( vlc_object_t * p_parent )
p_aout->p_input = NULL; p_aout->p_input = NULL;
p_aout->mixer_multiplier = 1.0; p_aout->mixer_multiplier = 1.0;
p_aout->p_mixer = NULL; p_aout->p_mixer = NULL;
p_aout->output.b_starving = 1; p_aout->b_starving = true;
p_aout->output.p_module = NULL; p_aout->module = NULL;
var_Create( p_aout, "intf-change", VLC_VAR_VOID ); var_Create( p_aout, "intf-change", VLC_VAR_VOID );
......
...@@ -91,7 +91,7 @@ static int commitVolume (vlc_object_t *obj, aout_instance_t *aout, ...@@ -91,7 +91,7 @@ static int commitVolume (vlc_object_t *obj, aout_instance_t *aout,
aout_lock (aout); aout_lock (aout);
#warning FIXME: wrong test. Need to check that aout_output is ready. #warning FIXME: wrong test. Need to check that aout_output is ready.
if (aout->p_mixer != NULL) if (aout->p_mixer != NULL)
ret = aout->output.pf_volume_set (aout, vol, mute); ret = aout->pf_volume_set (aout, vol, mute);
aout_unlock (aout); aout_unlock (aout);
if (ret == 0) if (ret == 0)
...@@ -255,7 +255,7 @@ void aout_VolumeSoftInit (aout_instance_t *aout) ...@@ -255,7 +255,7 @@ void aout_VolumeSoftInit (aout_instance_t *aout)
audio_volume_t volume = var_InheritInteger (aout, "volume"); audio_volume_t volume = var_InheritInteger (aout, "volume");
bool mute = var_InheritBool (aout, "mute"); bool mute = var_InheritBool (aout, "mute");
aout->output.pf_volume_set = aout_VolumeSoftSet; aout->pf_volume_set = aout_VolumeSoftSet;
aout_VolumeSoftSet (aout, volume / (float)AOUT_VOLUME_DEFAULT, mute); aout_VolumeSoftSet (aout, volume / (float)AOUT_VOLUME_DEFAULT, mute);
} }
...@@ -273,7 +273,7 @@ static int aout_VolumeNoneSet (aout_instance_t *aout, float volume, bool mute) ...@@ -273,7 +273,7 @@ static int aout_VolumeNoneSet (aout_instance_t *aout, float volume, bool mute)
/* Meant to be called by the output plug-in's Open(). */ /* Meant to be called by the output plug-in's Open(). */
void aout_VolumeNoneInit( aout_instance_t * p_aout ) void aout_VolumeNoneInit( aout_instance_t * p_aout )
{ {
p_aout->output.pf_volume_set = aout_VolumeNoneSet; p_aout->pf_volume_set = aout_VolumeNoneSet;
} }
......
...@@ -96,7 +96,7 @@ static int MixBuffer( aout_instance_t * p_aout, float volume ) ...@@ -96,7 +96,7 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
aout_mixer_input_t *p_input = p_mixer->input; aout_mixer_input_t *p_input = p_mixer->input;
aout_fifo_t *p_fifo = &p_input->fifo; aout_fifo_t *p_fifo = &p_input->fifo;
mtime_t now = mdate(); mtime_t now = mdate();
const unsigned samples = p_aout->output.i_nb_samples; const unsigned samples = p_aout->i_nb_samples;
/* FIXME: Remove this silly constraint. Just pass buffers as they come to /* FIXME: Remove this silly constraint. Just pass buffers as they come to
* "smart" audio outputs. */ * "smart" audio outputs. */
assert( samples > 0 ); assert( samples > 0 );
...@@ -104,7 +104,7 @@ static int MixBuffer( aout_instance_t * p_aout, float volume ) ...@@ -104,7 +104,7 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
vlc_assert_locked( &p_aout->lock ); vlc_assert_locked( &p_aout->lock );
/* Retrieve the date of the next buffer. */ /* Retrieve the date of the next buffer. */
date_t exact_start_date = p_aout->output.fifo.end_date; date_t exact_start_date = p_aout->fifo.end_date;
mtime_t start_date = date_Get( &exact_start_date ); mtime_t start_date = date_Get( &exact_start_date );
if( start_date != 0 && start_date < now ) if( start_date != 0 && start_date < now )
...@@ -114,7 +114,7 @@ static int MixBuffer( aout_instance_t * p_aout, float volume ) ...@@ -114,7 +114,7 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
* happen :). */ * happen :). */
msg_Warn( p_mixer, "output PTS is out of range (%"PRId64"), clearing out", msg_Warn( p_mixer, "output PTS is out of range (%"PRId64"), clearing out",
mdate() - start_date ); mdate() - start_date );
aout_FifoSet( &p_aout->output.fifo, 0 ); aout_FifoSet( &p_aout->fifo, 0 );
date_Set( &exact_start_date, 0 ); date_Set( &exact_start_date, 0 );
start_date = 0; start_date = 0;
} }
...@@ -187,7 +187,7 @@ static int MixBuffer( aout_instance_t * p_aout, float volume ) ...@@ -187,7 +187,7 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
if( delta < 0 ) if( delta < 0 )
{ {
/* Is it really the best way to do it ? */ /* Is it really the best way to do it ? */
aout_FifoSet( &p_aout->output.fifo, 0 ); aout_FifoSet( &p_aout->fifo, 0 );
date_Set( &exact_start_date, 0 ); date_Set( &exact_start_date, 0 );
return -1; return -1;
} }
......
...@@ -45,17 +45,17 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -45,17 +45,17 @@ int aout_OutputNew( aout_instance_t * p_aout,
const audio_sample_format_t * p_format ) const audio_sample_format_t * p_format )
{ {
vlc_assert_locked( &p_aout->lock ); vlc_assert_locked( &p_aout->lock );
p_aout->output.output = *p_format; p_aout->format = *p_format;
/* Retrieve user defaults. */ /* Retrieve user defaults. */
int i_rate = var_InheritInteger( p_aout, "aout-rate" ); int i_rate = var_InheritInteger( p_aout, "aout-rate" );
if ( i_rate != 0 ) if ( i_rate != 0 )
p_aout->output.output.i_rate = i_rate; p_aout->format.i_rate = i_rate;
aout_FormatPrepare( &p_aout->output.output ); aout_FormatPrepare( &p_aout->format );
/* Find the best output plug-in. */ /* Find the best output plug-in. */
p_aout->output.p_module = module_need( p_aout, "audio output", "$aout", false ); p_aout->module = module_need( p_aout, "audio output", "$aout", false );
if ( p_aout->output.p_module == NULL ) if ( p_aout->module == NULL )
{ {
msg_Err( p_aout, "no suitable audio output module" ); msg_Err( p_aout, "no suitable audio output module" );
return -1; return -1;
...@@ -68,27 +68,26 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -68,27 +68,26 @@ int aout_OutputNew( aout_instance_t * p_aout,
switch( var_InheritInteger( p_aout, "audio-channels" ) ) switch( var_InheritInteger( p_aout, "audio-channels" ) )
{ {
case AOUT_VAR_CHAN_RSTEREO: case AOUT_VAR_CHAN_RSTEREO:
p_aout->output.output.i_original_channels |= p_aout->format.i_original_channels |= AOUT_CHAN_REVERSESTEREO;
AOUT_CHAN_REVERSESTEREO;
break; break;
case AOUT_VAR_CHAN_STEREO: case AOUT_VAR_CHAN_STEREO:
p_aout->output.output.i_original_channels = p_aout->format.i_original_channels =
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
break; break;
case AOUT_VAR_CHAN_LEFT: case AOUT_VAR_CHAN_LEFT:
p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; p_aout->format.i_original_channels = AOUT_CHAN_LEFT;
break; break;
case AOUT_VAR_CHAN_RIGHT: case AOUT_VAR_CHAN_RIGHT:
p_aout->output.output.i_original_channels = AOUT_CHAN_RIGHT; p_aout->format.i_original_channels = AOUT_CHAN_RIGHT;
break; break;
case AOUT_VAR_CHAN_DOLBYS: case AOUT_VAR_CHAN_DOLBYS:
p_aout->output.output.i_original_channels = p_aout->format.i_original_channels =
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_DOLBYSTEREO; AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_DOLBYSTEREO;
break; break;
} }
} }
else if ( p_aout->output.output.i_physical_channels == AOUT_CHAN_CENTER else if ( p_aout->format.i_physical_channels == AOUT_CHAN_CENTER
&& (p_aout->output.output.i_original_channels && (p_aout->format.i_original_channels
& AOUT_CHAN_PHYSMASK) == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) ) & AOUT_CHAN_PHYSMASK) == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) )
{ {
vlc_value_t val, text; vlc_value_t val, text;
...@@ -105,18 +104,18 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -105,18 +104,18 @@ int aout_OutputNew( aout_instance_t * p_aout,
var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text );
val.i_int = AOUT_VAR_CHAN_RIGHT; text.psz_string = _("Right"); val.i_int = AOUT_VAR_CHAN_RIGHT; text.psz_string = _("Right");
var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text );
if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DUALMONO ) if ( p_aout->format.i_original_channels & AOUT_CHAN_DUALMONO )
{ {
/* Go directly to the left channel. */ /* Go directly to the left channel. */
p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; p_aout->format.i_original_channels = AOUT_CHAN_LEFT;
var_SetInteger( p_aout, "audio-channels", AOUT_VAR_CHAN_LEFT ); var_SetInteger( p_aout, "audio-channels", AOUT_VAR_CHAN_LEFT );
} }
var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart, var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart,
NULL ); NULL );
} }
else if ( p_aout->output.output.i_physical_channels == else if ( p_aout->format.i_physical_channels ==
(AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)
&& (p_aout->output.output.i_original_channels & && (p_aout->format.i_original_channels &
(AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)) ) (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)) )
{ {
vlc_value_t val, text; vlc_value_t val, text;
...@@ -127,7 +126,7 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -127,7 +126,7 @@ int aout_OutputNew( aout_instance_t * p_aout,
text.psz_string = _("Audio Channels"); text.psz_string = _("Audio Channels");
var_Change( p_aout, "audio-channels", VLC_VAR_SETTEXT, &text, NULL ); var_Change( p_aout, "audio-channels", VLC_VAR_SETTEXT, &text, NULL );
if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DOLBYSTEREO ) if ( p_aout->format.i_original_channels & AOUT_CHAN_DOLBYSTEREO )
{ {
val.i_int = AOUT_VAR_CHAN_DOLBYS; val.i_int = AOUT_VAR_CHAN_DOLBYS;
text.psz_string = _("Dolby Surround"); text.psz_string = _("Dolby Surround");
...@@ -144,10 +143,10 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -144,10 +143,10 @@ int aout_OutputNew( aout_instance_t * p_aout,
var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text );
val.i_int = AOUT_VAR_CHAN_RSTEREO; text.psz_string=_("Reverse stereo"); val.i_int = AOUT_VAR_CHAN_RSTEREO; text.psz_string=_("Reverse stereo");
var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text );
if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DUALMONO ) if ( p_aout->format.i_original_channels & AOUT_CHAN_DUALMONO )
{ {
/* Go directly to the left channel. */ /* Go directly to the left channel. */
p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; p_aout->format.i_original_channels = AOUT_CHAN_LEFT;
var_SetInteger( p_aout, "audio-channels", AOUT_VAR_CHAN_LEFT ); var_SetInteger( p_aout, "audio-channels", AOUT_VAR_CHAN_LEFT );
} }
var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart, var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart,
...@@ -155,15 +154,15 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -155,15 +154,15 @@ int aout_OutputNew( aout_instance_t * p_aout,
} }
var_TriggerCallback( p_aout, "intf-change" ); var_TriggerCallback( p_aout, "intf-change" );
aout_FormatPrepare( &p_aout->output.output ); aout_FormatPrepare( &p_aout->format );
/* Prepare FIFO. */ /* Prepare FIFO. */
aout_FifoInit( p_aout, &p_aout->output.fifo, p_aout->output.output.i_rate ); aout_FifoInit( p_aout, &p_aout->fifo, p_aout->format.i_rate );
aout_FormatPrint( p_aout, "output", &p_aout->output.output ); aout_FormatPrint( p_aout, "output", &p_aout->format );
/* Choose the mixer format. */ /* Choose the mixer format. */
p_aout->mixer_format = p_aout->output.output; p_aout->mixer_format = p_aout->format;
if ( AOUT_FMT_NON_LINEAR(&p_aout->output.output) ) if ( AOUT_FMT_NON_LINEAR(&p_aout->format) )
p_aout->mixer_format.i_format = p_format->i_format; p_aout->mixer_format.i_format = p_format->i_format;
else else
/* Most audio filters can only deal with single-precision, /* Most audio filters can only deal with single-precision,
...@@ -184,15 +183,15 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -184,15 +183,15 @@ int aout_OutputNew( aout_instance_t * p_aout,
aout_FormatPrint( p_aout, "mixer", &p_aout->mixer_format ); aout_FormatPrint( p_aout, "mixer", &p_aout->mixer_format );
/* Create filters. */ /* Create filters. */
p_aout->output.i_nb_filters = 0; p_aout->i_nb_filters = 0;
if ( aout_FiltersCreatePipeline( p_aout, p_aout->output.pp_filters, if ( aout_FiltersCreatePipeline( p_aout, p_aout->pp_filters,
&p_aout->output.i_nb_filters, &p_aout->i_nb_filters,
&p_aout->mixer_format, &p_aout->mixer_format,
&p_aout->output.output ) < 0 ) &p_aout->format ) < 0 )
{ {
msg_Err( p_aout, "couldn't create audio output pipeline" ); msg_Err( p_aout, "couldn't create audio output pipeline" );
module_unneed( p_aout, p_aout->output.p_module ); module_unneed( p_aout, p_aout->module );
p_aout->output.p_module = NULL; p_aout->module = NULL;
return -1; return -1;
} }
return 0; return 0;
...@@ -207,14 +206,13 @@ void aout_OutputDelete( aout_instance_t * p_aout ) ...@@ -207,14 +206,13 @@ void aout_OutputDelete( aout_instance_t * p_aout )
{ {
vlc_assert_locked( &p_aout->lock ); vlc_assert_locked( &p_aout->lock );
if( p_aout->output.p_module == NULL ) if( p_aout->module == NULL )
return; return;
module_unneed( p_aout, p_aout->output.p_module ); module_unneed( p_aout, p_aout->module );
p_aout->output.p_module = NULL; p_aout->module = NULL;
aout_FiltersDestroyPipeline( p_aout->output.pp_filters, aout_FiltersDestroyPipeline( p_aout->pp_filters, p_aout->i_nb_filters );
p_aout->output.i_nb_filters ); aout_FifoDestroy( &p_aout->fifo );
aout_FifoDestroy( &p_aout->output.fifo );
} }
/***************************************************************************** /*****************************************************************************
...@@ -226,8 +224,7 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer ) ...@@ -226,8 +224,7 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
{ {
vlc_assert_locked( &p_aout->lock ); vlc_assert_locked( &p_aout->lock );
aout_FiltersPlay( p_aout->output.pp_filters, p_aout->output.i_nb_filters, aout_FiltersPlay( p_aout->pp_filters, p_aout->i_nb_filters, &p_buffer );
&p_buffer );
if( !p_buffer ) if( !p_buffer )
return; return;
if( p_buffer->i_buffer == 0 ) if( p_buffer->i_buffer == 0 )
...@@ -236,8 +233,8 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer ) ...@@ -236,8 +233,8 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
return; return;
} }
aout_FifoPush( &p_aout->output.fifo, p_buffer ); aout_FifoPush( &p_aout->fifo, p_buffer );
p_aout->output.pf_play( p_aout ); p_aout->pf_play( p_aout );
} }
/** /**
...@@ -249,8 +246,8 @@ void aout_OutputPause( aout_instance_t *aout, bool pause, mtime_t date ) ...@@ -249,8 +246,8 @@ void aout_OutputPause( aout_instance_t *aout, bool pause, mtime_t date )
{ {
vlc_assert_locked( &aout->lock ); vlc_assert_locked( &aout->lock );
if( aout->output.pf_pause != NULL ) if( aout->pf_pause != NULL )
aout->output.pf_pause( aout, pause, date ); aout->pf_pause( aout, pause, date );
} }
/***************************************************************************** /*****************************************************************************
...@@ -265,7 +262,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, ...@@ -265,7 +262,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
mtime_t start_date, mtime_t start_date,
bool b_can_sleek ) bool b_can_sleek )
{ {
aout_fifo_t *p_fifo = &p_aout->output.fifo; aout_fifo_t *p_fifo = &p_aout->fifo;
aout_buffer_t * p_buffer; aout_buffer_t * p_buffer;
mtime_t now = mdate(); mtime_t now = mdate();
...@@ -290,11 +287,11 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, ...@@ -290,11 +287,11 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
* to deal with this kind of starvation. */ * to deal with this kind of starvation. */
/* Set date to 0, to allow the mixer to send a new buffer ASAP */ /* Set date to 0, to allow the mixer to send a new buffer ASAP */
aout_FifoSet( &p_aout->output.fifo, 0 ); aout_FifoSet( &p_aout->fifo, 0 );
if ( !p_aout->output.b_starving ) if ( !p_aout->b_starving )
msg_Dbg( p_aout, msg_Dbg( p_aout,
"audio output is starving (no input), playing silence" ); "audio output is starving (no input), playing silence" );
p_aout->output.b_starving = true; p_aout->b_starving = true;
#endif #endif
goto out; goto out;
} }
...@@ -305,15 +302,15 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, ...@@ -305,15 +302,15 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
*/ */
if ( 0 > delta + p_buffer->i_length ) if ( 0 > delta + p_buffer->i_length )
{ {
if ( !p_aout->output.b_starving ) if ( !p_aout->b_starving )
msg_Dbg( p_aout, "audio output is starving (%"PRId64"), " msg_Dbg( p_aout, "audio output is starving (%"PRId64"), "
"playing silence", -delta ); "playing silence", -delta );
p_aout->output.b_starving = true; p_aout->b_starving = true;
p_buffer = NULL; p_buffer = NULL;
goto out; goto out;
} }
p_aout->output.b_starving = false; p_aout->b_starving = false;
p_buffer = aout_FifoPop( p_fifo ); p_buffer = aout_FifoPop( p_fifo );
if( !b_can_sleek if( !b_can_sleek
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment