~ubuntu-branches/ubuntu/maverick/vlc/maverick

« back to all changes in this revision

Viewing changes to src/control/audio.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-09-17 21:56:14 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20080917215614-tj0vx8xzd57e52t8
Tags: 0.9.2-1ubuntu1
* New Upstream Release, exception granted by
    - dktrkranz, norsetto, Hobbsee (via irc). LP: #270404

Changes done in ubuntu:

* add libxul-dev to build-depends
* make sure that vlc is build against libxul in configure. This doesn't
  change anything in the package, but makes it more robust if building
  in an 'unclean' chroot or when modifying the package.
* debian/control: make Vcs-* fields point to the motumedia branch
* add libx264-dev and libass-dev to build-depends
  LP: #210354, #199870
* actually enable libass support by passing --enable-libass to configure
* enable libdca: add libdca-dev to build depends and --enable-libdca
* install the x264 plugin.

Changes already in the pkg-multimedia branch in debian:

* don't install usr/share/vlc/mozilla in debian/mozilla-plugin-vlc.install  
* new upstream .desktop file now registers flash video mimetype LP: #261567
* add Xb-Npp-Applications to mozilla-plugin-vlc
* remove duplicate entries in debian/vlc-nox.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * libvlc_audio.c: New libvlc audio control API
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2006 the VideoLAN team
5
 
 * $Id: 58e663d66a7c00fe7f029277b672c4984f03301a $
 
5
 * $Id$
6
6
 *
7
7
 * Authors: Filippo Carone <filippo@carone.org>
8
8
 *          Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
22
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
23
 *****************************************************************************/
24
24
 
25
 
#include <libvlc_internal.h>
 
25
#include "libvlc_internal.h"
26
26
#include <vlc/libvlc.h>
27
27
 
28
 
#include <audio_output.h> /* for audio_volume_t, AOUT_VOLUME_MAX */
 
28
#include <vlc_input.h>
 
29
#include <vlc_aout.h>
 
30
 
 
31
 
 
32
/*
 
33
 * Remember to release the returned aout_instance_t since it is locked at
 
34
 * the end of this function.
 
35
 */
 
36
static aout_instance_t *GetAOut( libvlc_instance_t *p_instance,
 
37
                                 libvlc_exception_t *p_exception )
 
38
{
 
39
    aout_instance_t * p_aout = NULL;
 
40
 
 
41
    p_aout = vlc_object_find( p_instance->p_libvlc_int, VLC_OBJECT_AOUT, FIND_CHILD );
 
42
    if( !p_aout )
 
43
    {
 
44
        libvlc_exception_raise( p_exception, "No active audio output" );
 
45
        return NULL;
 
46
    }
 
47
 
 
48
    return p_aout;
 
49
}
 
50
 
29
51
 
30
52
/*****************************************************************************
31
53
 * libvlc_audio_get_mute : Get the volume state, true if muted
33
55
void libvlc_audio_toggle_mute( libvlc_instance_t *p_instance,
34
56
                               libvlc_exception_t *p_e )
35
57
{
36
 
    aout_VolumeMute( p_instance->p_vlc, NULL );
 
58
    VLC_UNUSED(p_e);
 
59
 
 
60
    aout_VolumeMute( p_instance->p_libvlc_int, NULL );
37
61
}
38
62
 
39
 
vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *p_instance,
40
 
                                  libvlc_exception_t *p_e )
 
63
int libvlc_audio_get_mute( libvlc_instance_t *p_instance,
 
64
                           libvlc_exception_t *p_e )
41
65
{
42
66
    /*
43
67
     * If the volume level is 0, then the channel is muted
46
70
 
47
71
    i_volume = libvlc_audio_get_volume(p_instance, p_e);
48
72
    if ( i_volume == 0 )
49
 
        return VLC_TRUE;
50
 
    return VLC_FALSE;
 
73
        return true;
 
74
    return false;
51
75
}
52
76
 
53
 
void libvlc_audio_set_mute( libvlc_instance_t *p_instance, vlc_bool_t status,
 
77
void libvlc_audio_set_mute( libvlc_instance_t *p_instance, int mute,
54
78
                            libvlc_exception_t *p_e )
55
79
{
56
 
    if ( status ^ libvlc_audio_get_mute( p_instance, p_e ) )
 
80
    if ( mute ^ libvlc_audio_get_mute( p_instance, p_e ) )
57
81
    {
58
 
        /* the aout_VolumeMute is a toggle function, so this is enough. */
59
 
        aout_VolumeMute( p_instance->p_vlc, NULL );
 
82
        aout_VolumeMute( p_instance->p_libvlc_int, NULL );
60
83
    }
61
84
}
62
85
 
