Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+28 -44
-1
apps/plugin.c
··· 644 644 #endif 645 645 &audio_master_sampr_list[0], 646 646 &hw_freq_sampr[0], 647 - pcm_apply_settings, 648 647 pcm_play_lock, 649 648 pcm_play_unlock, 650 649 pcm_current_sink_caps,
+1 -2
apps/plugin.h
··· 179 179 * when this happens please take the opportunity to sort in 180 180 * any new functions "waiting" at the end of the list. 181 181 */ 182 - #define PLUGIN_API_VERSION 279 182 + #define PLUGIN_API_VERSION 280 183 183 184 184 /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ 185 185 ··· 743 743 #endif 744 744 const unsigned long *audio_master_sampr_list; 745 745 const unsigned long *hw_freq_sampr; 746 - void (*pcm_apply_settings)(void); 747 746 void (*pcm_play_lock)(void); 748 747 void (*pcm_play_unlock)(void); 749 748 const struct pcm_sink_caps* (*pcm_current_sink_caps)(void);
-1
apps/plugins/lua/include_lua/pcm.lua
··· 24 24 -- [[ conversion to old style pcm_ functions ]] 25 25 if not rb.pcm then rb.splash(rb.HZ, "No Support!") return nil end 26 26 27 - rb.pcm_apply_settings = function() rb.pcm("apply_settings") end 28 27 rb.pcm_play_lock = function() rb.pcm("play_lock") end 29 28 rb.pcm_play_unlock = function() rb.pcm("play_unlock") end
+2 -5
apps/plugins/lua/rocklib.c
··· 549 549 550 550 RB_WRAP(pcm) 551 551 { 552 - enum e_pcm {PCM_APPLYSETTINGS = 0, PCM_PLAYLOCK, PCM_PLAYUNLOCK, 552 + enum e_pcm {PCM_PLAYLOCK = 0, PCM_PLAYUNLOCK, 553 553 PCM_ECOUNT}; 554 554 555 - const char *pcm_option[] = {"apply_settings", "play_lock", "play_unlock", 555 + const char *pcm_option[] = {"play_lock", "play_unlock", 556 556 NULL}; 557 557 558 558 lua_pushnil(L); /*push nil so options w/o return have something to return */ ··· 560 560 int option = luaL_checkoption (L, 1, NULL, pcm_option); 561 561 switch(option) 562 562 { 563 - case PCM_APPLYSETTINGS: 564 - rb->pcm_apply_settings(); 565 - break; 566 563 case PCM_PLAYLOCK: 567 564 rb->pcm_play_lock(); 568 565 break;
-2
apps/plugins/pdbox/PDa/src/s_audio_rockbox.c
··· 64 64 65 65 /* Set sample rate of the audio buffer. */ 66 66 rb->mixer_set_frequency(rate); 67 - rb->pcm_apply_settings(); 68 67 69 68 /* Initialize output buffer. */ 70 69 for(i = 0; i < OUTBUFSIZE; i++) ··· 86 85 87 86 /* Restore default sampling rate. */ 88 87 rb->mixer_set_frequency(HW_SAMPR_DEFAULT); 89 - rb->pcm_apply_settings(); 90 88 } 91 89 92 90 /* Rockbox audio callback. */
-1
apps/plugins/test_sampr.c
··· 168 168 update_gen_step(); 169 169 170 170 rb->mixer_set_frequency(hw_sampr); 171 - rb->pcm_apply_settings(); 172 171 } 173 172 174 173 #ifndef HAVE_VOLUME_IN_LIST
-2
apps/plugins/xrick/system/syssnd_rockbox.c
··· 253 253 #endif 254 254 255 255 rb->mixer_set_frequency(HW_FREQ_44); 256 - rb->pcm_apply_settings(); 257 256 258 257 rb->memset(channels, 0, sizeof(channels)); 259 258 rb->memset(mixBuffers, 0, sizeof(mixBuffers)); ··· 286 285 287 286 /* Restore default sampling rate. */ 288 287 rb->mixer_set_frequency(HW_SAMPR_DEFAULT); 289 - rb->pcm_apply_settings(); 290 288 291 289 rb->talk_disable(false); 292 290
+5 -1
apps/recorder/pcm_record.c
··· 616 616 record_status = RECORD_STOPPED; 617 617 } 618 618 619 + /* To avoid having to pull in all of pcm-internal.h */ 620 + void pcm_set_frequency(unsigned int samplerate); 621 + void pcm_apply_settings(void); 622 + 619 623 /* Set hardware samplerate and save it */ 620 624 static void update_samplerate_config(unsigned long sampr) 621 625 { ··· 876 880 int16_t *d = (int16_t*) dst; 877 881 int16_t const *s = (int16_t const*) src; 878 882 ssize_t copy_size = src_size; 879 - 883 + 880 884 /* mono = (L + R) / 2 */ 881 885 while(copy_size > 0) { 882 886 *d++ = ((int32_t)s[0] + (int32_t)s[1] + 1) >> 1;
-4
docs/PLUGIN_API
··· 1754 1754 \param state 1755 1755 \description 1756 1756 1757 - void pcm_apply_settings(void) 1758 - \group sound 1759 - \description 1760 - 1761 1757 void pcm_calculate_rec_peaks(int *left, int *right) 1762 1758 \group sound 1763 1759 \conditions (defined(HAVE_RECORDING))
+14 -1
firmware/export/pcm-internal.h
··· 71 71 ({ (start) = (void *)(((uintptr_t)(start) + 3) & ~3); \ 72 72 (size) &= ~3; }) 73 73 74 + /* Internal PCM API calls for playback */ 75 + void pcm_play_data(pcm_play_callback_type get_more, 76 + pcm_status_callback_type status_cb, 77 + const void *start, size_t size); 78 + 79 + void pcm_play_stop(void); 80 + void pcm_play_stop_int(void); /* requires PCM lock held */ 81 + bool pcm_is_playing(void); 82 + 83 + void pcm_set_frequency(unsigned int samplerate); 84 + unsigned int pcm_get_frequency(void); 85 + /* apply settings to hardware immediately */ 86 + void pcm_apply_settings(void); 87 + 74 88 void pcm_do_peak_calculation(struct pcm_peaks *peaks, bool active, 75 89 const void *addr, int count); 76 90 ··· 125 139 #if defined(HAVE_SW_VOLUME_CONTROL) && !defined(PCM_SW_VOLUME_UNBUFFERED) 126 140 void pcm_play_dma_start_int(const void *addr, size_t size); 127 141 void pcm_play_dma_stop_int(void); 128 - void pcm_play_stop_int(void); 129 142 #endif /* HAVE_SW_VOLUME_CONTROL && !PCM_SW_VOLUME_UNBUFFERED */ 130 143 131 144 /* Called by the bottom layer ISR when more data is needed. Returns true
+1 -18
firmware/export/pcm.h
··· 44 44 /* Typedef for registered status callback */ 45 45 typedef enum pcm_dma_status (*pcm_status_callback_type)(enum pcm_dma_status status); 46 46 47 - /* set the pcm frequency - use values in hw_sampr_list 47 + /* set the pcm frequency - use values in hw_sampr_list 48 48 * when CONFIG_SAMPR_TYPES is #defined, or-in SAMPR_TYPE_* fields with 49 49 * frequency value. SAMPR_TYPE_PLAY is 0 and the default if none is 50 50 * specified. */ ··· 54 54 #endif 55 55 #endif /* CONFIG_SAMPR_TYPES */ 56 56 57 - /* set next frequency to be used */ 58 - void pcm_set_frequency(unsigned int samplerate); 59 - /* return last-set frequency */ 60 - unsigned int pcm_get_frequency(void); 61 - /* apply settings to hardware immediately */ 62 - void pcm_apply_settings(void); 63 - 64 - /** RAW PCM playback routines **/ 65 - 66 57 /* Reenterable locks for locking and unlocking the playback interrupt */ 67 58 void pcm_play_lock(void); 68 59 void pcm_play_unlock(void); ··· 77 68 /* shortcut for plugins */ 78 69 const struct pcm_sink_caps* pcm_current_sink_caps(void); 79 70 80 - /* This is for playing "raw" PCM data */ 81 - void pcm_play_data(pcm_play_callback_type get_more, 82 - pcm_status_callback_type status_cb, 83 - const void *start, size_t size); 84 - 85 71 /* Kept internally for global PCM and used by mixer's verion of peak 86 72 calculation */ 87 73 struct pcm_peaks ··· 91 77 long period; /* For tracking calling period */ 92 78 long tick; /* Last tick called */ 93 79 }; 94 - 95 - void pcm_play_stop(void); 96 - bool pcm_is_playing(void); 97 80 98 81 #ifdef HAVE_RECORDING 99 82
-2
firmware/pcm.c
··· 94 94 /* PCM playback state */ 95 95 volatile bool pcm_playing SHAREDBSS_ATTR = false; 96 96 97 - void pcm_play_stop_int(void); 98 - 99 97 struct pcm_sink* pcm_get_current_sink(void) 100 98 { 101 99 return sinks[cur_sink];
+3
firmware/pcm_mixer.c
··· 475 475 mix_frame_size = 1; 476 476 477 477 mix_frame_size *= MIX_FRAME_SAMPLES * 4; 478 + 479 + if (pcm_is_initialized()) 480 + pcm_apply_settings(); 478 481 } 479 482 480 483 /* Get output samplerate */
+2 -4
firmware/usbstack/usb_audio.c
··· 493 493 hw_freq_sampr[as_playback_freq_idx], f); 494 494 495 495 mixer_set_frequency(hw_freq_sampr[as_playback_freq_idx]); 496 - pcm_apply_settings(); 497 496 } 498 497 499 498 unsigned long usb_audio_get_playback_sampling_frequency(void) ··· 706 705 #endif 707 706 logf("usbaudio: start playback at %lu Hz", hw_freq_sampr[as_playback_freq_idx]); 708 707 mixer_set_frequency(hw_freq_sampr[as_playback_freq_idx]); 709 - pcm_apply_settings(); 710 708 mixer_channel_set_amplitude(PCM_MIXER_CHAN_USBAUDIO, MIX_AMP_UNITY); 711 709 712 710 usb_drv_recv_nonblocking(EP_ISO_OUT, rx_buffer, BUFFER_SIZE); ··· 787 785 { 788 786 return usb_as_playback_intf_alt; 789 787 } 790 - 788 + 791 789 int32_t usb_audio_get_samplesperframe(void) 792 790 { 793 791 return samples_fb; ··· 1348 1346 { 1349 1347 retval = false; 1350 1348 } 1351 - 1349 + 1352 1350 // send feedback value every N frames! 1353 1351 // NOTE: important that we need to queue this up _the frame before_ it's needed - on MacOS especially! 1354 1352 if ((usb_drv_get_frame_number()+1) % FEEDBACK_UPDATE_RATE_FRAMES == 0 && send_fb)