abrepeat add dummy functions and remove some of the ifdefs

Change-Id: Icae7e334e87bb1974712a7a76296cf69bbdbffba
This commit is contained in:
William Wilgus 2022-12-14 23:37:14 -05:00
parent 6b87bfadff
commit 99839960a2
3 changed files with 39 additions and 22 deletions

View file

@ -20,9 +20,38 @@
****************************************************************************/ ****************************************************************************/
#ifndef _ABREPEAT_H_ #ifndef _ABREPEAT_H_
#define _ABREPEAT_H_ #define _ABREPEAT_H_
#ifdef AB_REPEAT_ENABLE
#include <stdbool.h> #include <stdbool.h>
#ifndef AB_REPEAT_ENABLE /* Dummy functions */
static inline bool ab_repeat_mode_enabled(void)
{
return false;
}
static inline bool ab_bool_dummy_marker(unsigned int song_position)
{
(void) song_position;
return false;
}
static inline void ab_void_dummy_marker(unsigned int song_position)
{
(void) song_position;
}
static inline void ab_dummy_voidfn(void){}
#define ab_repeat_init ab_dummy_voidfn
#define ab_before_A_marker ab_bool_dummy_marker
#define ab_after_A_marker ab_bool_dummy_marker
#define ab_jump_to_A_marker ab_dummy_voidfn
#define ab_reset_markers ab_dummy_voidfn
#define ab_set_A_marker ab_void_dummy_marker
#define ab_set_B_marker ab_void_dummy_marker
#define ab_get_A_marker ab_bool_dummy_marker
#define ab_get_B_marker ab_bool_dummy_marker
#define ab_end_of_track_report ab_dummy_voidfn
#define ab_reached_B_marker ab_bool_dummy_marker
#define ab_position_report ab_void_dummy_marker
#else /*def AB_REPEAT_ENABLE*/
#include "audio.h" #include "audio.h"
#include "kernel.h" /* needed for HZ */ #include "kernel.h" /* needed for HZ */

View file

@ -613,9 +613,9 @@ static long do_wps_exit(long action, bool bookmark)
if (bookmark) if (bookmark)
bookmark_autobookmark(true); bookmark_autobookmark(true);
audio_stop(); audio_stop();
#ifdef AB_REPEAT_ENABLE
ab_reset_markers(); ab_reset_markers();
#endif
gwps_leave_wps(true); gwps_leave_wps(true);
#ifdef HAVE_RECORDING #ifdef HAVE_RECORDING
if (action == ACTION_WPS_REC) if (action == ACTION_WPS_REC)
@ -678,10 +678,9 @@ long gui_wps_show(void)
long last_left = 0, last_right = 0; long last_left = 0, last_right = 0;
struct wps_state *state = get_wps_state(); struct wps_state *state = get_wps_state();
#ifdef AB_REPEAT_ENABLE
ab_repeat_init(); ab_repeat_init();
ab_reset_markers(); ab_reset_markers();
#endif
wps_state_init(); wps_state_init();
while ( 1 ) while ( 1 )
{ {
@ -904,7 +903,7 @@ long gui_wps_show(void)
/* prev / restart */ /* prev / restart */
case ACTION_WPS_SKIPPREV: case ACTION_WPS_SKIPPREV:
last_left = current_tick; last_left = current_tick;
#ifdef AB_REPEAT_ENABLE
/* if we're in A/B repeat mode and the current position /* if we're in A/B repeat mode and the current position
is past the A marker, jump back to the A marker... */ is past the A marker, jump back to the A marker... */
if ( ab_repeat_mode_enabled() && ab_after_A_marker(state->id3->elapsed) ) if ( ab_repeat_mode_enabled() && ab_after_A_marker(state->id3->elapsed) )
@ -912,9 +911,7 @@ long gui_wps_show(void)
ab_jump_to_A_marker(); ab_jump_to_A_marker();
break; break;
} }
else else /* ...otherwise, do it normally */
/* ...otherwise, do it normally */
#endif
play_hop(-1); play_hop(-1);
break; break;
@ -922,7 +919,7 @@ long gui_wps_show(void)
OR if skip length set, hop by predetermined amount. */ OR if skip length set, hop by predetermined amount. */
case ACTION_WPS_SKIPNEXT: case ACTION_WPS_SKIPNEXT:
last_right = current_tick; last_right = current_tick;
#ifdef AB_REPEAT_ENABLE
/* if we're in A/B repeat mode and the current position is /* if we're in A/B repeat mode and the current position is
before the A marker, jump to the A marker... */ before the A marker, jump to the A marker... */
if ( ab_repeat_mode_enabled() ) if ( ab_repeat_mode_enabled() )
@ -933,32 +930,26 @@ long gui_wps_show(void)
break; break;
} }
} }
else else /* ...otherwise, do it normally */
/* ...otherwise, do it normally */
#endif
play_hop(1); play_hop(1);
break; break;
/* next / prev directories */ /* next / prev directories */
/* and set A-B markers if in a-b mode */ /* and set A-B markers if in a-b mode */
case ACTION_WPS_ABSETB_NEXTDIR: case ACTION_WPS_ABSETB_NEXTDIR:
#if defined(AB_REPEAT_ENABLE)
if (ab_repeat_mode_enabled()) if (ab_repeat_mode_enabled())
{ {
ab_set_B_marker(state->id3->elapsed); ab_set_B_marker(state->id3->elapsed);
ab_jump_to_A_marker(); ab_jump_to_A_marker();
} }
else else
#endif
{ {
change_dir(1); change_dir(1);
} }
break; break;
case ACTION_WPS_ABSETA_PREVDIR: case ACTION_WPS_ABSETA_PREVDIR:
#if defined(AB_REPEAT_ENABLE)
if (ab_repeat_mode_enabled()) if (ab_repeat_mode_enabled())
ab_set_A_marker(state->id3->elapsed); ab_set_A_marker(state->id3->elapsed);
else else
#endif
{ {
change_dir(-1); change_dir(-1);
} }
@ -1010,7 +1001,6 @@ long gui_wps_show(void)
break; break;
#endif /* HAVE_PITCHCONTROL */ #endif /* HAVE_PITCHCONTROL */
#ifdef AB_REPEAT_ENABLE
/* reset A&B markers */ /* reset A&B markers */
case ACTION_WPS_ABRESET: case ACTION_WPS_ABRESET:
if (ab_repeat_mode_enabled()) if (ab_repeat_mode_enabled())
@ -1019,7 +1009,6 @@ long gui_wps_show(void)
update = true; update = true;
} }
break; break;
#endif /* AB_REPEAT_ENABLE */
/* stop and exit wps */ /* stop and exit wps */
case ACTION_WPS_STOP: case ACTION_WPS_STOP:

View file

@ -3479,9 +3479,8 @@ static void buffer_event_finished_callback(unsigned short id, void *ev_data)
/* Update elapsed time for next PCM insert */ /* Update elapsed time for next PCM insert */
void audio_codec_update_elapsed(unsigned long elapsed) void audio_codec_update_elapsed(unsigned long elapsed)
{ {
#ifdef AB_REPEAT_ENABLE
ab_position_report(elapsed); ab_position_report(elapsed);
#endif
/* Save in codec's id3 where it is used at next pcm insert */ /* Save in codec's id3 where it is used at next pcm insert */
id3_get(CODEC_ID3)->elapsed = elapsed; id3_get(CODEC_ID3)->elapsed = elapsed;
} }