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

aout: move packet FIFO management to plugins that need it

parent af6b8c3b
...@@ -175,7 +175,6 @@ struct audio_output ...@@ -175,7 +175,6 @@ struct audio_output
void (* pf_flush)( audio_output_t *, bool ); /**< Flush/drain callback void (* pf_flush)( audio_output_t *, bool ); /**< Flush/drain callback
(optional, may be NULL) */ (optional, may be NULL) */
aout_volume_cb pf_volume_set; /**< Volume setter (or NULL) */ aout_volume_cb pf_volume_set; /**< Volume setter (or NULL) */
int i_nb_samples;
}; };
/** /**
......
...@@ -44,7 +44,6 @@ vlc_module_begin () ...@@ -44,7 +44,6 @@ vlc_module_begin ()
add_shortcut( "dummy" ) add_shortcut( "dummy" )
vlc_module_end () vlc_module_end ()
#define FRAME_SIZE 2048
#define A52_FRAME_NB 1536 #define A52_FRAME_NB 1536
/***************************************************************************** /*****************************************************************************
...@@ -73,7 +72,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -73,7 +72,6 @@ static int Open( vlc_object_t * p_this )
} }
else else
p_aout->format.i_format = HAVE_FPU ? VLC_CODEC_FL32 : VLC_CODEC_S16N; p_aout->format.i_format = HAVE_FPU ? VLC_CODEC_FL32 : VLC_CODEC_S16N;
p_aout->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 );
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
*****************************************************************************/ *****************************************************************************/
struct aout_sys_t struct aout_sys_t
{ {
aout_packet_t packet;
snd_pcm_t * p_snd_pcm; snd_pcm_t * p_snd_pcm;
unsigned int i_period_time; unsigned int i_period_time;
...@@ -344,7 +345,7 @@ static int Open (vlc_object_t *obj) ...@@ -344,7 +345,7 @@ static int Open (vlc_object_t *obj)
pcm_format = SND_PCM_FORMAT_S16; pcm_format = SND_PCM_FORMAT_S16;
channels = 2; channels = 2;
p_aout->i_nb_samples = i_period_size = ALSA_SPDIF_PERIOD_SIZE; i_period_size = ALSA_SPDIF_PERIOD_SIZE;
p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->format.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
...@@ -355,7 +356,7 @@ static int Open (vlc_object_t *obj) ...@@ -355,7 +356,7 @@ static int Open (vlc_object_t *obj)
i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE; i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE;
channels = aout_FormatNbChannels( &p_aout->format ); channels = aout_FormatNbChannels( &p_aout->format );
p_aout->i_nb_samples = i_period_size = ALSA_DEFAULT_PERIOD_SIZE; i_period_size = ALSA_DEFAULT_PERIOD_SIZE;
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
} }
...@@ -433,7 +434,6 @@ static int Open (vlc_object_t *obj) ...@@ -433,7 +434,6 @@ static int Open (vlc_object_t *obj)
snd_strerror( val ) ); snd_strerror( val ) );
goto error; goto error;
} }
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,
...@@ -466,8 +466,7 @@ static int Open (vlc_object_t *obj) ...@@ -466,8 +466,7 @@ static int Open (vlc_object_t *obj)
/* Get Initial software parameters */ /* Get Initial software parameters */
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, i_period_size );
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);
...@@ -495,6 +494,7 @@ static int Open (vlc_object_t *obj) ...@@ -495,6 +494,7 @@ static int Open (vlc_object_t *obj)
p_sys->start_date = 0; p_sys->start_date = 0;
vlc_sem_init( &p_sys->wait, 0 ); vlc_sem_init( &p_sys->wait, 0 );
aout_PacketInit (p_aout, &p_sys->packet, i_period_size);
/* Create ALSA thread and wait for its readiness. */ /* Create ALSA thread and wait for its readiness. */
if( vlc_clone( &p_sys->thread, ALSAThread, p_aout, if( vlc_clone( &p_sys->thread, ALSAThread, p_aout,
...@@ -549,6 +549,7 @@ static void Close (vlc_object_t *obj) ...@@ -549,6 +549,7 @@ static void Close (vlc_object_t *obj)
vlc_cancel( p_sys->thread ); vlc_cancel( p_sys->thread );
vlc_join( p_sys->thread, NULL ); vlc_join( p_sys->thread, NULL );
vlc_sem_destroy( &p_sys->wait ); vlc_sem_destroy( &p_sys->wait );
aout_PacketDestroy (p_aout);
snd_pcm_drop( p_sys->p_snd_pcm ); snd_pcm_drop( p_sys->p_snd_pcm );
snd_pcm_close( p_sys->p_snd_pcm ); snd_pcm_close( p_sys->p_snd_pcm );
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <AudioToolBox/AudioToolBox.h> #include <AudioToolBox/AudioToolBox.h>
#define FRAME_SIZE 2048
#define NUMBER_OF_BUFFERS 3 #define NUMBER_OF_BUFFERS 3
/***************************************************************************** /*****************************************************************************
...@@ -46,6 +45,7 @@ ...@@ -46,6 +45,7 @@
*****************************************************************************/ *****************************************************************************/
struct aout_sys_t struct aout_sys_t
{ {
aout_packet_t packet;
AudioQueueRef audioQueue; AudioQueueRef audioQueue;
}; };
...@@ -121,7 +121,7 @@ static int Open ( vlc_object_t *p_this ) ...@@ -121,7 +121,7 @@ static int Open ( vlc_object_t *p_this )
p_aout->format.i_format = VLC_CODEC_S16L; p_aout->format.i_format = VLC_CODEC_S16L;
p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
p_aout->format.i_rate = 44100; p_aout->format.i_rate = 44100;
p_aout->format.i_nb_samples = FRAME_SIZE; aout_PacketInit(p_aout, &p_sys->packet, FRAME_SIZE);
p_aout->pf_play = aout_PacketPlay; p_aout->pf_play = aout_PacketPlay;
p_aout->pf_pause = aout_PacketPause; p_aout->pf_pause = aout_PacketPause;
p_aout->pf_flush = aout_PacketFlush; p_aout->pf_flush = aout_PacketFlush;
...@@ -144,6 +144,7 @@ static void Close ( vlc_object_t *p_this ) ...@@ -144,6 +144,7 @@ static void Close ( vlc_object_t *p_this )
AudioQueueStop(p_sys->audioQueue, false); AudioQueueStop(p_sys->audioQueue, false);
msg_Dbg(p_aout, "Disposing of AudioQueue"); msg_Dbg(p_aout, "Disposing of AudioQueue");
AudioQueueDispose(p_sys->audioQueue, false); AudioQueueDispose(p_sys->audioQueue, false);
aout_PacketDestroy(p_aout);
free (p_sys); free (p_sys);
} }
......
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
*****************************************************************************/ *****************************************************************************/
struct aout_sys_t struct aout_sys_t
{ {
aout_packet_t packet;
AudioDeviceID i_default_dev; /* Keeps DeviceID of defaultOutputDevice */ AudioDeviceID i_default_dev; /* Keeps DeviceID of defaultOutputDevice */
AudioDeviceID i_selected_dev; /* Keeps DeviceID of the selected device */ AudioDeviceID i_selected_dev; /* Keeps DeviceID of the selected device */
AudioDeviceIOProcID i_procID; /* DeviceID of current device */ AudioDeviceIOProcID i_procID; /* DeviceID of current device */
...@@ -566,7 +567,7 @@ static int OpenAnalog( audio_output_t *p_aout ) ...@@ -566,7 +567,7 @@ static int OpenAnalog( audio_output_t *p_aout )
/* Do the last VLC aout setups */ /* Do the last VLC aout setups */
aout_FormatPrepare( &p_aout->format ); aout_FormatPrepare( &p_aout->format );
p_aout->i_nb_samples = FRAMESIZE; aout_PacketInit( p_aout, &p_sys->packet, FRAMESIZE );
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
/* set the IOproc callback */ /* set the IOproc callback */
...@@ -782,9 +783,9 @@ static int OpenSPDIF( audio_output_t * p_aout ) ...@@ -782,9 +783,9 @@ static int OpenSPDIF( audio_output_t * p_aout )
p_aout->format.i_format = VLC_CODEC_SPDIFL; p_aout->format.i_format = VLC_CODEC_SPDIFL;
p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->format.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
p_aout->i_nb_samples = p_aout->format.i_frame_length;
p_aout->format.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->format ); aout_FormatPrepare( &p_aout->format );
aout_PacketInit( p_aout, &p_sys->packet, A52_FRAME_NB );
aout_VolumeNoneInit( p_aout ); aout_VolumeNoneInit( p_aout );
/* Add IOProc callback */ /* Add IOProc callback */
...@@ -904,6 +905,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -904,6 +905,7 @@ static void Close( vlc_object_t * p_this )
if( err != noErr ) msg_Err( p_aout, "Could not release hogmode: [%4.4s]", (char *)&err ); if( err != noErr ) msg_Err( p_aout, "Could not release hogmode: [%4.4s]", (char *)&err );
} }
aout_PacketDestroy( p_aout );
free( p_sys ); free( p_sys );
} }
......
...@@ -64,6 +64,7 @@ typedef struct notification_thread_t ...@@ -64,6 +64,7 @@ typedef struct notification_thread_t
*****************************************************************************/ *****************************************************************************/
struct aout_sys_t struct aout_sys_t
{ {
aout_packet_t packet;
HINSTANCE hdsound_dll; /* handle of the opened dsound dll */ HINSTANCE hdsound_dll; /* handle of the opened dsound dll */
char * psz_device; /* user defined device name */ char * psz_device; /* user defined device name */
...@@ -224,7 +225,6 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -224,7 +225,6 @@ static int OpenAudio( vlc_object_t *p_this )
p_aout->format.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->i_nb_samples = A52_FRAME_NB;
p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->format.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
p_aout->sys->i_frame_size = p_aout->format.i_bytes_per_frame; p_aout->sys->i_frame_size = p_aout->format.i_bytes_per_frame;
...@@ -241,6 +241,7 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -241,6 +241,7 @@ static int OpenAudio( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
aout_PacketInit( p_aout, &p_sys->packet, A52_FRAME_NB );
aout_VolumeNoneInit( p_aout ); aout_VolumeNoneInit( p_aout );
} }
else else
...@@ -294,8 +295,8 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -294,8 +295,8 @@ static int OpenAudio( vlc_object_t *p_this )
} }
/* Calculate the frame size in bytes */ /* Calculate the frame size in bytes */
p_aout->i_nb_samples = FRAME_SIZE;
aout_FormatPrepare( &p_aout->format ); aout_FormatPrepare( &p_aout->format );
aout_PacketInit( p_aout, &p_sys->packet, FRAME_SIZE );
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
} }
...@@ -613,6 +614,7 @@ static void CloseAudio( vlc_object_t *p_this ) ...@@ -613,6 +614,7 @@ static void CloseAudio( vlc_object_t *p_this )
if( p_sys->hdsound_dll ) FreeLibrary( p_sys->hdsound_dll ); if( p_sys->hdsound_dll ) FreeLibrary( p_sys->hdsound_dll );
free( p_aout->sys->p_device_guid ); free( p_aout->sys->p_device_guid );
aout_PacketDestroy( p_aout );
free( p_sys ); free( p_sys );
} }
...@@ -1042,7 +1044,7 @@ static void* DirectSoundThread( void *data ) ...@@ -1042,7 +1044,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->i_nb_samples; unsigned i_frame_siz = p_sys->packet.samples;
mtime_t mtime = mdate(); mtime_t mtime = mdate();
int i; int i;
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <vlc_codecs.h> /* WAVEHEADER */ #include <vlc_codecs.h> /* WAVEHEADER */
#include <vlc_fs.h> #include <vlc_fs.h>
#define FRAME_SIZE 2048
#define A52_FRAME_NB 1536 #define A52_FRAME_NB 1536
/***************************************************************************** /*****************************************************************************
...@@ -193,16 +192,12 @@ static int Open( vlc_object_t * p_this ) ...@@ -193,16 +192,12 @@ static int Open( vlc_object_t * p_this )
p_aout->format.i_format = format_int[i]; p_aout->format.i_format = format_int[i];
if ( AOUT_FMT_NON_LINEAR( &p_aout->format ) ) if ( AOUT_FMT_NON_LINEAR( &p_aout->format ) )
{ {
p_aout->i_nb_samples = A52_FRAME_NB;
p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->format.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->i_nb_samples = FRAME_SIZE;
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
}
/* Channels number */ /* Channels number */
i_channels = var_CreateGetInteger( p_this, "audiofile-channels" ); i_channels = var_CreateGetInteger( p_this, "audiofile-channels" );
......
...@@ -50,6 +50,7 @@ typedef jack_default_audio_sample_t jack_sample_t; ...@@ -50,6 +50,7 @@ typedef jack_default_audio_sample_t jack_sample_t;
*****************************************************************************/ *****************************************************************************/
struct aout_sys_t struct aout_sys_t
{ {
aout_packet_t packet;
jack_client_t *p_jack_client; jack_client_t *p_jack_client;
jack_port_t **p_jack_ports; jack_port_t **p_jack_ports;
jack_sample_t **p_jack_buffers; jack_sample_t **p_jack_buffers;
...@@ -135,12 +136,13 @@ static int Open( vlc_object_t *p_this ) ...@@ -135,12 +136,13 @@ static int Open( vlc_object_t *p_this )
p_aout->pf_play = aout_PacketPlay; p_aout->pf_play = aout_PacketPlay;
p_aout->pf_pause = aout_PacketPause; p_aout->pf_pause = aout_PacketPause;
p_aout->pf_flush = aout_PacketFlush; p_aout->pf_flush = aout_PacketFlush;
aout_PacketInit( p_aout, &p_sys->packet,
jack_get_buffer_size( p_sys->p_jack_client ) );
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
/* JACK only supports fl32 format */ /* JACK only supports fl32 format */
p_aout->format.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->i_nb_samples = jack_get_buffer_size( p_sys->p_jack_client );
p_aout->format.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->format ); p_sys->i_channels = aout_FormatNbChannels( &p_aout->format );
...@@ -223,9 +225,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -223,9 +225,8 @@ static int Open( vlc_object_t *p_this )
free( pp_in_ports ); free( pp_in_ports );
} }
msg_Dbg( p_aout, "JACK audio output initialized (%d channels, buffer " msg_Dbg( p_aout, "JACK audio output initialized (%d channels, rate=%d)",
"size=%d, rate=%d)", p_sys->i_channels, p_sys->i_channels, p_aout->format.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 */
...@@ -352,5 +353,6 @@ static void Close( vlc_object_t *p_this ) ...@@ -352,5 +353,6 @@ static void Close( vlc_object_t *p_this )
} }
free( p_sys->p_jack_ports ); free( p_sys->p_jack_ports );
free( p_sys->p_jack_buffers ); free( p_sys->p_jack_buffers );
aout_PacketDestroy( p_aout );
free( p_sys ); free( p_sys );
} }
...@@ -257,7 +257,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -257,7 +257,6 @@ static int Open( vlc_object_t * p_this )
// we want 16bit signed data little endian. // we want 16bit signed data little endian.
p_aout->format.i_format = VLC_CODEC_S16L; p_aout->format.i_format = VLC_CODEC_S16L;
p_aout->i_nb_samples = 2048;
p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
p_aout->pf_play = Play; p_aout->pf_play = Play;
p_aout->pf_pause = NULL; p_aout->pf_pause = NULL;
......
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
*****************************************************************************/ *****************************************************************************/
struct aout_sys_t struct aout_sys_t
{ {
aout_packet_t packet;
int i_fd; int i_fd;
int i_fragstotal; int i_fragstotal;
mtime_t max_buffer_duration; mtime_t max_buffer_duration;
...@@ -381,10 +382,10 @@ static int Open( vlc_object_t *p_this ) ...@@ -381,10 +382,10 @@ static int Open( vlc_object_t *p_this )
} }
p_aout->format.i_format = VLC_CODEC_SPDIFL; p_aout->format.i_format = VLC_CODEC_SPDIFL;
p_aout->i_nb_samples = A52_FRAME_NB;
p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->format.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
aout_PacketInit( p_aout, &p_sys->packet, A52_FRAME_NB );
aout_VolumeNoneInit( p_aout ); aout_VolumeNoneInit( p_aout );
} }
...@@ -485,8 +486,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -485,8 +486,7 @@ static int Open( vlc_object_t *p_this )
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
else
{
/* Number of fragments actually allocated */ /* Number of fragments actually allocated */
p_aout->sys->i_fragstotal = audio_buf.fragstotal; p_aout->sys->i_fragstotal = audio_buf.fragstotal;
...@@ -497,10 +497,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -497,10 +497,8 @@ static int Open( vlc_object_t *p_this )
/ p_aout->format.i_rate / p_aout->format.i_rate
* p_aout->format.i_frame_length; * p_aout->format.i_frame_length;
p_aout->i_nb_samples = audio_buf.fragsize / aout_PacketInit( p_aout, &p_sys->packet,
p_aout->format.i_bytes_per_frame; audio_buf.fragsize/p_aout->format.i_bytes_per_frame );
}
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
} }
...@@ -532,6 +530,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -532,6 +530,7 @@ static void Close( vlc_object_t * p_this )
ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL ); ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL );
close( p_sys->i_fd ); close( p_sys->i_fd );
aout_PacketDestroy( p_aout );
free( p_sys ); free( p_sys );
} }
......
...@@ -63,6 +63,7 @@ typedef struct ...@@ -63,6 +63,7 @@ typedef struct
struct aout_sys_t struct aout_sys_t
{ {
aout_packet_t packet;
audio_output_t *p_aout; audio_output_t *p_aout;
PaStream *p_stream; PaStream *p_stream;
...@@ -328,6 +329,7 @@ static void Close ( vlc_object_t *p_this ) ...@@ -328,6 +329,7 @@ static void Close ( vlc_object_t *p_this )
#endif #endif
msg_Dbg( p_aout, "portaudio closed"); msg_Dbg( p_aout, "portaudio closed");
aout_PacketDestroy( p_aout );
free( p_sys ); free( p_sys );
} }
...@@ -501,8 +503,8 @@ static int PAOpenStream( audio_output_t *p_aout ) ...@@ -501,8 +503,8 @@ static int PAOpenStream( audio_output_t *p_aout )
/* 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->i_nb_samples = FRAME_SIZE;
aout_FormatPrepare( &p_aout->format ); aout_FormatPrepare( &p_aout->format );
aout_PacketInit( p_aout, &p_sys->packet, FRAME_SIZE );
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
/* Check for channel reordering */ /* Check for channel reordering */
......
...@@ -791,8 +791,6 @@ static int Open(vlc_object_t *obj) ...@@ -791,8 +791,6 @@ 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->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,
&(vlc_value_t){ .psz_string = (char *)_("Audio device") }, &(vlc_value_t){ .psz_string = (char *)_("Audio device") },
......
...@@ -111,6 +111,7 @@ vlc_module_end () ...@@ -111,6 +111,7 @@ vlc_module_end ()
*****************************************************************************/ *****************************************************************************/
struct aout_sys_t struct aout_sys_t
{ {
aout_packet_t packet;
uint32_t i_wave_device_id; /* ID of selected output device */ uint32_t i_wave_device_id; /* ID of selected output device */
HWAVEOUT h_waveout; /* handle to waveout instance */ HWAVEOUT h_waveout; /* handle to waveout instance */
...@@ -234,12 +235,12 @@ static int Open( vlc_object_t *p_this ) ...@@ -234,12 +235,12 @@ static int Open( vlc_object_t *p_this )
} }
/* Calculate the frame size in bytes */ /* Calculate the frame size in bytes */
p_aout->i_nb_samples = A52_FRAME_NB;
p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
p_aout->format.i_frame_length = A52_FRAME_NB; p_aout->format.i_frame_length = A52_FRAME_NB;
p_aout->sys->i_buffer_size = p_aout->sys->i_buffer_size =
p_aout->format.i_bytes_per_frame; p_aout->format.i_bytes_per_frame;
aout_PacketInit( p_aout, &p_aout->p_sys->packet, A52_FRAME_NB );
aout_VolumeNoneInit( p_aout ); aout_VolumeNoneInit( p_aout );
} }
else else
...@@ -281,11 +282,11 @@ static int Open( vlc_object_t *p_this ) ...@@ -281,11 +282,11 @@ static int Open( vlc_object_t *p_this )
} }
/* Calculate the frame size in bytes */ /* Calculate the frame size in bytes */
p_aout->i_nb_samples = FRAME_SIZE;
aout_FormatPrepare( &p_aout->format ); aout_FormatPrepare( &p_aout->format );
p_aout->sys->i_buffer_size = FRAME_SIZE * p_aout->sys->i_buffer_size = FRAME_SIZE *
p_aout->format.i_bytes_per_frame; p_aout->format.i_bytes_per_frame;
aout_PacketInit( p_aout, &p_aout->p_sys->packet, FRAME_SIZE );
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
/* Check for hardware volume support */ /* Check for hardware volume support */
...@@ -566,6 +567,7 @@ static void Close( vlc_object_t *p_this ) ...@@ -566,6 +567,7 @@ static void Close( vlc_object_t *p_this )
CloseHandle( p_sys->new_buffer_event); CloseHandle( p_sys->new_buffer_event);
free( p_sys->p_silence_buffer ); free( p_sys->p_silence_buffer );
aout_PacketDestroy( p_aout );
free( p_sys ); free( p_sys );
} }
......
...@@ -107,8 +107,6 @@ typedef struct ...@@ -107,8 +107,6 @@ typedef struct
/* Filters between mixer and output */ /* Filters between mixer and output */
filter_t *filters[AOUT_MAX_FILTERS]; filter_t *filters[AOUT_MAX_FILTERS];
int nb_filters; int nb_filters;
aout_packet_t packet;
} aout_owner_t; } aout_owner_t;
typedef struct typedef struct
......
...@@ -161,9 +161,6 @@ int aout_OutputNew( audio_output_t *p_aout, ...@@ -161,9 +161,6 @@ int aout_OutputNew( audio_output_t *p_aout,
aout_FormatPrepare( &p_aout->format ); aout_FormatPrepare( &p_aout->format );
aout_FormatPrint( p_aout, "output", &p_aout->format ); aout_FormatPrint( p_aout, "output", &p_aout->format );
/* Prepare FIFO. */
aout_PacketInit (p_aout, &owner->packet, p_aout->i_nb_samples);
/* Choose the mixer format. */ /* Choose the mixer format. */
owner->mixer_format = p_aout->format; owner->mixer_format = p_aout->format;
if (AOUT_FMT_NON_LINEAR(&p_aout->format)) if (AOUT_FMT_NON_LINEAR(&p_aout->format))
...@@ -218,7 +215,6 @@ void aout_OutputDelete( audio_output_t * p_aout ) ...@@ -218,7 +215,6 @@ void aout_OutputDelete( audio_output_t * p_aout )
aout_VolumeNoneInit( p_aout ); /* clear volume callback */ aout_VolumeNoneInit( p_aout ); /* clear volume callback */
owner->module = NULL; owner->module = NULL;
aout_FiltersDestroyPipeline (owner->filters, owner->nb_filters); aout_FiltersDestroyPipeline (owner->filters, owner->nb_filters);
aout_PacketDestroy (p_aout);
} }
/***************************************************************************** /*****************************************************************************
...@@ -370,8 +366,7 @@ void aout_VolumeHardSet (audio_output_t *aout, float volume, bool mute) ...@@ -370,8 +366,7 @@ void aout_VolumeHardSet (audio_output_t *aout, float volume, bool mute)
static inline aout_packet_t *aout_packet (audio_output_t *aout) static inline aout_packet_t *aout_packet (audio_output_t *aout)
{ {
aout_owner_t *owner = aout_owner (aout); return (aout_packet_t *)(aout->sys);
return &owner->packet;
} }
void aout_PacketInit (audio_output_t *aout, aout_packet_t *p, unsigned samples) void aout_PacketInit (audio_output_t *aout, aout_packet_t *p, unsigned samples)
...@@ -444,9 +439,7 @@ static block_t *aout_OutputSlice (audio_output_t *p_aout) ...@@ -444,9 +439,7 @@ static block_t *aout_OutputSlice (audio_output_t *p_aout)
{ {
aout_packet_t *p = aout_packet (p_aout); aout_packet_t *p = aout_packet (p_aout);
aout_fifo_t *p_fifo = &p->partial; aout_fifo_t *p_fifo = &p->partial;
const unsigned samples = p_aout->i_nb_samples; const unsigned samples = p->samples;
/* FIXME: Remove this silly constraint. Just pass buffers as they come to
* "smart" audio outputs. */
assert( samples > 0 ); assert( samples > 0 );
vlc_assert_locked( &p_aout->lock ); vlc_assert_locked( &p_aout->lock );
......
...@@ -21,6 +21,8 @@ aout_FormatPrepare ...@@ -21,6 +21,8 @@ aout_FormatPrepare
aout_FormatPrint aout_FormatPrint
aout_FormatPrintChannels aout_FormatPrintChannels
aout_OutputNextBuffer aout_OutputNextBuffer
aout_PacketInit
aout_PacketDestroy
aout_PacketPlay aout_PacketPlay
aout_PacketPause aout_PacketPause
aout_PacketFlush aout_PacketFlush
......
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