mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-04-12 00:47:49 -04:00
pcm: Make more of the low-level PCM API private
* pcm_play_data * pcm_play_stop * pcm_play_stop_int * pcm_is_playing * pcm_set_frequency * pcm_get_frequency * pcm_apply_settings Now, the only user of these functions are the mixer and recording layers that provide a higher-level API to plugins and the main [playback] application. Outside of the PCM core, pcm_apply_settings() was only used immediately following a call to mixer_set_frequency(), so the latter function now always calls the former. Change-Id: I61c3144dc156b9de9b7963160b525c6d10c6ad4b
This commit is contained in:
parent
be1e074800
commit
ea570c5728
14 changed files with 28 additions and 44 deletions
|
|
@ -644,7 +644,6 @@ static const struct plugin_api rockbox_api = {
|
|||
#endif
|
||||
&audio_master_sampr_list[0],
|
||||
&hw_freq_sampr[0],
|
||||
pcm_apply_settings,
|
||||
pcm_play_lock,
|
||||
pcm_play_unlock,
|
||||
pcm_current_sink_caps,
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ int plugin_open(const char *plugin, const char *parameter);
|
|||
* when this happens please take the opportunity to sort in
|
||||
* any new functions "waiting" at the end of the list.
|
||||
*/
|
||||
#define PLUGIN_API_VERSION 279
|
||||
#define PLUGIN_API_VERSION 280
|
||||
|
||||
/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
|
||||
|
||||
|
|
@ -743,7 +743,6 @@ struct plugin_api {
|
|||
#endif
|
||||
const unsigned long *audio_master_sampr_list;
|
||||
const unsigned long *hw_freq_sampr;
|
||||
void (*pcm_apply_settings)(void);
|
||||
void (*pcm_play_lock)(void);
|
||||
void (*pcm_play_unlock)(void);
|
||||
const struct pcm_sink_caps* (*pcm_current_sink_caps)(void);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,5 @@
|
|||
-- [[ conversion to old style pcm_ functions ]]
|
||||
if not rb.pcm then rb.splash(rb.HZ, "No Support!") return nil end
|
||||
|
||||
rb.pcm_apply_settings = function() rb.pcm("apply_settings") end
|
||||
rb.pcm_play_lock = function() rb.pcm("play_lock") end
|
||||
rb.pcm_play_unlock = function() rb.pcm("play_unlock") end
|
||||
|
|
|
|||
|
|
@ -549,10 +549,10 @@ RB_WRAP(sound)
|
|||
|
||||
RB_WRAP(pcm)
|
||||
{
|
||||
enum e_pcm {PCM_APPLYSETTINGS = 0, PCM_PLAYLOCK, PCM_PLAYUNLOCK,
|
||||
enum e_pcm {PCM_PLAYLOCK = 0, PCM_PLAYUNLOCK,
|
||||
PCM_ECOUNT};
|
||||
|
||||
const char *pcm_option[] = {"apply_settings", "play_lock", "play_unlock",
|
||||
const char *pcm_option[] = {"play_lock", "play_unlock",
|
||||
NULL};
|
||||
|
||||
lua_pushnil(L); /*push nil so options w/o return have something to return */
|
||||
|
|
@ -560,9 +560,6 @@ RB_WRAP(pcm)
|
|||
int option = luaL_checkoption (L, 1, NULL, pcm_option);
|
||||
switch(option)
|
||||
{
|
||||
case PCM_APPLYSETTINGS:
|
||||
rb->pcm_apply_settings();
|
||||
break;
|
||||
case PCM_PLAYLOCK:
|
||||
rb->pcm_play_lock();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ void rockbox_open_audio(int rate)
|
|||
|
||||
/* Set sample rate of the audio buffer. */
|
||||
rb->mixer_set_frequency(rate);
|
||||
rb->pcm_apply_settings();
|
||||
|
||||
/* Initialize output buffer. */
|
||||
for(i = 0; i < OUTBUFSIZE; i++)
|
||||
|
|
@ -86,7 +85,6 @@ void rockbox_close_audio(void)
|
|||
|
||||
/* Restore default sampling rate. */
|
||||
rb->mixer_set_frequency(HW_SAMPR_DEFAULT);
|
||||
rb->pcm_apply_settings();
|
||||
}
|
||||
|
||||
/* Rockbox audio callback. */
|
||||
|
|
|
|||
|
|
@ -168,7 +168,6 @@ static void set_frequency(int index)
|
|||
update_gen_step();
|
||||
|
||||
rb->mixer_set_frequency(hw_sampr);
|
||||
rb->pcm_apply_settings();
|
||||
}
|
||||
|
||||
#ifndef HAVE_VOLUME_IN_LIST
|
||||
|
|
|
|||
|
|
@ -253,7 +253,6 @@ bool syssnd_init(void)
|
|||
#endif
|
||||
|
||||
rb->mixer_set_frequency(HW_FREQ_44);
|
||||
rb->pcm_apply_settings();
|
||||
|
||||
rb->memset(channels, 0, sizeof(channels));
|
||||
rb->memset(mixBuffers, 0, sizeof(mixBuffers));
|
||||
|
|
@ -286,7 +285,6 @@ void syssnd_shutdown(void)
|
|||
|
||||
/* Restore default sampling rate. */
|
||||
rb->mixer_set_frequency(HW_SAMPR_DEFAULT);
|
||||
rb->pcm_apply_settings();
|
||||
|
||||
rb->talk_disable(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -616,6 +616,10 @@ static void init_state(void)
|
|||
record_status = RECORD_STOPPED;
|
||||
}
|
||||
|
||||
/* To avoid having to pull in all of pcm-internal.h */
|
||||
void pcm_set_frequency(unsigned int samplerate);
|
||||
void pcm_apply_settings(void);
|
||||
|
||||
/* Set hardware samplerate and save it */
|
||||
static void update_samplerate_config(unsigned long sampr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1754,10 +1754,6 @@ void pcmbuf_set_low_latency(bool state)
|
|||
\param state
|
||||
\description
|
||||
|
||||
void pcm_apply_settings(void)
|
||||
\group sound
|
||||
\description
|
||||
|
||||
void pcm_calculate_rec_peaks(int *left, int *right)
|
||||
\group sound
|
||||
\conditions (defined(HAVE_RECORDING))
|
||||
|
|
|
|||
|
|
@ -71,6 +71,20 @@ void pcm_sync_pcm_factors(void);
|
|||
({ (start) = (void *)(((uintptr_t)(start) + 3) & ~3); \
|
||||
(size) &= ~3; })
|
||||
|
||||
/* Internal PCM API calls for playback */
|
||||
void pcm_play_data(pcm_play_callback_type get_more,
|
||||
pcm_status_callback_type status_cb,
|
||||
const void *start, size_t size);
|
||||
|
||||
void pcm_play_stop(void);
|
||||
void pcm_play_stop_int(void); /* requires PCM lock held */
|
||||
bool pcm_is_playing(void);
|
||||
|
||||
void pcm_set_frequency(unsigned int samplerate);
|
||||
unsigned int pcm_get_frequency(void);
|
||||
/* apply settings to hardware immediately */
|
||||
void pcm_apply_settings(void);
|
||||
|
||||
void pcm_do_peak_calculation(struct pcm_peaks *peaks, bool active,
|
||||
const void *addr, int count);
|
||||
|
||||
|
|
@ -125,7 +139,6 @@ pcm_play_dma_status_callback(enum pcm_dma_status status)
|
|||
#if defined(HAVE_SW_VOLUME_CONTROL) && !defined(PCM_SW_VOLUME_UNBUFFERED)
|
||||
void pcm_play_dma_start_int(const void *addr, size_t size);
|
||||
void pcm_play_dma_stop_int(void);
|
||||
void pcm_play_stop_int(void);
|
||||
#endif /* HAVE_SW_VOLUME_CONTROL && !PCM_SW_VOLUME_UNBUFFERED */
|
||||
|
||||
/* Called by the bottom layer ISR when more data is needed. Returns true
|
||||
|
|
|
|||
|
|
@ -54,15 +54,6 @@ unsigned int pcm_sampr_type_rec_to_play(unsigned int samplerate);
|
|||
#endif
|
||||
#endif /* CONFIG_SAMPR_TYPES */
|
||||
|
||||
/* set next frequency to be used */
|
||||
void pcm_set_frequency(unsigned int samplerate);
|
||||
/* return last-set frequency */
|
||||
unsigned int pcm_get_frequency(void);
|
||||
/* apply settings to hardware immediately */
|
||||
void pcm_apply_settings(void);
|
||||
|
||||
/** RAW PCM playback routines **/
|
||||
|
||||
/* Reenterable locks for locking and unlocking the playback interrupt */
|
||||
void pcm_play_lock(void);
|
||||
void pcm_play_unlock(void);
|
||||
|
|
@ -77,11 +68,6 @@ const struct pcm_sink_caps* pcm_sink_caps(enum pcm_sink_ids sink);
|
|||
/* shortcut for plugins */
|
||||
const struct pcm_sink_caps* pcm_current_sink_caps(void);
|
||||
|
||||
/* This is for playing "raw" PCM data */
|
||||
void pcm_play_data(pcm_play_callback_type get_more,
|
||||
pcm_status_callback_type status_cb,
|
||||
const void *start, size_t size);
|
||||
|
||||
/* Kept internally for global PCM and used by mixer's verion of peak
|
||||
calculation */
|
||||
struct pcm_peaks
|
||||
|
|
@ -92,9 +78,6 @@ struct pcm_peaks
|
|||
long tick; /* Last tick called */
|
||||
};
|
||||
|
||||
void pcm_play_stop(void);
|
||||
bool pcm_is_playing(void);
|
||||
|
||||
#ifdef HAVE_RECORDING
|
||||
|
||||
/** RAW PCM recording routines **/
|
||||
|
|
|
|||
|
|
@ -94,8 +94,6 @@ volatile pcm_status_callback_type
|
|||
/* PCM playback state */
|
||||
volatile bool pcm_playing SHAREDBSS_ATTR = false;
|
||||
|
||||
void pcm_play_stop_int(void);
|
||||
|
||||
struct pcm_sink* pcm_get_current_sink(void)
|
||||
{
|
||||
return sinks[cur_sink];
|
||||
|
|
|
|||
|
|
@ -475,6 +475,9 @@ void mixer_set_frequency(unsigned int samplerate)
|
|||
mix_frame_size = 1;
|
||||
|
||||
mix_frame_size *= MIX_FRAME_SAMPLES * 4;
|
||||
|
||||
if (pcm_is_initialized())
|
||||
pcm_apply_settings();
|
||||
}
|
||||
|
||||
/* Get output samplerate */
|
||||
|
|
|
|||
|
|
@ -493,7 +493,6 @@ static void set_playback_sampling_frequency(unsigned long f)
|
|||
hw_freq_sampr[as_playback_freq_idx], f);
|
||||
|
||||
mixer_set_frequency(hw_freq_sampr[as_playback_freq_idx]);
|
||||
pcm_apply_settings();
|
||||
}
|
||||
|
||||
unsigned long usb_audio_get_playback_sampling_frequency(void)
|
||||
|
|
@ -706,7 +705,6 @@ static void usb_audio_start_playback(void)
|
|||
#endif
|
||||
logf("usbaudio: start playback at %lu Hz", hw_freq_sampr[as_playback_freq_idx]);
|
||||
mixer_set_frequency(hw_freq_sampr[as_playback_freq_idx]);
|
||||
pcm_apply_settings();
|
||||
mixer_channel_set_amplitude(PCM_MIXER_CHAN_USBAUDIO, MIX_AMP_UNITY);
|
||||
|
||||
usb_drv_recv_nonblocking(EP_ISO_OUT, rx_buffer, BUFFER_SIZE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue