/*****************************************************************************
* kai.c : KAI audio output plugin for vlc
*****************************************************************************
- * Copyright (C) 2010 the VideoLAN team
+ * Copyright (C) 2010 VLC authors and VideoLAN
*
* Authors: KO Myung-Hun <komh@chollian.net>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
{
aout_packet_t packet;
HKAI hkai;
+ float soft_gain;
+ bool soft_mute;
+ audio_sample_format_t format;
};
/*****************************************************************************
static ULONG APIENTRY KaiCallback ( PVOID, PVOID, ULONG );
+#include "volume.h"
+
/*****************************************************************************
* Module descriptor
*****************************************************************************/
set_subcategory( SUBCAT_AUDIO_AOUT )
add_string( "kai-audio-device", ppsz_kai_audio_device[0],
KAI_AUDIO_DEVICE_TEXT, KAI_AUDIO_DEVICE_LONGTEXT, false )
- change_string_list( ppsz_kai_audio_device, ppsz_kai_audio_device_text,
- 0 )
+ change_string_list( ppsz_kai_audio_device, ppsz_kai_audio_device_text )
+ add_sw_gain( )
add_bool( "kai-audio-exclusive-mode", false,
KAI_AUDIO_EXCLUSIVE_MODE_TEXT, KAI_AUDIO_EXCLUSIVE_MODE_LONGTEXT,
true )
/*****************************************************************************
* Open: open the audio device
*****************************************************************************/
-static int Open ( vlc_object_t *p_this )
+static int Start ( audio_output_t *p_aout, audio_sample_format_t *fmt )
{
- audio_output_t *p_aout = (audio_output_t *)p_this;
- aout_sys_t *p_sys;
+ aout_sys_t *p_sys = p_aout->sys;
char *psz_mode;
ULONG i_kai_mode;
KAISPEC ks_wanted, ks_obtained;
int i_nb_channels;
int i_bytes_per_frame;
vlc_value_t val, text;
- audio_format_t format = p_aout->format;
-
- /* Allocate structure */
- p_aout->sys = calloc( 1, sizeof( aout_sys_t ) );
-
- if( p_aout->sys == NULL )
- return VLC_ENOMEM;
-
- p_sys = p_aout->sys;
+ audio_sample_format_t format = *fmt;
if( var_Get( p_aout, "audio-device", &val ) != VLC_ENOVAR )
{
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
}
- /* Support s16l only */
- format.i_format = VLC_CODEC_S16L;
+ /* Support S16 only */
+ format.i_format = VLC_CODEC_S16N;
aout_FormatPrepare( &format );
{
msg_Err( p_aout, "cannot initialize KAI");
- goto exit_free_sys;
+ return VLC_EGENERIC;
}
ks_wanted.usDeviceIndex = 0;
msg_Dbg( p_aout, "obtained i_bytes_per_frame = %d",
format.i_bytes_per_frame );
- p_aout->format = format;
+ p_sys->format = *fmt = format;
+
+ p_aout->time_get = aout_PacketTimeGet;
+ p_aout->play = Play;
+ p_aout->pause = NULL;
+ p_aout->flush = aout_PacketFlush;
- p_aout->pf_play = Play;
- p_aout->pf_pause = aout_PacketPause;
- p_aout->pf_flush = aout_PacketFlush;
+ aout_SoftVolumeStart( p_aout );
aout_PacketInit( p_aout, &p_sys->packet,
- ks_obtained.ulBufferSize / i_bytes_per_frame );
- aout_VolumeSoftInit( p_aout );
+ ks_obtained.ulBufferSize / i_bytes_per_frame, &format );
if ( var_Type( p_aout, "audio-device" ) == 0 )
{
exit_kai_done :
kaiDone();
-exit_free_sys :
- free( p_sys );
-
return VLC_EGENERIC;
}
/*****************************************************************************
* Close: close the audio device
*****************************************************************************/
-static void Close ( vlc_object_t *p_this )
+static void Stop ( audio_output_t *p_aout )
{
- audio_output_t *p_aout = (audio_output_t *)p_this;
aout_sys_t *p_sys = p_aout->sys;
kaiClose( p_sys->hkai );
kaiDone();
aout_PacketDestroy( p_aout );
- free( p_sys );
}
/*****************************************************************************
ULONG i_buf_size )
{
audio_output_t *p_aout = (audio_output_t *)p_cb_data;
+ aout_sys_t *sys = p_aout->sys;
block_t *p_aout_buffer;
mtime_t current_date, next_date;
ULONG i_len;
* remaining buffer.
*/
next_date = mdate() + ( i_buf_size * 1000000LL
- / p_aout->format.i_bytes_per_frame
- / p_aout->format.i_rate
- * p_aout->format.i_frame_length );
+ / sys->format.i_bytes_per_frame
+ / sys->format.i_rate
+ * sys->format.i_frame_length );
for (i_len = 0; i_len < i_buf_size;)
{
return i_buf_size;
}
+
+static int Open (vlc_object_t *obj)
+{
+ audio_output_t *aout = (audio_output_t *)obj;
+ aout_sys_t *sys = calloc( 1, sizeof( aout_sys_t ) );
+
+ if( unlikely( sys == NULL ))
+ return VLC_ENOMEM;
+
+ aout->sys = sys;
+ aout->start = Start;
+ aout->stop = Stop;
+ aout_SoftVolumeInit( aout );
+ return VLC_SUCCESS;
+}
+
+static void Close( vlc_object_t *obj )
+{
+ audio_output_t *aout = (audio_output_t *)obj;
+ aout_sys_t *sys = aout->sys;
+
+ free(sys);
+}