2010-05-15 21:02:47 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright © 2010 Thomas Martitz
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <SDL_audio.h>
|
|
|
|
#include "config.h"
|
2013-04-15 18:00:48 +00:00
|
|
|
#include "sound.h"
|
2010-06-26 10:37:41 +00:00
|
|
|
#include "pcm_sampr.h"
|
2013-04-23 07:20:49 +00:00
|
|
|
#ifdef HAVE_SW_VOLUME_CONTROL
|
|
|
|
#include "pcm_sw_volume.h"
|
|
|
|
#include "fixedpoint.h"
|
|
|
|
#endif
|
2010-05-15 21:02:47 +00:00
|
|
|
|
|
|
|
/**
|
2013-04-23 07:20:49 +00:00
|
|
|
* Audio Hardware api. Make some of them do nothing as we cannot properly
|
|
|
|
* simulate with SDL. if we used DSP we would run code that doesn't actually
|
|
|
|
* run on the target
|
2010-05-15 21:02:47 +00:00
|
|
|
**/
|
2013-04-11 22:57:06 +00:00
|
|
|
#ifdef HAVE_SW_VOLUME_CONTROL
|
2013-04-23 07:20:49 +00:00
|
|
|
static int sdl_volume_level(int volume)
|
2013-04-11 22:57:06 +00:00
|
|
|
{
|
2013-04-23 07:20:49 +00:00
|
|
|
int shift = (1 - sound_numdecimals(SOUND_VOLUME)) << 16;
|
|
|
|
int minvol = fp_mul(sound_min(SOUND_VOLUME), fp_exp10(shift, 16), 16);
|
|
|
|
return volume <= minvol ? INT_MIN : volume;
|
2013-04-11 22:57:06 +00:00
|
|
|
}
|
2013-04-23 07:20:49 +00:00
|
|
|
#endif /* HAVE_SW_VOLUME_CONTROL */
|
2013-04-13 03:35:47 +00:00
|
|
|
|
2013-04-23 07:20:49 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_MONO_VOLUME)
|
2010-05-15 21:02:47 +00:00
|
|
|
void audiohw_set_volume(int volume)
|
|
|
|
{
|
2013-04-23 07:20:49 +00:00
|
|
|
#ifdef HAVE_SW_VOLUME_CONTROL
|
|
|
|
volume = sdl_volume_level(volume);
|
|
|
|
pcm_set_master_volume(volume, volume);
|
2020-07-17 04:01:32 +00:00
|
|
|
#else
|
2013-04-20 08:06:13 +00:00
|
|
|
extern void pcm_set_mixer_volume(int volume);
|
2011-02-08 20:05:25 +00:00
|
|
|
pcm_set_mixer_volume(volume);
|
2013-04-20 08:06:13 +00:00
|
|
|
#endif
|
2013-04-13 03:35:47 +00:00
|
|
|
(void)volume;
|
2010-05-15 21:02:47 +00:00
|
|
|
}
|
2013-04-23 07:20:49 +00:00
|
|
|
#else /* !AUDIOHW_HAVE_MONO_VOLUME */
|
|
|
|
void audiohw_set_volume(int vol_l, int vol_r)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SW_VOLUME_CONTROL
|
|
|
|
vol_l = sdl_volume_level(vol_l);
|
|
|
|
vol_r = sdl_volume_level(vol_r);
|
|
|
|
pcm_set_master_volume(vol_l, vol_r);
|
|
|
|
#endif
|
|
|
|
(void)vol_l; (void)vol_r;
|
|
|
|
}
|
|
|
|
#endif /* AUDIOHW_HAVE_MONO_VOLUME */
|
2010-05-15 21:02:47 +00:00
|
|
|
|
|
|
|
#if defined(AUDIOHW_HAVE_PRESCALER)
|
2013-04-11 22:57:06 +00:00
|
|
|
void audiohw_set_prescaler(int value)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SW_VOLUME_CONTROL
|
|
|
|
pcm_set_prescaler(value);
|
|
|
|
#endif
|
|
|
|
(void)value;
|
|
|
|
}
|
2013-04-23 07:20:49 +00:00
|
|
|
#endif /* AUDIOHW_HAVE_PRESCALER */
|
|
|
|
|
2010-05-15 21:02:47 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_BALANCE)
|
|
|
|
void audiohw_set_balance(int value) { (void)value; }
|
|
|
|
#endif
|
2013-04-13 03:35:47 +00:00
|
|
|
#ifndef HAVE_SW_TONE_CONTROLS
|
2010-05-15 21:02:47 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_BASS)
|
|
|
|
void audiohw_set_bass(int value) { (void)value; }
|
|
|
|
#endif
|
|
|
|
#if defined(AUDIOHW_HAVE_TREBLE)
|
|
|
|
void audiohw_set_treble(int value) { (void)value; }
|
|
|
|
#endif
|
2013-04-13 03:35:47 +00:00
|
|
|
#endif /* HAVE_SW_TONE_CONTROLS */
|
2010-05-15 21:02:47 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
|
|
|
|
void audiohw_set_bass_cutoff(int value) { (void)value; }
|
|
|
|
#endif
|
|
|
|
#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
|
|
|
|
void audiohw_set_treble_cutoff(int value){ (void)value; }
|
|
|
|
#endif
|
|
|
|
/* EQ-based tone controls */
|
|
|
|
#if defined(AUDIOHW_HAVE_EQ)
|
|
|
|
void audiohw_set_eq_band_gain(unsigned int band, int value)
|
|
|
|
{ (void)band; (void)value; }
|
|
|
|
#endif
|
|
|
|
#if defined(AUDIOHW_HAVE_EQ_FREQUENCY)
|
|
|
|
void audiohw_set_eq_band_frequency(unsigned int band, int value)
|
|
|
|
{ (void)band; (void)value; }
|
|
|
|
#endif
|
|
|
|
#if defined(AUDIOHW_HAVE_EQ_WIDTH)
|
|
|
|
void audiohw_set_eq_band_width(unsigned int band, int value)
|
|
|
|
{ (void)band; (void)value; }
|
|
|
|
#endif
|
|
|
|
#if defined(AUDIOHW_HAVE_DEPTH_3D)
|
|
|
|
void audiohw_set_depth_3d(int value)
|
|
|
|
{ (void)value; }
|
|
|
|
#endif
|
2013-04-13 03:35:47 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_LINEOUT)
|
|
|
|
void audiohw_set_lineout_volume(int vol_l, int vol_r)
|
|
|
|
{ (void)vol_l; (void)vol_r; }
|
|
|
|
#endif
|
2018-06-28 10:24:26 +00:00
|
|
|
#if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF)
|
|
|
|
void audiohw_set_filter_roll_off(int value)
|
|
|
|
{ (void)value; }
|
|
|
|
#endif
|
2012-01-03 23:44:38 +00:00
|
|
|
|
|
|
|
void audiohw_close(void) {}
|
|
|
|
|
2011-12-08 20:05:48 +00:00
|
|
|
#ifdef CONFIG_SAMPR_TYPES
|
|
|
|
unsigned int pcm_sampr_to_hw_sampr(unsigned int samplerate,
|
|
|
|
unsigned int type)
|
|
|
|
{ return samplerate; (void)type; }
|
|
|
|
#endif /* CONFIG_SAMPR_TYPES */
|