* coreaudio.c: CoreAudio output plugin
*****************************************************************************
* Copyright (C) 2002-2003 VideoLAN
- * $Id: coreaudio.c,v 1.1 2003/03/30 23:35:06 jlj Exp $
+ * $Id: coreaudio.c,v 1.6 2003/06/06 02:23:30 hartman Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
/*****************************************************************************
* Module descriptor
*****************************************************************************/
-#define ADEV_TEXT N_("audio device")
+#define ADEV_TEXT N_("Audio device")
+#define ADEV_LONGTEXT N_("Choose a number corresponding to the number of an " \
+ "audio device, as listed in your 'audio device' menu. This device will " \
+ "then be used by default for audio playback.")
vlc_module_begin();
set_description( _("CoreAudio output") );
set_capability( "audio output", 100 );
set_callbacks( Open, Close );
add_category_hint( N_("Audio"), NULL, VLC_FALSE );
- add_integer( "coreaudio-dev", -1, NULL, ADEV_TEXT, ADEV_TEXT, VLC_FALSE );
+ add_integer( "coreaudio-dev", -1, NULL, ADEV_TEXT, ADEV_LONGTEXT, VLC_FALSE );
vlc_module_end();
/*****************************************************************************
msg_Dbg( p_aout, "device buffer size set to: [%ld]",
p_sys->i_buffer_size );
+
+ /* Set buffer frame size */
+ i_param_size = sizeof( p_aout->output.i_nb_samples );
+ err = AudioDeviceSetProperty( p_sys->devid, 0, 0, FALSE,
+ kAudioDevicePropertyBufferFrameSize,
+ i_param_size,
+ &p_aout->output.i_nb_samples );
+ if( err != noErr )
+ {
+ msg_Err( p_aout, "failed to set buffer frame size: [%4.4s]",
+ (char *)&err );
+ FreeDevice( p_aout );
+ FreeHardwareInfo( p_aout );
+ vlc_mutex_destroy( &p_sys->lock );
+ free( (void *)p_sys );
+ return( VLC_EGENERIC );
+ }
+
+ msg_Dbg( p_aout, "device buffer frame size set to: [%d]",
+ p_aout->output.i_nb_samples );
}
switch( p_sys->stream_format.mFormatID )
return( VLC_EGENERIC );
}
- /* Set buffer frame size */
- i_param_size = sizeof( p_aout->output.i_nb_samples );
- err = AudioDeviceSetProperty( p_sys->devid, 0, 0, FALSE,
- kAudioDevicePropertyBufferFrameSize,
- i_param_size,
- &p_aout->output.i_nb_samples );
- if( err != noErr )
- {
- msg_Err( p_aout, "failed to set buffer frame size: [%4.4s]",
- (char *)&err );
- FreeDevice( p_aout );
- FreeHardwareInfo( p_aout );
- vlc_mutex_destroy( &p_sys->lock );
- free( (void *)p_sys );
- return( VLC_EGENERIC );
- }
-
- msg_Dbg( p_aout, "device buffer frame size set to: [%d]",
- p_aout->output.i_nb_samples );
-
/* Add callback */
err = AudioDeviceAddIOProc( p_sys->devid,
(AudioDeviceIOProc)IOCallback,
host_time.mFlags = kAudioTimeStampHostTimeValid;
AudioDeviceTranslateTime( inDevice, inOutputTime, &host_time );
+
+#if 1
+ p_sys->clock_diff = - (mtime_t)
+ AudioConvertHostTimeToNanos( AudioGetCurrentHostTime() ) / 1000;
+ p_sys->clock_diff += mdate();
+#endif
+
current_date = p_sys->clock_diff +
AudioConvertHostTimeToNanos( host_time.mHostTime ) / 1000;
return( VLC_ENOVAR );
}
- if( !sscanf( val.psz_string, "%d:", &i_option ) ||
- p_sys->i_options <= i_option )
- {
- i_option = 0;
- }
-
- free( (void *)val.psz_string );
-
+ i_option = val.i_int;
p_option = &p_sys->p_options[i_option];
p_dev = &p_sys->p_devices[p_option->i_dev];
vlc_bool_t b_change )
{
UInt32 i;
- vlc_value_t val;
+ vlc_value_t val, text;
struct aout_sys_t * p_sys = p_aout->output.p_sys;
}
}
- var_Create( p_aout, "audio-device", VLC_VAR_STRING |
- VLC_VAR_HASCHOICE );
+ var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
+ text.psz_string = _("Audio device");
+ var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL );
for( i = 0; i < p_sys->i_options; i++ )
{
- val.psz_string = p_sys->p_options[i].sz_option;
- var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
+ text.psz_string = p_sys->p_options[i].sz_option;
+ val.i_int = i;
+ var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
if( !b_change && i == (UInt32)i_option )
{
if( b_change )
{
- val.psz_string = p_sys->p_options[i_option].sz_option;
+ val.i_int = i_option;
var_Set( p_aout, "audio-device", val );
}