66
89
int libvlc_audio_get_volume( libvlc_instance_t *p_instance,
67
90
                             libvlc_exception_t *p_e )
68
91
{
 
92
    VLC_UNUSED(p_e);
 
93
 
69
94
    audio_volume_t i_volume;
70
95
 
71
 
    aout_VolumeGet( p_instance->p_vlc, &i_volume );
 
96
    aout_VolumeGet( p_instance->p_libvlc_int, &i_volume );
72
97
 
73
98
    return (i_volume*200+AOUT_VOLUME_MAX/2)/AOUT_VOLUME_MAX;
74
99
}
83
108
    if( i_volume >= 0 && i_volume <= 200 )
84
109
    {
85
110
        i_volume = (i_volume * AOUT_VOLUME_MAX + 100) / 200;
86
 
        aout_VolumeSet( p_instance->p_vlc, i_volume );
 
111
 
 
112
        aout_VolumeSet( p_instance->p_libvlc_int, i_volume );
87
113
    }
88
114
    else
89
115
    {
90
116
        libvlc_exception_raise( p_e, "Volume out of range" );
91
117
    }
92
118
}
 
119
 
 
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 )
 
125
{
 
126
    input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
 
127
    vlc_value_t val_list;
 
128
 
 
129
    if( !p_input_thread )
 
130
        return -1;
 
131
 
 
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;
 
135
}
 
136
 
 
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 )
 
142
{
 
143
    input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
 
144
    vlc_value_t val_list;
 
145
    vlc_value_t val;
 
146
    int i_track = -1;
 
147
    int i_ret = -1;
 
148
    int i;
 
149
 
 
150
    if( !p_input_thread )
 
151
        return -1;
 
152
 
 
153
    i_ret = var_Get( p_input_thread, "audio-es", &val );
 
154
    if( i_ret < 0 )
 
155
    {
 
156
        libvlc_exception_raise( p_e, "Getting Audio track information failed" );
 
157
        vlc_object_release( p_input_thread );
 
158
        return i_ret;
 
159
    }
 
160
 
 
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++ )
 
163
    {
 
164
        vlc_value_t track_val = val_list.p_list->p_values[i];
 
165
        if( track_val.i_int == val.i_int )
 
166
        {
 
167
            i_track = i;
 
168
            break;
 
169
       }
 
170
    }
 
171
    vlc_object_release( p_input_thread );
 
172
    return i_track;
 
173
}
 
174
 
 
175
 
 
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 )
 
181
{
 
182
    input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
 
183
    vlc_value_t val_list;
 
184
    int i_ret = -1;
 
185
    int i;
 
186
 
 
187
    if( !p_input_thread )
 
188
        return;
 
189
 
 
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++ )
 
192
    {
 
193
        vlc_value_t val = val_list.p_list->p_values[i];
 
194
        if( i_track == val.i_int )
 
195
        {
 
196
            i_ret = var_Set( p_input_thread, "audio-es", val );
 
197
            if( i_ret < 0 )
 
198
            {
 
199
                libvlc_exception_raise( p_e, "Setting audio track failed" );
 
200
            }
 
201
            vlc_object_release( p_input_thread );
 
202
            return;
 
203
        }
 
204
    }
 
205
    libvlc_exception_raise( p_e, "Audio track out of range" );
 
206
    vlc_object_release( p_input_thread );
 
207
}
 
208
 
 
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 )
 
214
{
 
215
    aout_instance_t *p_aout = GetAOut( p_instance, p_e );
 
216
    if( p_aout )
 
217
    {
 
218
        vlc_value_t val;
 
219
 
 
220
        var_Get( p_aout, "audio-channels", &val );
 
221
        vlc_object_release( p_aout );
 
222
        return val.i_int;
 
223
    }
 
224
    return -1;
 
225
}
 
226
 
 
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 )
 
232
{
 
233
    aout_instance_t *p_aout = GetAOut( p_instance, p_e );
 
234
    if( p_aout )
 
235
    {
 
236
        vlc_value_t val;
 
237
        int i_ret = -1;
 
238
 
 
239
        val.i_int = i_channel;
 
240
        switch( i_channel )
 
241
        {
 
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 );
 
248
                if( i_ret < 0 )
 
249
                {
 
250
                    libvlc_exception_raise( p_e, "Failed setting audio channel" );
 
251
                    vlc_object_release( p_aout );
 
252
                    return;
 
253
                }
 
254
                vlc_object_release( p_aout );
 
255
                return; /* Found */
 
256
            default:
 
257
                libvlc_exception_raise( p_e, "Audio channel out of range" );
 
258
                break;
 
259
        }
 
260
        vlc_object_release( p_aout );
 
261
    }
 
262
}