summaryrefslogtreecommitdiffstats
path: root/firmware/target/hosted/pcm-alsa.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2018-02-19 16:28:11 +1100
committerSolomon Peachy <pizza@shaftnet.org>2020-10-31 14:16:31 +0000
commitdd82f13fa1241266576b508180fcf90b8d9bda2c (patch)
treecdae2331353e4f85a296782b14001d021923ddfc /firmware/target/hosted/pcm-alsa.c
parentce9e7e712238dc69a825a49f4f226ff47fbbff69 (diff)
downloadrockbox-dd82f13fa1241266576b508180fcf90b8d9bda2c.tar.gz
rockbox-dd82f13fa1241266576b508180fcf90b8d9bda2c.zip
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
Diffstat (limited to 'firmware/target/hosted/pcm-alsa.c')
-rw-r--r--firmware/target/hosted/pcm-alsa.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/firmware/target/hosted/pcm-alsa.c b/firmware/target/hosted/pcm-alsa.c
index 939a0cabb5..970abc78cf 100644
--- a/firmware/target/hosted/pcm-alsa.c
+++ b/firmware/target/hosted/pcm-alsa.c
@@ -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;