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
/* FIXME to remove once aout.h is cleaned a bit more */
#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;
/** audio output thread descriptor */
/** Audio output object */
struct aout_instance_t
{
VLC_COMMON_MEMBERS
......@@ -205,8 +183,27 @@ struct aout_instance_t
float mixer_multiplier;
struct aout_mixer_t *p_mixer;
/* Output plug-in */
aout_output_t output;
audio_sample_format_t format; /**< Output format (plugin can modify it
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)
return VLC_ENOMEM;
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;
switch (fourcc)
......@@ -242,7 +242,7 @@ static int Open (vlc_object_t *obj)
pcm_format = SND_PCM_FORMAT_U8;
break;
default:
if (AOUT_FMT_NON_LINEAR(&p_aout->output.output))
if (AOUT_FMT_NON_LINEAR(&p_aout->format))
spdif = var_InheritBool (p_aout, "spdif");
if (HAVE_FPU)
{
......@@ -263,7 +263,7 @@ static int Open (vlc_object_t *obj)
{
unsigned aes3;
switch (p_aout->output.output.i_rate)
switch (p_aout->format.i_rate)
{
#define FS(freq) \
case freq: aes3 = IEC958_AES3_CON_FS_ ## freq; break;
......@@ -293,7 +293,7 @@ static int Open (vlc_object_t *obj)
free (psz_device);
return VLC_ENOMEM;
}
p_aout->output.p_sys = p_sys;
p_aout->sys = p_sys;
#ifdef ALSA_DEBUG
snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 );
......@@ -349,24 +349,24 @@ static int Open (vlc_object_t *obj)
pcm_format = SND_PCM_FORMAT_S16;
i_channels = 2;
p_aout->output.i_nb_samples = i_period_size = ALSA_SPDIF_PERIOD_SIZE;
p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->output.output.i_frame_length = A52_FRAME_NB;
p_aout->i_nb_samples = i_period_size = ALSA_SPDIF_PERIOD_SIZE;
p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->format.i_frame_length = A52_FRAME_NB;
aout_VolumeNoneInit( p_aout );
}
else
{
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 );
}
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
snd_pcm_hw_params_t *p_hw;
snd_pcm_sw_params_t *p_sw;
......@@ -391,7 +391,7 @@ static int Open (vlc_object_t *obj)
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,
SND_PCM_ACCESS_RW_INTERLEAVED );
......@@ -412,9 +412,9 @@ static int Open (vlc_object_t *obj)
}
/* 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,
&p_aout->output.output.i_rate,
&p_aout->format.i_rate,
NULL);
if (val < 0)
{
......@@ -422,9 +422,9 @@ static int Open (vlc_object_t *obj)
snd_strerror (val));
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,
p_aout->output.output.i_rate);
p_aout->format.i_rate);
/* Set period size. */
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)
snd_strerror( val ) );
goto error;
}
p_aout->output.i_nb_samples = i_period_size;
p_aout->i_nb_samples = i_period_size;
/* Set buffer size. */
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)
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,
p_aout->output.i_nb_samples );
p_aout->i_nb_samples );
/* start playing when one period has been written */
val = snd_pcm_sw_params_set_start_threshold( p_sys->p_snd_pcm, p_sw,
ALSA_DEFAULT_PERIOD_SIZE);
......@@ -529,13 +529,13 @@ static void PlayIgnore( 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 */
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 */
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 )
static void Close (vlc_object_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 */
vlc_cancel( p_sys->thread );
......@@ -565,7 +565,7 @@ static void Close (vlc_object_t *obj)
static void* ALSAThread( void *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) */
vlc_sem_wait( &p_sys->wait );
......@@ -583,7 +583,7 @@ static void* ALSAThread( void *data )
*****************************************************************************/
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_status_t * p_status;
int i_snd_rc;
......@@ -635,9 +635,9 @@ static void ALSAFill( aout_instance_t * p_aout )
size_t i_bytes = snd_pcm_frames_to_bytes( p_pcm, delay );
mtime_t delay_us = CLOCK_FREQ * i_bytes
/ p_aout->output.output.i_bytes_per_frame
/ p_aout->output.output.i_rate
* p_aout->output.output.i_frame_length;
/ p_aout->format.i_bytes_per_frame
/ p_aout->format.i_rate
* p_aout->format.i_frame_length;
#ifdef ALSA_DEBUG
snd_pcm_state_t state = snd_pcm_status_get_state( p_status );
......@@ -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, "Bytes per frame: %d", p_aout->output.output.i_bytes_per_frame );
msg_Dbg( p_aout, "Rate: %d", p_aout->output.output.i_rate );
msg_Dbg( p_aout, "Frame length: %d", p_aout->output.output.i_frame_length );
msg_Dbg( p_aout, "Bytes per frame: %d", p_aout->format.i_bytes_per_frame );
msg_Dbg( p_aout, "Rate: %d", p_aout->format.i_rate );
msg_Dbg( p_aout, "Frame length: %d", p_aout->format.i_frame_length );
msg_Dbg( p_aout, "Next date: in %"PRId64" microseconds", delay_us );
#endif
next_date = mdate() + delay_us;
}
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 */
if( p_buffer == NULL )
......
......@@ -61,10 +61,10 @@ struct aout_sys_t
static void Play (aout_instance_t *aout)
{
aout_sys_t *sys = aout->output.p_sys;
aout_sys_t *sys = aout->sys;
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,
block->i_pts);
......@@ -74,7 +74,7 @@ static void Play (aout_instance_t *aout)
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;
}
......@@ -88,7 +88,7 @@ static int Open (vlc_object_t *obj)
if (unlikely(sys == NULL))
return VLC_ENOMEM;
aout->output.p_sys = sys;
aout->sys = sys;
sys->opaque = var_InheritAddress (obj, "amem-data");
sys->play = var_InheritAddress (obj, "amem-play");
sys->set_volume = var_InheritAddress (obj, "amem-set-volume");
......@@ -102,8 +102,8 @@ static int Open (vlc_object_t *obj)
if (setup != NULL)
{
rate = aout->output.output.i_rate;
channels = aout_FormatNbChannels(&aout->output.output);
rate = aout->format.i_rate;
channels = aout_FormatNbChannels(&aout->format);
if (setup (&sys->opaque, format, &rate, &channels))
goto error;
......@@ -122,18 +122,18 @@ static int Open (vlc_object_t *obj)
/* TODO: amem-format */
/* 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");
goto error;
}
aout->output.output.i_format = VLC_CODEC_S16N;
aout->output.output.i_rate = rate;
aout->format.i_format = VLC_CODEC_S16N;
aout->format.i_rate = rate;
aout->output.pf_play = Play;
aout->output.pf_pause = NULL;
aout->pf_play = Play;
aout->pf_pause = NULL;
if (sys->set_volume != NULL)
aout->output.pf_volume_set = VolumeSet;
aout->pf_volume_set = VolumeSet;
else
aout_VolumeSoftInit (aout);
return VLC_SUCCESS;
......@@ -146,7 +146,7 @@ error:
static void Close (vlc_object_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)
sys->cleanup (sys->opaque);
......
......@@ -78,7 +78,7 @@ static int Open ( vlc_object_t *p_this )
{
aout_instance_t *p_aout = (aout_instance_t *)p_this;
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;
......@@ -118,12 +118,12 @@ static int Open ( vlc_object_t *p_this )
/* Volume is entirely done in software. */
aout_VolumeSoftInit( p_aout );
p_aout->output.output.i_format = VLC_CODEC_S16L;
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
p_aout->output.output.i_rate = 44100;
p_aout->output.i_nb_samples = FRAME_SIZE;
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
p_aout->format.i_format = VLC_CODEC_S16L;
p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
p_aout->format.i_rate = 44100;
p_aout->format.i_nb_samples = FRAME_SIZE;
p_aout->format.pf_play = Play;
p_aout->format.pf_pause = NULL;
msg_Dbg(p_aout, "Starting AudioQueue (status = %i)", status);
status = AudioQueueStart(p_sys->audioQueue, NULL);
......@@ -145,7 +145,7 @@ static void Play( aout_instance_t * p_aout )
static void Close ( vlc_object_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");
AudioQueueStop(p_sys->audioQueue, false);
......@@ -160,7 +160,7 @@ void AudioQueueCallback(void * inUserData, AudioQueueRef inAQ, AudioQueueBufferR
if (p_aout) {
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 );
}
......
......@@ -165,11 +165,11 @@ static int Open( vlc_object_t * p_this )
int b_alive = false;
/* Allocate structure */
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->output.p_sys == NULL )
p_aout->sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->sys == NULL )
return VLC_ENOMEM;
p_sys = p_aout->output.p_sys;
p_sys = p_aout->sys;
p_sys->i_default_dev = 0;
p_sys->i_selected_dev = 0;
p_sys->i_devices = 0;
......@@ -187,10 +187,10 @@ static int Open( vlc_object_t * p_this )
p_sys->b_changed_mixing = false;
memset( p_sys->p_remainder_buffer, 0, sizeof(uint8_t) * BUFSIZE );
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
p_aout->pf_play = Play;
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 */
if( var_Type( p_aout->p_libvlc, "macosx-audio-device" ) == 0 )
......@@ -262,7 +262,7 @@ static int Open( vlc_object_t * p_this )
}
/* 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 ) )
{
......@@ -292,7 +292,7 @@ error:
*****************************************************************************/
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;
UInt32 i_param_size = 0;
int i_original;
......@@ -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 );
/* Initialize the VLC core channel count */
p_aout->output.output.i_physical_channels = 0;
i_original = p_aout->output.output.i_original_channels & AOUT_CHAN_PHYSMASK;
p_aout->format.i_physical_channels = 0;
i_original = p_aout->format.i_original_channels & AOUT_CHAN_PHYSMASK;
if( i_original == AOUT_CHAN_CENTER || layout->mNumberChannelDescriptions < 2 )
{
/* 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 )
{
/* 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
{
......@@ -413,39 +413,39 @@ static int OpenAnalog( aout_instance_t *p_aout )
switch( layout->mChannelDescriptions[i].mChannelLabel )
{
case kAudioChannelLabel_Left:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_LEFT;
p_aout->format.i_physical_channels |= AOUT_CHAN_LEFT;
continue;
case kAudioChannelLabel_Right:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_RIGHT;
p_aout->format.i_physical_channels |= AOUT_CHAN_RIGHT;
continue;
case kAudioChannelLabel_Center:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_CENTER;
p_aout->format.i_physical_channels |= AOUT_CHAN_CENTER;
continue;
case kAudioChannelLabel_LFEScreen:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_LFE;
p_aout->format.i_physical_channels |= AOUT_CHAN_LFE;
continue;
case kAudioChannelLabel_LeftSurround:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARLEFT;
p_aout->format.i_physical_channels |= AOUT_CHAN_REARLEFT;
continue;
case kAudioChannelLabel_RightSurround:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARRIGHT;
p_aout->format.i_physical_channels |= AOUT_CHAN_REARRIGHT;
continue;
case kAudioChannelLabel_RearSurroundLeft:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_MIDDLELEFT;
p_aout->format.i_physical_channels |= AOUT_CHAN_MIDDLELEFT;
continue;
case kAudioChannelLabel_RearSurroundRight:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_MIDDLERIGHT;
p_aout->format.i_physical_channels |= AOUT_CHAN_MIDDLERIGHT;
continue;
case kAudioChannelLabel_CenterSurround:
p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARCENTER;
p_aout->format.i_physical_channels |= AOUT_CHAN_REARCENTER;
continue;
default:
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." );
dialog_Fatal( p_aout, _("Audio device is not configured"), "%s",
_("You should configure your speaker layout with "
......@@ -458,14 +458,14 @@ static int OpenAnalog( aout_instance_t *p_aout )
else
{
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, "VLC will output: %s", aout_FormatPrintChannels( &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->format ));
memset (&new_layout, 0, sizeof(new_layout));
switch( aout_FormatNbChannels( &p_aout->output.output ) )
switch( aout_FormatNbChannels( &p_aout->format ) )
{
case 1:
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_Mono;
......@@ -474,41 +474,41 @@ static int OpenAnalog( aout_instance_t *p_aout )
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo;
break;
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
}
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
}
break;
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
}
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
}
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
}
break;
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
}
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
}
break;
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
}
......@@ -528,14 +528,14 @@ static int OpenAnalog( aout_instance_t *p_aout )
}
/* 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;
/* 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.mBitsPerChannel = 32;
DeviceFormat.mChannelsPerFrame = aout_FormatNbChannels( &p_aout->output.output );
DeviceFormat.mChannelsPerFrame = aout_FormatNbChannels( &p_aout->format );
/* Calculate framesizes and stuff */
DeviceFormat.mFramesPerPacket = 1;
......@@ -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 ) );
/* Do the last VLC aout setups */
aout_FormatPrepare( &p_aout->output.output );
p_aout->output.i_nb_samples = FRAMESIZE;
aout_FormatPrepare( &p_aout->format );
p_aout->i_nb_samples = FRAMESIZE;
aout_VolumeSoftInit( p_aout );
/* set the IOproc callback */
......@@ -608,7 +608,7 @@ static int OpenAnalog( 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;
UInt32 i_param_size = 0, b_mix = 0;
Boolean b_writeable = false;
......@@ -741,7 +741,7 @@ static int OpenSPDIF( aout_instance_t * p_aout )
if( p_format_list[j].mFormatID == 'IAC3' ||
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;
break;
......@@ -776,14 +776,14 @@ static int OpenSPDIF( aout_instance_t * p_aout )
/* Set the format flags */
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
p_aout->output.output.i_format = VLC_CODEC_SPDIFL;
p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->output.output.i_frame_length = A52_FRAME_NB;
p_aout->output.i_nb_samples = p_aout->output.output.i_frame_length;
p_aout->output.output.i_rate = (unsigned int)p_sys->stream_format.mSampleRate;
aout_FormatPrepare( &p_aout->output.output );
p_aout->format.i_format = VLC_CODEC_SPDIFL;
p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->format.i_frame_length = A52_FRAME_NB;
p_aout->format.i_nb_samples = p_aout->format.i_frame_length;
p_aout->format.i_rate = (unsigned int)p_sys->stream_format.mSampleRate;
aout_FormatPrepare( &p_aout->format );
aout_VolumeNoneInit( p_aout );
/* Add IOProc callback */
......@@ -827,7 +827,7 @@ static int OpenSPDIF( aout_instance_t * p_aout )
static void Close( vlc_object_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;
UInt32 i_param_size = 0;
......@@ -926,7 +926,7 @@ static void Probe( aout_instance_t * p_aout )
AudioDeviceID *p_devices = NULL;
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 */
AudioObjectPropertyAddress audioDevicesAddress = { kAudioHardwarePropertyDevices, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
......@@ -1262,7 +1262,7 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout,
uint32_t i_mData_bytes = 0;
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(inBusNumber);
......@@ -1278,7 +1278,7 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout,
current_date = p_sys->clock_diff +
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 )
{
......@@ -1296,8 +1296,8 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout,
&p_sys->p_remainder_buffer[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 ) *
( i_mData_bytes / 4 / aout_FormatNbChannels( &p_aout->output.output ) ); // 4 is fl32 specific
current_date += (mtime_t) ( (mtime_t) 1000000 / p_aout->format.i_rate ) *
( i_mData_bytes / 4 / aout_FormatNbChannels( &p_aout->format ) ); // 4 is fl32 specific
if( p_sys->i_read_bytes >= p_sys->i_total_bytes )
p_sys->i_read_bytes = p_sys->i_total_bytes = 0;
......@@ -1329,8 +1329,8 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout,
else
{
/* update current_date */
current_date += (mtime_t) ( (mtime_t) 1000000 / p_aout->output.output.i_rate ) *
( i_second_mData_bytes / 4 / aout_FormatNbChannels( &p_aout->output.output ) ); // 4 is fl32 specific
current_date += (mtime_t) ( (mtime_t) 1000000 / p_aout->format.i_rate ) *
( i_second_mData_bytes / 4 / aout_FormatNbChannels( &p_aout->format ) ); // 4 is fl32 specific
}
aout_BufferFree( p_buffer );
}
......@@ -1359,7 +1359,7 @@ static OSStatus RenderCallbackSPDIF( AudioDeviceID inDevice,
mtime_t current_date;
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(inInputData);
......@@ -1372,7 +1372,7 @@ static OSStatus RenderCallbackSPDIF( AudioDeviceID inDevice,
current_date = p_sys->clock_diff +
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 );
......
......@@ -37,7 +37,7 @@
#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
......@@ -163,18 +163,18 @@ static int OpenAudio( vlc_object_t *p_this )
msg_Dbg( p_aout, "Opening DirectSound Audio Output" );
/* Allocate structure */
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );