mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-13 07:02:31 -05:00
nwz/alsa: various improvements
Also audiohw driver to specific device name, rewrite alsa controls code to cache more data, thus making the code easier and use less stack. Avoid using short/long in pcm alsa code since it's the wrong size on 64-bit (simulator for example) Change-Id: Ibc1ec44396e37b6cbdedbcf37300878638e5d2d3
This commit is contained in:
parent
ce9e7e7122
commit
dd82f13fa1
10 changed files with 122 additions and 93 deletions
|
|
@ -66,10 +66,10 @@ static const snd_pcm_access_t access_ = SND_PCM_ACCESS_RW_INTERLEAVED; /* access
|
|||
#if defined(SONY_NWZ_LINUX) || defined(HAVE_FIIO_LINUX_CODEC)
|
||||
/* Sony NWZ must use 32-bit per sample */
|
||||
static const snd_pcm_format_t format = SND_PCM_FORMAT_S32_LE; /* sample format */
|
||||
typedef long sample_t;
|
||||
typedef int32_t sample_t;
|
||||
#else
|
||||
static const snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */
|
||||
typedef short sample_t;
|
||||
typedef int16_t sample_t;
|
||||
#endif
|
||||
static const int channels = 2; /* count of channels */
|
||||
static unsigned int real_sample_rate;
|
||||
|
|
@ -260,10 +260,9 @@ error:
|
|||
* and add 48dB to the input volume. We cannot go lower -43dB because several
|
||||
* values between -48dB and -43dB would require a fractional multiplier, which is
|
||||
* stupid to implement for such very low volume. */
|
||||
static int dig_vol_mult_l = 2 ^ 16; /* multiplicative factor to apply to each sample */
|
||||
static int dig_vol_mult_r = 2 ^ 16; /* multiplicative factor to apply to each sample */
|
||||
|
||||
void pcm_alsa_set_digital_volume(int vol_db_l, int vol_db_r)
|
||||
static int dig_vol_mult_l = 2 << 16; /* multiplicative factor to apply to each sample */
|
||||
static int dig_vol_mult_r = 2 << 16; /* multiplicative factor to apply to each sample */
|
||||
void pcm_set_mixer_volume(int vol_db_l, int vol_db_r)
|
||||
{
|
||||
if(vol_db_l > 0 || vol_db_r > 0 || vol_db_l < -43 || vol_db_r < -43)
|
||||
panicf("invalid pcm alsa volume");
|
||||
|
|
@ -336,7 +335,7 @@ static bool copy_frames(bool first)
|
|||
{
|
||||
/* We have to convert 16-bit to 32-bit, the need to multiply the
|
||||
* sample by some value so the sound is not too low */
|
||||
const short *pcm_ptr = pcm_data;
|
||||
const int16_t *pcm_ptr = pcm_data;
|
||||
sample_t *sample_ptr = &frames[2*(period_size-frames_left)];
|
||||
for (int i = 0; i < nframes; i++)
|
||||
{
|
||||
|
|
@ -757,11 +756,6 @@ void pcm_play_dma_postinit(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void pcm_set_mixer_volume(int volume)
|
||||
{
|
||||
(void)volume;
|
||||
}
|
||||
|
||||
int pcm_alsa_get_rate(void)
|
||||
{
|
||||
return real_sample_rate;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue