22
22
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
23
*****************************************************************************/
25
#include <libvlc_internal.h>
25
#include "libvlc_internal.h"
26
26
#include <vlc/libvlc.h>
28
#include <audio_output.h> /* for audio_volume_t, AOUT_VOLUME_MAX */
28
#include <vlc_input.h>
33
* Remember to release the returned aout_instance_t since it is locked at
34
* the end of this function.
36
static aout_instance_t *GetAOut( libvlc_instance_t *p_instance,
37
libvlc_exception_t *p_exception )
39
aout_instance_t * p_aout = NULL;
41
p_aout = vlc_object_find( p_instance->p_libvlc_int, VLC_OBJECT_AOUT, FIND_CHILD );
44
libvlc_exception_raise( p_exception, "No active audio output" );
30
52
/*****************************************************************************
31
53
* libvlc_audio_get_mute : Get the volume state, true if muted
83
108
if( i_volume >= 0 && i_volume <= 200 )
85
110
i_volume = (i_volume * AOUT_VOLUME_MAX + 100) / 200;
86
aout_VolumeSet( p_instance->p_vlc, i_volume );
112
aout_VolumeSet( p_instance->p_libvlc_int, i_volume );
90
116
libvlc_exception_raise( p_e, "Volume out of range" );
120
/*****************************************************************************
121
* libvlc_audio_get_track_count : Get the number of available audio tracks
122
*****************************************************************************/
123
int libvlc_audio_get_track_count( libvlc_media_player_t *p_mi,
124
libvlc_exception_t *p_e )
126
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
127
vlc_value_t val_list;
129
if( !p_input_thread )
132
var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
133
vlc_object_release( p_input_thread );
134
return val_list.p_list->i_count;
137
/*****************************************************************************
138
* libvlc_audio_get_track : Get the current audio track
139
*****************************************************************************/
140
int libvlc_audio_get_track( libvlc_media_player_t *p_mi,
141
libvlc_exception_t *p_e )
143
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
144
vlc_value_t val_list;
150
if( !p_input_thread )
153
i_ret = var_Get( p_input_thread, "audio-es", &val );
156
libvlc_exception_raise( p_e, "Getting Audio track information failed" );
157
vlc_object_release( p_input_thread );
161
var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
162
for( i = 0; i < val_list.p_list->i_count; i++ )
164
vlc_value_t track_val = val_list.p_list->p_values[i];
165
if( track_val.i_int == val.i_int )
171
vlc_object_release( p_input_thread );
176
/*****************************************************************************
177
* libvlc_audio_set_track : Set the current audio track
178
*****************************************************************************/
179
void libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track,
180
libvlc_exception_t *p_e )
182
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
183
vlc_value_t val_list;
187
if( !p_input_thread )
190
var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
191
for( i = 0; i < val_list.p_list->i_count; i++ )
193
vlc_value_t val = val_list.p_list->p_values[i];
194
if( i_track == val.i_int )
196
i_ret = var_Set( p_input_thread, "audio-es", val );
199
libvlc_exception_raise( p_e, "Setting audio track failed" );
201
vlc_object_release( p_input_thread );
205
libvlc_exception_raise( p_e, "Audio track out of range" );
206
vlc_object_release( p_input_thread );
209
/*****************************************************************************
210
* libvlc_audio_get_channel : Get the current audio channel
211
*****************************************************************************/
212
int libvlc_audio_get_channel( libvlc_instance_t *p_instance,
213
libvlc_exception_t *p_e )
215
aout_instance_t *p_aout = GetAOut( p_instance, p_e );
220
var_Get( p_aout, "audio-channels", &val );
221
vlc_object_release( p_aout );
227
/*****************************************************************************
228
* libvlc_audio_set_channel : Set the current audio channel
229
*****************************************************************************/
230
void libvlc_audio_set_channel( libvlc_instance_t *p_instance, int i_channel,
231
libvlc_exception_t *p_e )
233
aout_instance_t *p_aout = GetAOut( p_instance, p_e );
239
val.i_int = i_channel;
242
case AOUT_VAR_CHAN_RSTEREO:
243
case AOUT_VAR_CHAN_STEREO:
244
case AOUT_VAR_CHAN_LEFT:
245
case AOUT_VAR_CHAN_RIGHT:
246
case AOUT_VAR_CHAN_DOLBYS:
247
i_ret = var_Set( p_aout, "audio-channels", val );
250
libvlc_exception_raise( p_e, "Failed setting audio channel" );
251
vlc_object_release( p_aout );
254
vlc_object_release( p_aout );
257
libvlc_exception_raise( p_e, "Audio channel out of range" );
260
vlc_object_release( p_aout );