/*****************************************************************************
* Preamble
*****************************************************************************/
+#include <vlc/vlc.h>
+
+#include <stdio.h>
#include <errno.h> /* ENOMEM */
#include <string.h> /* strerror() */
#include <stdlib.h> /* calloc(), malloc(), free() */
+#include <vlc_interface.h>
-#include <vlc/vlc.h>
-
-#include <vlc/aout.h>
-
-#include "aout_internal.h"
+#include <vlc_aout.h>
/* ALSA part
Note: we use the new API which is available since 0.9.0beta10a. */
if( (psz_device = config_GetPsz( p_aout, "alsadev" )) == NULL )
{
msg_Err( p_aout, "no audio device given (maybe \"default\" ?)" );
+ intf_UserFatal( p_aout, VLC_FALSE, _("No Audio Device"),
+ _("No audio device name was given. You might want to " \
+ "enter \"default\".") );
free( p_sys );
return VLC_EGENERIC;
}
/* Choose the linear PCM format (read the comment above about FPU
and float32) */
- if( p_aout->p_libvlc->i_cpu & CPU_CAPABILITY_FPU )
+ if( vlc_CPU() & CPU_CAPABILITY_FPU )
{
i_vlc_pcm_format = VLC_FOURCC('f','l','3','2');
i_snd_pcm_format = SND_PCM_FORMAT_FLOAT;
{
msg_Err( p_aout, "cannot open ALSA device `%s' (%s)",
psz_iec_device, snd_strerror( i_snd_rc ) );
+ intf_UserFatal( p_aout, VLC_FALSE, _("Audio output failed"),
+ _("VLC could not open the ALSA device \"%s\" (%s)."),
+ psz_iec_device, snd_strerror( i_snd_rc ) );
free( p_sys );
free( psz_device );
return VLC_EGENERIC;
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK ) ) == -EBUSY )
{
if( i ) msleep( 100000 /* 100ms */ );
- else msg_Err( p_aout, "audio device: %s is already in use",
+ else
+ {
+ msg_Err( p_aout, "audio device: %s is already in use",
psz_device );
+ intf_UserFatal( p_aout, VLC_FALSE, _("Audio output failed"),
+ _("The audio device \"%s\" is already in use."),
+ psz_device );
+ }
continue;
}
break;
{
msg_Err( p_aout, "cannot open ALSA device `%s' (%s)",
psz_device, snd_strerror( i_snd_rc ) );
+ intf_UserFatal( p_aout, VLC_FALSE, _("Audio output failed"),
+ _("VLC could not open the ALSA device \"%s\" (%s)."),
+ psz_device, snd_strerror( i_snd_rc ) );
free( p_sys );
free( psz_device );
return VLC_EGENERIC;
vlc_cond_signal( &p_aout->output.p_sys->wait );
vlc_mutex_unlock( &p_aout->output.p_sys->lock );
- p_aout->b_die = VLC_TRUE;
+ vlc_object_kill( p_aout );
vlc_thread_join( p_aout );
p_aout->b_die = VLC_FALSE;
static void ALSAFill( aout_instance_t * p_aout )
{
struct aout_sys_t * p_sys = p_aout->output.p_sys;
-
aout_buffer_t * p_buffer;
snd_pcm_status_t * p_status = p_sys->p_status;
- snd_timestamp_t ts_next;
int i_snd_rc;
mtime_t next_date;
/* Here the device should be either in the RUNNING state.
* p_status is valid. */
+#if 0
+ /* This apparently does not work correctly in Alsa 1.0.11 */
snd_pcm_status_get_tstamp( p_status, &ts_next );
next_date = (mtime_t)ts_next.tv_sec * 1000000 + ts_next.tv_usec;
if( next_date )
* 1000000 / p_aout->output.output.i_rate;
}
else
+#endif
{
/* With screwed ALSA drivers the timestamp is always zero;
* use another method then */
- snd_pcm_sframes_t delay;
- ssize_t i_bytes = 0;
+ snd_pcm_sframes_t delay = 0;
- if( !snd_pcm_delay( p_sys->p_snd_pcm, &delay ) )
- {
- i_bytes = snd_pcm_frames_to_bytes(p_sys->p_snd_pcm, delay);
- }
- next_date = mdate() + (mtime_t)i_bytes * 1000000
- / p_aout->output.output.i_bytes_per_frame
- / p_aout->output.output.i_rate
+ snd_pcm_delay( p_sys->p_snd_pcm, &delay );
+ next_date = mdate() + (mtime_t)(delay) * 1000000 /
+ p_aout->output.output.i_rate
* p_aout->output.output.i_frame_length;
}
}
p_item->i_list++;
p_item->ppsz_list[ p_item->i_list ] = NULL;
p_item->ppsz_list_text[ p_item->i_list ] = NULL;
-
}
snd_ctl_close( p_ctl );