#include <vlc_cpu.h>
#include <vlc_aout.h>
-#if !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__)
-# define USE_SOFTVOL
-#endif
-
#define A52_FRAME_NB 1536
struct aout_sys_t
int fd;
audio_sample_format_t format;
bool starting;
-#ifndef USE_SOFTVOL
- bool mute;
- uint8_t level;
-#else
bool soft_mute;
float soft_gain;
-#endif
char *device;
};
-#ifdef USE_SOFTVOL
-# include "volume.h"
-#endif
+#include "volume.h"
static int Open (vlc_object_t *);
static void Close (vlc_object_t *);
set_subcategory( SUBCAT_AUDIO_AOUT )
add_string ("oss-audio-device", "",
AUDIO_DEV_TEXT, AUDIO_DEV_LONGTEXT, false)
-#ifdef USE_SOFTVOL
add_sw_gain ()
-#endif
set_capability( "audio output", 100 )
set_callbacks (Open, Close)
vlc_module_end ()
static void Play (audio_output_t *, block_t *);
static void Pause (audio_output_t *, bool, mtime_t);
static void Flush (audio_output_t *, bool);
-#ifndef USE_SOFTVOL
-static int VolumeSync (audio_output_t *);
-#endif
static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
{
vlc_strerror_c(errno));
sys->fd = fd;
-#ifndef USE_SOFTVOL
- VolumeSync (aout);
-#else
aout_SoftVolumeStart (aout);
-#endif
sys->starting = true;
sys->format = *fmt;
return VLC_SUCCESS;
msg_Err (aout, "cannot write samples: %s", vlc_strerror_c(errno));
}
block_Release (block);
-
-#ifndef USE_SOFTVOL
- /* Dumb OSS cannot send any kind of events for this... */
- VolumeSync (aout);
-#endif
}
/**
ioctl (fd, SNDCTL_DSP_HALT, NULL);
}
-#ifndef USE_SOFTVOL
-static int VolumeSync (audio_output_t *aout)
-{
- aout_sys_t *sys = aout->sys;
- int fd = sys->fd;
-
- int level;
- if (ioctl (fd, SNDCTL_DSP_GETPLAYVOL, &level) < 0)
- return -1;
-
- sys->mute = !level;
- if (level) /* try to keep last volume before mute */
- sys->level = level;
- aout_MuteReport (aout, !level);
- aout_VolumeReport (aout, (float)(level & 0xFF) / 100.f);
- return 0;
-}
-#endif
-
/**
* Releases the audio output device.
*/
sys->fd = -1;
}
-#ifndef USE_SOFTVOL
-static int VolumeSet (audio_output_t *aout, float vol)
-{
- aout_sys_t *sys = aout->sys;
- int fd = sys->fd;
- if (fd == -1)
- return -1;
-
- int level = lroundf (vol * 100.f);
- if (level > 0xFF)
- level = 0xFFFF;
- else
- level |= level << 8;
- if (!sys->mute && ioctl (fd, SNDCTL_DSP_SETPLAYVOL, &level) < 0)
- {
- msg_Err (aout, "cannot set volume: %s", vlc_strerror_c(errno));
- return -1;
- }
-
- sys->level = level;
- aout_VolumeReport (aout, (float)(level & 0xFF) / 100.f);
- return 0;
-}
-
-static int MuteSet (audio_output_t *aout, bool mute)
-{
- aout_sys_t *sys = aout->sys;
- int fd = sys->fd;
- if (fd == -1)
- return -1;
-
- int level = mute ? 0 : (sys->level | (sys->level << 8));
- if (ioctl (fd, SNDCTL_DSP_SETPLAYVOL, &level) < 0)
- {
- msg_Err (aout, "cannot mute: %s", vlc_strerror_c(errno));
- return -1;
- }
-
- sys->mute = mute;
- aout_MuteReport (aout, mute);
- return 0;
-}
-#endif
-
static int DevicesEnum (audio_output_t *aout)
{
int fd = vlc_open ("/dev/dsp", O_WRONLY);
return VLC_ENOMEM;
sys->fd = -1;
-#ifndef USE_SOFTVOL
- sys->level = 100;
- sys->mute = false;
-#endif
sys->device = var_InheritString (aout, "oss-audio-device");
aout->sys = sys;
aout->start = Start;
aout->stop = Stop;
- aout->volume_set = VolumeSet;
- aout->mute_set = MuteSet;
aout->device_select = DeviceSelect;
-
-#ifdef USE_SOFTVOL
aout_SoftVolumeInit (aout);
-#endif
+
DevicesEnum (aout);
return VLC_SUCCESS;
}