AC_SUBST(GNUGETOPT_LIBS)
AC_CHECK_LIB(m,cos,[
- VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix rotate noise grain scene kate flac lua chorus_flanger freetype avcodec avformat access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mpc dmo mp4 quicktime qt4 compressor headphone_channel_mixer normvol audiobargraph_a speex mono colorthres extract ball access_imem hotkeys mosaic gaussianblur dbus x26410b hqdn3d anaglyph],[-lm])
+ VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix rotate noise grain scene kate flac lua chorus_flanger freetype avcodec avformat access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mpc dmo mp4 quicktime qt4 compressor headphone_channel_mixer normvol audiobargraph_a speex mono colorthres extract ball access_imem hotkeys mosaic gaussianblur dbus x26410b hqdn3d anaglyph oldrc ncurses],[-lm])
LIBM="-lm"
], [
LIBM=""
#define AOUT_VOLUME_DEFAULT 256
#define AOUT_VOLUME_MAX 512
-VLC_API audio_volume_t aout_VolumeGet( vlc_object_t * );
+VLC_API float aout_VolumeGet( vlc_object_t * );
#define aout_VolumeGet(a) aout_VolumeGet(VLC_OBJECT(a))
-VLC_API int aout_VolumeSet( vlc_object_t *, audio_volume_t );
+VLC_API int aout_VolumeSet( vlc_object_t *, float );
#define aout_VolumeSet(a, b) aout_VolumeSet(VLC_OBJECT(a), b)
-VLC_API int aout_VolumeUp( vlc_object_t *, int, audio_volume_t * );
+VLC_API int aout_VolumeUp( vlc_object_t *, int, float * );
#define aout_VolumeUp(a, b, c) aout_VolumeUp(VLC_OBJECT(a), b, c)
#define aout_VolumeDown(a, b, c) aout_VolumeUp(a, -(b), c)
VLC_API int aout_MuteToggle( vlc_object_t * );
#endif
#include <assert.h>
+#include <math.h>
#include <vlc/libvlc.h>
#include <vlc/libvlc_media.h>
aout_MuteSet( VLC_OBJECT(mp), mute != 0 );
}
-/*****************************************************************************
- * libvlc_audio_get_volume : Get the current volume
- *****************************************************************************/
int libvlc_audio_get_volume( libvlc_media_player_t *mp )
{
- unsigned volume = aout_VolumeGet( mp );
-
- return (volume * 100 + AOUT_VOLUME_DEFAULT / 2) / AOUT_VOLUME_DEFAULT;
+ float vol = aout_VolumeGet( mp );
+ return ( vol >= 0.f ) ? lroundf( vol * 100.f ) : -1;
}
-
-/*****************************************************************************
- * libvlc_audio_set_volume : Set the current volume
- *****************************************************************************/
int libvlc_audio_set_volume( libvlc_media_player_t *mp, int volume )
{
- volume = (volume * AOUT_VOLUME_DEFAULT + 50) / 100;
- if (volume < 0 || volume > AOUT_VOLUME_MAX)
+ float vol = volume / 100.f;
+ if (vol < 0.f)
{
libvlc_printerr( "Volume out of range" );
return -1;
}
- aout_VolumeSet (mp, volume);
+ aout_VolumeSet (mp, vol);
return 0;
}
static void
MarshalVolume( intf_thread_t *p_intf, DBusMessageIter *container )
{
- audio_volume_t i_vol = aout_VolumeGet( p_intf->p_sys->p_playlist );
-
- /* A volume of 1.0 represents a sensible maximum, ie: 0dB */
- double d_vol = (double) i_vol / AOUT_VOLUME_DEFAULT;
+ float f_vol = aout_VolumeGet( p_intf->p_sys->p_playlist );
+ if( f_vol < 0.f )
+ f_vol = 1.f; /* ? */
+ double d_vol = f_vol;
dbus_message_iter_append_basic( container, DBUS_TYPE_DOUBLE, &d_vol );
}
d_dbus_vol *= AOUT_VOLUME_DEFAULT;
if( d_dbus_vol < 0. )
d_dbus_vol = 0.;
- if( d_dbus_vol > AOUT_VOLUME_MAX )
- d_dbus_vol = AOUT_VOLUME_MAX;
- aout_VolumeSet( PL, lround(d_dbus_vol) );
+ aout_VolumeSet( PL, d_dbus_vol );
REPLY_SEND;
}
static void PlayBookmark( intf_thread_t *, int );
static void SetBookmark ( intf_thread_t *, int );
static void DisplayPosition( intf_thread_t *, vout_thread_t *, input_thread_t * );
-static void DisplayVolume ( intf_thread_t *, vout_thread_t *, audio_volume_t );
+static void DisplayVolume( intf_thread_t *, vout_thread_t *, float );
static void DisplayRate ( vout_thread_t *, float );
static float AdjustRateFine( input_thread_t *, const int );
static void ClearChannels ( intf_thread_t *, vout_thread_t * );
/* Volume and audio actions */
case ACTIONID_VOL_UP:
{
- audio_volume_t i_newvol;
- aout_VolumeUp( p_playlist, 1, &i_newvol );
- DisplayVolume( p_intf, p_vout, i_newvol );
+ float vol;
+ if( aout_VolumeUp( p_playlist, 1, &vol ) == 0 )
+ DisplayVolume( p_intf, p_vout, vol );
break;
}
case ACTIONID_VOL_DOWN:
{
- audio_volume_t i_newvol;
- aout_VolumeDown( p_playlist, 1, &i_newvol );
- DisplayVolume( p_intf, p_vout, i_newvol );
+ float vol;
+ if( aout_VolumeDown( p_playlist, 1, &vol ) == 0 )
+ DisplayVolume( p_intf, p_vout, vol );
break;
}
case ACTIONID_VOL_MUTE:
- if( aout_MuteToggle( p_playlist ) == 0 && p_vout != NULL )
+ if( aout_MuteToggle( p_playlist ) == 0 )
{
- if( aout_MuteGet( p_playlist ) > 0 )
+ float vol = aout_VolumeGet( p_playlist );
+ if( aout_MuteGet( p_playlist ) > 0 || vol == 0.f )
{
ClearChannels( p_intf, p_vout );
DisplayIcon( p_vout, OSD_MUTE_ICON );
}
else
- {
- audio_volume_t i_vol = aout_VolumeGet( p_playlist );
- DisplayVolume( p_intf, p_vout, i_vol );
- }
+ DisplayVolume( p_intf, p_vout, vol );
}
break;
}
static void DisplayVolume( intf_thread_t *p_intf, vout_thread_t *p_vout,
- audio_volume_t i_vol )
+ float vol )
{
if( p_vout == NULL )
- {
return;
- }
ClearChannels( p_intf, p_vout );
if( var_GetBool( p_vout, "fullscreen" ) )
- {
- vout_OSDSlider( p_vout, VOLUME_WIDGET_CHAN,
- i_vol*100/AOUT_VOLUME_MAX, OSD_VERT_SLIDER );
- }
- DisplayMessage( p_vout, VOLUME_TEXT_CHAN, _( "Volume %d%%" ),
- i_vol*100/AOUT_VOLUME_DEFAULT );
+ vout_OSDSlider( p_vout, VOLUME_WIDGET_CHAN, lround(vol * 100.),
+ OSD_VERT_SLIDER );
+ DisplayMessage( p_vout, VOLUME_TEXT_CHAN, _( "Volume %ld%%" ),
+ lround(vol * 100.) );
}
static void DisplayRate( vout_thread_t *p_vout, float f_rate )
#include <errno.h> /* ENOMEM */
#include <signal.h>
#include <assert.h>
+#include <math.h>
#include <vlc_interface.h>
#include <vlc_aout_intf.h>
if ( *newval.psz_string )
{
/* Set. */
- audio_volume_t i_volume = atoi( newval.psz_string );
- if( !aout_VolumeSet( p_playlist, i_volume ) )
+ int i_volume = atoi( newval.psz_string );
+ if( !aout_VolumeSet( p_playlist,
+ i_volume / (float)AOUT_VOLUME_DEFAULT ) )
i_error = VLC_SUCCESS;
aout_MuteSet( p_playlist, i_volume == 0 );
osd_Volume( p_this );
else
{
/* Get. */
- audio_volume_t i_volume = aout_VolumeGet( p_playlist );
- msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
+ msg_rc( STATUS_CHANGE "( audio volume: %ld )",
+ lroundf( aout_VolumeGet( p_playlist ) * AOUT_VOLUME_DEFAULT ) );
i_error = VLC_SUCCESS;
}
{
VLC_UNUSED(oldval); VLC_UNUSED(p_data);
intf_thread_t *p_intf = (intf_thread_t*)p_this;
- audio_volume_t i_volume;
+ float volume;
input_thread_t *p_input =
playlist_CurrentInput( p_intf->p_sys->p_playlist );
int i_nb_steps = atoi(newval.psz_string);
if( !strcmp(psz_cmd, "voldown") )
i_nb_steps *= -1;
- if( aout_VolumeUp( p_intf->p_sys->p_playlist, i_nb_steps, &i_volume ) < 0 )
+ if( aout_VolumeUp( p_intf->p_sys->p_playlist, i_nb_steps, &volume ) < 0 )
i_error = VLC_EGENERIC;
osd_Volume( p_this );
- if ( !i_error ) msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
+ if ( !i_error )
+ msg_rc( STATUS_CHANGE "( audio volume: %ld )",
+ lroundf( volume * AOUT_VOLUME_DEFAULT ) );
return i_error;
}
#import "intf.h"
#import "open.h"
#import "playlist.h"
+#import <math.h>
#import <vlc_playlist.h>
#import <vlc_input.h>
#import <vlc_keys.h>
if( !p_intf )
return 0;
- audio_volume_t i_volume = aout_VolumeGet( pl_Get( p_intf ) );
+ float volume = aout_VolumeGet( pl_Get( p_intf ) );
- return (int)i_volume;
+ return lroundf(volume * AOUT_VOLUME_DEFAULT);
}
- (void)setVolume: (int)i_value
if( !p_intf )
return;
- aout_VolumeSet( pl_Get( p_intf ), i_value );
+ aout_VolumeSet( pl_Get( p_intf ), i_value / (float)AOUT_VOLUME_DEFAULT );
}
#pragma mark -
#import "controls.h" // TODO: remove me
#import "playlist.h"
#import "SideBarItem.h"
+#import <math.h>
#import <vlc_playlist.h>
#import <vlc_aout_intf.h>
#import <vlc_url.h>
- (void)updateVolumeSlider
{
- audio_volume_t i_volume;
playlist_t * p_playlist = pl_Get( VLCIntf );
-
- i_volume = aout_VolumeGet( p_playlist );
+ int i_volume = lroundf(aout_VolumeGet( p_playlist ) * AOUT_VOLUME_DEFAULT);
BOOL b_muted = [[VLCCoreInteraction sharedInstance] isMuted];
if( !b_muted )
#include <assert.h>
#include <wchar.h>
#include <sys/stat.h>
+#include <math.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
};
char buf1[MSTRTIME_MAX_SIZE];
char buf2[MSTRTIME_MAX_SIZE];
- unsigned i_volume;
+ float volume;
case INIT_S:
case END_S:
mvnprintw(y++, 0, COLS, _(" Position : %s/%s"), buf1, buf2);
- i_volume = aout_VolumeGet(p_playlist);
- mvnprintw(y++, 0, COLS, _(" Volume : %u%%"),
- i_volume*100/AOUT_VOLUME_DEFAULT);
+ volume = aout_VolumeGet(p_playlist);
+ if (volume >= 0.f)
+ mvnprintw(y++, 0, COLS, _(" Volume : %3ld%%"),
+ lroundf(volume * 100.f));
+ else
+ mvnprintw(y++, 0, COLS, _(" Volume : ----"),
+ lroundf(volume * 100.f));
if (!var_Get(p_input, "title", &val)) {
int i_title_count = var_CountChoices(p_input, "title");
#include "input_manager.hpp" /* Get notification of Volume Change */
#include "util/input_slider.hpp" /* SoundSlider */
+#include <math.h>
#include <vlc_aout_intf.h> /* Volume functions */
#include <QLabel>
/* Only if volume is set by user action on slider */
setMuted( false );
playlist_t *p_playlist = pl_Get( p_intf );
- int i_res = i_sliderVolume * (AOUT_VOLUME_DEFAULT * 2) / VOLUME_MAX;
- aout_VolumeSet( p_playlist, i_res );
+ aout_VolumeSet( p_playlist, i_sliderVolume / 100.f );
refreshLabels();
}
void SoundWidget::libUpdateVolume()
{
/* Audio part */
- audio_volume_t i_volume;
playlist_t *p_playlist = pl_Get( p_intf );
-
- i_volume = aout_VolumeGet( p_playlist );
- i_volume = (i_volume * VOLUME_MAX ) / (AOUT_VOLUME_DEFAULT * 2);
+ long i_volume = lroundf(aout_VolumeGet( p_playlist ) * 100.f);
if ( i_volume - volumeSlider->value() != 0 )
{
(void)p_obj; (void)newVal;
playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
- audio_volume_t volume = aout_VolumeGet( pPlaylist );
+ float volume = aout_VolumeGet( pPlaylist ) * 100.f;
SET_VOLUME( m_cVarVolume, volume, false );
bool b_is_muted = aout_MuteGet( pPlaylist ) > 0;
SET_BOOL( m_cVarMute, b_is_muted );
SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
- audio_volume_t volume = aout_VolumeGet( pPlaylist );
+ float volume = aout_VolumeGet( pPlaylist ) * 100.f;
SET_VOLUME( m_cVarVolume, volume, false );
bool b_is_muted = aout_MuteGet( pPlaylist ) > 0;
SET_BOOL( m_cVarMute, b_is_muted );
m_volumeMax = AOUT_VOLUME_DEFAULT * 2;
// Initial value
- audio_volume_t val = aout_VolumeGet( getIntf()->p_sys->p_playlist );
+ float val = aout_VolumeGet( getIntf()->p_sys->p_playlist ) * 100.f;
set( val, false );
}
# include "config.h"
#endif
+#include <math.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_meta.h>
static int vlclua_volume_set( lua_State *L )
{
playlist_t *p_this = vlclua_get_playlist_internal( L );
- int i_volume = VLC_CLIP( luaL_checkint( L, 1 ), 0, AOUT_VOLUME_MAX );
- int i_ret = aout_VolumeSet( p_this, i_volume );
+ int i_volume = luaL_checkint( L, 1 );
+ if( i_volume < 0 )
+ i_volume = 0;
+ int i_ret = aout_VolumeSet( p_this, i_volume/(float)AOUT_VOLUME_DEFAULT );
return vlclua_push_ret( L, i_ret );
}
static int vlclua_volume_get( lua_State *L )
{
playlist_t *p_this = vlclua_get_playlist_internal( L );
- audio_volume_t i_volume = aout_VolumeGet( p_this );
+ long i_volume = lroundf(aout_VolumeGet( p_this ) * AOUT_VOLUME_DEFAULT);
lua_pushnumber( L, i_volume );
return 1;
}
static int vlclua_volume_up( lua_State *L )
{
- audio_volume_t i_volume;
playlist_t *p_this = vlclua_get_playlist_internal( L );
- aout_VolumeUp( p_this, luaL_optint( L, 1, 1 ), &i_volume );
- lua_pushnumber( L, i_volume );
+ float volume;
+
+ aout_VolumeUp( p_this, luaL_optint( L, 1, 1 ), &volume );
+ lua_pushnumber( L, lroundf(volume * AOUT_VOLUME_DEFAULT) );
return 1;
}
static int vlclua_volume_down( lua_State *L )
{
- audio_volume_t i_volume;
playlist_t *p_this = vlclua_get_playlist_internal( L );
- aout_VolumeDown( p_this, luaL_optint( L, 1, 1 ), &i_volume );
- lua_pushnumber( L, i_volume );
+ float volume;
+
+ aout_VolumeDown( p_this, luaL_optint( L, 1, 1 ), &volume );
+ lua_pushnumber( L, lroundf(volume * AOUT_VOLUME_DEFAULT) );
return 1;
}
#undef aout_VolumeGet
/**
* Gets the volume of the output device (independent of mute).
+ * \return Current audio volume (0 = silent, 1 = nominal),
+ * or a strictly negative value if undefined.
*/
-audio_volume_t aout_VolumeGet (vlc_object_t *obj)
+float aout_VolumeGet (vlc_object_t *obj)
{
audio_output_t *aout;
float vol;
prepareVolume (obj, &aout, &vol, NULL);
cancelVolume (obj, aout);
- return lroundf (vol * AOUT_VOLUME_DEFAULT);
+ return vol;
}
#undef aout_VolumeSet
* Sets the volume of the output device.
* The mute status is not changed.
*/
-int aout_VolumeSet (vlc_object_t *obj, audio_volume_t volume)
+int aout_VolumeSet (vlc_object_t *obj, float vol)
{
audio_output_t *aout;
- float vol = volume / (float)AOUT_VOLUME_DEFAULT;
bool mute;
prepareVolume (obj, &aout, NULL, &mute);
* \param value how much to increase (> 0) or decrease (< 0) the volume
* \param volp if non-NULL, will contain contain the resulting volume
*/
-int aout_VolumeUp (vlc_object_t *obj, int value, audio_volume_t *volp)
+int aout_VolumeUp (vlc_object_t *obj, int value, float *volp)
{
audio_output_t *aout;
int ret;
vol = AOUT_VOLUME_MAX / AOUT_VOLUME_DEFAULT;
ret = commitVolume (obj, aout, vol, mute);
if (volp != NULL)
- *volp = lroundf (vol * AOUT_VOLUME_DEFAULT);
+ *volp = vol;
return ret;
}
*/
static void aout_OutputVolumeReport (audio_output_t *aout, float volume)
{
- audio_volume_t vol = lroundf (volume * (float)AOUT_VOLUME_DEFAULT);
+ long vol = lroundf (volume * (float)AOUT_VOLUME_DEFAULT);
/* We cannot acquire the volume lock as this gets called from the audio
* output plug-in (it would cause a lock inversion). */
*/
void aout_VolumeSoftInit (audio_output_t *aout)
{
- audio_volume_t volume = var_GetInteger (aout, "volume");
+ long volume = var_GetInteger (aout, "volume");
bool mute = var_GetBool (aout, "mute");
aout_assert_locked (aout);
/* Needed by str_format_time */
#include <time.h>
#include <limits.h>
+#include <math.h>
/* Needed by str_format_meta */
#include <vlc_input.h>
}
break;
case 'V':
+ {
+ float vol = aout_VolumeGet( p_object );
+ if( vol >= 0. )
{
- audio_volume_t volume = aout_VolumeGet( p_object );
- snprintf( buf, 10, "%d", volume );
+ snprintf( buf, 10, "%ld",
+ lroundf(vol * AOUT_VOLUME_DEFAULT ) );
INSERT_STRING_NO_FREE( buf );
- break;
}
+ else
+ INSERT_STRING_NO_FREE( "---" );
+ break;
+ }
case '_':
*(dst+d) = '\n';
d++;