alsa: instead of per-target tests, use HAVE_ALSA_32BIT
Affects all Sony NWZ (linux) and the fiio m3k linux targets. Change-Id: I2fcf121bd026103d2b72332a5a52cc2b5e93949f
This commit is contained in:
parent
e17337c9aa
commit
54fcb907c1
4 changed files with 34 additions and 28 deletions
|
@ -117,6 +117,7 @@
|
|||
|
||||
/* Audio codec */
|
||||
#define HAVE_FIIO_LINUX_CODEC
|
||||
#define HAVE_ALSA_32BIT
|
||||
|
||||
/* We don't have hardware controls */
|
||||
#define HAVE_SW_TONE_CONTROLS
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
|
||||
/* Audio codec */
|
||||
#define HAVE_NWZ_LINUX_CODEC
|
||||
#define HAVE_ALSA_32BIT
|
||||
|
||||
#endif /* SIMULATOR */
|
||||
|
||||
|
|
|
@ -69,8 +69,7 @@
|
|||
#endif
|
||||
|
||||
static const snd_pcm_access_t access_ = SND_PCM_ACCESS_RW_INTERLEAVED; /* access mode */
|
||||
#if defined(SONY_NWZ_LINUX) || defined(HAVE_FIIO_LINUX_CODEC)
|
||||
/* Sony NWZ must use 32-bit per sample */
|
||||
#if defined(HAE_ALSA_32BIT)
|
||||
static const snd_pcm_format_t format = SND_PCM_FORMAT_S32_LE; /* sample format */
|
||||
typedef int32_t sample_t;
|
||||
#else
|
||||
|
@ -262,6 +261,7 @@ error:
|
|||
return err;
|
||||
}
|
||||
|
||||
#if defined(HAVE_ALSA_32BIT)
|
||||
/* Digital volume explanation:
|
||||
* with very good approximation (<0.1dB) the convertion from dB to multiplicative
|
||||
* factor, for dB>=0, is 2^(dB/3). We can then notice that if we write dB=3*k+r
|
||||
|
@ -303,6 +303,7 @@ void pcm_set_mixer_volume(int vol_db_l, int vol_db_r)
|
|||
dig_vol_mult_r = 1 << vol_shift_r | 1 << (vol_shift_r - 1);
|
||||
logf("r: %d dB -> factor = %d", vol_db_r - 48, dig_vol_mult_r);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* copy pcm samples to a spare buffer, suitable for snd_pcm_writei() */
|
||||
static bool copy_frames(bool first)
|
||||
|
@ -343,6 +344,13 @@ static bool copy_frames(bool first)
|
|||
panicf("Wrong pcm_size");
|
||||
/* the compiler will optimize this test away */
|
||||
nframes = MIN((ssize_t)pcm_size/4, frames_left);
|
||||
|
||||
#ifdef HAVE_RECORDING
|
||||
switch (current_alsa_mode)
|
||||
{
|
||||
case SND_PCM_STREAM_PLAYBACK:
|
||||
#endif
|
||||
#if defined(HAVE_ALSA_32BIT)
|
||||
if (format == SND_PCM_FORMAT_S32_LE)
|
||||
{
|
||||
/* We have to convert 16-bit to 32-bit, the need to multiply the
|
||||
|
@ -356,14 +364,11 @@ static bool copy_frames(bool first)
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef HAVE_RECORDING
|
||||
switch (current_alsa_mode)
|
||||
{
|
||||
case SND_PCM_STREAM_PLAYBACK:
|
||||
#endif
|
||||
{
|
||||
/* Rockbox and PCM have same format: memcopy */
|
||||
memcpy(&frames[2*(period_size-frames_left)], pcm_data, nframes * 4);
|
||||
}
|
||||
#ifdef HAVE_RECORDING
|
||||
break;
|
||||
case SND_PCM_STREAM_CAPTURE:
|
||||
|
@ -373,7 +378,6 @@ static bool copy_frames(bool first)
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
pcm_data += nframes*4;
|
||||
pcm_size -= nframes*4;
|
||||
frames_left -= nframes;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#if defined(SONY_NWZ_LINUX) || defined(HAVE_FIIO_LINUX_CODEC)
|
||||
#if defined(HAVE_ALSA_32BIT)
|
||||
/* Set the PCM volume in dB: each sample with have this volume applied digitally
|
||||
* before being sent to ALSA. Volume must satisfy -43 <= dB <= 0 */
|
||||
void pcm_set_mixer_volume(int vol_db_l, int vol_db_r);
|
||||
|
|
Loading…
Reference in a new issue