summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/SOURCES6
-rw-r--r--apps/abrepeat.c46
-rw-r--r--apps/abrepeat.h11
-rw-r--r--apps/action.c2
-rw-r--r--apps/bookmark.c27
-rw-r--r--apps/codecs.c1
-rw-r--r--apps/cuesheet.c6
-rw-r--r--apps/debug_menu.c50
-rw-r--r--apps/features.txt8
-rw-r--r--apps/filetypes.c7
-rw-r--r--apps/gui/list.c9
-rw-r--r--apps/gui/list.h2
-rw-r--r--apps/gui/pitchscreen.c78
-rw-r--r--apps/gui/skin_engine/skin_display.c2
-rw-r--r--apps/gui/skin_engine/skin_tokens.c39
-rw-r--r--apps/gui/splash.c2
-rw-r--r--apps/gui/statusbar.c49
-rw-r--r--apps/gui/wps.c128
-rw-r--r--apps/lang/english.lang51
-rw-r--r--apps/main.c49
-rw-r--r--apps/menu.c2
-rw-r--r--apps/menus/eq_menu.c1
-rw-r--r--apps/menus/menu_common.c5
-rw-r--r--apps/menus/menu_common.h2
-rw-r--r--apps/menus/playback_menu.c27
-rw-r--r--apps/menus/radio_menu.c18
-rw-r--r--apps/menus/recording_menu.c20
-rw-r--r--apps/menus/settings_menu.c10
-rw-r--r--apps/menus/sound_menu.c12
-rw-r--r--apps/misc.c31
-rw-r--r--apps/misc.h4
-rw-r--r--apps/mpeg.c1979
-rw-r--r--apps/mpeg.h28
-rw-r--r--apps/playback.h3
-rw-r--r--apps/playlist.c16
-rw-r--r--apps/playlist.h4
-rw-r--r--apps/plugin.c16
-rw-r--r--apps/plugin.h21
-rw-r--r--apps/plugins/SOURCES18
-rw-r--r--apps/plugins/SOURCES.app_build4
-rw-r--r--apps/plugins/SUBDIRS7
-rw-r--r--apps/plugins/SUBDIRS.app_build5
-rw-r--r--apps/plugins/bitmaps/mono/SOURCES2
-rw-r--r--apps/plugins/bitmaps/native/SOURCES2
-rw-r--r--apps/plugins/chip8.c47
-rw-r--r--apps/plugins/lua/rocklib.c6
-rw-r--r--apps/plugins/metronome.c194
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c2
-rw-r--r--apps/plugins/oscilloscope.c8
-rw-r--r--apps/plugins/properties.c6
-rw-r--r--apps/plugins/rockboy/rbsound.c26
-rw-r--r--apps/plugins/splitedit.c1231
-rw-r--r--apps/plugins/starfield.c3
-rw-r--r--apps/plugins/vu_meter.c8
-rw-r--r--apps/plugins/zxbox/spmain.c4
-rw-r--r--apps/plugins/zxbox/zxbox.c4
-rw-r--r--apps/plugins/zxbox/zxconfig.h2
-rw-r--r--apps/radio/radio.c111
-rw-r--r--apps/radio/radio_skin.c5
-rw-r--r--apps/recorder/icons.c8
-rw-r--r--apps/recorder/icons.h7
-rw-r--r--apps/recorder/keyboard.c4
-rw-r--r--apps/recorder/peakmeter.c75
-rw-r--r--apps/recorder/recording.c78
-rw-r--r--apps/recorder/recording.h3
-rw-r--r--apps/screens.c9
-rw-r--r--apps/scrobbler.c2
-rw-r--r--apps/settings.c12
-rw-r--r--apps/settings.h29
-rw-r--r--apps/settings_list.c25
-rw-r--r--apps/tagcache.c4
-rw-r--r--apps/tagtree.c10
-rw-r--r--apps/talk.c105
-rw-r--r--apps/tree.c12
74 files changed, 62 insertions, 4788 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index 6a0b817834..d7cec53506 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -19,7 +19,6 @@ menus/plugin_menu.c
19#if CONFIG_TUNER 19#if CONFIG_TUNER
20menus/radio_menu.c 20menus/radio_menu.c
21#endif 21#endif
22#if CONFIG_CODEC == SWCODEC
23#ifdef HAVE_WM8978 22#ifdef HAVE_WM8978
24menus/audiohw_eq_menu.c 23menus/audiohw_eq_menu.c
25#endif 24#endif
@@ -27,9 +26,6 @@ menus/eq_menu.c
27buffering.c 26buffering.c
28voice_thread.c 27voice_thread.c
29rbcodec_helpers.c 28rbcodec_helpers.c
30#else /* !SWCODEC */
31mpeg.c
32#endif
33menus/main_menu.c 29menus/main_menu.c
34menus/playback_menu.c 30menus/playback_menu.c
35menus/playlist_menu.c 31menus/playlist_menu.c
@@ -163,7 +159,6 @@ radio/radioart.c
163#endif 159#endif
164#endif 160#endif
165 161
166#if CONFIG_CODEC == SWCODEC
167#if INPUT_SRC_CAPS != 0 162#if INPUT_SRC_CAPS != 0
168audio_path.c 163audio_path.c
169#endif /* INPUT_SRC_CAPS != 0 */ 164#endif /* INPUT_SRC_CAPS != 0 */
@@ -179,7 +174,6 @@ beep.c
179enc_config.c 174enc_config.c
180recorder/pcm_record.c 175recorder/pcm_record.c
181#endif 176#endif
182#endif
183#ifdef USB_ENABLE_HID 177#ifdef USB_ENABLE_HID
184usb_keymaps.c 178usb_keymaps.c
185#endif 179#endif
diff --git a/apps/abrepeat.c b/apps/abrepeat.c
index 999d9dcf38..19e9450c99 100644
--- a/apps/abrepeat.c
+++ b/apps/abrepeat.c
@@ -39,7 +39,6 @@ static inline bool ab_B_marker_set(void)
39} 39}
40 40
41 41
42#if (CONFIG_CODEC == SWCODEC)
43void ab_end_of_track_report(void) 42void ab_end_of_track_report(void)
44{ 43{
45 if ( ab_A_marker_set() && ! ab_B_marker_set() ) 44 if ( ab_A_marker_set() && ! ab_B_marker_set() )
@@ -47,38 +46,6 @@ void ab_end_of_track_report(void)
47 ab_jump_to_A_marker(); 46 ab_jump_to_A_marker();
48 } 47 }
49} 48}
50#else
51static int ab_audio_event_handler(unsigned short event, unsigned long data)
52{
53 int rc = AUDIO_EVENT_RC_IGNORED;
54 if ( ab_repeat_mode_enabled() )
55 {
56 switch(event)
57 {
58 case AUDIO_EVENT_POS_REPORT:
59 {
60 if ( ! (audio_status() & AUDIO_STATUS_PAUSE) &&
61 ab_reached_B_marker(data) )
62 {
63 ab_jump_to_A_marker();
64 rc = AUDIO_EVENT_RC_HANDLED;
65 }
66 break;
67 }
68 case AUDIO_EVENT_END_OF_TRACK:
69 {
70 if ( ab_A_marker_set() && ! ab_B_marker_set() )
71 {
72 ab_jump_to_A_marker();
73 rc = AUDIO_EVENT_RC_HANDLED;
74 }
75 break;
76 }
77 }
78 }
79 return rc;
80}
81#endif
82 49
83void ab_repeat_init(void) 50void ab_repeat_init(void)
84{ 51{
@@ -86,10 +53,6 @@ void ab_repeat_init(void)
86 if ( ! ab_initialized ) 53 if ( ! ab_initialized )
87 { 54 {
88 ab_initialized = true; 55 ab_initialized = true;
89#if (CONFIG_CODEC != SWCODEC)
90 audio_register_event_handler(ab_audio_event_handler,
91 AUDIO_EVENT_POS_REPORT | AUDIO_EVENT_END_OF_TRACK );
92#endif
93 } 56 }
94} 57}
95 58
@@ -116,16 +79,7 @@ reasonable amount of time for the typical user to react */
116 79
117void ab_jump_to_A_marker(void) 80void ab_jump_to_A_marker(void)
118{ 81{
119#if (CONFIG_CODEC != SWCODEC)
120 bool paused = (audio_status() & AUDIO_STATUS_PAUSE) != 0;
121 if ( ! paused )
122 audio_pause();
123#endif
124 audio_ff_rewind(ab_A_marker); 82 audio_ff_rewind(ab_A_marker);
125#if (CONFIG_CODEC != SWCODEC)
126 if ( ! paused )
127 audio_resume();
128#endif
129} 83}
130 84
131void ab_reset_markers(void) 85void ab_reset_markers(void)
diff --git a/apps/abrepeat.h b/apps/abrepeat.h
index ec0a07c827..f7ee65247c 100644
--- a/apps/abrepeat.h
+++ b/apps/abrepeat.h
@@ -41,9 +41,7 @@ void ab_set_B_marker(unsigned int song_position);
41 * The actual positions are returned via output parameter */ 41 * The actual positions are returned via output parameter */
42bool ab_get_A_marker(unsigned int *song_position); 42bool ab_get_A_marker(unsigned int *song_position);
43bool ab_get_B_marker(unsigned int *song_position); 43bool ab_get_B_marker(unsigned int *song_position);
44#if (CONFIG_CODEC == SWCODEC)
45void ab_end_of_track_report(void); 44void ab_end_of_track_report(void);
46#endif
47 45
48/* These functions really need to be inlined for speed */ 46/* These functions really need to be inlined for speed */
49extern unsigned int ab_A_marker; 47extern unsigned int ab_A_marker;
@@ -59,16 +57,9 @@ static inline bool ab_reached_B_marker(unsigned int song_position)
59/* following is the size of the window in which we'll detect that the B marker 57/* following is the size of the window in which we'll detect that the B marker
60was hit; it must be larger than the frequency (in milliseconds) at which this 58was hit; it must be larger than the frequency (in milliseconds) at which this
61function is called otherwise detection of the B marker will be unreliable */ 59function is called otherwise detection of the B marker will be unreliable */
62#if (CONFIG_CODEC == SWCODEC)
63/* On swcodec, the worst case seems to be 9600kHz with 1024 samples between 60/* On swcodec, the worst case seems to be 9600kHz with 1024 samples between
64 * calls, meaning ~9 calls per second, look within 1/5 of a second */ 61 * calls, meaning ~9 calls per second, look within 1/5 of a second */
65#define B_MARKER_DETECT_WINDOW 200 62#define B_MARKER_DETECT_WINDOW 200
66#else
67/* we assume that this function will be called on each system tick and derive
68the window size from this with a generous margin of error (note: the number
69of ticks per second is given by HZ) */
70#define B_MARKER_DETECT_WINDOW ((1000/HZ)*10)
71#endif
72 if (ab_B_marker != AB_MARKER_NONE) 63 if (ab_B_marker != AB_MARKER_NONE)
73 { 64 {
74 if ( (song_position >= ab_B_marker) 65 if ( (song_position >= ab_B_marker)
@@ -78,7 +69,6 @@ of ticks per second is given by HZ) */
78 return false; 69 return false;
79} 70}
80 71
81#if (CONFIG_CODEC == SWCODEC)
82static inline void ab_position_report(unsigned long position) 72static inline void ab_position_report(unsigned long position)
83{ 73{
84 if (ab_repeat_mode_enabled()) 74 if (ab_repeat_mode_enabled())
@@ -90,7 +80,6 @@ static inline void ab_position_report(unsigned long position)
90 } 80 }
91 } 81 }
92} 82}
93#endif
94 83
95#endif 84#endif
96 85
diff --git a/apps/action.c b/apps/action.c
index f92b84d105..2aee56ee04 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -832,10 +832,8 @@ static inline int update_action_last(action_last_t *last, action_cur_t *cur)
832 last->data = button_get_data(); 832 last->data = button_get_data();
833 last->tick = current_tick; 833 last->tick = current_tick;
834 834
835#if CONFIG_CODEC == SWCODEC
836 /* Produce keyclick */ 835 /* Produce keyclick */
837 keyclick_click(false, action); 836 keyclick_click(false, action);
838#endif
839 837
840 return action; 838 return action;
841} 839}
diff --git a/apps/bookmark.c b/apps/bookmark.c
index b19841fda0..22dfad6cce 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -183,13 +183,6 @@ bool bookmark_autobookmark(bool prompt_ok)
183 audio_pause(); /* first pause playback */ 183 audio_pause(); /* first pause playback */
184 update = (global_settings.autoupdatebookmark && bookmark_exists()); 184 update = (global_settings.autoupdatebookmark && bookmark_exists());
185 bookmark = create_bookmark(); 185 bookmark = create_bookmark();
186#if CONFIG_CODEC != SWCODEC
187 /* Workaround for inability to speak when paused: all callers will
188 just do audio_stop() when we return, so we can do it right
189 away. This makes it possible to speak the "Create a Bookmark?"
190 prompt and the "Bookmark Created" splash. */
191 audio_stop();
192#endif
193 186
194 if (update) 187 if (update)
195 return write_bookmark(true, bookmark); 188 return write_bookmark(true, bookmark);
@@ -415,13 +408,13 @@ static char* create_bookmark()
415 snprintf(global_bookmark, sizeof(global_bookmark), 408 snprintf(global_bookmark, sizeof(global_bookmark),
416 /* new optional bookmark token descriptors should be inserted 409 /* new optional bookmark token descriptors should be inserted
417 just before the "%s;%s" in this line... */ 410 just before the "%s;%s" in this line... */
418#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHCONTROL) 411#if defined(HAVE_PITCHCONTROL)
419 ">%d;%d;%ld;%d;%ld;%d;%d;%ld;%ld;%s;%s", 412 ">%d;%d;%ld;%d;%ld;%d;%d;%ld;%ld;%s;%s",
420#else 413#else
421 ">%d;%d;%ld;%d;%ld;%d;%d;%s;%s", 414 ">%d;%d;%ld;%d;%ld;%d;%d;%s;%s",
422#endif 415#endif
423 /* ... their flags should go here ... */ 416 /* ... their flags should go here ... */
424#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHCONTROL) 417#if defined(HAVE_PITCHCONTROL)
425 BM_PITCH | BM_SPEED, 418 BM_PITCH | BM_SPEED,
426#else 419#else
427 0, 420 0,
@@ -433,7 +426,7 @@ static char* create_bookmark()
433 global_settings.repeat_mode, 426 global_settings.repeat_mode,
434 global_settings.playlist_shuffle, 427 global_settings.playlist_shuffle,
435 /* ...and their values should go here */ 428 /* ...and their values should go here */
436#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHCONTROL) 429#if defined(HAVE_PITCHCONTROL)
437 (long)sound_get_pitch(), 430 (long)sound_get_pitch(),
438 (long)dsp_get_timestretch(), 431 (long)dsp_get_timestretch(),
439#endif 432#endif
@@ -950,7 +943,6 @@ static void say_bookmark(const char* bookmark,
950 943
951 talk_number(bookmark_id + 1, false); 944 talk_number(bookmark_id + 1, false);
952 945
953#if CONFIG_CODEC == SWCODEC
954 bool is_dir = (global_temp_buffer[0] 946 bool is_dir = (global_temp_buffer[0]
955 && global_temp_buffer[strlen(global_temp_buffer)-1] == '/'); 947 && global_temp_buffer[strlen(global_temp_buffer)-1] == '/');
956 948
@@ -965,9 +957,6 @@ static void say_bookmark(const char* bookmark,
965 else talk_file_or_spell(NULL, global_temp_buffer, 957 else talk_file_or_spell(NULL, global_temp_buffer,
966 TALK_IDARRAY(LANG_PLAYLIST), true); 958 TALK_IDARRAY(LANG_PLAYLIST), true);
967 } 959 }
968#else
969 (void)show_playlist_name;
970#endif
971 960
972 if(bm.shuffle) 961 if(bm.shuffle)
973 talk_id(LANG_SHUFFLE, true); 962 talk_id(LANG_SHUFFLE, true);
@@ -977,13 +966,11 @@ static void say_bookmark(const char* bookmark,
977 talk_id(LANG_TIME, true); 966 talk_id(LANG_TIME, true);
978 talk_value(bm.resume_time / 1000, UNIT_TIME, true); 967 talk_value(bm.resume_time / 1000, UNIT_TIME, true);
979 968
980#if CONFIG_CODEC == SWCODEC
981 /* Track filename */ 969 /* Track filename */
982 if(!is_dir) 970 if(!is_dir)
983 global_temp_buffer[0] = 0; 971 global_temp_buffer[0] = 0;
984 talk_file_or_spell(global_temp_buffer, global_filename, 972 talk_file_or_spell(global_temp_buffer, global_filename,
985 TALK_IDARRAY(VOICE_FILE), true); 973 TALK_IDARRAY(VOICE_FILE), true);
986#endif
987} 974}
988 975
989/* ----------------------------------------------------------------------- */ 976/* ----------------------------------------------------------------------- */
@@ -992,17 +979,17 @@ static void say_bookmark(const char* bookmark,
992/* ------------------------------------------------------------------------*/ 979/* ------------------------------------------------------------------------*/
993static bool play_bookmark(const char* bookmark) 980static bool play_bookmark(const char* bookmark)
994{ 981{
995#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHCONTROL) 982#if defined(HAVE_PITCHCONTROL)
996 /* preset pitch and speed to 100% in case bookmark doesn't have info */ 983 /* preset pitch and speed to 100% in case bookmark doesn't have info */
997 bm.pitch = sound_get_pitch(); 984 bm.pitch = sound_get_pitch();
998 bm.speed = dsp_get_timestretch(); 985 bm.speed = dsp_get_timestretch();
999#endif 986#endif
1000 987
1001 if (parse_bookmark(bookmark, true, true)) 988 if (parse_bookmark(bookmark, true, true))
1002 { 989 {
1003 global_settings.repeat_mode = bm.repeat_mode; 990 global_settings.repeat_mode = bm.repeat_mode;
1004 global_settings.playlist_shuffle = bm.shuffle; 991 global_settings.playlist_shuffle = bm.shuffle;
1005#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHCONTROL) 992#if defined(HAVE_PITCHCONTROL)
1006 sound_set_pitch(bm.pitch); 993 sound_set_pitch(bm.pitch);
1007 dsp_set_timestretch(bm.speed); 994 dsp_set_timestretch(bm.speed);
1008#endif 995#endif
@@ -1011,7 +998,7 @@ static bool play_bookmark(const char* bookmark)
1011 return bookmark_play(global_temp_buffer, bm.resume_index, 998 return bookmark_play(global_temp_buffer, bm.resume_index,
1012 bm.resume_time, bm.resume_offset, bm.resume_seed, global_filename); 999 bm.resume_time, bm.resume_offset, bm.resume_seed, global_filename);
1013 } 1000 }
1014 1001
1015 return false; 1002 return false;
1016} 1003}
1017 1004
diff --git a/apps/codecs.c b/apps/codecs.c
index cabc9ba993..4d2dd34ce0 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -40,7 +40,6 @@
40#include "lang.h" 40#include "lang.h"
41#include "keyboard.h" 41#include "keyboard.h"
42#include "buffering.h" 42#include "buffering.h"
43#include "mp3_playback.h"
44#include "backlight.h" 43#include "backlight.h"
45#include "storage.h" 44#include "storage.h"
46#include "talk.h" 45#include "talk.h"
diff --git a/apps/cuesheet.c b/apps/cuesheet.c
index 24df4d49da..39152185e5 100644
--- a/apps/cuesheet.c
+++ b/apps/cuesheet.c
@@ -313,14 +313,8 @@ static bool seek(unsigned long pos)
313 } 313 }
314 else 314 else
315 { 315 {
316#if (CONFIG_CODEC == SWCODEC)
317 audio_pre_ff_rewind(); 316 audio_pre_ff_rewind();
318 audio_ff_rewind(pos); 317 audio_ff_rewind(pos);
319#else
320 audio_pause();
321 audio_ff_rewind(pos);
322 audio_resume();
323#endif
324 return true; 318 return true;
325 } 319 }
326} 320}
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 8913558e6c..92451f284c 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -37,7 +37,6 @@
37#include "system.h" 37#include "system.h"
38#include "font.h" 38#include "font.h"
39#include "audio.h" 39#include "audio.h"
40#include "mp3_playback.h"
41#include "settings.h" 40#include "settings.h"
42#include "list.h" 41#include "list.h"
43#include "statusbar.h" 42#include "statusbar.h"
@@ -88,14 +87,12 @@
88#endif 87#endif
89#include "logfdisp.h" 88#include "logfdisp.h"
90#include "core_alloc.h" 89#include "core_alloc.h"
91#if CONFIG_CODEC == SWCODEC
92#include "pcmbuf.h" 90#include "pcmbuf.h"
93#include "buffering.h" 91#include "buffering.h"
94#include "playback.h" 92#include "playback.h"
95#if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN) 93#if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
96#include "spdif.h" 94#include "spdif.h"
97#endif 95#endif
98#endif
99#ifdef IRIVER_H300_SERIES 96#ifdef IRIVER_H300_SERIES
100#include "pcf50606.h" /* for pcf50606_read */ 97#include "pcf50606.h" /* for pcf50606_read */
101#endif 98#endif
@@ -304,48 +301,6 @@ static bool dbg_cpuinfo(void)
304#endif 301#endif
305 302
306#ifdef HAVE_LCD_BITMAP 303#ifdef HAVE_LCD_BITMAP
307#if CONFIG_CODEC != SWCODEC
308#ifndef SIMULATOR
309static bool dbg_audio_thread(void)
310{
311 struct audio_debug d;
312
313 lcd_setfont(FONT_SYSFIXED);
314
315 while(1)
316 {
317 if (action_userabort(HZ/5))
318 return false;
319
320 audio_get_debugdata(&d);
321
322 lcd_clear_display();
323
324 lcd_putsf(0, 0, "read: %x", d.audiobuf_read);
325 lcd_putsf(0, 1, "write: %x", d.audiobuf_write);
326 lcd_putsf(0, 2, "swap: %x", d.audiobuf_swapwrite);
327 lcd_putsf(0, 3, "playing: %d", d.playing);
328 lcd_putsf(0, 4, "playable: %x", d.playable_space);
329 lcd_putsf(0, 5, "unswapped: %x", d.unswapped_space);
330
331 /* Playable space left */
332 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, 6*8, 112, 4, d.audiobuflen, 0,
333 d.playable_space, HORIZONTAL);
334
335 /* Show the watermark limit */
336 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, 6*8+4, 112, 4, d.audiobuflen, 0,
337 d.low_watermark_level, HORIZONTAL);
338
339 lcd_putsf(0, 7, "wm: %x - %x",
340 d.low_watermark_level, d.lowest_watermark_level);
341
342 lcd_update();
343 }
344 lcd_setfont(FONT_UI);
345 return false;
346}
347#endif /* !SIMULATOR */
348#else /* CONFIG_CODEC == SWCODEC */
349static unsigned int ticks, freq_sum; 304static unsigned int ticks, freq_sum;
350#ifndef CPU_MULTI_FREQUENCY 305#ifndef CPU_MULTI_FREQUENCY
351static unsigned int boost_ticks; 306static unsigned int boost_ticks;
@@ -487,7 +442,6 @@ static bool dbg_buffering_thread(void)
487 442
488 return false; 443 return false;
489} 444}
490#endif /* CONFIG_CODEC */
491#endif /* HAVE_LCD_BITMAP */ 445#endif /* HAVE_LCD_BITMAP */
492 446
493static const char* bf_getname(int selected_item, void *data, 447static const char* bf_getname(int selected_item, void *data,
@@ -2606,11 +2560,7 @@ static const struct {
2606 { "View database info", dbg_tagcache_info }, 2560 { "View database info", dbg_tagcache_info },
2607#endif 2561#endif
2608#ifdef HAVE_LCD_BITMAP 2562#ifdef HAVE_LCD_BITMAP
2609#if CONFIG_CODEC == SWCODEC
2610 { "View buffering thread", dbg_buffering_thread }, 2563 { "View buffering thread", dbg_buffering_thread },
2611#elif !defined(SIMULATOR)
2612 { "View audio thread", dbg_audio_thread },
2613#endif
2614#ifdef PM_DEBUG 2564#ifdef PM_DEBUG
2615 { "pm histogram", peak_meter_histogram}, 2565 { "pm histogram", peak_meter_histogram},
2616#endif /* PM_DEBUG */ 2566#endif /* PM_DEBUG */
diff --git a/apps/features.txt b/apps/features.txt
index 1c942a7fe2..657b799345 100644
--- a/apps/features.txt
+++ b/apps/features.txt
@@ -109,11 +109,7 @@ radio_remote
109 109
110#if defined(HAVE_RECORDING) 110#if defined(HAVE_RECORDING)
111recording 111recording
112#if CONFIG_CODEC == SWCODEC
113recording_swcodec 112recording_swcodec
114#else
115recording_hwcodec
116#endif
117#if defined(HAVE_LINE_IN) 113#if defined(HAVE_LINE_IN)
118recording_linein 114recording_linein
119#endif 115#endif
@@ -151,11 +147,7 @@ spdif_power
151speaker 147speaker
152#endif 148#endif
153 149
154#if CONFIG_CODEC == SWCODEC
155swcodec 150swcodec
156#else
157hwcodec
158#endif
159 151
160#if defined(HAVE_TAGCACHE) 152#if defined(HAVE_TAGCACHE)
161tagcache 153tagcache
diff --git a/apps/filetypes.c b/apps/filetypes.c
index a30f012e53..9abcfec884 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -41,11 +41,7 @@
41#include "logf.h" 41#include "logf.h"
42 42
43/* max filetypes (plugins & icons stored here) */ 43/* max filetypes (plugins & icons stored here) */
44#if CONFIG_CODEC == SWCODEC
45#define MAX_FILETYPES 192 44#define MAX_FILETYPES 192
46#else
47#define MAX_FILETYPES 128
48#endif
49/* max viewer plugins */ 45/* max viewer plugins */
50#ifdef HAVE_LCD_BITMAP 46#ifdef HAVE_LCD_BITMAP
51#define MAX_VIEWERS 56 47#define MAX_VIEWERS 56
@@ -58,8 +54,6 @@ static const struct filetype inbuilt_filetypes[] = {
58 { "mp3", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 54 { "mp3", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
59 { "mp2", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 55 { "mp2", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
60 { "mpa", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 56 { "mpa", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
61#if CONFIG_CODEC == SWCODEC
62 /* Temporary hack to allow playlist creation */
63 { "mp1", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 57 { "mp1", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
64 { "ogg", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 58 { "ogg", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
65 { "oga", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 59 { "oga", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
@@ -121,7 +115,6 @@ static const struct filetype inbuilt_filetypes[] = {
121 { "vgz", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 115 { "vgz", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
122 { "kss", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 116 { "kss", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
123 { "aac", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 117 { "aac", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
124#endif
125 { "m3u", FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, 118 { "m3u", FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST },
126 { "m3u8",FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, 119 { "m3u8",FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST },
127 { "cfg", FILE_ATTR_CFG, Icon_Config, VOICE_EXT_CFG }, 120 { "cfg", FILE_ATTR_CFG, Icon_Config, VOICE_EXT_CFG },
diff --git a/apps/gui/list.c b/apps/gui/list.c
index ce444cc9c2..b1120aa794 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -317,10 +317,6 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list,
317 317
318static void edge_beep(struct gui_synclist * gui_list, bool wrap) 318static void edge_beep(struct gui_synclist * gui_list, bool wrap)
319{ 319{
320#if CONFIG_CODEC != SWCODEC
321 (void)gui_list;
322 (void)wrap;
323#else
324 if (global_settings.keyclick) 320 if (global_settings.keyclick)
325 { 321 {
326 list_speak_item *cb = gui_list->callback_speak_item; 322 list_speak_item *cb = gui_list->callback_speak_item;
@@ -354,7 +350,6 @@ static void edge_beep(struct gui_synclist * gui_list, bool wrap)
354 talk_force_shutup(); 350 talk_force_shutup();
355 } 351 }
356 } 352 }
357#endif
358} 353}
359 354
360static void _gui_synclist_speak_item(struct gui_synclist *lists) 355static void _gui_synclist_speak_item(struct gui_synclist *lists)
@@ -615,7 +610,6 @@ static void gui_synclist_scroll_left(struct gui_synclist * lists)
615} 610}
616#endif /* HAVE_LCD_BITMAP */ 611#endif /* HAVE_LCD_BITMAP */
617 612
618#if CONFIG_CODEC == SWCODEC
619bool gui_synclist_keyclick_callback(int action, void* data) 613bool gui_synclist_keyclick_callback(int action, void* data)
620{ 614{
621 struct gui_synclist *lists = (struct gui_synclist *)data; 615 struct gui_synclist *lists = (struct gui_synclist *)data;
@@ -633,7 +627,6 @@ bool gui_synclist_keyclick_callback(int action, void* data)
633 627
634 return action != ACTION_NONE; 628 return action != ACTION_NONE;
635} 629}
636#endif
637 630
638/* 631/*
639 * Magic to make sure the list gets updated correctly if the skin does 632 * Magic to make sure the list gets updated correctly if the skin does
@@ -864,9 +857,7 @@ bool list_do_action(int context, int timeout,
864 do_button, and places the action from get_action in *action. */ 857 do_button, and places the action from get_action in *action. */
865{ 858{
866 timeout = list_do_action_timeout(lists, timeout); 859 timeout = list_do_action_timeout(lists, timeout);
867#if CONFIG_CODEC == SWCODEC
868 keyclick_set_callback(gui_synclist_keyclick_callback, lists); 860 keyclick_set_callback(gui_synclist_keyclick_callback, lists);
869#endif
870 *action = get_action(context, timeout); 861 *action = get_action(context, timeout);
871 return gui_synclist_do_button(lists, action, wrap); 862 return gui_synclist_do_button(lists, action, wrap);
872} 863}
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 1be9da496a..9107bf0591 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -170,9 +170,7 @@ extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
170extern bool gui_synclist_item_is_onscreen(struct gui_synclist *lists, 170extern bool gui_synclist_item_is_onscreen(struct gui_synclist *lists,
171 enum screen_type screen, int item); 171 enum screen_type screen, int item);
172 172
173#if CONFIG_CODEC == SWCODEC
174extern bool gui_synclist_keyclick_callback(int action, void* data); 173extern bool gui_synclist_keyclick_callback(int action, void* data);
175#endif
176/* 174/*
177 * Do the action implied by the given button, 175 * Do the action implied by the given button,
178 * returns true if the action was handled. 176 * returns true if the action was handled.
diff --git a/apps/gui/pitchscreen.c b/apps/gui/pitchscreen.c
index bf016fdd5f..0d31193fa6 100644
--- a/apps/gui/pitchscreen.c
+++ b/apps/gui/pitchscreen.c
@@ -38,9 +38,7 @@
38#include "misc.h" 38#include "misc.h"
39#include "pitchscreen.h" 39#include "pitchscreen.h"
40#include "settings.h" 40#include "settings.h"
41#if CONFIG_CODEC == SWCODEC
42#include "tdspeed.h" 41#include "tdspeed.h"
43#endif
44 42
45#define ICON_BORDER 12 /* icons are currently 7x8, so add ~2 pixels */ 43#define ICON_BORDER 12 /* icons are currently 7x8, so add ~2 pixels */
46 /* on both sides when drawing */ 44 /* on both sides when drawing */
@@ -167,13 +165,9 @@ static bool at_limit = false;
167 165
168static void speak_pitch_mode(bool enqueue) 166static void speak_pitch_mode(bool enqueue)
169{ 167{
170#if CONFIG_CODEC == SWCODEC
171 bool timestretch_mode = global_settings.pitch_mode_timestretch && dsp_timestretch_available(); 168 bool timestretch_mode = global_settings.pitch_mode_timestretch && dsp_timestretch_available();
172 if (timestretch_mode) 169 if (timestretch_mode)
173 talk_id(VOICE_PITCH_TIMESTRETCH_MODE, enqueue); 170 talk_id(VOICE_PITCH_TIMESTRETCH_MODE, enqueue);
174#else
175#define timestretch_mode 0
176#endif
177 if (global_settings.pitch_mode_semitone) 171 if (global_settings.pitch_mode_semitone)
178 talk_id(VOICE_PITCH_SEMITONE_MODE, timestretch_mode ? true : enqueue); 172 talk_id(VOICE_PITCH_SEMITONE_MODE, timestretch_mode ? true : enqueue);
179 else 173 else
@@ -238,9 +232,7 @@ static void pitchscreen_draw_icons(struct screen *display,
238static void pitchscreen_draw(struct screen *display, int max_lines, 232static void pitchscreen_draw(struct screen *display, int max_lines,
239 struct viewport pitch_viewports[PITCH_ITEM_COUNT], 233 struct viewport pitch_viewports[PITCH_ITEM_COUNT],
240 int32_t pitch, int32_t semitone 234 int32_t pitch, int32_t semitone
241#if CONFIG_CODEC == SWCODEC
242 ,int32_t speed 235 ,int32_t speed
243#endif
244 ) 236 )
245{ 237{
246 const char* ptr; 238 const char* ptr;
@@ -308,7 +300,6 @@ static void pitchscreen_draw(struct screen *display, int max_lines,
308 /* Middle section upper line - hide for a small screen */ 300 /* Middle section upper line - hide for a small screen */
309 if ((show_lang_pitch = (max_lines >= 3))) 301 if ((show_lang_pitch = (max_lines >= 3)))
310 { 302 {
311#if CONFIG_CODEC == SWCODEC
312 if(global_settings.pitch_mode_timestretch) 303 if(global_settings.pitch_mode_timestretch)
313 { 304 {
314 /* Pitch:XXX.X% */ 305 /* Pitch:XXX.X% */
@@ -330,7 +321,6 @@ static void pitchscreen_draw(struct screen *display, int max_lines,
330 } 321 }
331 } 322 }
332 else 323 else
333#endif
334 { 324 {
335 /* Rate */ 325 /* Rate */
336 snprintf(buf, sizeof(buf), "%s:", str(LANG_PLAYBACK_RATE)); 326 snprintf(buf, sizeof(buf), "%s:", str(LANG_PLAYBACK_RATE));
@@ -344,7 +334,6 @@ static void pitchscreen_draw(struct screen *display, int max_lines,
344 334
345 /* Middle section lower line */ 335 /* Middle section lower line */
346 /* "Speed:XXX%" */ 336 /* "Speed:XXX%" */
347#if CONFIG_CODEC == SWCODEC
348 if(global_settings.pitch_mode_timestretch) 337 if(global_settings.pitch_mode_timestretch)
349 { 338 {
350 snprintf(buf, sizeof(buf), "%s: %ld.%ld%%", str(LANG_SPEED), 339 snprintf(buf, sizeof(buf), "%s: %ld.%ld%%", str(LANG_SPEED),
@@ -352,7 +341,6 @@ static void pitchscreen_draw(struct screen *display, int max_lines,
352 (speed % PITCH_SPEED_PRECISION) / (PITCH_SPEED_PRECISION / 10)); 341 (speed % PITCH_SPEED_PRECISION) / (PITCH_SPEED_PRECISION / 10));
353 } 342 }
354 else 343 else
355#endif
356 { 344 {
357 if(global_settings.pitch_mode_semitone) 345 if(global_settings.pitch_mode_semitone)
358 { 346 {
@@ -396,13 +384,11 @@ static void pitchscreen_draw(struct screen *display, int max_lines,
396 /* Middle section left/right labels */ 384 /* Middle section left/right labels */
397 const char *leftlabel = "-2%"; 385 const char *leftlabel = "-2%";
398 const char *rightlabel = "+2%"; 386 const char *rightlabel = "+2%";
399#if CONFIG_CODEC == SWCODEC
400 if (global_settings.pitch_mode_timestretch) 387 if (global_settings.pitch_mode_timestretch)
401 { 388 {
402 leftlabel = "<<"; 389 leftlabel = "<<";
403 rightlabel = ">>"; 390 rightlabel = ">>";
404 } 391 }
405#endif
406 392
407 /* Only display if they fit */ 393 /* Only display if they fit */
408 display->getstringsize(leftlabel, &w, &h); 394 display->getstringsize(leftlabel, &w, &h);
@@ -423,16 +409,12 @@ static void pitchscreen_draw(struct screen *display, int max_lines,
423} 409}
424 410
425static int32_t pitch_increase(int32_t pitch, int32_t pitch_delta, bool allow_cutoff 411static int32_t pitch_increase(int32_t pitch, int32_t pitch_delta, bool allow_cutoff
426#if CONFIG_CODEC == SWCODEC
427 /* need this to maintain correct pitch/speed caps */ 412 /* need this to maintain correct pitch/speed caps */
428 , int32_t speed 413 , int32_t speed
429#endif
430 ) 414 )
431{ 415{
432 int32_t new_pitch; 416 int32_t new_pitch;
433#if CONFIG_CODEC == SWCODEC
434 int32_t new_stretch; 417 int32_t new_stretch;
435#endif
436 at_limit = false; 418 at_limit = false;
437 419
438 if (pitch_delta < 0) 420 if (pitch_delta < 0)
@@ -480,7 +462,6 @@ static int32_t pitch_increase(int32_t pitch, int32_t pitch_delta, bool allow_cut
480 /* pitch_delta == 0 -> no real change */ 462 /* pitch_delta == 0 -> no real change */
481 return pitch; 463 return pitch;
482 } 464 }
483#if CONFIG_CODEC == SWCODEC
484 if (dsp_timestretch_available()) 465 if (dsp_timestretch_available())
485 { 466 {
486 /* increase the multiple to increase precision of this calculation */ 467 /* increase the multiple to increase precision of this calculation */
@@ -504,7 +485,6 @@ static int32_t pitch_increase(int32_t pitch, int32_t pitch_delta, bool allow_cut
504 at_limit = true; 485 at_limit = true;
505 } 486 }
506 } 487 }
507#endif
508 488
509 sound_set_pitch(new_pitch); 489 sound_set_pitch(new_pitch);
510 490
@@ -579,9 +559,7 @@ static int32_t get_pitch_from_semitone(int32_t semitone)
579static int32_t pitch_increase_semitone(int32_t pitch, 559static int32_t pitch_increase_semitone(int32_t pitch,
580 int32_t current_semitone, 560 int32_t current_semitone,
581 int32_t semitone_delta 561 int32_t semitone_delta
582#if CONFIG_CODEC == SWCODEC
583 , int32_t speed 562 , int32_t speed
584#endif
585 ) 563 )
586{ 564{
587 int32_t new_semitone = current_semitone; 565 int32_t new_semitone = current_semitone;
@@ -613,7 +591,6 @@ static int32_t pitch_increase_semitone(int32_t pitch,
613 591
614 int32_t new_pitch = get_pitch_from_semitone(new_semitone); 592 int32_t new_pitch = get_pitch_from_semitone(new_semitone);
615 593
616#if CONFIG_CODEC == SWCODEC
617 int32_t new_stretch = GET_STRETCH(new_pitch, speed); 594 int32_t new_stretch = GET_STRETCH(new_pitch, speed);
618 595
619 /* clamp the pitch so it doesn't go beyond the stretch limits */ 596 /* clamp the pitch so it doesn't go beyond the stretch limits */
@@ -629,12 +606,9 @@ static int32_t pitch_increase_semitone(int32_t pitch,
629 new_semitone = get_semitone_from_pitch(new_pitch); 606 new_semitone = get_semitone_from_pitch(new_pitch);
630 at_limit = true; 607 at_limit = true;
631 } 608 }
632#endif
633 609
634 pitch_increase(pitch, new_pitch - pitch, false 610 pitch_increase(pitch, new_pitch - pitch, false
635#if CONFIG_CODEC == SWCODEC
636 , speed 611 , speed
637#endif
638 ); 612 );
639 613
640 return new_semitone; 614 return new_semitone;
@@ -765,7 +739,6 @@ int gui_syncpitchscreen_run(void)
765 739
766 push_current_activity(ACTIVITY_PITCHSCREEN); 740 push_current_activity(ACTIVITY_PITCHSCREEN);
767 741
768#if CONFIG_CODEC == SWCODEC
769 int32_t new_speed = 0, new_stretch; 742 int32_t new_speed = 0, new_stretch;
770 743
771 /* the speed variable holds the apparent speed of the playback */ 744 /* the speed variable holds the apparent speed of the playback */
@@ -785,7 +758,6 @@ int gui_syncpitchscreen_run(void)
785 global_settings.pitch_mode_timestretch = false; 758 global_settings.pitch_mode_timestretch = false;
786 settings_save(); 759 settings_save();
787 } 760 }
788#endif
789 761
790 /* Count decimals for speaking */ 762 /* Count decimals for speaking */
791 for (i = PITCH_SPEED_PRECISION; i >= 10; i /= 10) 763 for (i = PITCH_SPEED_PRECISION; i >= 10; i /= 10)
@@ -806,23 +778,17 @@ int gui_syncpitchscreen_run(void)
806 /* also, draw the icons now, it's only needed once */ 778 /* also, draw the icons now, it's only needed once */
807 pitchscreen_draw_icons(&screens[i], &parent[i]); 779 pitchscreen_draw_icons(&screens[i], &parent[i]);
808 } 780 }
809#if CONFIG_CODEC == SWCODEC
810 pcmbuf_set_low_latency(true); 781 pcmbuf_set_low_latency(true);
811#endif
812 782
813 while (!exit) 783 while (!exit)
814 { 784 {
815 FOR_NB_SCREENS(i) 785 FOR_NB_SCREENS(i)
816 pitchscreen_draw(&screens[i], max_lines[i], 786 pitchscreen_draw(&screens[i], max_lines[i],
817 pitch_viewports[i], pitch, semitone 787 pitch_viewports[i], pitch, semitone
818#if CONFIG_CODEC == SWCODEC
819 , speed 788 , speed
820#endif
821 ); 789 );
822 pitch_delta = 0; 790 pitch_delta = 0;
823#if CONFIG_CODEC == SWCODEC
824 new_speed = 0; 791 new_speed = 0;
825#endif
826 792
827 if (global_settings.talk_menu && updated) 793 if (global_settings.talk_menu && updated)
828 { 794 {
@@ -835,29 +801,23 @@ int gui_syncpitchscreen_run(void)
835 else 801 else
836 talk_value_decimal(pitch, UNIT_PERCENT, decimals, false); 802 talk_value_decimal(pitch, UNIT_PERCENT, decimals, false);
837 break; 803 break;
838#if CONFIG_CODEC == SWCODEC
839 case 2: 804 case 2:
840 talk_value_decimal(speed, UNIT_PERCENT, decimals, false); 805 talk_value_decimal(speed, UNIT_PERCENT, decimals, false);
841 break; 806 break;
842#endif
843 case 3: 807 case 3:
844 speak_pitch_mode(false); 808 speak_pitch_mode(false);
845 break; 809 break;
846 case 4: 810 case 4:
847#if CONFIG_CODEC == SWCODEC
848 if (global_settings.pitch_mode_timestretch && dsp_timestretch_available()) 811 if (global_settings.pitch_mode_timestretch && dsp_timestretch_available())
849 talk_id(LANG_PITCH, false); 812 talk_id(LANG_PITCH, false);
850 else 813 else
851#endif
852 talk_id(LANG_PLAYBACK_RATE, false); 814 talk_id(LANG_PLAYBACK_RATE, false);
853 talk_value_decimal(pitch, UNIT_PERCENT, decimals, true); 815 talk_value_decimal(pitch, UNIT_PERCENT, decimals, true);
854#if CONFIG_CODEC == SWCODEC
855 if (global_settings.pitch_mode_timestretch && dsp_timestretch_available()) 816 if (global_settings.pitch_mode_timestretch && dsp_timestretch_available())
856 { 817 {
857 talk_id(LANG_SPEED, true); 818 talk_id(LANG_SPEED, true);
858 talk_value_decimal(speed, UNIT_PERCENT, decimals, true); 819 talk_value_decimal(speed, UNIT_PERCENT, decimals, true);
859 } 820 }
860#endif
861 speak_pitch_mode(true); 821 speak_pitch_mode(true);
862 break; 822 break;
863 default: 823 default:
@@ -910,24 +870,17 @@ int gui_syncpitchscreen_run(void)
910 break; 870 break;
911 871
912 case ACTION_PS_NUDGE_RIGHT: 872 case ACTION_PS_NUDGE_RIGHT:
913#if CONFIG_CODEC == SWCODEC
914 if (!global_settings.pitch_mode_timestretch) 873 if (!global_settings.pitch_mode_timestretch)
915 { 874 {
916#endif
917 new_pitch = pitch_increase(pitch, PITCH_NUDGE_DELTA, false 875 new_pitch = pitch_increase(pitch, PITCH_NUDGE_DELTA, false
918#if CONFIG_CODEC == SWCODEC
919 , speed 876 , speed
920#endif
921 ); 877 );
922 nudged = (new_pitch != pitch); 878 nudged = (new_pitch != pitch);
923 pitch = new_pitch; 879 pitch = new_pitch;
924 semitone = get_semitone_from_pitch(pitch); 880 semitone = get_semitone_from_pitch(pitch);
925#if CONFIG_CODEC == SWCODEC
926 speed = pitch; 881 speed = pitch;
927#endif
928 updated = nudged ? 1 : 0; 882 updated = nudged ? 1 : 0;
929 break; 883 break;
930#if CONFIG_CODEC == SWCODEC
931 } 884 }
932 else 885 else
933 { 886 {
@@ -948,19 +901,14 @@ int gui_syncpitchscreen_run(void)
948 updated = 2; 901 updated = 2;
949 } 902 }
950 break; 903 break;
951#endif
952 904
953 case ACTION_PS_NUDGE_RIGHTOFF: 905 case ACTION_PS_NUDGE_RIGHTOFF:
954 if (nudged) 906 if (nudged)
955 { 907 {
956 pitch = pitch_increase(pitch, -PITCH_NUDGE_DELTA, false 908 pitch = pitch_increase(pitch, -PITCH_NUDGE_DELTA, false
957#if CONFIG_CODEC == SWCODEC
958 , speed 909 , speed
959#endif
960 ); 910 );
961#if CONFIG_CODEC == SWCODEC
962 speed = pitch; 911 speed = pitch;
963#endif
964 semitone = get_semitone_from_pitch(pitch); 912 semitone = get_semitone_from_pitch(pitch);
965 nudged = false; 913 nudged = false;
966 updated = 1; 914 updated = 1;
@@ -968,24 +916,17 @@ int gui_syncpitchscreen_run(void)
968 break; 916 break;
969 917
970 case ACTION_PS_NUDGE_LEFT: 918 case ACTION_PS_NUDGE_LEFT:
971#if CONFIG_CODEC == SWCODEC
972 if (!global_settings.pitch_mode_timestretch) 919 if (!global_settings.pitch_mode_timestretch)
973 { 920 {
974#endif
975 new_pitch = pitch_increase(pitch, -PITCH_NUDGE_DELTA, false 921 new_pitch = pitch_increase(pitch, -PITCH_NUDGE_DELTA, false
976#if CONFIG_CODEC == SWCODEC
977 , speed 922 , speed
978#endif
979 ); 923 );
980 nudged = (new_pitch != pitch); 924 nudged = (new_pitch != pitch);
981 pitch = new_pitch; 925 pitch = new_pitch;
982 semitone = get_semitone_from_pitch(pitch); 926 semitone = get_semitone_from_pitch(pitch);
983#if CONFIG_CODEC == SWCODEC
984 speed = pitch; 927 speed = pitch;
985#endif
986 updated = nudged ? 1 : 0; 928 updated = nudged ? 1 : 0;
987 break; 929 break;
988#if CONFIG_CODEC == SWCODEC
989 } 930 }
990 else 931 else
991 { 932 {
@@ -1006,19 +947,14 @@ int gui_syncpitchscreen_run(void)
1006 updated = 2; 947 updated = 2;
1007 } 948 }
1008 break; 949 break;
1009#endif
1010 950
1011 case ACTION_PS_NUDGE_LEFTOFF: 951 case ACTION_PS_NUDGE_LEFTOFF:
1012 if (nudged) 952 if (nudged)
1013 { 953 {
1014 pitch = pitch_increase(pitch, PITCH_NUDGE_DELTA, false 954 pitch = pitch_increase(pitch, PITCH_NUDGE_DELTA, false
1015#if CONFIG_CODEC == SWCODEC
1016 , speed 955 , speed
1017#endif
1018 ); 956 );
1019#if CONFIG_CODEC == SWCODEC
1020 speed = pitch; 957 speed = pitch;
1021#endif
1022 semitone = get_semitone_from_pitch(pitch); 958 semitone = get_semitone_from_pitch(pitch);
1023 nudged = false; 959 nudged = false;
1024 updated = 1; 960 updated = 1;
@@ -1028,21 +964,18 @@ int gui_syncpitchscreen_run(void)
1028 case ACTION_PS_RESET: 964 case ACTION_PS_RESET:
1029 pitch = PITCH_SPEED_100; 965 pitch = PITCH_SPEED_100;
1030 sound_set_pitch(pitch); 966 sound_set_pitch(pitch);
1031#if CONFIG_CODEC == SWCODEC
1032 speed = PITCH_SPEED_100; 967 speed = PITCH_SPEED_100;
1033 if (dsp_timestretch_available()) 968 if (dsp_timestretch_available())
1034 { 969 {
1035 dsp_set_timestretch(PITCH_SPEED_100); 970 dsp_set_timestretch(PITCH_SPEED_100);
1036 at_limit = false; 971 at_limit = false;
1037 } 972 }
1038#endif
1039 semitone = get_semitone_from_pitch(pitch); 973 semitone = get_semitone_from_pitch(pitch);
1040 updated = 4; 974 updated = 4;
1041 break; 975 break;
1042 976
1043 case ACTION_PS_TOGGLE_MODE: 977 case ACTION_PS_TOGGLE_MODE:
1044 global_settings.pitch_mode_semitone = !global_settings.pitch_mode_semitone; 978 global_settings.pitch_mode_semitone = !global_settings.pitch_mode_semitone;
1045#if CONFIG_CODEC == SWCODEC
1046 979
1047 if (dsp_timestretch_available() && !global_settings.pitch_mode_semitone) 980 if (dsp_timestretch_available() && !global_settings.pitch_mode_semitone)
1048 { 981 {
@@ -1055,7 +988,6 @@ int gui_syncpitchscreen_run(void)
1055 } 988 }
1056 } 989 }
1057 settings_save(); 990 settings_save();
1058#endif
1059 updated = 3; 991 updated = 3;
1060 break; 992 break;
1061 993
@@ -1073,22 +1005,17 @@ int gui_syncpitchscreen_run(void)
1073 if (global_settings.pitch_mode_semitone) 1005 if (global_settings.pitch_mode_semitone)
1074 { 1006 {
1075 semitone = pitch_increase_semitone(pitch, semitone, pitch_delta 1007 semitone = pitch_increase_semitone(pitch, semitone, pitch_delta
1076#if CONFIG_CODEC == SWCODEC
1077 , speed 1008 , speed
1078#endif
1079 ); 1009 );
1080 pitch = get_pitch_from_semitone(semitone); 1010 pitch = get_pitch_from_semitone(semitone);
1081 } 1011 }
1082 else 1012 else
1083 { 1013 {
1084 pitch = pitch_increase(pitch, pitch_delta, true 1014 pitch = pitch_increase(pitch, pitch_delta, true
1085#if CONFIG_CODEC == SWCODEC
1086 , speed 1015 , speed
1087#endif
1088 ); 1016 );
1089 semitone = get_semitone_from_pitch(pitch); 1017 semitone = get_semitone_from_pitch(pitch);
1090 } 1018 }
1091#if CONFIG_CODEC == SWCODEC
1092 if (global_settings.pitch_mode_timestretch) 1019 if (global_settings.pitch_mode_timestretch)
1093 { 1020 {
1094 /* do this to make sure we properly obey the stretch limits */ 1021 /* do this to make sure we properly obey the stretch limits */
@@ -1098,10 +1025,8 @@ int gui_syncpitchscreen_run(void)
1098 { 1025 {
1099 speed = pitch; 1026 speed = pitch;
1100 } 1027 }
1101#endif
1102 } 1028 }
1103 1029
1104#if CONFIG_CODEC == SWCODEC
1105 if(new_speed) 1030 if(new_speed)
1106 { 1031 {
1107 new_stretch = GET_STRETCH(pitch, new_speed); 1032 new_stretch = GET_STRETCH(pitch, new_speed);
@@ -1135,11 +1060,8 @@ int gui_syncpitchscreen_run(void)
1135 /* when needed */ 1060 /* when needed */
1136 new_speed = 0; 1061 new_speed = 0;
1137 } 1062 }
1138#endif
1139 } 1063 }
1140#if CONFIG_CODEC == SWCODEC
1141 pcmbuf_set_low_latency(false); 1064 pcmbuf_set_low_latency(false);
1142#endif
1143 pop_current_activity(); 1065 pop_current_activity();
1144 return 0; 1066 return 0;
1145} 1067}
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 7ee349b346..345d74b65c 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -57,9 +57,7 @@
57#endif 57#endif
58 58
59#include "cuesheet.h" 59#include "cuesheet.h"
60#if CONFIG_CODEC == SWCODEC
61#include "playback.h" 60#include "playback.h"
62#endif
63#include "backdrop.h" 61#include "backdrop.h"
64#include "viewport.h" 62#include "viewport.h"
65#if CONFIG_TUNER 63#if CONFIG_TUNER
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index 50704fd66e..2528a0af55 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -47,10 +47,8 @@
47#include "albumart.h" 47#include "albumart.h"
48#endif 48#endif
49#include "playlist.h" 49#include "playlist.h"
50#if CONFIG_CODEC == SWCODEC
51#include "playback.h" 50#include "playback.h"
52#include "tdspeed.h" 51#include "tdspeed.h"
53#endif
54#include "viewport.h" 52#include "viewport.h"
55#include "tagcache.h" 53#include "tagcache.h"
56 54
@@ -558,18 +556,16 @@ static struct mp3entry* get_mp3entry_from_offset(int offset, char **filename)
558 static char filename_buf[MAX_PATH + 1]; 556 static char filename_buf[MAX_PATH + 1];
559 fname = playlist_peek(offset, filename_buf, sizeof(filename_buf)); 557 fname = playlist_peek(offset, filename_buf, sizeof(filename_buf));
560 *filename = (char*)fname; 558 *filename = (char*)fname;
561#if CONFIG_CODEC == SWCODEC
562 static struct mp3entry tempid3; 559 static struct mp3entry tempid3;
563 if ( 560 if (
564#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) 561#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
565 tagcache_fill_tags(&tempid3, fname) || 562 tagcache_fill_tags(&tempid3, fname) ||
566#endif 563#endif
567 audio_peek_track(&tempid3, offset) 564 audio_peek_track(&tempid3, offset)
568 ) 565 )
569 { 566 {
570 pid3 = &tempid3; 567 pid3 = &tempid3;
571 } 568 }
572#endif
573 } 569 }
574 return pid3; 570 return pid3;
575} 571}
@@ -1224,7 +1220,6 @@ const char *get_token_value(struct gui_wps *gwps,
1224 } 1220 }
1225#endif 1221#endif
1226 1222
1227#if (CONFIG_CODEC == SWCODEC)
1228 case SKIN_TOKEN_CROSSFADE: 1223 case SKIN_TOKEN_CROSSFADE:
1229#ifdef HAVE_CROSSFADE 1224#ifdef HAVE_CROSSFADE
1230 if (intval) 1225 if (intval)
@@ -1277,7 +1272,6 @@ const char *get_token_value(struct gui_wps *gwps,
1277 } 1272 }
1278 return buf; 1273 return buf;
1279 } 1274 }
1280#endif /* (CONFIG_CODEC == SWCODEC) */
1281 1275
1282#if defined (HAVE_PITCHCONTROL) 1276#if defined (HAVE_PITCHCONTROL)
1283 case SKIN_TOKEN_SOUND_PITCH: 1277 case SKIN_TOKEN_SOUND_PITCH:
@@ -1294,7 +1288,7 @@ const char *get_token_value(struct gui_wps *gwps,
1294 } 1288 }
1295#endif 1289#endif
1296 1290
1297#if (CONFIG_CODEC == SWCODEC) && defined (HAVE_PITCHCONTROL) 1291#if defined (HAVE_PITCHCONTROL)
1298 case SKIN_TOKEN_SOUND_SPEED: 1292 case SKIN_TOKEN_SOUND_SPEED:
1299 { 1293 {
1300 int32_t pitch = sound_get_pitch(); 1294 int32_t pitch = sound_get_pitch();
@@ -1462,7 +1456,6 @@ const char *get_token_value(struct gui_wps *gwps,
1462 return NULL; 1456 return NULL;
1463 case SKIN_TOKEN_REC_FREQ: /* order from REC_FREQ_CFG_VAL_LIST */ 1457 case SKIN_TOKEN_REC_FREQ: /* order from REC_FREQ_CFG_VAL_LIST */
1464 { 1458 {
1465#if CONFIG_CODEC == SWCODEC
1466 unsigned long samprk; 1459 unsigned long samprk;
1467 int rec_freq = global_settings.rec_frequency; 1460 int rec_freq = global_settings.rec_frequency;
1468 1461
@@ -1528,26 +1521,8 @@ const char *get_token_value(struct gui_wps *gwps,
1528 } 1521 }
1529 } 1522 }
1530 snprintf(buf, buf_size, "%lu.%1lu", samprk/1000,samprk%1000); 1523 snprintf(buf, buf_size, "%lu.%1lu", samprk/1000,samprk%1000);
1531#else /* HWCODEC */
1532
1533 static const char * const freq_strings[] =
1534 {"--", "44", "48", "32", "22", "24", "16"};
1535 int freq = 1 + global_settings.rec_frequency;
1536#ifdef HAVE_SPDIF_REC
1537 if (global_settings.rec_source == AUDIO_SRC_SPDIF)
1538 {
1539 /* Can't measure S/PDIF sample rate on Archos/Sim yet */
1540 freq = 0;
1541 }
1542#endif /* HAVE_SPDIF_IN */
1543 if (intval)
1544 *intval = freq+1; /* so the token gets a value 1<=x<=7 */
1545 snprintf(buf, buf_size, "%s\n",
1546 freq_strings[global_settings.rec_frequency]);
1547#endif
1548 return buf; 1524 return buf;
1549 } 1525 }
1550#if CONFIG_CODEC == SWCODEC
1551 case SKIN_TOKEN_REC_ENCODER: 1526 case SKIN_TOKEN_REC_ENCODER:
1552 { 1527 {
1553 int rec_format = global_settings.rec_format+1; /* WAV, AIFF, WV, MPEG */ 1528 int rec_format = global_settings.rec_format+1; /* WAV, AIFF, WV, MPEG */
@@ -1568,9 +1543,7 @@ const char *get_token_value(struct gui_wps *gwps,
1568 } 1543 }
1569 break; 1544 break;
1570 } 1545 }
1571#endif
1572 case SKIN_TOKEN_REC_BITRATE: 1546 case SKIN_TOKEN_REC_BITRATE:
1573#if CONFIG_CODEC == SWCODEC
1574 if (global_settings.rec_format == REC_FORMAT_MPA_L3) 1547 if (global_settings.rec_format == REC_FORMAT_MPA_L3)
1575 { 1548 {
1576 if (intval) 1549 if (intval)
@@ -1632,17 +1605,11 @@ const char *get_token_value(struct gui_wps *gwps,
1632 } 1605 }
1633 else 1606 else
1634 return NULL; /* Fixme later */ 1607 return NULL; /* Fixme later */
1635#else /* CONFIG_CODEC == HWCODEC */
1636 if (intval)
1637 *intval = global_settings.rec_quality+1;
1638 snprintf(buf, buf_size, "%d", global_settings.rec_quality);
1639 return buf;
1640#endif
1641 case SKIN_TOKEN_REC_MONO: 1608 case SKIN_TOKEN_REC_MONO:
1642 if (!global_settings.rec_channels) 1609 if (!global_settings.rec_channels)
1643 return "m"; 1610 return "m";
1644 return NULL; 1611 return NULL;
1645 1612
1646 case SKIN_TOKEN_REC_SECONDS: 1613 case SKIN_TOKEN_REC_SECONDS:
1647 { 1614 {
1648 int time = (audio_recorded_time() / HZ) % 60; 1615 int time = (audio_recorded_time() / HZ) % 60;
diff --git a/apps/gui/splash.c b/apps/gui/splash.c
index 56df77d57a..fa2c21768a 100644
--- a/apps/gui/splash.c
+++ b/apps/gui/splash.c
@@ -199,7 +199,7 @@ void splashf(int ticks, const char *fmt, ...)
199 199
200void splash(int ticks, const char *str) 200void splash(int ticks, const char *str)
201{ 201{
202#if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC 202#if !defined(SIMULATOR)
203 long id; 203 long id;
204 /* fmt may be a so called virtual pointer. See settings.h. */ 204 /* fmt may be a so called virtual pointer. See settings.h. */
205 if((id = P2ID((const unsigned char*)str)) >= 0) 205 if((id = P2ID((const unsigned char*)str)) >= 0)
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index 90d04a7930..0c8f54f749 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -27,9 +27,7 @@
27#include "sound.h" 27#include "sound.h"
28#include "settings.h" 28#include "settings.h"
29#include "viewport.h" 29#include "viewport.h"
30#if CONFIG_CODEC == SWCODEC
31#include "metadata.h" 30#include "metadata.h"
32#endif
33#include "icons.h" 31#include "icons.h"
34#include "powermgmt.h" 32#include "powermgmt.h"
35#include "usb.h" 33#include "usb.h"
@@ -602,7 +600,6 @@ static void gui_statusbar_time(struct screen * display, struct tm *time)
602#endif 600#endif
603 601
604#ifdef HAVE_RECORDING 602#ifdef HAVE_RECORDING
605#if CONFIG_CODEC == SWCODEC
606/** 603/**
607 * Write a number to the display using bitmaps and return new position 604 * Write a number to the display using bitmaps and return new position
608 */ 605 */
@@ -650,7 +647,7 @@ static void gui_statusbar_write_format_info(struct screen * display)
650 xpos += BM_GLYPH_WIDTH; 647 xpos += BM_GLYPH_WIDTH;
651 } 648 }
652 } 649 }
653 650
654 651
655 /* Show bitmap - clipping right edge if needed */ 652 /* Show bitmap - clipping right edge if needed */
656 display->mono_bitmap_part(bm, 0, 0, STATUSBAR_ENCODER_WIDTH, 653 display->mono_bitmap_part(bm, 0, 0, STATUSBAR_ENCODER_WIDTH,
@@ -695,58 +692,14 @@ static void gui_statusbar_write_samplerate_info(struct screen * display)
695 STATUSBAR_Y_POS, BM_GLYPH_WIDTH, 692 STATUSBAR_Y_POS, BM_GLYPH_WIDTH,
696 STATUSBAR_HEIGHT); 693 STATUSBAR_HEIGHT);
697} 694}
698#endif /* CONFIG_CODEC == SWCODEC */
699 695
700static void gui_statusbar_icon_recording_info(struct screen * display) 696static void gui_statusbar_icon_recording_info(struct screen * display)
701{ 697{
702#if CONFIG_CODEC != SWCODEC
703 char buffer[3];
704 const char *p = buffer;
705 int width, height;
706 display->setfont(FONT_SYSFIXED);
707#endif /* CONFIG_CODEC != SWCODEC */
708
709 /* Display Codec info in statusbar */ 698 /* Display Codec info in statusbar */
710#if CONFIG_CODEC == SWCODEC
711 gui_statusbar_write_format_info(display); 699 gui_statusbar_write_format_info(display);
712#else /* !SWCODEC */
713 display->mono_bitmap(bitmap_icons_5x8[Icon_q],
714 STATUSBAR_ENCODER_X_POS + 8, STATUSBAR_Y_POS,
715 5, STATUSBAR_HEIGHT);
716
717 snprintf(buffer, sizeof(buffer), "%d", global_settings.rec_quality);
718 display->getstringsize(buffer, &width, &height);
719 if (height <= STATUSBAR_HEIGHT)
720 display->putsxy(STATUSBAR_ENCODER_X_POS + 13, STATUSBAR_Y_POS, buffer);
721#endif /* CONFIG_CODEC == SWCODEC */
722 700
723 /* Display Samplerate info in statusbar */ 701 /* Display Samplerate info in statusbar */
724#if CONFIG_CODEC == SWCODEC
725 /* SWCODEC targets use bitmaps for glyphs */
726 gui_statusbar_write_samplerate_info(display); 702 gui_statusbar_write_samplerate_info(display);
727#else /* !SWCODEC */
728 /* hwcodec targets have sysfont characters */
729#ifdef HAVE_SPDIF_REC
730 if (global_settings.rec_source == AUDIO_SRC_SPDIF)
731 {
732 /* Can't measure S/PDIF sample rate on Archos/Sim yet */
733 p = "--";
734 }
735 else
736#endif /* HAVE_SPDIF_IN */
737 {
738 static const char * const freq_strings[] =
739 {"44", "48", "32", "22", "24", "16"};
740 p = freq_strings[global_settings.rec_frequency];
741 }
742
743 display->getstringsize(p, &width, &height);
744
745 if (height <= STATUSBAR_HEIGHT)
746 display->putsxy(STATUSBAR_RECFREQ_X_POS, STATUSBAR_Y_POS, p);
747
748 display->setfont(FONT_UI);
749#endif /* CONFIG_CODEC == SWCODEC */
750 703
751 /* Display Channel status in status bar */ 704 /* Display Channel status in status bar */
752 if(global_settings.rec_channels) 705 if(global_settings.rec_channels)
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index b417f82922..82321ff945 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -33,7 +33,6 @@
33#include "filetypes.h" 33#include "filetypes.h"
34#include "settings.h" 34#include "settings.h"
35#include "skin_engine/skin_engine.h" 35#include "skin_engine/skin_engine.h"
36#include "mp3_playback.h"
37#include "audio.h" 36#include "audio.h"
38#include "usb.h" 37#include "usb.h"
39#include "status.h" 38#include "status.h"
@@ -124,26 +123,17 @@ static void update_non_static(void)
124 123
125void pause_action(bool may_fade, bool updatewps) 124void pause_action(bool may_fade, bool updatewps)
126{ 125{
127#if CONFIG_CODEC == SWCODEC
128 /* Do audio first, then update, unless skin were to use its local 126 /* Do audio first, then update, unless skin were to use its local
129 status in which case, reverse it */ 127 status in which case, reverse it */
130 audio_pause(); 128 audio_pause();
131 129
132 if (updatewps) 130 if (updatewps)
133 update_non_static(); 131 update_non_static();
134#else
135 if (may_fade && global_settings.fade_on_stop)
136 fade(false, updatewps);
137 else
138 audio_pause();
139#endif
140 132
141 if (global_settings.pause_rewind) { 133 if (global_settings.pause_rewind) {
142 long newpos; 134 long newpos;
143 135
144#if (CONFIG_CODEC == SWCODEC)
145 audio_pre_ff_rewind(); 136 audio_pre_ff_rewind();
146#endif
147 newpos = audio_current_track()->elapsed 137 newpos = audio_current_track()->elapsed
148 - global_settings.pause_rewind * 1000; 138 - global_settings.pause_rewind * 1000;
149 audio_ff_rewind(newpos > 0 ? newpos : 0); 139 audio_ff_rewind(newpos > 0 ? newpos : 0);
@@ -154,80 +144,16 @@ void pause_action(bool may_fade, bool updatewps)
154 144
155void unpause_action(bool may_fade, bool updatewps) 145void unpause_action(bool may_fade, bool updatewps)
156{ 146{
157#if CONFIG_CODEC == SWCODEC
158 /* Do audio first, then update, unless skin were to use its local 147 /* Do audio first, then update, unless skin were to use its local
159 status in which case, reverse it */ 148 status in which case, reverse it */
160 audio_resume(); 149 audio_resume();
161 150
162 if (updatewps) 151 if (updatewps)
163 update_non_static(); 152 update_non_static();
164#else
165 if (may_fade && global_settings.fade_on_stop)
166 fade(true, updatewps);
167 else
168 audio_resume();
169#endif
170 153
171 (void)may_fade; 154 (void)may_fade;
172} 155}
173 156
174#if CONFIG_CODEC != SWCODEC
175void fade(bool fade_in, bool updatewps)
176{
177 int fp_global_vol = global_settings.volume << 8;
178 int fp_min_vol = sound_min(SOUND_VOLUME) << 8;
179 int fp_step = (fp_global_vol - fp_min_vol) / 10;
180
181 skin_get_global_state()->is_fading = !fade_in;
182 if (fade_in) {
183 /* fade in */
184 int fp_volume = fp_min_vol;
185
186 /* zero out the sound */
187 sound_set_volume(fp_min_vol >> 8);
188
189 sleep(HZ/10); /* let audio thread run */
190 audio_resume();
191
192 if (updatewps)
193 update_non_static();
194
195 while (fp_volume < fp_global_vol - fp_step) {
196 fp_volume += fp_step;
197 sound_set_volume(fp_volume >> 8);
198 sleep(1);
199 }
200 sound_set_volume(global_settings.volume);
201 }
202 else {
203 /* fade out */
204 int fp_volume = fp_global_vol;
205
206 if (updatewps)
207 update_non_static();
208
209 while (fp_volume > fp_min_vol + fp_step) {
210 fp_volume -= fp_step;
211 sound_set_volume(fp_volume >> 8);
212 sleep(1);
213 }
214 audio_pause();
215
216 skin_get_global_state()->is_fading = false;
217#if CONFIG_CODEC != SWCODEC
218#ifndef SIMULATOR
219 /* let audio thread run and wait for the mas to run out of data */
220 while (!mp3_pause_done())
221#endif
222 sleep(HZ/10);
223#endif
224
225 /* reset volume to what it was before the fade */
226 sound_set_volume(global_settings.volume);
227 }
228}
229#endif /* SWCODEC */
230
231static bool update_onvol_change(enum screen_type screen) 157static bool update_onvol_change(enum screen_type screen)
232{ 158{
233 skin_update(WPS, screen, SKIN_REFRESH_NON_STATIC); 159 skin_update(WPS, screen, SKIN_REFRESH_NON_STATIC);
@@ -264,17 +190,8 @@ static int skintouch_to_wps(struct wps_data *data)
264#endif 190#endif
265 case ACTION_TOUCH_SCROLLBAR: 191 case ACTION_TOUCH_SCROLLBAR:
266 skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/100; 192 skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/100;
267#if (CONFIG_CODEC == SWCODEC)
268 audio_pre_ff_rewind(); 193 audio_pre_ff_rewind();
269#else
270 if (!skin_get_global_state()->paused)
271 audio_pause();
272#endif
273 audio_ff_rewind(skin_get_global_state()->id3->elapsed); 194 audio_ff_rewind(skin_get_global_state()->id3->elapsed);
274#if (CONFIG_CODEC != SWCODEC)
275 if (!skin_get_global_state()->paused)
276 audio_resume();
277#endif
278 return ACTION_TOUCHSCREEN; 195 return ACTION_TOUCHSCREEN;
279 case ACTION_TOUCH_VOLUME: 196 case ACTION_TOUCH_VOLUME:
280 { 197 {
@@ -344,12 +261,7 @@ bool ffwd_rew(int button)
344 if ( (audio_status() & AUDIO_STATUS_PLAY) && 261 if ( (audio_status() & AUDIO_STATUS_PLAY) &&
345 skin_get_global_state()->id3 && skin_get_global_state()->id3->length ) 262 skin_get_global_state()->id3 && skin_get_global_state()->id3->length )
346 { 263 {
347#if (CONFIG_CODEC == SWCODEC)
348 audio_pre_ff_rewind(); 264 audio_pre_ff_rewind();
349#else
350 if (!skin_get_global_state()->paused)
351 audio_pause();
352#endif
353 if (direction > 0) 265 if (direction > 0)
354 status_set_ffmode(STATUS_FASTFORWARD); 266 status_set_ffmode(STATUS_FASTFORWARD);
355 else 267 else
@@ -393,10 +305,6 @@ bool ffwd_rew(int button)
393 skin_get_global_state()->ff_rewind_count = 0; 305 skin_get_global_state()->ff_rewind_count = 0;
394 skin_get_global_state()->ff_rewind = false; 306 skin_get_global_state()->ff_rewind = false;
395 status_set_ffmode(0); 307 status_set_ffmode(0);
396#if (CONFIG_CODEC != SWCODEC)
397 if (!skin_get_global_state()->paused)
398 audio_resume();
399#endif
400 exit = true; 308 exit = true;
401 break; 309 break;
402 310
@@ -495,19 +403,8 @@ static void prev_track(unsigned long skip_thresh)
495 return; 403 return;
496 } 404 }
497 405
498#if (CONFIG_CODEC == SWCODEC)
499 audio_pre_ff_rewind(); 406 audio_pre_ff_rewind();
500#else
501 if (!state->paused)
502 audio_pause();
503#endif
504
505 audio_ff_rewind(0); 407 audio_ff_rewind(0);
506
507#if (CONFIG_CODEC != SWCODEC)
508 if (!state->paused)
509 audio_resume();
510#endif
511 } 408 }
512} 409}
513 410
@@ -573,9 +470,7 @@ static void play_hop(int direction)
573 } 470 }
574 else if (direction == 1 && step >= remaining) 471 else if (direction == 1 && step >= remaining)
575 { 472 {
576#if CONFIG_CODEC == SWCODEC
577 system_sound_play(SOUND_TRACK_NO_MORE); 473 system_sound_play(SOUND_TRACK_NO_MORE);
578#endif
579 return; 474 return;
580 } 475 }
581 else if (direction == -1 && elapsed < step) 476 else if (direction == -1 && elapsed < step)
@@ -588,21 +483,10 @@ static void play_hop(int direction)
588 } 483 }
589 if(audio_status() & AUDIO_STATUS_PLAY) 484 if(audio_status() & AUDIO_STATUS_PLAY)
590 { 485 {
591#if (CONFIG_CODEC == SWCODEC)
592 audio_pre_ff_rewind(); 486 audio_pre_ff_rewind();
593#else
594 if (!state->paused)
595 audio_pause();
596#endif
597 } 487 }
598 488
599#if (CONFIG_CODEC == SWCODEC)
600 audio_ff_rewind(elapsed); 489 audio_ff_rewind(elapsed);
601#else
602 audio_ff_rewind(state->id3->elapsed = elapsed);
603 if (!state->paused)
604 audio_resume();
605#endif
606} 490}
607 491
608 492
@@ -867,12 +751,7 @@ long gui_wps_show(void)
867 { 751 {
868 if (state->id3->cuesheet) 752 if (state->id3->cuesheet)
869 { 753 {
870#if (CONFIG_CODEC == SWCODEC)
871 audio_pre_ff_rewind(); 754 audio_pre_ff_rewind();
872#else
873 if (!state->paused)
874 audio_pause();
875#endif
876 audio_ff_rewind(0); 755 audio_ff_rewind(0);
877 } 756 }
878 else 757 else
@@ -1128,13 +1007,8 @@ long gui_wps_show(void)
1128 } 1007 }
1129 1008
1130 if (exit) { 1009 if (exit) {
1131#if CONFIG_CODEC != SWCODEC
1132 if (global_settings.fade_on_stop)
1133 fade(false, true);
1134#else
1135 audio_pause(); 1010 audio_pause();
1136 update_non_static(); 1011 update_non_static();
1137#endif
1138 if (bookmark) 1012 if (bookmark)
1139 bookmark_autobookmark(true); 1013 bookmark_autobookmark(true);
1140 audio_stop(); 1014 audio_stop();
@@ -1200,11 +1074,9 @@ static void wps_state_init(void)
1200 /* add the WPS track event callbacks */ 1074 /* add the WPS track event callbacks */
1201 add_event(PLAYBACK_EVENT_TRACK_CHANGE, track_info_callback); 1075 add_event(PLAYBACK_EVENT_TRACK_CHANGE, track_info_callback);
1202 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, track_info_callback); 1076 add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, track_info_callback);
1203#if CONFIG_CODEC == SWCODEC
1204 /* Use the same callback as ..._TRACK_CHANGE for when remaining handles have 1077 /* Use the same callback as ..._TRACK_CHANGE for when remaining handles have
1205 finished */ 1078 finished */
1206 add_event(PLAYBACK_EVENT_CUR_TRACK_READY, track_info_callback); 1079 add_event(PLAYBACK_EVENT_CUR_TRACK_READY, track_info_callback);
1207#endif
1208#ifdef AUDIO_FAST_SKIP_PREVIEW 1080#ifdef AUDIO_FAST_SKIP_PREVIEW
1209 add_event(PLAYBACK_EVENT_TRACK_SKIP, track_info_callback); 1081 add_event(PLAYBACK_EVENT_TRACK_SKIP, track_info_callback);
1210#endif 1082#endif
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 11770606a1..fbd49c233d 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -5368,23 +5368,6 @@
5368 </voice> 5368 </voice>
5369</phrase> 5369</phrase>
5370<phrase> 5370<phrase>
5371 id: LANG_RECORDING_QUALITY
5372 desc: in the recording settings
5373 user: core
5374 <source>
5375 *: none
5376 recording_hwcodec: "Quality"
5377 </source>
5378 <dest>
5379 *: none
5380 recording_hwcodec: "Quality"
5381 </dest>
5382 <voice>
5383 *: none
5384 recording_hwcodec: "Quality"
5385 </voice>
5386</phrase>
5387<phrase>
5388 id: LANG_FREQUENCY 5371 id: LANG_FREQUENCY
5389 desc: in recording and playback settings 5372 desc: in recording and playback settings
5390 user: core 5373 user: core
@@ -5490,23 +5473,6 @@
5490 </voice> 5473 </voice>
5491</phrase> 5474</phrase>
5492<phrase> 5475<phrase>
5493 id: LANG_RECORDING_EDITABLE
5494 desc: Editable recordings setting
5495 user: core
5496 <source>
5497 *: none
5498 recording_hwcodec: "Independent Frames"
5499 </source>
5500 <dest>
5501 *: none
5502 recording_hwcodec: "Independent Frames"
5503 </dest>
5504 <voice>
5505 *: none
5506 recording_hwcodec: "Independent Frames"
5507 </voice>
5508</phrase>
5509<phrase>
5510 id: LANG_RECORD_TIMESPLIT 5476 id: LANG_RECORD_TIMESPLIT
5511 desc: Record split menu 5477 desc: Record split menu
5512 user: core 5478 user: core
@@ -9464,23 +9430,6 @@
9464 </voice> 9430 </voice>
9465</phrase> 9431</phrase>
9466<phrase> 9432<phrase>
9467 id: LANG_SYSFONT_RECORDING_QUALITY
9468 desc: in the recording settings
9469 user: core
9470 <source>
9471 *: none
9472 recording_hwcodec: "Quality"
9473 </source>
9474 <dest>
9475 *: none
9476 recording_hwcodec: "Quality"
9477 </dest>
9478 <voice>
9479 *: none
9480 recording_hwcodec: "Quality"
9481 </voice>
9482</phrase>
9483<phrase>
9484 id: LANG_SYSFONT_RECORDING_FREQUENCY 9433 id: LANG_SYSFONT_RECORDING_FREQUENCY
9485 desc: in the recording settings 9434 desc: in the recording settings
9486 user: core 9435 user: core
diff --git a/apps/main.c b/apps/main.c
index fe15675c69..4f468fa65b 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -45,7 +45,6 @@
45#include "serial.h" 45#include "serial.h"
46#endif 46#endif
47#include "audio.h" 47#include "audio.h"
48#include "mp3_playback.h"
49#include "settings.h" 48#include "settings.h"
50#include "backlight.h" 49#include "backlight.h"
51#include "status.h" 50#include "status.h"
@@ -87,12 +86,10 @@
87#include "iap.h" 86#include "iap.h"
88#endif 87#endif
89 88
90#if (CONFIG_CODEC == SWCODEC)
91#include "audio_thread.h" 89#include "audio_thread.h"
92#include "playback.h" 90#include "playback.h"
93#include "tdspeed.h" 91#include "tdspeed.h"
94#endif 92#if defined(HAVE_RECORDING) && !defined(SIMULATOR)
95#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && !defined(SIMULATOR)
96#include "pcm_record.h" 93#include "pcm_record.h"
97#endif 94#endif
98 95
@@ -258,7 +255,7 @@ static void init_tagcache(void) INIT_ATTR;
258static void init_tagcache(void) 255static void init_tagcache(void)
259{ 256{
260 bool clear = false; 257 bool clear = false;
261#if 0 /* CONFIG_CODEC == SWCODEC */ 258#if 0
262 long talked_tick = 0; 259 long talked_tick = 0;
263#endif 260#endif
264 tagcache_init(); 261 tagcache_init();
@@ -269,7 +266,7 @@ static void init_tagcache(void)
269 266
270 if (ret > 0) 267 if (ret > 0)
271 { 268 {
272#if 0 /* FIXME: Audio isn't even initialized yet! */ /* CONFIG_CODEC == SWCODEC */ 269#if 0 /* FIXME: Audio isn't even initialized yet! */
273 /* hwcodec can't use voice here, as the database commit 270 /* hwcodec can't use voice here, as the database commit
274 * uses the audio buffer. */ 271 * uses the audio buffer. */
275 if(global_settings.talk_menu 272 if(global_settings.talk_menu
@@ -365,10 +362,8 @@ static void init(void)
365 viewportmanager_init(); 362 viewportmanager_init();
366 363
367 storage_init(); 364 storage_init();
368#if CONFIG_CODEC == SWCODEC
369 pcm_init(); 365 pcm_init();
370 dsp_init(); 366 dsp_init();
371#endif
372 settings_reset(); 367 settings_reset();
373 settings_load(SETTINGS_ALL); 368 settings_load(SETTINGS_ALL);
374 settings_apply(true); 369 settings_apply(true);
@@ -384,23 +379,6 @@ static void init(void)
384 playlist_init(); 379 playlist_init();
385 shortcuts_init(); 380 shortcuts_init();
386 381
387#if CONFIG_CODEC != SWCODEC
388 mp3_init( global_settings.volume,
389 global_settings.bass,
390 global_settings.treble,
391 global_settings.balance,
392 global_settings.loudness,
393 global_settings.avc,
394 global_settings.channel_config,
395 global_settings.stereo_width,
396 global_settings.mdb_strength,
397 global_settings.mdb_harmonics,
398 global_settings.mdb_center,
399 global_settings.mdb_shape,
400 global_settings.mdb_enable,
401 global_settings.superbass);
402#endif /* CONFIG_CODEC != SWCODEC */
403
404 if (global_settings.audioscrobbler) 382 if (global_settings.audioscrobbler)
405 scrobbler_init(); 383 scrobbler_init();
406 384
@@ -599,10 +577,8 @@ static void init(void)
599 } 577 }
600 } 578 }
601 579
602#if CONFIG_CODEC == SWCODEC
603 pcm_init(); 580 pcm_init();
604 dsp_init(); 581 dsp_init();
605#endif
606 582
607#if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD) || \ 583#if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD) || \
608 (CONFIG_KEYPAD == IRIVER_H10_PAD) 584 (CONFIG_KEYPAD == IRIVER_H10_PAD)
@@ -669,25 +645,6 @@ static void init(void)
669 645
670 shortcuts_init(); 646 shortcuts_init();
671 647
672#if CONFIG_CODEC != SWCODEC
673 /* No buffer allocation (see buffer.c) may take place after the call to
674 audio_init() since the mpeg thread takes the rest of the buffer space */
675 mp3_init( global_settings.volume,
676 global_settings.bass,
677 global_settings.treble,
678 global_settings.balance,
679 global_settings.loudness,
680 global_settings.avc,
681 global_settings.channel_config,
682 global_settings.stereo_width,
683 global_settings.mdb_strength,
684 global_settings.mdb_harmonics,
685 global_settings.mdb_center,
686 global_settings.mdb_shape,
687 global_settings.mdb_enable,
688 global_settings.superbass);
689#endif /* CONFIG_CODEC != SWCODEC */
690
691 CHART(">audio_init"); 648 CHART(">audio_init");
692 audio_init(); 649 audio_init();
693 CHART("<audio_init"); 650 CHART("<audio_init");
diff --git a/apps/menu.c b/apps/menu.c
index 97af181267..49e6c58b2b 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -391,9 +391,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
391 { 391 {
392 int new_audio_status; 392 int new_audio_status;
393 redraw_lists = false; 393 redraw_lists = false;
394#if CONFIG_CODEC == SWCODEC
395 keyclick_set_callback(gui_synclist_keyclick_callback, &lists); 394 keyclick_set_callback(gui_synclist_keyclick_callback, &lists);
396#endif
397 action = get_action(CONTEXT_MAINMENU, 395 action = get_action(CONTEXT_MAINMENU,
398 list_do_action_timeout(&lists, HZ)); 396 list_do_action_timeout(&lists, HZ));
399 397
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c
index b41e4b0981..683025629b 100644
--- a/apps/menus/eq_menu.c
+++ b/apps/menus/eq_menu.c
@@ -30,7 +30,6 @@
30#include "list.h" 30#include "list.h"
31#include "menu.h" 31#include "menu.h"
32#include "action.h" 32#include "action.h"
33#include "mp3_playback.h"
34#include "settings.h" 33#include "settings.h"
35#include "screens.h" 34#include "screens.h"
36#include "icons.h" 35#include "icons.h"
diff --git a/apps/menus/menu_common.c b/apps/menus/menu_common.c
index 2ef48cc23b..1fa8ba3af2 100644
--- a/apps/menus/menu_common.c
+++ b/apps/menus/menu_common.c
@@ -25,11 +25,8 @@
25#include "action.h" 25#include "action.h"
26#include "menu.h" 26#include "menu.h"
27#include "menu_common.h" 27#include "menu_common.h"
28#if CONFIG_CODEC == SWCODEC
29#include "pcmbuf.h" 28#include "pcmbuf.h"
30#endif
31 29
32#if CONFIG_CODEC == SWCODEC
33/* Use this callback if your menu adjusts DSP settings. */ 30/* Use this callback if your menu adjusts DSP settings. */
34int lowlatency_callback(int action, 31int lowlatency_callback(int action,
35 const struct menu_item_ex *this_item, 32 const struct menu_item_ex *this_item,
@@ -48,5 +45,3 @@ int lowlatency_callback(int action,
48 } 45 }
49 return action; 46 return action;
50} 47}
51#endif
52
diff --git a/apps/menus/menu_common.h b/apps/menus/menu_common.h
index e85ed8dc61..5a28c3f03c 100644
--- a/apps/menus/menu_common.h
+++ b/apps/menus/menu_common.h
@@ -24,11 +24,9 @@
24#include "menu.h" 24#include "menu.h"
25#include "config.h" 25#include "config.h"
26 26
27#if CONFIG_CODEC == SWCODEC
28int lowlatency_callback(int action, 27int lowlatency_callback(int action,
29 const struct menu_item_ex *this_item, 28 const struct menu_item_ex *this_item,
30 struct gui_synclist *this_list); 29 struct gui_synclist *this_list);
31#endif
32 30
33#endif /* _MENU_COMMON_H */ 31#endif /* _MENU_COMMON_H */
34 32
diff --git a/apps/menus/playback_menu.c b/apps/menus/playback_menu.c
index bf770c0f11..41c738725c 100644
--- a/apps/menus/playback_menu.c
+++ b/apps/menus/playback_menu.c
@@ -35,16 +35,13 @@
35#include "audio.h" 35#include "audio.h"
36#include "cuesheet.h" 36#include "cuesheet.h"
37#include "misc.h" 37#include "misc.h"
38#if CONFIG_CODEC == SWCODEC
39#include "playback.h" 38#include "playback.h"
40#include "pcm_sampr.h" 39#include "pcm_sampr.h"
41#ifdef HAVE_PLAY_FREQ 40#ifdef HAVE_PLAY_FREQ
42#include "talk.h" 41#include "talk.h"
43#endif 42#endif
44#endif
45
46 43
47#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_CROSSFADE) 44#if defined(HAVE_CROSSFADE)
48static int setcrossfadeonexit_callback(int action, 45static int setcrossfadeonexit_callback(int action,
49 const struct menu_item_ex *this_item, 46 const struct menu_item_ex *this_item,
50 struct gui_synclist *this_list) 47 struct gui_synclist *this_list)
@@ -60,7 +57,7 @@ static int setcrossfadeonexit_callback(int action,
60 return action; 57 return action;
61} 58}
62 59
63#endif /* CONFIG_CODEC == SWCODEC */ 60#endif /* HAVE_CROSSFADE */
64 61
65/***********************************/ 62/***********************************/
66/* PLAYBACK MENU */ 63/* PLAYBACK MENU */
@@ -77,7 +74,6 @@ MENUITEM_SETTING(ff_rewind_min_step, &global_settings.ff_rewind_min_step, NULL);
77MAKE_MENU(ff_rewind_settings_menu, ID2P(LANG_WIND_MENU), 0, Icon_NOICON, 74MAKE_MENU(ff_rewind_settings_menu, ID2P(LANG_WIND_MENU), 0, Icon_NOICON,
78 &ff_rewind_min_step, &ff_rewind_accel); 75 &ff_rewind_min_step, &ff_rewind_accel);
79#ifdef HAVE_DISK_STORAGE 76#ifdef HAVE_DISK_STORAGE
80#if CONFIG_CODEC == SWCODEC
81static int buffermargin_callback(int action, 77static int buffermargin_callback(int action,
82 const struct menu_item_ex *this_item, 78 const struct menu_item_ex *this_item,
83 struct gui_synclist *this_list) 79 struct gui_synclist *this_list)
@@ -92,16 +88,12 @@ static int buffermargin_callback(int action,
92 } 88 }
93 return action; 89 return action;
94} 90}
95#else
96# define buffermargin_callback NULL
97#endif
98MENUITEM_SETTING(buffer_margin, &global_settings.buffer_margin, 91MENUITEM_SETTING(buffer_margin, &global_settings.buffer_margin,
99 buffermargin_callback); 92 buffermargin_callback);
100#endif /*HAVE_DISK_STORAGE */ 93#endif /*HAVE_DISK_STORAGE */
101MENUITEM_SETTING(fade_on_stop, &global_settings.fade_on_stop, NULL); 94MENUITEM_SETTING(fade_on_stop, &global_settings.fade_on_stop, NULL);
102MENUITEM_SETTING(party_mode, &global_settings.party_mode, NULL); 95MENUITEM_SETTING(party_mode, &global_settings.party_mode, NULL);
103 96
104#if CONFIG_CODEC == SWCODEC
105#ifdef HAVE_CROSSFADE 97#ifdef HAVE_CROSSFADE
106/* crossfade submenu */ 98/* crossfade submenu */
107MENUITEM_SETTING(crossfade, &global_settings.crossfade, setcrossfadeonexit_callback); 99MENUITEM_SETTING(crossfade, &global_settings.crossfade, setcrossfadeonexit_callback);
@@ -150,7 +142,6 @@ MAKE_MENU(replaygain_settings_menu,ID2P(LANG_REPLAYGAIN),0, Icon_NOICON,
150 &replaygain_type, &replaygain_noclip, &replaygain_preamp); 142 &replaygain_type, &replaygain_noclip, &replaygain_preamp);
151 143
152MENUITEM_SETTING(beep, &global_settings.beep ,NULL); 144MENUITEM_SETTING(beep, &global_settings.beep ,NULL);
153#endif /* CONFIG_CODEC == SWCODEC */
154 145
155#ifdef HAVE_SPDIF_POWER 146#ifdef HAVE_SPDIF_POWER
156MENUITEM_SETTING(spdif_enable, &global_settings.spdif_enable, NULL); 147MENUITEM_SETTING(spdif_enable, &global_settings.spdif_enable, NULL);
@@ -188,13 +179,7 @@ static int cuesheet_callback(int action,
188 switch (action) 179 switch (action)
189 { 180 {
190 case ACTION_EXIT_MENUITEM: /* on exit */ 181 case ACTION_EXIT_MENUITEM: /* on exit */
191#if CONFIG_CODEC == SWCODEC
192 audio_set_cuesheet(global_settings.cuesheet); 182 audio_set_cuesheet(global_settings.cuesheet);
193#else
194 if (global_settings.cuesheet)
195 splash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
196 break;
197#endif
198 } 183 }
199 return action; 184 return action;
200} 185}
@@ -209,9 +194,7 @@ MAKE_MENU(unplug_menu, ID2P(LANG_HEADPHONE_UNPLUG), 0, Icon_NOICON,
209 194
210MENUITEM_SETTING(skip_length, &global_settings.skip_length, NULL); 195MENUITEM_SETTING(skip_length, &global_settings.skip_length, NULL);
211MENUITEM_SETTING(prevent_skip, &global_settings.prevent_skip, NULL); 196MENUITEM_SETTING(prevent_skip, &global_settings.prevent_skip, NULL);
212#if CONFIG_CODEC == SWCODEC
213MENUITEM_SETTING(resume_rewind, &global_settings.resume_rewind, NULL); 197MENUITEM_SETTING(resume_rewind, &global_settings.resume_rewind, NULL);
214#endif
215MENUITEM_SETTING(pause_rewind, &global_settings.pause_rewind, NULL); 198MENUITEM_SETTING(pause_rewind, &global_settings.pause_rewind, NULL);
216#ifdef HAVE_PLAY_FREQ 199#ifdef HAVE_PLAY_FREQ
217MENUITEM_SETTING(play_frequency, &global_settings.play_frequency, 200MENUITEM_SETTING(play_frequency, &global_settings.play_frequency,
@@ -227,13 +210,11 @@ MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0,
227#endif 210#endif
228 &fade_on_stop, &party_mode, 211 &fade_on_stop, &party_mode,
229 212
230#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_CROSSFADE) 213#if defined(HAVE_CROSSFADE)
231 &crossfade_settings_menu, 214 &crossfade_settings_menu,
232#endif 215#endif
233 216
234#if CONFIG_CODEC == SWCODEC
235 &replaygain_settings_menu, &beep, 217 &replaygain_settings_menu, &beep,
236#endif
237 218
238#ifdef HAVE_SPDIF_POWER 219#ifdef HAVE_SPDIF_POWER
239 &spdif_enable, 220 &spdif_enable,
@@ -244,9 +225,7 @@ MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0,
244#endif 225#endif
245 ,&skip_length, &prevent_skip 226 ,&skip_length, &prevent_skip
246 227
247#if CONFIG_CODEC == SWCODEC
248 ,&resume_rewind 228 ,&resume_rewind
249#endif
250 ,&pause_rewind 229 ,&pause_rewind
251#ifdef HAVE_PLAY_FREQ 230#ifdef HAVE_PLAY_FREQ
252 ,&play_frequency 231 ,&play_frequency
diff --git a/apps/menus/radio_menu.c b/apps/menus/radio_menu.c
index 8871421c11..a6d259a21d 100644
--- a/apps/menus/radio_menu.c
+++ b/apps/menus/radio_menu.c
@@ -34,7 +34,7 @@
34#ifdef HAVE_RECORDING 34#ifdef HAVE_RECORDING
35#include "recording.h" /* recording_screen() */ 35#include "recording.h" /* recording_screen() */
36 36
37#if defined(HAVE_FMRADIO_REC) && CONFIG_CODEC == SWCODEC 37#if defined(HAVE_FMRADIO_REC)
38#define FM_RECORDING_SCREEN 38#define FM_RECORDING_SCREEN
39static int fm_recording_screen(void) 39static int fm_recording_screen(void)
40{ 40{
@@ -53,30 +53,20 @@ static int fm_recording_screen(void)
53 53
54MENUITEM_FUNCTION(recscreen_item, 0, ID2P(LANG_RECORDING), 54MENUITEM_FUNCTION(recscreen_item, 0, ID2P(LANG_RECORDING),
55 fm_recording_screen, NULL, NULL, Icon_Recording); 55 fm_recording_screen, NULL, NULL, Icon_Recording);
56#endif /* defined(HAVE_FMRADIO_REC) && CONFIG_CODEC == SWCODEC */ 56#endif /* defined(HAVE_FMRADIO_REC) */
57 57
58#if defined(HAVE_FMRADIO_REC) || CONFIG_CODEC != SWCODEC 58#if defined(HAVE_FMRADIO_REC)
59#define FM_RECORDING_SETTINGS 59#define FM_RECORDING_SETTINGS
60static int fm_recording_settings(void) 60static int fm_recording_settings(void)
61{ 61{
62 int ret = recording_menu(true); 62 int ret = recording_menu(true);
63 63
64#if CONFIG_CODEC != SWCODEC
65 if (!ret)
66 {
67 struct audio_recording_options rec_options;
68 rec_init_recording_options(&rec_options);
69 rec_options.rec_source = AUDIO_SRC_LINEIN;
70 rec_set_recording_options(&rec_options);
71 }
72#endif
73
74 return ret; 64 return ret;
75} 65}
76 66
77MENUITEM_FUNCTION(recsettings_item, 0, ID2P(LANG_RECORDING_SETTINGS), 67MENUITEM_FUNCTION(recsettings_item, 0, ID2P(LANG_RECORDING_SETTINGS),
78 fm_recording_settings, NULL, NULL, Icon_Recording); 68 fm_recording_settings, NULL, NULL, Icon_Recording);
79#endif /* defined(HAVE_FMRADIO_REC) || CONFIG_CODEC != SWCODEC */ 69#endif /* defined(HAVE_FMRADIO_REC) */
80#endif /* HAVE_RECORDING */ 70#endif /* HAVE_RECORDING */
81 71
82#ifndef FM_PRESET 72#ifndef FM_PRESET
diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c
index 0f24420a63..c841de4e89 100644
--- a/apps/menus/recording_menu.c
+++ b/apps/menus/recording_menu.c
@@ -29,7 +29,6 @@
29#include "lcd.h" 29#include "lcd.h"
30#include "menu.h" 30#include "menu.h"
31#include "button.h" 31#include "button.h"
32#include "mp3_playback.h"
33#include "settings.h" 32#include "settings.h"
34#include "screens.h" 33#include "screens.h"
35#include "icons.h" 34#include "icons.h"
@@ -51,14 +50,12 @@
51#include "peakmeter.h" 50#include "peakmeter.h"
52#endif 51#endif
53#include "splash.h" 52#include "splash.h"
54#if CONFIG_CODEC == SWCODEC
55#include "metadata.h" 53#include "metadata.h"
56#include "menus/eq_menu.h" 54#include "menus/eq_menu.h"
57#ifdef HAVE_RECORDING 55#ifdef HAVE_RECORDING
58#include "enc_config.h" 56#include "enc_config.h"
59#endif 57#endif
60#include "general.h" 58#include "general.h"
61#endif
62#include "action.h" 59#include "action.h"
63#include "recording.h" 60#include "recording.h"
64#include "sound_menu.h" 61#include "sound_menu.h"
@@ -101,7 +98,6 @@ static int recsource_func(void)
101MENUITEM_FUNCTION(recsource, 0, ID2P(LANG_RECORDING_SOURCE), 98MENUITEM_FUNCTION(recsource, 0, ID2P(LANG_RECORDING_SOURCE),
102 recsource_func, NULL, recmenu_callback, Icon_Menu_setting); 99 recsource_func, NULL, recmenu_callback, Icon_Menu_setting);
103 100
104#if CONFIG_CODEC == SWCODEC
105/* Makes an options list from a source list of options and indexes */ 101/* Makes an options list from a source list of options and indexes */
106static void make_options_from_indexes(const struct opt_items *src_names, 102static void make_options_from_indexes(const struct opt_items *src_names,
107 const long *src_indexes, 103 const long *src_indexes,
@@ -112,12 +108,8 @@ static void make_options_from_indexes(const struct opt_items *src_names,
112 dst_names[n_indexes] = src_names[src_indexes[n_indexes]]; 108 dst_names[n_indexes] = src_names[src_indexes[n_indexes]];
113} /* make_options_from_indexes */ 109} /* make_options_from_indexes */
114 110
115
116#endif /* CONFIG_CODEC == SWCODEC */
117
118static int recfrequency_func(void) 111static int recfrequency_func(void)
119{ 112{
120#if CONFIG_CODEC == SWCODEC
121 static const struct opt_items names[REC_NUM_FREQ] = { 113 static const struct opt_items names[REC_NUM_FREQ] = {
122 REC_HAVE_96_([REC_FREQ_96] = { "96kHz", TALK_ID(96, UNIT_KHZ) },) 114 REC_HAVE_96_([REC_FREQ_96] = { "96kHz", TALK_ID(96, UNIT_KHZ) },)
123 REC_HAVE_88_([REC_FREQ_88] = { "88.2kHz", TALK_ID(88, UNIT_KHZ) },) 115 REC_HAVE_88_([REC_FREQ_88] = { "88.2kHz", TALK_ID(88, UNIT_KHZ) },)
@@ -195,7 +187,6 @@ static int recfrequency_func(void)
195 } 187 }
196 188
197 return ret; 189 return ret;
198#endif /* CONFIG_CODEC == SWCODEC */
199} /* recfrequency */ 190} /* recfrequency */
200MENUITEM_FUNCTION(recfrequency, 0, ID2P(LANG_FREQUENCY), 191MENUITEM_FUNCTION(recfrequency, 0, ID2P(LANG_FREQUENCY),
201 recfrequency_func, NULL, NULL, Icon_Menu_setting); 192 recfrequency_func, NULL, NULL, Icon_Menu_setting);
@@ -208,7 +199,6 @@ static int recchannels_func(void)
208 [CHN_MODE_MONO] = { STR(LANG_CHANNEL_MONO) } 199 [CHN_MODE_MONO] = { STR(LANG_CHANNEL_MONO) }
209 }; 200 };
210 201
211#if CONFIG_CODEC == SWCODEC
212 struct opt_items opts[CHN_NUM_MODES]; 202 struct opt_items opts[CHN_NUM_MODES];
213 long table[CHN_NUM_MODES]; 203 long table[CHN_NUM_MODES];
214 struct encoder_caps caps; 204 struct encoder_caps caps;
@@ -238,13 +228,10 @@ static int recchannels_func(void)
238 global_settings.rec_channels = table[rec_channels]; 228 global_settings.rec_channels = table[rec_channels];
239 229
240 return ret; 230 return ret;
241#endif /* CONFIG_CODEC == SWCODEC */
242} 231}
243MENUITEM_FUNCTION(recchannels, 0, ID2P(LANG_CHANNELS), 232MENUITEM_FUNCTION(recchannels, 0, ID2P(LANG_CHANNELS),
244 recchannels_func, NULL, NULL, Icon_Menu_setting); 233 recchannels_func, NULL, NULL, Icon_Menu_setting);
245 234
246#if CONFIG_CODEC == SWCODEC
247
248static int recmonomode_func(void) 235static int recmonomode_func(void)
249{ 236{
250 static const struct opt_items names[3] = { 237 static const struct opt_items names[3] = {
@@ -293,9 +280,6 @@ MENUITEM_FUNCTION(enc_global_config_menu_item, 0, ID2P(LANG_ENCODER_SETTINGS),
293 enc_global_config_menu, 280 enc_global_config_menu,
294 NULL, NULL, Icon_Submenu); 281 NULL, NULL, Icon_Submenu);
295 282
296#endif /* CONFIG_CODEC == SWCODEC */
297
298
299static int recmenu_callback(int action, 283static int recmenu_callback(int action,
300 const struct menu_item_ex *this_item, 284 const struct menu_item_ex *this_item,
301 struct gui_synclist *this_list) 285 struct gui_synclist *this_list)
@@ -603,14 +587,10 @@ MENUITEM_FUNCTION(save_recpresets_item, 0, ID2P(LANG_SAVE_SETTINGS),
603 587
604MAKE_MENU(recording_settings_menu, ID2P(LANG_RECORDING_SETTINGS), 588MAKE_MENU(recording_settings_menu, ID2P(LANG_RECORDING_SETTINGS),
605 NULL, Icon_Recording, 589 NULL, Icon_Recording,
606#if CONFIG_CODEC == SWCODEC
607 &recformat, &enc_global_config_menu_item, 590 &recformat, &enc_global_config_menu_item,
608#endif
609 &recfrequency, &recsource, /* recsource not shown if no_source */ 591 &recfrequency, &recsource, /* recsource not shown if no_source */
610 &recchannels, 592 &recchannels,
611#if CONFIG_CODEC == SWCODEC
612 &recmonomode, 593 &recmonomode,
613#endif
614 &filesplitoptionsmenu, 594 &filesplitoptionsmenu,
615 &rec_prerecord_time, 595 &rec_prerecord_time,
616 &clear_rec_directory_item, 596 &clear_rec_directory_item,
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index 2957b0635c..e2b496a6f7 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -38,9 +38,7 @@
38#include "yesno.h" 38#include "yesno.h"
39#include "talk.h" 39#include "talk.h"
40#include "powermgmt.h" 40#include "powermgmt.h"
41#if CONFIG_CODEC == SWCODEC
42#include "playback.h" 41#include "playback.h"
43#endif
44#if CONFIG_RTC 42#if CONFIG_RTC
45#include "screens.h" 43#include "screens.h"
46#endif 44#endif
@@ -326,7 +324,6 @@ MAKE_MENU(limits_menu, ID2P(LANG_LIMITS_MENU), 0, Icon_NOICON,
326 324
327 325
328/* Keyclick menu */ 326/* Keyclick menu */
329#if CONFIG_CODEC == SWCODEC
330MENUITEM_SETTING(keyclick, &global_settings.keyclick, NULL); 327MENUITEM_SETTING(keyclick, &global_settings.keyclick, NULL);
331MENUITEM_SETTING(keyclick_repeats, &global_settings.keyclick_repeats, NULL); 328MENUITEM_SETTING(keyclick_repeats, &global_settings.keyclick_repeats, NULL);
332#ifdef HAVE_HARDWARE_CLICK 329#ifdef HAVE_HARDWARE_CLICK
@@ -337,7 +334,6 @@ MAKE_MENU(keyclick_menu, ID2P(LANG_KEYCLICK), 0, Icon_NOICON,
337MAKE_MENU(keyclick_menu, ID2P(LANG_KEYCLICK), 0, Icon_NOICON, 334MAKE_MENU(keyclick_menu, ID2P(LANG_KEYCLICK), 0, Icon_NOICON,
338 &keyclick, &keyclick_repeats); 335 &keyclick, &keyclick_repeats);
339#endif 336#endif
340#endif
341 337
342#if CONFIG_CHARGING 338#if CONFIG_CHARGING
343MENUITEM_SETTING(car_adapter_mode, &global_settings.car_adapter_mode, NULL); 339MENUITEM_SETTING(car_adapter_mode, &global_settings.car_adapter_mode, NULL);
@@ -437,9 +433,7 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
437#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS 433#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
438 &buttonlight_brightness, 434 &buttonlight_brightness,
439#endif 435#endif
440#if CONFIG_CODEC == SWCODEC
441 &keyclick_menu, 436 &keyclick_menu,
442#endif
443#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING 437#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
444 &touchpad_sensitivity, 438 &touchpad_sensitivity,
445#endif 439#endif
@@ -619,7 +613,6 @@ MAKE_MENU(bookmark_settings_menu, ID2P(LANG_BOOKMARK_SETTINGS), 0,
619/***********************************/ 613/***********************************/
620/* AUTORESUME MENU */ 614/* AUTORESUME MENU */
621#ifdef HAVE_TAGCACHE 615#ifdef HAVE_TAGCACHE
622#if CONFIG_CODEC == SWCODEC
623 616
624static int autoresume_callback(int action, 617static int autoresume_callback(int action,
625 const struct menu_item_ex *this_item, 618 const struct menu_item_ex *this_item,
@@ -674,7 +667,6 @@ MAKE_MENU(autoresume_menu, ID2P(LANG_AUTORESUME),
674 0, Icon_NOICON, 667 0, Icon_NOICON,
675 &autoresume_enable, &autoresume_automatic); 668 &autoresume_enable, &autoresume_automatic);
676 669
677#endif /* CONFIG_CODEC == SWCODEC */
678#endif /* HAVE_TAGCACHE */ 670#endif /* HAVE_TAGCACHE */
679/* AUTORESUME MENU */ 671/* AUTORESUME MENU */
680/***********************************/ 672/***********************************/
@@ -758,10 +750,8 @@ MAKE_MENU(settings_menu_item, ID2P(LANG_GENERAL_SETTINGS), 0,
758 &startup_shutdown_menu, 750 &startup_shutdown_menu,
759 &bookmark_settings_menu, 751 &bookmark_settings_menu,
760#ifdef HAVE_TAGCACHE 752#ifdef HAVE_TAGCACHE
761#if CONFIG_CODEC == SWCODEC
762 &autoresume_menu, 753 &autoresume_menu,
763#endif 754#endif
764#endif
765 &browse_langs, &voice_settings_menu, 755 &browse_langs, &voice_settings_menu,
766#ifdef HAVE_HOTKEY 756#ifdef HAVE_HOTKEY
767 &hotkey_menu, 757 &hotkey_menu,
diff --git a/apps/menus/sound_menu.c b/apps/menus/sound_menu.c
index ee966ac62a..174329fcc8 100644
--- a/apps/menus/sound_menu.c
+++ b/apps/menus/sound_menu.c
@@ -108,18 +108,10 @@ MENUITEM_SETTING(treble_cutoff, &global_settings.treble_cutoff, NULL);
108 108
109MENUITEM_SETTING(balance, &global_settings.balance, NULL); 109MENUITEM_SETTING(balance, &global_settings.balance, NULL);
110MENUITEM_SETTING(channel_config, &global_settings.channel_config, 110MENUITEM_SETTING(channel_config, &global_settings.channel_config,
111#if CONFIG_CODEC == SWCODEC
112 lowlatency_callback 111 lowlatency_callback
113#else
114 NULL
115#endif
116); 112);
117MENUITEM_SETTING(stereo_width, &global_settings.stereo_width, 113MENUITEM_SETTING(stereo_width, &global_settings.stereo_width,
118#if CONFIG_CODEC == SWCODEC
119 lowlatency_callback 114 lowlatency_callback
120#else
121 NULL
122#endif
123); 115);
124 116
125#ifdef AUDIOHW_HAVE_DEPTH_3D 117#ifdef AUDIOHW_HAVE_DEPTH_3D
@@ -134,7 +126,6 @@ MENUITEM_SETTING(roll_off, &global_settings.roll_off, NULL);
134MENUITEM_SETTING(func_mode, &global_settings.func_mode, NULL); 126MENUITEM_SETTING(func_mode, &global_settings.func_mode, NULL);
135#endif 127#endif
136 128
137#if CONFIG_CODEC == SWCODEC
138 /* Crossfeed Submenu */ 129 /* Crossfeed Submenu */
139 MENUITEM_SETTING(crossfeed, &global_settings.crossfeed, lowlatency_callback); 130 MENUITEM_SETTING(crossfeed, &global_settings.crossfeed, lowlatency_callback);
140 MENUITEM_SETTING(crossfeed_direct_gain, 131 MENUITEM_SETTING(crossfeed_direct_gain,
@@ -216,7 +207,6 @@ static int timestretch_callback(int action,
216 MAKE_MENU(compressor_menu,ID2P(LANG_COMPRESSOR), NULL, Icon_NOICON, 207 MAKE_MENU(compressor_menu,ID2P(LANG_COMPRESSOR), NULL, Icon_NOICON,
217 &compressor_threshold, &compressor_gain, &compressor_ratio, 208 &compressor_threshold, &compressor_gain, &compressor_ratio,
218 &compressor_knee, &compressor_attack, &compressor_release); 209 &compressor_knee, &compressor_attack, &compressor_release);
219#endif
220 210
221#ifdef HAVE_SPEAKER 211#ifdef HAVE_SPEAKER
222 MENUITEM_SETTING(speaker_mode, &global_settings.speaker_mode, NULL); 212 MENUITEM_SETTING(speaker_mode, &global_settings.speaker_mode, NULL);
@@ -253,14 +243,12 @@ MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, Icon_Audio,
253#ifdef AUDIOHW_HAVE_FUNCTIONAL_MODE 243#ifdef AUDIOHW_HAVE_FUNCTIONAL_MODE
254 ,&func_mode 244 ,&func_mode
255#endif 245#endif
256#if CONFIG_CODEC == SWCODEC
257 ,&crossfeed_menu, &equalizer_menu, &dithering_enabled 246 ,&crossfeed_menu, &equalizer_menu, &dithering_enabled
258 ,&surround_menu, &pbe_menu, &afr_enabled 247 ,&surround_menu, &pbe_menu, &afr_enabled
259#ifdef HAVE_PITCHCONTROL 248#ifdef HAVE_PITCHCONTROL
260 ,&timestretch_enabled 249 ,&timestretch_enabled
261#endif 250#endif
262 ,&compressor_menu 251 ,&compressor_menu
263#endif
264#ifdef HAVE_SPEAKER 252#ifdef HAVE_SPEAKER
265 ,&speaker_mode 253 ,&speaker_mode
266#endif 254#endif
diff --git a/apps/misc.c b/apps/misc.c
index 2e3292dba5..b20a0095ab 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -91,11 +91,7 @@
91#include "bookmark.h" 91#include "bookmark.h"
92#include "wps.h" 92#include "wps.h"
93#include "playback.h" 93#include "playback.h"
94#if CONFIG_CODEC == SWCODEC
95#include "voice_thread.h" 94#include "voice_thread.h"
96#else
97#include "mp3_playback.h"
98#endif
99 95
100#ifdef BOOTFILE 96#ifdef BOOTFILE
101#if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) \ 97#if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) \
@@ -302,7 +298,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
302#endif 298#endif
303 { 299 {
304 bool batt_safe = battery_level_safe(); 300 bool batt_safe = battery_level_safe();
305#if CONFIG_CODEC != SWCODEC || defined(HAVE_RECORDING) 301#if defined(HAVE_RECORDING)
306 int audio_stat = audio_status(); 302 int audio_stat = audio_status();
307#endif 303#endif
308 304
@@ -339,19 +335,12 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
339 splashf(0, "%s %s", str(LANG_WARNING_BATTERY_EMPTY), 335 splashf(0, "%s %s", str(LANG_WARNING_BATTERY_EMPTY),
340 str(LANG_SHUTTINGDOWN)); 336 str(LANG_SHUTTINGDOWN));
341 } 337 }
342#if CONFIG_CODEC != SWCODEC
343 if (global_settings.fade_on_stop
344 && (audio_stat & AUDIO_STATUS_PLAY))
345 {
346 fade(false, false);
347 }
348#endif
349 338
350#ifdef HAVE_DISK_STORAGE 339#ifdef HAVE_DISK_STORAGE
351 if (batt_safe) /* do not save on critical battery */ 340 if (batt_safe) /* do not save on critical battery */
352#endif 341#endif
353 { 342 {
354#if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC 343#if defined(HAVE_RECORDING)
355 if (audio_stat & AUDIO_STATUS_RECORD) 344 if (audio_stat & AUDIO_STATUS_RECORD)
356 { 345 {
357 rec_command(RECORDING_CMD_STOP); 346 rec_command(RECORDING_CMD_STOP);
@@ -368,13 +357,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
368 if (callback != NULL) 357 if (callback != NULL)
369 callback(parameter); 358 callback(parameter);
370 359
371#if CONFIG_CODEC != SWCODEC 360#if defined(HAVE_RECORDING)
372 /* wait for audio_stop or audio_stop_recording to complete */
373 while (audio_status())
374 sleep(1);
375#endif
376
377#if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
378 audio_close_recording(); 361 audio_close_recording();
379#endif 362#endif
380 scrobbler_shutdown(true); 363 scrobbler_shutdown(true);
@@ -403,9 +386,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
403 enqueue = true; 386 enqueue = true;
404 } 387 }
405 talk_id(LANG_SHUTTINGDOWN, enqueue); 388 talk_id(LANG_SHUTTINGDOWN, enqueue);
406#if CONFIG_CODEC == SWCODEC
407 voice_wait(); 389 voice_wait();
408#endif
409 } 390 }
410 391
411 shutdown_hw(); 392 shutdown_hw();
@@ -426,10 +407,6 @@ bool list_stop_handler(void)
426 { 407 {
427 if (!global_settings.party_mode) 408 if (!global_settings.party_mode)
428 { 409 {
429#if CONFIG_CODEC != SWCODEC
430 if (global_settings.fade_on_stop)
431 fade(false, false);
432#endif
433 bookmark_autobookmark(true); 410 bookmark_autobookmark(true);
434 audio_stop(); 411 audio_stop();
435 ret = true; /* bookmarking can make a refresh necessary */ 412 ret = true; /* bookmarking can make a refresh necessary */
@@ -894,7 +871,6 @@ char *strip_extension(char* buffer, int buffer_size, const char *filename)
894 return buffer; 871 return buffer;
895} 872}
896 873
897#if CONFIG_CODEC == SWCODEC
898/* Play a standard sound */ 874/* Play a standard sound */
899void system_sound_play(enum system_sound sound) 875void system_sound_play(enum system_sound sound)
900{ 876{
@@ -1046,7 +1022,6 @@ void replaygain_update(void)
1046 settings.type = replaygain_setting_mode(settings.type); 1022 settings.type = replaygain_setting_mode(settings.type);
1047 dsp_replaygain_set_settings(&settings); 1023 dsp_replaygain_set_settings(&settings);
1048} 1024}
1049#endif /* CONFIG_CODEC == SWCODEC */
1050 1025
1051/* format a sound value like: -1.05 dB */ 1026/* format a sound value like: -1.05 dB */
1052int format_sound_value(char *buf, size_t size, int snd, int val) 1027int format_sound_value(char *buf, size_t size, int snd, int val)
diff --git a/apps/misc.h b/apps/misc.h
index 8d72e79a3d..10626dfaf4 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -181,7 +181,6 @@ enum current_activity {
181 ACTIVITY_USBSCREEN 181 ACTIVITY_USBSCREEN
182}; 182};
183 183
184#if CONFIG_CODEC == SWCODEC
185void beep_play(unsigned int frequency, unsigned int duration, 184void beep_play(unsigned int frequency, unsigned int duration,
186 unsigned int amplitude); 185 unsigned int amplitude);
187 186
@@ -209,9 +208,6 @@ void keyclick_click(bool rawbutton, int action);
209struct mp3entry; 208struct mp3entry;
210int id3_get_replaygain_mode(const struct mp3entry *id3); 209int id3_get_replaygain_mode(const struct mp3entry *id3);
211void replaygain_update(void); 210void replaygain_update(void);
212#else
213static inline void replaygain_update(void) {}
214#endif /* CONFIG_CODEC == SWCODEC */
215 211
216void push_current_activity(enum current_activity screen); 212void push_current_activity(enum current_activity screen);
217void pop_current_activity(void); 213void pop_current_activity(void);
diff --git a/apps/mpeg.c b/apps/mpeg.c
deleted file mode 100644
index e04c227cb1..0000000000
--- a/apps/mpeg.c
+++ /dev/null
@@ -1,1979 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <stdbool.h>
22#include <stdlib.h>
23#include "config.h"
24
25#if CONFIG_CODEC != SWCODEC
26
27#include "debug.h"
28#include "panic.h"
29#include "metadata.h"
30#include "mpeg.h"
31#include "audio.h"
32#include "storage.h"
33#include "string.h"
34#include <kernel.h>
35#include "thread.h"
36#include "errno.h"
37#include "mp3data.h"
38#include "core_alloc.h"
39#include "mp3_playback.h"
40#include "talk.h"
41#include "sound.h"
42#include "system.h"
43#include "appevents.h"
44#include "playlist.h"
45#include "cuesheet.h"
46#include "settings.h"
47#ifndef SIMULATOR
48#include "i2c.h"
49#include "system.h"
50#include "usb.h"
51#include "file.h"
52#include "hwcompat.h"
53#endif /* !SIMULATOR */
54#ifdef HAVE_LCD_BITMAP
55#include "lcd.h"
56#endif /* CONFIG_CODEC != SWCODEC */
57
58#define MPEG_SWAP_CHUNKSIZE 0x2000
59#define MPEG_HIGH_WATER 2 /* We leave 2 bytes empty because otherwise we
60 wouldn't be able to see the difference between
61 an empty buffer and a full one. */
62#define MPEG_LOW_WATER 0x60000
63#define MPEG_RECORDING_LOW_WATER 0x80000
64#define MPEG_LOW_WATER_CHUNKSIZE 0x40000
65#define MPEG_LOW_WATER_SWAP_CHUNKSIZE 0x10000
66#if (CONFIG_STORAGE & STORAGE_MMC)
67#define MPEG_PLAY_PENDING_THRESHOLD 0x20000
68#define MPEG_PLAY_PENDING_SWAPSIZE 0x20000
69#else
70#define MPEG_PLAY_PENDING_THRESHOLD 0x10000
71#define MPEG_PLAY_PENDING_SWAPSIZE 0x10000
72#endif
73
74#define MPEG_MAX_PRERECORD_SECONDS 30
75
76/* For ID3 info and VBR header */
77#define MPEG_RESERVED_HEADER_SPACE (4096 + 576)
78
79#ifndef SIMULATOR
80extern unsigned long mas_version_code;
81#endif
82
83#define MPEG_PLAY 1
84#define MPEG_STOP 2
85#define MPEG_PAUSE 3
86#define MPEG_RESUME 4
87#define MPEG_NEXT 5
88#define MPEG_PREV 6
89#define MPEG_FF_REWIND 7
90#define MPEG_FLUSH_RELOAD 8
91#define MPEG_RECORD 9
92#define MPEG_INIT_RECORDING 10
93#define MPEG_INIT_PLAYBACK 11
94#define MPEG_NEW_FILE 12
95#define MPEG_PAUSE_RECORDING 13
96#define MPEG_RESUME_RECORDING 14
97#define MPEG_NEED_DATA 100
98#define MPEG_TRACK_CHANGE 101
99#define MPEG_SAVE_DATA 102
100#define MPEG_STOP_DONE 103
101#define MPEG_PRERECORDING_TICK 104
102
103/* indicator for MPEG_NEED_DATA */
104#define GENERATE_UNBUFFER_EVENTS 1
105
106/* list of tracks in memory */
107#define MAX_TRACK_ENTRIES (1<<4) /* Must be power of 2 */
108#define MAX_TRACK_ENTRIES_MASK (MAX_TRACK_ENTRIES - 1)
109
110struct trackdata
111{
112 struct mp3entry id3;
113 int mempos;
114 int load_ahead_index;
115};
116
117static struct trackdata trackdata[MAX_TRACK_ENTRIES];
118
119static unsigned int current_track_counter = 0;
120
121#ifndef SIMULATOR
122static void stop_playing(void);
123
124static int track_read_idx = 0;
125static int track_write_idx = 0;
126#endif /* !SIMULATOR */
127
128/* Cuesheet support */
129static struct cuesheet *curr_cuesheet = NULL;
130static bool checked_for_cuesheet = false;
131
132static const char mpeg_thread_name[] = "mpeg";
133static unsigned int audio_thread_id;
134static bool audio_is_initialized;
135static unsigned int mpeg_errno;
136
137static bool playing = false; /* We are playing an MP3 stream */
138static bool is_playing = false; /* We are (attempting to) playing MP3 files */
139static bool paused; /* playback is paused */
140static int audiobuf_handle; /* handle to the audio buffer */
141static char* mpeg_audiobuf; /* poiunter to the audio buffer */
142static long audiobuflen; /* length of the audio buffer */
143#define AUDIO_BUFFER_RESERVE (256*1024)
144#ifdef SIMULATOR
145static char mpeg_stack[DEFAULT_STACK_SIZE];
146static struct mp3entry taginfo;
147#else /* !SIMULATOR */
148static struct event_queue mpeg_queue SHAREDBSS_ATTR;
149static long mpeg_stack[(DEFAULT_STACK_SIZE + 0x1000)/sizeof(long)];
150
151static int audiobuf_write;
152static int audiobuf_swapwrite;
153static long audiobuf_read;
154
155static int mpeg_file;
156
157static bool play_pending; /* We are about to start playing */
158static bool play_pending_track_change; /* When starting play we're starting a new file */
159static bool filling; /* We are filling the buffer with data from disk */
160static bool dma_underrun; /* True when the DMA has stopped because of
161 slow disk reading (read error, shaking) */
162static bool mpeg_stop_done;
163
164static int last_dma_tick = 0;
165static int last_dma_chunk_size;
166
167static long low_watermark; /* Dynamic low watermark level */
168static long low_watermark_margin = 0; /* Extra time in seconds for watermark */
169static long lowest_watermark_level; /* Debug value to observe the buffer
170 usage */
171
172struct audio_resume_info
173{
174 unsigned long elapsed;
175 unsigned long offset;
176};
177
178#ifdef HAVE_RECORDING
179static const unsigned char empty_id3_header[] =
180{
181 'I', 'D', '3', 0x03, 0x00, 0x00,
182 0x00, 0x00, 0x1f, 0x76 /* Size is 4096 minus 10 bytes for the header */
183};
184#endif /* HAVE_RECORDING */
185
186
187static int get_unplayed_space(void);
188static int get_playable_space(void);
189static int get_unswapped_space(void);
190#endif /* !SIMULATOR */
191
192static void audio_reset_buffer_noalloc(void* buf, size_t bufsize);
193static void audio_reset_buffer(void);
194
195
196#ifndef SIMULATOR
197static int num_tracks_in_memory(void)
198{
199 return (track_write_idx - track_read_idx) & MAX_TRACK_ENTRIES_MASK;
200}
201
202#ifdef DEBUG_TAGS
203static void debug_tags(void)
204{
205 int i;
206
207 for(i = 0;i < MAX_TRACK_ENTRIES;i++)
208 {
209 DEBUGF("%d - %s\n", i, trackdata[i].id3.path);
210 }
211 DEBUGF("read: %d, write :%d\n", track_read_idx, track_write_idx);
212 DEBUGF("num_tracks_in_memory: %d\n", num_tracks_in_memory());
213}
214#else /* !DEBUG_TAGS */
215#define debug_tags()
216#endif /* !DEBUG_TAGS */
217
218static void remove_current_tag(void)
219{
220 if(num_tracks_in_memory() > 0)
221 {
222 /* First move the index, so nobody tries to access the tag */
223 track_read_idx = (track_read_idx+1) & MAX_TRACK_ENTRIES_MASK;
224 checked_for_cuesheet = false;
225 debug_tags();
226 }
227 else
228 {
229 DEBUGF("remove_current_tag: no tracks to remove\n");
230 }
231}
232
233static void remove_all_non_current_tags(void)
234{
235 track_write_idx = (track_read_idx+1) & MAX_TRACK_ENTRIES_MASK;
236 debug_tags();
237}
238
239static void remove_all_tags(void)
240{
241 track_write_idx = track_read_idx;
242
243 debug_tags();
244}
245
246static struct trackdata *get_trackdata(int offset)
247{
248 if(offset >= num_tracks_in_memory())
249 return NULL;
250 else
251 return &trackdata[(track_read_idx + offset) & MAX_TRACK_ENTRIES_MASK];
252}
253#endif /* !SIMULATOR */
254
255/***********************************************************************/
256/* audio event handling */
257
258#define MAX_EVENT_HANDLERS 10
259struct event_handlers_table
260{
261 AUDIO_EVENT_HANDLER handler;
262 unsigned short mask;
263};
264static struct event_handlers_table event_handlers[MAX_EVENT_HANDLERS];
265static int event_handlers_count = 0;
266
267void audio_register_event_handler(AUDIO_EVENT_HANDLER handler, unsigned short mask)
268{
269 if (event_handlers_count < MAX_EVENT_HANDLERS)
270 {
271 event_handlers[event_handlers_count].handler = handler;
272 event_handlers[event_handlers_count].mask = mask;
273 event_handlers_count++;
274 }
275}
276
277/* dispatch calls each handler in the order registered and returns after some
278 handler actually handles the event (the event is assumed to no longer be valid
279 after this, due to the handler changing some condition); returns true if someone
280 handled the event, which is expected to cause the caller to skip its own handling
281 of the event */
282#ifndef SIMULATOR
283static bool audio_dispatch_event(unsigned short event, unsigned long data)
284{
285 int i = 0;
286 for(i=0; i < event_handlers_count; i++)
287 {
288 if ( event_handlers[i].mask & event )
289 {
290 int rc = event_handlers[i].handler(event, data);
291 if ( rc == AUDIO_EVENT_RC_HANDLED )
292 return true;
293 }
294 }
295 return false;
296}
297
298static void send_track_event(unsigned int id, struct mp3entry *id3)
299{
300 struct mp3entry *cur_id3 =
301 &trackdata[track_read_idx & MAX_TRACK_ENTRIES_MASK].id3;
302 unsigned int flags = id3 == cur_id3 ? TEF_CURRENT : 0;
303 send_event(id, &(struct track_event){ .flags = flags, .id3 = id3 });
304}
305#endif /* SIMULATOR */
306
307/***********************************************************************/
308
309static void set_elapsed(struct mp3entry* id3)
310{
311 if ( id3->vbr ) {
312 if ( id3->has_toc ) {
313 /* calculate elapsed time using TOC */
314 int i;
315 unsigned int remainder, plen, relpos, nextpos;
316
317 /* find wich percent we're at */
318 for (i=0; i<100; i++ )
319 {
320 if ( id3->offset < id3->toc[i] * (id3->filesize / 256) )
321 {
322 break;
323 }
324 }
325
326 i--;
327 if (i < 0)
328 i = 0;
329
330 relpos = id3->toc[i];
331
332 if (i < 99)
333 {
334 nextpos = id3->toc[i+1];
335 }
336 else
337 {
338 nextpos = 256;
339 }
340
341 remainder = id3->offset - (relpos * (id3->filesize / 256));
342
343 /* set time for this percent (divide before multiply to prevent
344 overflow on long files. loss of precision is negligible on
345 short files) */
346 id3->elapsed = i * (id3->length / 100);
347
348 /* calculate remainder time */
349 plen = (nextpos - relpos) * (id3->filesize / 256);
350 id3->elapsed += (((remainder * 100) / plen) *
351 (id3->length / 10000));
352 }
353 else {
354 /* no TOC exists. set a rough estimate using average bitrate */
355 int tpk = id3->length / (id3->filesize / 1024);
356 id3->elapsed = id3->offset / 1024 * tpk;
357 }
358 }
359 else
360 /* constant bitrate, use exact calculation */
361 id3->elapsed = id3->offset / (id3->bitrate / 8);
362}
363
364static int audio_get_file_pos_int(struct mp3entry *id3)
365{
366 int pos = -1;
367
368 if (id3->vbr)
369 {
370 if (id3->has_toc)
371 {
372 /* Use the TOC to find the new position */
373 unsigned int percent, remainder;
374 int curtoc, nexttoc, plen;
375
376 percent = (id3->elapsed*100)/id3->length;
377 if (percent > 99)
378 percent = 99;
379
380 curtoc = id3->toc[percent];
381
382 if (percent < 99)
383 nexttoc = id3->toc[percent+1];
384 else
385 nexttoc = 256;
386
387 pos = (id3->filesize/256)*curtoc;
388
389 /* Use the remainder to get a more accurate position */
390 remainder = (id3->elapsed*100)%id3->length;
391 remainder = (remainder*100)/id3->length;
392 plen = (nexttoc - curtoc)*(id3->filesize/256);
393 pos += (plen/100)*remainder;
394 }
395 else
396 {
397 /* No TOC exists, estimate the new position */
398 pos = (id3->filesize / (id3->length / 1000)) *
399 (id3->elapsed / 1000);
400 }
401 }
402 else if (id3->bitrate)
403 pos = id3->elapsed * (id3->bitrate / 8);
404 else
405 {
406 return -1;
407 }
408
409 if (pos >= (int)(id3->filesize - id3->id3v1len))
410 {
411 /* Don't seek right to the end of the file so that we can
412 transition properly to the next song */
413 pos = id3->filesize - id3->id3v1len - 1;
414 }
415 else if (pos < (int)id3->first_frame_offset)
416 {
417 /* skip past id3v2 tag and other leading garbage */
418 pos = id3->first_frame_offset;
419 }
420 return pos;
421}
422
423int audio_get_file_pos(void)
424{
425 struct mp3entry *id3 = audio_current_track();
426 return id3 ? audio_get_file_pos_int(id3) : 0;
427}
428
429unsigned long mpeg_get_last_header(void)
430{
431#ifdef SIMULATOR
432 return 0;
433#else /* !SIMULATOR */
434 unsigned long tmp[2];
435
436 /* Read the frame data from the MAS and reconstruct it with the
437 frame sync and all */
438 mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_STATUS_1, tmp, 2);
439 return 0xffe00000 | ((tmp[0] & 0x7c00) << 6) | (tmp[1] & 0xffff);
440#endif /* !SIMULATOR */
441}
442
443static void do_stop(void)
444{
445 is_playing = false;
446 paused = false;
447
448#ifndef SIMULATOR
449 if (playing)
450 playlist_update_resume_info(audio_current_track());
451
452 stop_playing();
453 mpeg_stop_done = true;
454#else
455 playing = false;
456#endif
457}
458
459/* Buffer must not move. */
460static int shrink_callback(int handle, unsigned hints, void* start, size_t old_size)
461{
462 ssize_t extradata_size = old_size - audiobuflen;
463 /* check what buflib requests */
464 size_t wanted_size = (hints & BUFLIB_SHRINK_SIZE_MASK);
465 ssize_t size = (ssize_t)old_size - wanted_size;
466
467 /* keep at least 256K for the buffering */
468 if ((size - extradata_size) < AUDIO_BUFFER_RESERVE)
469 {
470 /* check if buflib needs the memory really hard. if yes we give
471 * up playback for now, otherwise refuse to shrink to keep at least
472 * 256K for the buffering */
473 if ((hints & BUFLIB_SHRINK_POS_MASK) != BUFLIB_SHRINK_POS_MASK)
474 return BUFLIB_CB_CANNOT_SHRINK;
475 }
476 /* TODO: Do it without stopping playback, if possible */
477 bool playing = (audio_status() & AUDIO_STATUS_PLAY) == AUDIO_STATUS_PLAY;
478 struct mp3entry *id3 = audio_current_track();
479 unsigned long elapsed = 0, offset = 0;
480 if (id3)
481 {
482 elapsed = id3->elapsed;
483 offset = id3->offset;
484 }
485 /* don't call audio_hard_stop() as it frees this handle */
486 if (thread_self() == audio_thread_id)
487 { /* inline case MPEG_STOP (audio_stop()) response
488 * if we're in the audio thread since audio_stop() otherwise deadlocks */
489 do_stop();
490 }
491 else
492 audio_stop();
493
494 switch (hints & BUFLIB_SHRINK_POS_MASK)
495 {
496 case BUFLIB_SHRINK_POS_BACK:
497 core_shrink(handle, start, size);
498 audio_reset_buffer_noalloc(start, size);
499 break;
500 case BUFLIB_SHRINK_POS_FRONT:
501 core_shrink(handle, start + wanted_size, size);
502 audio_reset_buffer_noalloc(start + wanted_size, size);
503 break;
504 case BUFLIB_SHRINK_POS_MASK:
505 audiobuf_handle = core_free(audiobuf_handle);
506 mpeg_audiobuf = NULL;
507 talk_buffer_set_policy(TALK_BUFFER_DEFAULT);
508 playing = false;
509 break;
510 }
511 if (playing)
512 { /* safe to call even from the audio thread (due to queue_post()) */
513 audio_play(elapsed, offset);
514 }
515
516 return BUFLIB_CB_OK;
517}
518
519static struct buflib_callbacks ops = {
520 .move_callback = NULL,
521 .shrink_callback = shrink_callback,
522};
523
524#ifndef SIMULATOR
525/* Send callback events to notify about removing old tracks. */
526static void generate_unbuffer_events(void)
527{
528 int i;
529 int numentries = MAX_TRACK_ENTRIES - num_tracks_in_memory();
530 int cur_idx = track_write_idx;
531
532 for (i = 0; i < numentries; i++)
533 {
534 /* Send an event to notify that track has finished. */
535 send_track_event(PLAYBACK_EVENT_TRACK_FINISH, &trackdata[cur_idx].id3);
536 cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;
537 }
538}
539
540/* Send callback events to notify about new tracks. */
541static void generate_postbuffer_events(void)
542{
543 int i;
544 int numentries = num_tracks_in_memory();
545 int cur_idx = track_read_idx;
546
547 for (i = 0; i < numentries; i++)
548 {
549 send_track_event(PLAYBACK_EVENT_TRACK_BUFFER, &trackdata[cur_idx].id3);
550 cur_idx = (cur_idx + 1) & MAX_TRACK_ENTRIES_MASK;
551 }
552}
553
554static void recalculate_watermark(int bitrate)
555{
556 int bytes_per_sec;
557 int time = storage_spinup_time();
558
559 /* A bitrate of 0 probably means empty VBR header. We play safe
560 and set a high threshold */
561 if(bitrate == 0)
562 bitrate = 320;
563
564 bytes_per_sec = bitrate * 1000 / 8;
565
566 if(time)
567 {
568 /* No drive spins up faster than 3.5s */
569 if(time < 350)
570 time = 350;
571
572 time = time * 3;
573 low_watermark = ((low_watermark_margin * HZ + time) *
574 bytes_per_sec) / HZ;
575 }
576 else
577 {
578 low_watermark = MPEG_LOW_WATER;
579 }
580}
581
582#ifdef HAVE_DISK_STORAGE
583void audio_set_buffer_margin(int setting)
584{
585 low_watermark_margin = setting; /* in seconds */
586}
587#endif
588
589void audio_get_debugdata(struct audio_debug *dbgdata)
590{
591 dbgdata->audiobuflen = audiobuflen;
592 dbgdata->audiobuf_write = audiobuf_write;
593 dbgdata->audiobuf_swapwrite = audiobuf_swapwrite;
594 dbgdata->audiobuf_read = audiobuf_read;
595
596 dbgdata->last_dma_chunk_size = last_dma_chunk_size;
597
598 dbgdata->playing = playing;
599 dbgdata->play_pending = play_pending;
600 dbgdata->is_playing = is_playing;
601 dbgdata->filling = filling;
602 dbgdata->dma_underrun = dma_underrun;
603
604 dbgdata->unplayed_space = get_unplayed_space();
605 dbgdata->playable_space = get_playable_space();
606 dbgdata->unswapped_space = get_unswapped_space();
607
608 dbgdata->low_watermark_level = low_watermark;
609 dbgdata->lowest_watermark_level = lowest_watermark_level;
610}
611
612#ifdef DEBUG
613static void dbg_timer_start(void)
614{
615 /* We are using timer 2 */
616
617 TSTR &= ~0x04; /* Stop the timer */
618 TSNC &= ~0x04; /* No synchronization */
619 TMDR &= ~0x44; /* Operate normally */
620
621 TCNT2 = 0; /* Start counting at 0 */
622 TCR2 = 0x03; /* Sysclock/8 */
623
624 TSTR |= 0x04; /* Start timer 2 */
625}
626
627static int dbg_cnt2us(unsigned int cnt)
628{
629 return (cnt * 10000) / (FREQ/800);
630}
631#endif /* DEBUG */
632
633static int get_unplayed_space(void)
634{
635 int space = audiobuf_write - audiobuf_read;
636 if (space < 0)
637 space += audiobuflen;
638 return space;
639}
640
641static int get_playable_space(void)
642{
643 int space = audiobuf_swapwrite - audiobuf_read;
644 if (space < 0)
645 space += audiobuflen;
646 return space;
647}
648
649static int get_unplayed_space_current_song(void)
650{
651 int space;
652
653 if (num_tracks_in_memory() > 1)
654 {
655 space = get_trackdata(1)->mempos - audiobuf_read;
656 }
657 else
658 {
659 space = audiobuf_write - audiobuf_read;
660 }
661
662 if (space < 0)
663 space += audiobuflen;
664
665 return space;
666}
667
668static int get_unswapped_space(void)
669{
670 int space = audiobuf_write - audiobuf_swapwrite;
671 if (space < 0)
672 space += audiobuflen;
673 return space;
674}
675
676void playback_tick(void)
677{
678 struct trackdata *ptd = get_trackdata(0);
679 if(ptd)
680 {
681 ptd->id3.elapsed += (current_tick - last_dma_tick) * 1000 / HZ;
682 last_dma_tick = current_tick;
683 audio_dispatch_event(AUDIO_EVENT_POS_REPORT,
684 (unsigned long)ptd->id3.elapsed);
685 }
686}
687
688static void reset_mp3_buffer(void)
689{
690 audiobuf_read = 0;
691 audiobuf_write = 0;
692 audiobuf_swapwrite = 0;
693 lowest_watermark_level = audiobuflen;
694}
695
696 /* DMA transfer end interrupt callback */
697static void transfer_end(const void** ppbuf, size_t* psize)
698{
699 if(playing && !paused)
700 {
701 int unplayed_space_left;
702 int space_until_end_of_buffer;
703 int track_offset = 1;
704 struct trackdata *track;
705
706 audiobuf_read += last_dma_chunk_size;
707 if(audiobuf_read >= audiobuflen)
708 audiobuf_read = 0;
709
710 /* First, check if we are on a track boundary */
711 if (num_tracks_in_memory() > 1)
712 {
713 if (audiobuf_read == get_trackdata(track_offset)->mempos)
714 {
715 if ( ! audio_dispatch_event(AUDIO_EVENT_END_OF_TRACK, 0) )
716 {
717 queue_post(&mpeg_queue, MPEG_TRACK_CHANGE, 0);
718 track_offset++;
719 }
720 }
721 }
722
723 unplayed_space_left = get_unplayed_space();
724
725 space_until_end_of_buffer = audiobuflen - audiobuf_read;
726
727 if(!filling && unplayed_space_left < low_watermark)
728 {
729 filling = true;
730 queue_post(&mpeg_queue, MPEG_NEED_DATA, GENERATE_UNBUFFER_EVENTS);
731 }
732
733 if(unplayed_space_left)
734 {
735 last_dma_chunk_size = MIN(0x2000, unplayed_space_left);
736 last_dma_chunk_size = MIN(last_dma_chunk_size,
737 space_until_end_of_buffer);
738
739 /* several tracks loaded? */
740 track = get_trackdata(track_offset);
741 if(track)
742 {
743 /* will we move across the track boundary? */
744 if (( audiobuf_read < track->mempos ) &&
745 ((audiobuf_read+last_dma_chunk_size) >
746 track->mempos ))
747 {
748 /* Make sure that we end exactly on the boundary */
749 last_dma_chunk_size = track->mempos - audiobuf_read;
750 }
751 }
752
753 *psize = last_dma_chunk_size & 0xffff;
754 *ppbuf = mpeg_audiobuf + audiobuf_read;
755 track = get_trackdata(0);
756 if(track)
757 track->id3.offset += last_dma_chunk_size;
758
759 /* Update the watermark debug level */
760 if(unplayed_space_left < lowest_watermark_level)
761 lowest_watermark_level = unplayed_space_left;
762 }
763 else
764 {
765 /* Check if the end of data is because of a hard disk error.
766 If there is an open file handle, we are still playing music.
767 If not, the last file has been loaded, and the file handle is
768 closed. */
769 if(mpeg_file >= 0)
770 {
771 /* Update the watermark debug level */
772 if(unplayed_space_left < lowest_watermark_level)
773 lowest_watermark_level = unplayed_space_left;
774
775 DEBUGF("DMA underrun.\n");
776 dma_underrun = true;
777 }
778 else
779 {
780 if ( ! audio_dispatch_event(AUDIO_EVENT_END_OF_TRACK, 0) )
781 {
782 DEBUGF("No more MP3 data. Stopping.\n");
783 queue_post(&mpeg_queue, MPEG_TRACK_CHANGE, 0);
784 playing = false;
785 }
786 }
787 *psize = 0; /* no more transfer */
788 }
789 }
790}
791
792static struct trackdata *add_track_to_tag_list(const char *filename)
793{
794 struct trackdata *track;
795 bool send_nid3_event;
796
797 if(num_tracks_in_memory() >= MAX_TRACK_ENTRIES)
798 {
799 DEBUGF("Tag memory is full\n");
800 return NULL;
801 }
802
803 track = &trackdata[track_write_idx];
804
805 /* grab id3 tag of new file and
806 remember where in memory it starts */
807 if(mp3info(&track->id3, filename))
808 {
809 DEBUGF("Bad mp3\n");
810 return NULL;
811 }
812 track->mempos = audiobuf_write;
813 track->id3.elapsed = 0;
814#ifdef HAVE_LCD_BITMAP
815 if (track->id3.title)
816 lcd_getstringsize(track->id3.title, NULL, NULL);
817 if (track->id3.artist)
818 lcd_getstringsize(track->id3.artist, NULL, NULL);
819 if (track->id3.album)
820 lcd_getstringsize(track->id3.album, NULL, NULL);
821#endif
822
823 /* if this track is the next track then let the UI know it can get it */
824 send_nid3_event = (track_write_idx == track_read_idx + 1);
825 track_write_idx = (track_write_idx+1) & MAX_TRACK_ENTRIES_MASK;
826 if (send_nid3_event)
827 send_track_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, &track->id3);
828 debug_tags();
829 return track;
830}
831
832static int new_file(int steps)
833{
834 int max_steps = playlist_amount();
835 int start = 0;
836 int i;
837 struct trackdata *track;
838 char name_buf[MAX_PATH+1];
839 const char *trackname;
840
841 /* Find out how many steps to advance. The load_ahead_index field tells
842 us how many playlist entries it had to skip to get to a valid one.
843 We add those together to find out where to start. */
844 if(steps > 0 && num_tracks_in_memory() > 1)
845 {
846 /* Begin with the song after the currently playing one */
847 i = 1;
848 while((track = get_trackdata(i++)))
849 {
850 start += track->load_ahead_index;
851 }
852 }
853
854 do {
855 trackname = playlist_peek(start + steps, name_buf, sizeof(name_buf));
856 if ( !trackname )
857 return -1;
858
859 DEBUGF("Loading %s\n", trackname);
860
861 mpeg_file = open(trackname, O_RDONLY);
862 if(mpeg_file < 0) {
863 DEBUGF("Couldn't open file: %s\n",trackname);
864 if(steps < 0)
865 steps--;
866 else
867 steps++;
868 }
869 else
870 {
871 struct trackdata *track = add_track_to_tag_list(trackname);
872
873 if(!track)
874 {
875 /* Bad mp3 file */
876 if(steps < 0)
877 steps--;
878 else
879 steps++;
880 close(mpeg_file);
881 mpeg_file = -1;
882 }
883 else
884 {
885 /* skip past id3v2 tag */
886 lseek(mpeg_file,
887 track->id3.first_frame_offset,
888 SEEK_SET);
889 track->id3.index = steps;
890 track->load_ahead_index = steps;
891 track->id3.offset = 0;
892
893 if(track->id3.vbr)
894 /* Average bitrate * 1.5 */
895 recalculate_watermark(
896 (track->id3.bitrate * 3) / 2);
897 else
898 recalculate_watermark(
899 track->id3.bitrate);
900
901 }
902 }
903
904 /* Bail out if no file could be opened */
905 if(abs(steps) > max_steps)
906 return -1;
907 } while ( mpeg_file < 0 );
908
909 return 0;
910}
911
912static void stop_playing(void)
913{
914 /* Stop the current stream */
915 mp3_play_stop();
916 playing = false;
917 filling = false;
918
919 if(mpeg_file >= 0)
920 close(mpeg_file);
921 mpeg_file = -1;
922 remove_all_tags();
923 generate_unbuffer_events();
924 reset_mp3_buffer();
925}
926
927static void end_current_track(void)
928{
929 play_pending = false;
930 playing = false;
931 mp3_play_pause(false);
932
933 reset_mp3_buffer();
934 remove_all_tags();
935 generate_unbuffer_events();
936
937 if(mpeg_file >= 0)
938 close(mpeg_file);
939}
940
941/* Is this a really the end of playback or is a new playlist starting */
942static void check_playlist_end(int direction)
943{
944 /* Use the largest possible step size to account for skipped tracks */
945 int steps = playlist_amount();
946
947 if (direction < 0)
948 steps = -steps;
949
950 if (playlist_next(steps) < 0)
951 is_playing = false;
952}
953
954static void update_playlist(void)
955{
956 if (num_tracks_in_memory() > 0)
957 {
958 struct trackdata *track = get_trackdata(0);
959 track->id3.index = playlist_next(track->id3.index);
960 }
961 else
962 {
963 /* End of playlist? */
964 check_playlist_end(1);
965 }
966
967 playlist_update_resume_info(audio_current_track());
968}
969
970static void track_change(void)
971{
972 DEBUGF("Track change\n");
973
974 if (num_tracks_in_memory() > 0)
975 {
976 remove_current_tag();
977 update_playlist();
978 if (is_playing)
979 {
980 send_track_event(PLAYBACK_EVENT_TRACK_CHANGE,
981 audio_current_track());
982 }
983 }
984
985 current_track_counter++;
986}
987
988#ifdef DEBUG
989void hexdump(const unsigned char *buf, int len)
990{
991 int i;
992
993 for(i = 0;i < len;i++)
994 {
995 if(i && (i & 15) == 0)
996 {
997 DEBUGF("\n");
998 }
999 DEBUGF("%02x ", buf[i]);
1000 }
1001 DEBUGF("\n");
1002}
1003#endif /* DEBUG */
1004
1005static void start_playback_if_ready(void)
1006{
1007 int playable_space;
1008
1009 playable_space = audiobuf_swapwrite - audiobuf_read;
1010 if(playable_space < 0)
1011 playable_space += audiobuflen;
1012
1013 /* See if we have started playing yet. If not, do it. */
1014 if(play_pending || dma_underrun)
1015 {
1016 /* If the filling has stopped, and we still haven't reached
1017 the watermark, the file must be smaller than the
1018 watermark. We must still play it. */
1019 if((playable_space >= MPEG_PLAY_PENDING_THRESHOLD) ||
1020 !filling || dma_underrun)
1021 {
1022 DEBUGF("P\n");
1023 if (play_pending) /* don't do this when recovering from DMA underrun */
1024 {
1025 generate_postbuffer_events(); /* signal first track as buffered */
1026 if (play_pending_track_change)
1027 {
1028 play_pending_track_change = false;
1029 send_track_event(PLAYBACK_EVENT_TRACK_CHANGE,
1030 audio_current_track());
1031 }
1032 play_pending = false;
1033 }
1034 playing = true;
1035
1036 last_dma_chunk_size = MIN(0x2000, get_unplayed_space_current_song());
1037 mp3_play_data(mpeg_audiobuf + audiobuf_read, last_dma_chunk_size, transfer_end);
1038 dma_underrun = false;
1039
1040 if (!paused)
1041 {
1042 last_dma_tick = current_tick;
1043 mp3_play_pause(true);
1044 }
1045
1046 /* Tell ourselves that we need more data */
1047 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
1048 }
1049 }
1050}
1051
1052static bool swap_one_chunk(void)
1053{
1054 int free_space_left;
1055 int amount_to_swap;
1056
1057 free_space_left = get_unswapped_space();
1058
1059 if(free_space_left == 0 && !play_pending)
1060 return false;
1061
1062 /* Swap in larger chunks when the user is waiting for the playback
1063 to start, or when there is dangerously little playable data left */
1064 if(play_pending)
1065 amount_to_swap = MIN(MPEG_PLAY_PENDING_SWAPSIZE, free_space_left);
1066 else
1067 {
1068 if(get_playable_space() < low_watermark)
1069 amount_to_swap = MIN(MPEG_LOW_WATER_SWAP_CHUNKSIZE,
1070 free_space_left);
1071 else
1072 amount_to_swap = MIN(MPEG_SWAP_CHUNKSIZE, free_space_left);
1073 }
1074
1075 if(audiobuf_write < audiobuf_swapwrite)
1076 amount_to_swap = MIN(audiobuflen - audiobuf_swapwrite,
1077 amount_to_swap);
1078 else
1079 amount_to_swap = MIN(audiobuf_write - audiobuf_swapwrite,
1080 amount_to_swap);
1081
1082 bitswap(mpeg_audiobuf + audiobuf_swapwrite, amount_to_swap);
1083
1084 audiobuf_swapwrite += amount_to_swap;
1085 if(audiobuf_swapwrite >= audiobuflen)
1086 {
1087 audiobuf_swapwrite = 0;
1088 }
1089
1090 return true;
1091}
1092
1093static void mpeg_thread(void)
1094{
1095 static int pause_tick = 0;
1096 static unsigned int pause_track = 0;
1097 struct queue_event ev;
1098 int len;
1099 int free_space_left;
1100 int unplayed_space_left;
1101 int amount_to_read;
1102 int t1, t2;
1103 unsigned long start_elapsed, start_offset;
1104
1105 is_playing = false;
1106 play_pending = false;
1107 playing = false;
1108 mpeg_file = -1;
1109
1110 while(1)
1111 {
1112 yield();
1113
1114 /* Swap if necessary, and don't block on the queue_wait() */
1115 if(swap_one_chunk())
1116 {
1117 queue_wait_w_tmo(&mpeg_queue, &ev, 0);
1118 }
1119 else if (playing)
1120 {
1121 /* periodically update resume info */
1122 queue_wait_w_tmo(&mpeg_queue, &ev, HZ/2);
1123 }
1124 else
1125 {
1126 DEBUGF("S R:%x W:%x SW:%x\n",
1127 audiobuf_read, audiobuf_write, audiobuf_swapwrite);
1128 queue_wait(&mpeg_queue, &ev);
1129 }
1130
1131 start_playback_if_ready();
1132
1133 switch(ev.id)
1134 {
1135 case MPEG_PLAY:
1136 DEBUGF("MPEG_PLAY\n");
1137
1138#if CONFIG_TUNER
1139 /* Silence the A/D input, it may be on because the radio
1140 may be playing */
1141 mas_codec_writereg(6, 0x0000);
1142#endif /* CONFIG_TUNER */
1143
1144 /* Stop the current stream */
1145 paused = false;
1146 end_current_track();
1147
1148 if ( new_file(0) == -1 )
1149 {
1150 is_playing = false;
1151 track_change();
1152 break;
1153 }
1154
1155 start_elapsed = ((struct audio_resume_info *)ev.data)->elapsed;
1156 start_offset = ((struct audio_resume_info *)ev.data)->offset;
1157
1158 /* mid-song resume? */
1159 if (!start_offset && start_elapsed) {
1160 struct mp3entry *id3 = &get_trackdata(0)->id3;
1161 id3->elapsed = start_elapsed;
1162 start_offset = audio_get_file_pos_int(id3);
1163 }
1164
1165 if (start_offset) {
1166 struct mp3entry* id3 = &get_trackdata(0)->id3;
1167 lseek(mpeg_file, start_offset, SEEK_SET);
1168 id3->offset = start_offset;
1169 set_elapsed(id3);
1170 }
1171 else {
1172 /* skip past id3v2 tag */
1173 lseek(mpeg_file,
1174 get_trackdata(0)->id3.first_frame_offset,
1175 SEEK_SET);
1176
1177 }
1178
1179 /* Make it read more data */
1180 filling = true;
1181 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
1182
1183 /* Tell the file loading code that we want to start playing
1184 as soon as we have some data */
1185 play_pending = true;
1186 play_pending_track_change = true;
1187
1188 update_playlist();
1189 current_track_counter++;
1190 break;
1191
1192 case MPEG_STOP:
1193 do_stop();
1194 break;
1195
1196 case MPEG_PAUSE:
1197 DEBUGF("MPEG_PAUSE\n");
1198 /* Stop the current stream */
1199 if (playing)
1200 playlist_update_resume_info(audio_current_track());
1201 paused = true;
1202 playing = false;
1203 pause_tick = current_tick;
1204 pause_track = current_track_counter;
1205 mp3_play_pause(false);
1206 break;
1207
1208 case MPEG_RESUME:
1209 DEBUGF("MPEG_RESUME\n");
1210 /* Continue the current stream */
1211 paused = false;
1212 if (!play_pending)
1213 {
1214 playing = true;
1215 if ( current_track_counter == pause_track )
1216 last_dma_tick += current_tick - pause_tick;
1217 else
1218 last_dma_tick = current_tick;
1219 pause_tick = 0;
1220 mp3_play_pause(true);
1221 }
1222 break;
1223
1224 case MPEG_NEXT:
1225 DEBUGF("MPEG_NEXT\n");
1226 /* is next track in ram? */
1227 if ( num_tracks_in_memory() > 1 ) {
1228 int unplayed_space_left, unswapped_space_left;
1229
1230 /* stop the current stream */
1231 play_pending = false;
1232 playing = false;
1233 mp3_play_pause(false);
1234
1235 track_change();
1236 audiobuf_read = get_trackdata(0)->mempos;
1237 last_dma_chunk_size = MIN(0x2000, get_unplayed_space_current_song());
1238 mp3_play_data(mpeg_audiobuf + audiobuf_read, last_dma_chunk_size, transfer_end);
1239 dma_underrun = false;
1240 last_dma_tick = current_tick;
1241
1242 unplayed_space_left = get_unplayed_space();
1243 unswapped_space_left = get_unswapped_space();
1244
1245 /* should we start reading more data? */
1246 if(!filling && (unplayed_space_left < low_watermark)) {
1247 filling = true;
1248 queue_post(&mpeg_queue, MPEG_NEED_DATA, GENERATE_UNBUFFER_EVENTS);
1249 play_pending = true;
1250 } else if(unswapped_space_left &&
1251 unswapped_space_left > unplayed_space_left) {
1252 /* Stop swapping the data from the previous file */
1253 audiobuf_swapwrite = audiobuf_read;
1254 play_pending = true;
1255 } else {
1256 playing = true;
1257 if (!paused)
1258 mp3_play_pause(true);
1259 }
1260 }
1261 else {
1262 if (!playlist_check(1))
1263 break;
1264
1265 /* stop the current stream */
1266 end_current_track();
1267
1268 if (new_file(1) < 0) {
1269 DEBUGF("No more files to play\n");
1270 filling = false;
1271
1272 check_playlist_end(1);
1273 current_track_counter++;
1274 } else {
1275 /* Make it read more data */
1276 filling = true;
1277 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
1278
1279 /* Tell the file loading code that we want
1280 to start playing as soon as we have some data */
1281 play_pending = true;
1282 play_pending_track_change = true;
1283
1284 update_playlist();
1285 current_track_counter++;
1286 }
1287 }
1288 break;
1289
1290 case MPEG_PREV: {
1291 DEBUGF("MPEG_PREV\n");
1292
1293 if (!playlist_check(-1))
1294 break;
1295
1296 /* stop the current stream */
1297 end_current_track();
1298
1299 /* Open the next file */
1300 if (new_file(-1) < 0) {
1301 DEBUGF("No more files to play\n");
1302 filling = false;
1303
1304 check_playlist_end(-1);
1305 current_track_counter++;
1306 } else {
1307 /* Make it read more data */
1308 filling = true;
1309 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
1310
1311 /* Tell the file loading code that we want to
1312 start playing as soon as we have some data */
1313 play_pending = true;
1314 play_pending_track_change = true;
1315
1316 update_playlist();
1317 current_track_counter++;
1318 }
1319 break;
1320 }
1321
1322 case MPEG_FF_REWIND: {
1323 struct mp3entry *id3 = audio_current_track();
1324 unsigned int oldtime = id3->elapsed;
1325 unsigned int newtime = (unsigned int)ev.data;
1326 int curpos, newpos, diffpos;
1327 DEBUGF("MPEG_FF_REWIND\n");
1328
1329 id3->elapsed = newtime;
1330
1331 newpos = audio_get_file_pos_int(id3);
1332 if(newpos < 0)
1333 {
1334 id3->elapsed = oldtime;
1335 break;
1336 }
1337
1338 if (mpeg_file >= 0)
1339 curpos = lseek(mpeg_file, 0, SEEK_CUR);
1340 else
1341 curpos = id3->filesize;
1342
1343 if (num_tracks_in_memory() > 1)
1344 {
1345 /* We have started loading other tracks that need to be
1346 accounted for */
1347 struct trackdata *track;
1348 int i = 0;
1349
1350 while((track = get_trackdata(i++)))
1351 {
1352 curpos += track->id3.filesize;
1353 }
1354 }
1355
1356 diffpos = curpos - newpos;
1357
1358 if(!filling && diffpos >= 0 && diffpos < audiobuflen)
1359 {
1360 int unplayed_space_left, unswapped_space_left;
1361
1362 /* We are changing to a position that's already in
1363 memory, so we just move the DMA read pointer. */
1364 audiobuf_read = audiobuf_write - diffpos;
1365 if (audiobuf_read < 0)
1366 {
1367 audiobuf_read += audiobuflen;
1368 }
1369
1370 unplayed_space_left = get_unplayed_space();
1371 unswapped_space_left = get_unswapped_space();
1372
1373 /* If unswapped_space_left is larger than
1374 unplayed_space_left, it means that the swapwrite pointer
1375 hasn't yet advanced up to the new location of the read
1376 pointer. We just move it, there is no need to swap
1377 data that won't be played anyway. */
1378
1379 if (unswapped_space_left > unplayed_space_left)
1380 {
1381 DEBUGF("Moved swapwrite\n");
1382 audiobuf_swapwrite = audiobuf_read;
1383 play_pending = true;
1384 }
1385
1386 if (mpeg_file>=0 && unplayed_space_left < low_watermark)
1387 {
1388 /* We need to load more data before starting */
1389 filling = true;
1390 queue_post(&mpeg_queue, MPEG_NEED_DATA, GENERATE_UNBUFFER_EVENTS);
1391 play_pending = true;
1392 }
1393 else
1394 {
1395 /* resume will start at new position */
1396 last_dma_chunk_size =
1397 MIN(0x2000, get_unplayed_space_current_song());
1398 mp3_play_data(mpeg_audiobuf + audiobuf_read,
1399 last_dma_chunk_size, transfer_end);
1400 dma_underrun = false;
1401 }
1402 }
1403 else
1404 {
1405 /* Move to the new position in the file and start
1406 loading data */
1407 reset_mp3_buffer();
1408
1409 if (num_tracks_in_memory() > 1)
1410 {
1411 /* We have to reload the current track */
1412 close(mpeg_file);
1413 remove_all_non_current_tags();
1414 generate_unbuffer_events();
1415 mpeg_file = -1;
1416 }
1417
1418 if (mpeg_file < 0)
1419 {
1420 mpeg_file = open(id3->path, O_RDONLY);
1421 if (mpeg_file < 0)
1422 {
1423 id3->elapsed = oldtime;
1424 break;
1425 }
1426 }
1427
1428 if(-1 == lseek(mpeg_file, newpos, SEEK_SET))
1429 {
1430 id3->elapsed = oldtime;
1431 break;
1432 }
1433
1434 filling = true;
1435 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
1436
1437 /* Tell the file loading code that we want to start playing
1438 as soon as we have some data */
1439 play_pending = true;
1440 }
1441
1442 id3->offset = newpos;
1443
1444 break;
1445 }
1446
1447 case MPEG_FLUSH_RELOAD: {
1448 int numtracks = num_tracks_in_memory();
1449 bool reload_track = false;
1450
1451 if (numtracks > 1)
1452 {
1453 /* Reset the buffer */
1454 audiobuf_write = get_trackdata(1)->mempos;
1455
1456 /* Reset swapwrite unless we're still swapping current
1457 track */
1458 if (get_unplayed_space() <= get_playable_space())
1459 audiobuf_swapwrite = audiobuf_write;
1460
1461 close(mpeg_file);
1462 remove_all_non_current_tags();
1463 generate_unbuffer_events();
1464 mpeg_file = -1;
1465 reload_track = true;
1466 }
1467 else if (numtracks == 1 && mpeg_file < 0)
1468 {
1469 reload_track = true;
1470 }
1471
1472 if(reload_track && new_file(1) >= 0)
1473 {
1474 /* Tell ourselves that we want more data */
1475 filling = true;
1476 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
1477 }
1478
1479 break;
1480 }
1481
1482 case MPEG_NEED_DATA:
1483 free_space_left = audiobuf_read - audiobuf_write;
1484
1485 /* We interpret 0 as "empty buffer" */
1486 if(free_space_left <= 0)
1487 free_space_left += audiobuflen;
1488
1489 unplayed_space_left = audiobuflen - free_space_left;
1490
1491 /* Make sure that we don't fill the entire buffer */
1492 free_space_left -= MPEG_HIGH_WATER;
1493
1494 if (ev.data == GENERATE_UNBUFFER_EVENTS)
1495 generate_unbuffer_events();
1496
1497 /* do we have any more buffer space to fill? */
1498 if(free_space_left <= 0)
1499 {
1500 DEBUGF("0\n");
1501 filling = false;
1502 generate_postbuffer_events();
1503 storage_sleep();
1504 break;
1505 }
1506
1507 /* Read small chunks while we are below the low water mark */
1508 if(unplayed_space_left < low_watermark)
1509 amount_to_read = MIN(MPEG_LOW_WATER_CHUNKSIZE,
1510 free_space_left);
1511 else
1512 amount_to_read = free_space_left;
1513
1514 /* Don't read more than until the end of the buffer */
1515 amount_to_read = MIN(audiobuflen - audiobuf_write,
1516 amount_to_read);
1517#if (CONFIG_STORAGE & STORAGE_MMC)
1518 /* MMC is slow, so don't read too large chunks */
1519 amount_to_read = MIN(0x40000, amount_to_read);
1520#elif MEMORYSIZE == 8
1521 amount_to_read = MIN(0x100000, amount_to_read);
1522#endif
1523
1524 /* Read as much mpeg data as we can fit in the buffer */
1525 if(mpeg_file >= 0)
1526 {
1527 DEBUGF("R\n");
1528 t1 = current_tick;
1529 len = read(mpeg_file, mpeg_audiobuf + audiobuf_write,
1530 amount_to_read);
1531 if(len > 0)
1532 {
1533 t2 = current_tick;
1534 DEBUGF("time: %d\n", t2 - t1);
1535 DEBUGF("R: %x\n", len);
1536
1537 /* Now make sure that we don't feed the MAS with ID3V1
1538 data */
1539 if (len < amount_to_read)
1540 {
1541 int i;
1542 static const unsigned char tag[] = "TAG";
1543 int taglen = 128;
1544 int tagptr = audiobuf_write + len - 128;
1545
1546 /* Really rare case: entire potential tag wasn't
1547 read in this call AND audiobuf_write < 128 */
1548 if (tagptr < 0)
1549 tagptr += audiobuflen;
1550
1551 for(i = 0;i < 3;i++)
1552 {
1553 if(tagptr >= audiobuflen)
1554 tagptr -= audiobuflen;
1555
1556 if(mpeg_audiobuf[tagptr] != tag[i])
1557 {
1558 taglen = 0;
1559 break;
1560 }
1561
1562 tagptr++;
1563 }
1564
1565 if(taglen)
1566 {
1567 /* Skip id3v1 tag */
1568 DEBUGF("Skipping ID3v1 tag\n");
1569 len -= taglen;
1570
1571 /* In the very rare case when the entire tag
1572 wasn't read in this read() len will be < 0.
1573 Take care of this when changing the write
1574 pointer. */
1575 }
1576 }
1577
1578 audiobuf_write += len;
1579
1580 if (audiobuf_write < 0)
1581 audiobuf_write += audiobuflen;
1582
1583 if(audiobuf_write >= audiobuflen)
1584 {
1585 audiobuf_write = 0;
1586 DEBUGF("W\n");
1587 }
1588
1589 /* Tell ourselves that we want more data */
1590 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
1591 }
1592 else
1593 {
1594 if(len < 0)
1595 {
1596 DEBUGF("MPEG read error\n");
1597 }
1598
1599 close(mpeg_file);
1600 mpeg_file = -1;
1601
1602 if(new_file(1) < 0)
1603 {
1604 /* No more data to play */
1605 DEBUGF("No more files to play\n");
1606 filling = false;
1607 }
1608 else
1609 {
1610 /* Tell ourselves that we want more data */
1611 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
1612 }
1613 }
1614 }
1615 break;
1616
1617 case MPEG_TRACK_CHANGE:
1618 track_change();
1619 break;
1620
1621#ifndef USB_NONE
1622 case SYS_USB_CONNECTED:
1623 is_playing = false;
1624 paused = false;
1625 stop_playing();
1626
1627 /* Tell the USB thread that we are safe */
1628 DEBUGF("mpeg_thread got SYS_USB_CONNECTED\n");
1629 usb_acknowledge(SYS_USB_CONNECTED_ACK);
1630
1631 /* Wait until the USB cable is extracted again */
1632 usb_wait_for_disconnect(&mpeg_queue);
1633 break;
1634#endif /* !USB_NONE */
1635
1636 case SYS_TIMEOUT:
1637 if (playing)
1638 playlist_update_resume_info(audio_current_track());
1639 break;
1640 }
1641 }
1642}
1643#endif /* !SIMULATOR */
1644
1645struct mp3entry* audio_current_track(void)
1646{
1647#ifdef SIMULATOR
1648 struct mp3entry *id3 = &taginfo;
1649#else /* !SIMULATOR */
1650 if(num_tracks_in_memory())
1651 {
1652 struct mp3entry *id3 = &get_trackdata(0)->id3;
1653#endif
1654 if (!checked_for_cuesheet && curr_cuesheet && id3->cuesheet == NULL)
1655 {
1656 checked_for_cuesheet = true; /* only check once per track */
1657 struct cuesheet_file cue_file;
1658
1659 if (look_for_cuesheet_file(id3, &cue_file) &&
1660 parse_cuesheet(&cue_file, curr_cuesheet))
1661 {
1662 id3->cuesheet = curr_cuesheet;
1663 }
1664 }
1665 return id3;
1666#ifndef SIMULATOR
1667 }
1668 else
1669 return NULL;
1670#endif /* !SIMULATOR */
1671}
1672
1673struct mp3entry* audio_next_track(void)
1674{
1675#ifdef SIMULATOR
1676 return &taginfo;
1677#else /* !SIMULATOR */
1678 if(num_tracks_in_memory() > 1)
1679 return &get_trackdata(1)->id3;
1680 else
1681 return NULL;
1682#endif /* !SIMULATOR */
1683}
1684
1685size_t audio_buffer_size(void)
1686{
1687 if (audiobuf_handle > 0)
1688 return audiobuflen;
1689 return 0;
1690}
1691
1692size_t audio_buffer_available(void)
1693{
1694 size_t size = 0;
1695 size_t core_size = core_available();
1696 if (audiobuf_handle > 0)
1697 return audiobuflen - AUDIO_BUFFER_RESERVE - 128;
1698 return MAX(core_size, size);
1699}
1700
1701static void audio_reset_buffer_noalloc(void* buf, size_t bufsize)
1702{
1703 mpeg_audiobuf = buf;
1704 audiobuflen = bufsize;
1705 if (global_settings.cuesheet)
1706 { /* enable cuesheet support */
1707 curr_cuesheet = (struct cuesheet*)mpeg_audiobuf;
1708 mpeg_audiobuf = SKIPBYTES(mpeg_audiobuf, sizeof(struct cuesheet));
1709 audiobuflen -= sizeof(struct cuesheet);
1710 }
1711}
1712
1713static void audio_reset_buffer(void)
1714{
1715 size_t bufsize = audiobuflen;
1716
1717 /* alloc buffer if it's was never allocated or freed by audio_hard_stop()
1718 * because voice cannot be played during audio playback make
1719 * talk.c give up all buffers and disable itself */
1720 if (!audiobuf_handle)
1721 {
1722 talk_buffer_set_policy(TALK_BUFFER_LOOSE);
1723 audiobuf_handle = core_alloc_maximum("audiobuf", &bufsize, &ops);
1724 }
1725
1726 audio_reset_buffer_noalloc(core_get_data(audiobuf_handle), bufsize);
1727}
1728
1729void audio_play(unsigned long elapsed, unsigned long offset)
1730{
1731 audio_reset_buffer();
1732#ifdef SIMULATOR
1733 char name_buf[MAX_PATH+1];
1734 const char* trackname;
1735 int steps=0;
1736
1737 is_playing = true;
1738
1739 do {
1740 trackname = playlist_peek(steps, name_buf, sizeof(name_buf));
1741 if (!trackname)
1742 break;
1743 if(mp3info(&taginfo, trackname)) {
1744 /* bad mp3, move on */
1745 if(++steps > playlist_amount())
1746 break;
1747 continue;
1748 }
1749#ifdef HAVE_MPEG_PLAY
1750 real_mpeg_play(trackname);
1751#endif
1752 playlist_next(steps);
1753 if (!offset && elapsed)
1754 {
1755 /* has an elapsed time but no offset; elapsed may take
1756 precedence in this case */
1757 taginfo.elapsed = elapsed;
1758 taginfo.offset = audio_get_file_pos_int(&taginfo);
1759 }
1760 else
1761 {
1762 taginfo.offset = offset;
1763 set_elapsed(&taginfo);
1764 }
1765 is_playing = true;
1766 playing = true;
1767 break;
1768 } while(1);
1769#else /* !SIMULATOR */
1770 static struct audio_resume_info resume;
1771 is_playing = true;
1772 resume.elapsed = elapsed;
1773 resume.offset = offset;
1774 queue_post(&mpeg_queue, MPEG_PLAY, (intptr_t)&resume);
1775#endif /* !SIMULATOR */
1776
1777 mpeg_errno = 0;
1778}
1779
1780void audio_stop(void)
1781{
1782 if (audiobuf_handle <= 0)
1783 return; /* nothing to do, must be hard-stopped already */
1784#ifndef SIMULATOR
1785 mpeg_stop_done = false;
1786 queue_post(&mpeg_queue, MPEG_STOP, 0);
1787 while(!mpeg_stop_done)
1788 yield();
1789#else /* SIMULATOR */
1790 paused = false;
1791 is_playing = false;
1792 playing = false;
1793#endif /* SIMULATOR */
1794}
1795
1796/* dummy */
1797void audio_stop_recording(void)
1798{
1799 audio_stop();
1800}
1801
1802void audio_hard_stop(void)
1803{
1804 if (audiobuf_handle > 0)
1805 {
1806 audio_stop();
1807 audiobuf_handle = core_free(audiobuf_handle);
1808 mpeg_audiobuf = NULL;
1809 talk_buffer_set_policy(TALK_BUFFER_DEFAULT);
1810 }
1811}
1812
1813void audio_pause(void)
1814{
1815#ifndef SIMULATOR
1816 queue_post(&mpeg_queue, MPEG_PAUSE, 0);
1817#else /* SIMULATOR */
1818 is_playing = true;
1819 playing = false;
1820 paused = true;
1821#endif /* SIMULATOR */
1822}
1823
1824void audio_resume(void)
1825{
1826#ifndef SIMULATOR
1827 queue_post(&mpeg_queue, MPEG_RESUME, 0);
1828#else /* SIMULATOR */
1829 is_playing = true;
1830 playing = true;
1831 paused = false;
1832#endif /* SIMULATOR */
1833}
1834
1835void audio_next(void)
1836{
1837#ifndef SIMULATOR
1838 queue_remove_from_head(&mpeg_queue, MPEG_NEED_DATA);
1839 queue_post(&mpeg_queue, MPEG_NEXT, 0);
1840#else /* SIMULATOR */
1841 char name_buf[MAX_PATH+1];
1842 const char* file;
1843 int steps = 1;
1844
1845 do {
1846 file = playlist_peek(steps, name_buf, sizeof(name_buf));
1847 if(!file)
1848 break;
1849 if(mp3info(&taginfo, file)) {
1850 if(++steps > playlist_amount())
1851 break;
1852 continue;
1853 }
1854 playlist_next(steps);
1855 current_track_counter++;
1856 is_playing = true;
1857 playing = true;
1858 break;
1859 } while(1);
1860#endif /* SIMULATOR */
1861}
1862
1863void audio_prev(void)
1864{
1865#ifndef SIMULATOR
1866 queue_remove_from_head(&mpeg_queue, MPEG_NEED_DATA);
1867 queue_post(&mpeg_queue, MPEG_PREV, 0);
1868#else /* SIMULATOR */
1869 char name_buf[MAX_PATH+1];
1870 const char* file;
1871 int steps = -1;
1872
1873 do {
1874 file = playlist_peek(steps, name_buf, sizeof(name_buf));
1875 if(!file)
1876 break;
1877 if(mp3info(&taginfo, file)) {
1878 steps--;
1879 continue;
1880 }
1881 playlist_next(steps);
1882 current_track_counter++;
1883 is_playing = true;
1884 playing = true;
1885 break;
1886 } while(1);
1887#endif /* SIMULATOR */
1888}
1889
1890void audio_ff_rewind(long newpos)
1891{
1892#ifndef SIMULATOR
1893 queue_post(&mpeg_queue, MPEG_FF_REWIND, newpos);
1894#else /* SIMULATOR */
1895 (void)newpos;
1896#endif /* SIMULATOR */
1897}
1898
1899void audio_flush_and_reload_tracks(void)
1900{
1901#ifndef SIMULATOR
1902 queue_post(&mpeg_queue, MPEG_FLUSH_RELOAD, 0);
1903#endif /* !SIMULATOR*/
1904}
1905
1906int audio_status(void)
1907{
1908 int ret = 0;
1909
1910 if(is_playing)
1911 ret |= AUDIO_STATUS_PLAY;
1912
1913 if(paused)
1914 ret |= AUDIO_STATUS_PAUSE;
1915
1916 if(mpeg_errno)
1917 ret |= AUDIO_STATUS_ERROR;
1918
1919 return ret;
1920}
1921
1922/* Unused function
1923unsigned int audio_error(void)
1924{
1925 return mpeg_errno;
1926}
1927*/
1928
1929void audio_error_clear(void)
1930{
1931 mpeg_errno = 0;
1932}
1933
1934#ifdef SIMULATOR
1935static void mpeg_thread(void)
1936{
1937 struct mp3entry* id3;
1938 while ( 1 ) {
1939 if (is_playing) {
1940 id3 = audio_current_track();
1941 if (!paused)
1942 {
1943 id3->elapsed+=1000;
1944 id3->offset+=1000;
1945 }
1946 if (id3->elapsed>=id3->length)
1947 audio_next();
1948 }
1949 sleep(HZ);
1950 }
1951}
1952#endif /* SIMULATOR */
1953
1954void audio_init(void)
1955{
1956 mpeg_errno = 0;
1957
1958 audio_reset_buffer();
1959
1960#ifndef SIMULATOR
1961 queue_init(&mpeg_queue, true);
1962#endif /* !SIMULATOR */
1963 audio_thread_id = create_thread(mpeg_thread, mpeg_stack,
1964 sizeof(mpeg_stack), 0, mpeg_thread_name
1965 IF_PRIO(, PRIORITY_SYSTEM)
1966 IF_COP(, CPU));
1967
1968 memset(trackdata, 0, sizeof(trackdata));
1969
1970#ifdef DEBUG
1971#ifndef SIMULATOR
1972 dbg_timer_start();
1973 dbg_cnt2us(0);
1974#endif /* !SIMULATOR */
1975#endif /* DEBUG */
1976 audio_is_initialized = true;
1977}
1978
1979#endif /* CONFIG_CODEC != SWCODEC */
diff --git a/apps/mpeg.h b/apps/mpeg.h
deleted file mode 100644
index 106933dba3..0000000000
--- a/apps/mpeg.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef _MPEG_H_
22#define _MPEG_H_
23
24#if CONFIG_CODEC != SWCODEC
25unsigned long mpeg_get_last_header(void);
26
27#endif
28#endif
diff --git a/apps/playback.h b/apps/playback.h
index c2682e6baf..a87ef873d0 100644
--- a/apps/playback.h
+++ b/apps/playback.h
@@ -26,7 +26,6 @@
26#include <stdlib.h> 26#include <stdlib.h>
27#include "config.h" 27#include "config.h"
28 28
29#if CONFIG_CODEC == SWCODEC
30/* Including the code for fast previews is entirely optional since it 29/* Including the code for fast previews is entirely optional since it
31 does add two more mp3entry's - for certain targets it may be less 30 does add two more mp3entry's - for certain targets it may be less
32 beneficial such as flash-only storage */ 31 beneficial such as flash-only storage */
@@ -34,8 +33,6 @@
34#define AUDIO_FAST_SKIP_PREVIEW 33#define AUDIO_FAST_SKIP_PREVIEW
35#endif 34#endif
36 35
37#endif /* CONFIG_CODEC == SWCODEC */
38
39#ifdef HAVE_ALBUMART 36#ifdef HAVE_ALBUMART
40 37
41#include "bmp.h" 38#include "bmp.h"
diff --git a/apps/playlist.c b/apps/playlist.c
index 2bdc1f39cc..f903458004 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -647,11 +647,7 @@ static int create_and_play_dir(int direction, bool play_last)
647 else 647 else
648 index = 0; 648 index = 0;
649 649
650#if (CONFIG_CODEC == SWCODEC)
651 current_playlist.started = true; 650 current_playlist.started = true;
652#else
653 playlist_start(index, 0, 0);
654#endif
655 } 651 }
656 652
657 /* we've overwritten the dircache when getting the next/previous dir, 653 /* we've overwritten the dircache when getting the next/previous dir,
@@ -1090,7 +1086,6 @@ static int calculate_step_count(const struct playlist_info *playlist, int steps)
1090 return steps; 1086 return steps;
1091} 1087}
1092 1088
1093#if CONFIG_CODEC == SWCODEC
1094/* Marks the index of the track to be skipped that is "steps" away from 1089/* Marks the index of the track to be skipped that is "steps" away from
1095 * current playing track. 1090 * current playing track.
1096 */ 1091 */
@@ -1100,7 +1095,7 @@ void playlist_skip_entry(struct playlist_info *playlist, int steps)
1100 1095
1101 if (playlist == NULL) 1096 if (playlist == NULL)
1102 playlist = &current_playlist; 1097 playlist = &current_playlist;
1103 1098
1104 /* need to account for already skipped tracks */ 1099 /* need to account for already skipped tracks */
1105 steps = calculate_step_count(playlist, steps); 1100 steps = calculate_step_count(playlist, steps);
1106 1101
@@ -1112,7 +1107,6 @@ void playlist_skip_entry(struct playlist_info *playlist, int steps)
1112 1107
1113 playlist->indices[index] |= PLAYLIST_SKIPPED; 1108 playlist->indices[index] |= PLAYLIST_SKIPPED;
1114} 1109}
1115#endif /* CONFIG_CODEC == SWCODEC */
1116 1110
1117/* 1111/*
1118 * returns the index of the track that is "steps" away from current playing 1112 * returns the index of the track that is "steps" away from current playing
@@ -2649,11 +2643,9 @@ const char* playlist_peek(int steps, char* buf, size_t buf_size)
2649 if (index < 0) 2643 if (index < 0)
2650 return NULL; 2644 return NULL;
2651 2645
2652#if CONFIG_CODEC == SWCODEC
2653 /* Just testing - don't care about the file name */ 2646 /* Just testing - don't care about the file name */
2654 if (!buf || !buf_size) 2647 if (!buf || !buf_size)
2655 return ""; 2648 return "";
2656#endif
2657 2649
2658 control_file = playlist->indices[index] & PLAYLIST_INSERT_TYPE_MASK; 2650 control_file = playlist->indices[index] & PLAYLIST_INSERT_TYPE_MASK;
2659 seek = playlist->indices[index] & PLAYLIST_SEEK_MASK; 2651 seek = playlist->indices[index] & PLAYLIST_SEEK_MASK;
@@ -2730,11 +2722,7 @@ int playlist_next(int steps)
2730 sort_playlist(playlist, false, false); 2722 sort_playlist(playlist, false, false);
2731 randomise_playlist(playlist, current_tick, false, true); 2723 randomise_playlist(playlist, current_tick, false, true);
2732 2724
2733#if CONFIG_CODEC == SWCODEC
2734 playlist->started = true; 2725 playlist->started = true;
2735#else
2736 playlist_start(0, 0, 0);
2737#endif
2738 playlist->index = 0; 2726 playlist->index = 0;
2739 index = 0; 2727 index = 0;
2740 } 2728 }
@@ -2780,7 +2768,6 @@ int playlist_next(int steps)
2780 return index; 2768 return index;
2781} 2769}
2782 2770
2783#if CONFIG_CODEC == SWCODEC
2784/* try playing next or previous folder */ 2771/* try playing next or previous folder */
2785bool playlist_next_dir(int direction) 2772bool playlist_next_dir(int direction)
2786{ 2773{
@@ -2790,7 +2777,6 @@ bool playlist_next_dir(int direction)
2790 2777
2791 return create_and_play_dir(direction, false) >= 0; 2778 return create_and_play_dir(direction, false) >= 0;
2792} 2779}
2793#endif /* CONFIG_CODEC == SWCODEC */
2794 2780
2795/* Get resume info for current playing song. If return value is -1 then 2781/* Get resume info for current playing song. If return value is -1 then
2796 settings shouldn't be saved. */ 2782 settings shouldn't be saved. */
diff --git a/apps/playlist.h b/apps/playlist.h
index 220a577fb2..2eca7355e4 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -139,9 +139,7 @@ void playlist_start(int start_index, unsigned long elapsed,
139bool playlist_check(int steps); 139bool playlist_check(int steps);
140const char *playlist_peek(int steps, char* buf, size_t buf_size); 140const char *playlist_peek(int steps, char* buf, size_t buf_size);
141int playlist_next(int steps); 141int playlist_next(int steps);
142#if CONFIG_CODEC == SWCODEC
143bool playlist_next_dir(int direction); 142bool playlist_next_dir(int direction);
144#endif
145int playlist_get_resume_info(int *resume_index); 143int playlist_get_resume_info(int *resume_index);
146int playlist_update_resume_info(const struct mp3entry* id3); 144int playlist_update_resume_info(const struct mp3entry* id3);
147int playlist_get_display_index(void); 145int playlist_get_display_index(void);
@@ -165,9 +163,7 @@ int playlist_insert_directory(struct playlist_info* playlist,
165 bool recurse); 163 bool recurse);
166int playlist_insert_playlist(struct playlist_info* playlist, const char *filename, 164int playlist_insert_playlist(struct playlist_info* playlist, const char *filename,
167 int position, bool queue); 165 int position, bool queue);
168#if CONFIG_CODEC == SWCODEC
169void playlist_skip_entry(struct playlist_info *playlist, int steps); 166void playlist_skip_entry(struct playlist_info *playlist, int steps);
170#endif
171int playlist_delete(struct playlist_info* playlist, int index); 167int playlist_delete(struct playlist_info* playlist, int index);
172int playlist_move(struct playlist_info* playlist, int index, int new_index); 168int playlist_move(struct playlist_info* playlist, int index, int new_index);
173int playlist_randomise(struct playlist_info* playlist, unsigned int seed, 169int playlist_randomise(struct playlist_info* playlist, unsigned int seed,
diff --git a/apps/plugin.c b/apps/plugin.c
index 0ab73281ee..4c0f44b2e8 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -466,7 +466,6 @@ static const struct plugin_api rockbox_api = {
466 thread_self, 466 thread_self,
467 thread_exit, 467 thread_exit,
468 thread_wait, 468 thread_wait,
469#if (CONFIG_CODEC == SWCODEC)
470 thread_thaw, 469 thread_thaw,
471#ifdef HAVE_PRIORITY_SCHEDULING 470#ifdef HAVE_PRIORITY_SCHEDULING
472 thread_set_priority, 471 thread_set_priority,
@@ -474,7 +473,6 @@ static const struct plugin_api rockbox_api = {
474 mutex_init, 473 mutex_init,
475 mutex_lock, 474 mutex_lock,
476 mutex_unlock, 475 mutex_unlock,
477#endif
478#ifdef HAVE_SEMAPHORE_OBJECTS 476#ifdef HAVE_SEMAPHORE_OBJECTS
479 semaphore_init, 477 semaphore_init,
480 semaphore_wait, 478 semaphore_wait,
@@ -517,13 +515,11 @@ static const struct plugin_api rockbox_api = {
517 queue_delete, 515 queue_delete,
518 queue_post, 516 queue_post,
519 queue_wait_w_tmo, 517 queue_wait_w_tmo,
520#if CONFIG_CODEC == SWCODEC
521 queue_enable_queue_send, 518 queue_enable_queue_send,
522 queue_empty, 519 queue_empty,
523 queue_wait, 520 queue_wait,
524 queue_send, 521 queue_send,
525 queue_reply, 522 queue_reply,
526#endif
527 523
528#ifdef RB_PROFILE 524#ifdef RB_PROFILE
529 profile_thread, 525 profile_thread,
@@ -601,7 +597,7 @@ static const struct plugin_api rockbox_api = {
601#ifdef AUDIOHW_HAVE_EQ 597#ifdef AUDIOHW_HAVE_EQ
602 sound_enum_hw_eq_band_setting, 598 sound_enum_hw_eq_band_setting,
603#endif 599#endif
604#if ((CONFIG_CODEC == SWCODEC)) && defined (HAVE_PITCHCONTROL) 600#if defined (HAVE_PITCHCONTROL)
605 sound_set_pitch, 601 sound_set_pitch,
606#endif 602#endif
607#if (CONFIG_PLATFORM & PLATFORM_NATIVE) 603#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
@@ -609,11 +605,7 @@ static const struct plugin_api rockbox_api = {
609 mp3_play_pause, 605 mp3_play_pause,
610 mp3_play_stop, 606 mp3_play_stop,
611 mp3_is_playing, 607 mp3_is_playing,
612#if CONFIG_CODEC != SWCODEC
613 bitswap,
614#endif 608#endif
615#endif
616#if CONFIG_CODEC == SWCODEC
617 &audio_master_sampr_list[0], 609 &audio_master_sampr_list[0],
618 &hw_freq_sampr[0], 610 &hw_freq_sampr[0],
619 pcm_apply_settings, 611 pcm_apply_settings,
@@ -667,7 +659,6 @@ static const struct plugin_api rockbox_api = {
667 pcmbuf_fade, 659 pcmbuf_fade,
668 system_sound_play, 660 system_sound_play,
669 keyclick_click, 661 keyclick_click,
670#endif /* CONFIG_CODEC == SWCODEC */
671 662
672 /* metadata */ 663 /* metadata */
673 get_metadata, 664 get_metadata,
@@ -716,9 +707,6 @@ static const struct plugin_api rockbox_api = {
716 audio_current_track, 707 audio_current_track,
717 audio_flush_and_reload_tracks, 708 audio_flush_and_reload_tracks,
718 audio_get_file_pos, 709 audio_get_file_pos,
719#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
720 mpeg_get_last_header,
721#endif
722 710
723 /* menu */ 711 /* menu */
724 root_menu_get_options, 712 root_menu_get_options,
@@ -783,7 +771,6 @@ static const struct plugin_api rockbox_api = {
783#ifdef ROCKBOX_HAS_LOGF 771#ifdef ROCKBOX_HAS_LOGF
784 _logf, 772 _logf,
785#endif 773#endif
786#if CONFIG_CODEC == SWCODEC
787 codec_thread_do_callback, 774 codec_thread_do_callback,
788 codec_load_file, 775 codec_load_file,
789 codec_run_proc, 776 codec_run_proc,
@@ -792,7 +779,6 @@ static const struct plugin_api rockbox_api = {
792 find_array_ptr, 779 find_array_ptr,
793 remove_array_ptr, 780 remove_array_ptr,
794 round_value_to_list32, 781 round_value_to_list32,
795#endif /* CONFIG_CODEC == SWCODEC */
796 782
797#ifdef HAVE_LCD_BITMAP 783#ifdef HAVE_LCD_BITMAP
798 read_bmp_file, 784 read_bmp_file,
diff --git a/apps/plugin.h b/apps/plugin.h
index 8584d45fa7..41f65947a3 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -66,9 +66,8 @@ void* plugin_get_buffer(size_t *buffer_size);
66#include "scroll_engine.h" 66#include "scroll_engine.h"
67#include "metadata.h" 67#include "metadata.h"
68#include "sound.h" 68#include "sound.h"
69#include "mpeg.h"
70#include "audio.h" 69#include "audio.h"
71#include "mp3_playback.h" 70#include "voice_thread.h"
72#include "root_menu.h" 71#include "root_menu.h"
73#include "talk.h" 72#include "talk.h"
74#include "lang_enum.h" 73#include "lang_enum.h"
@@ -77,7 +76,6 @@ void* plugin_get_buffer(size_t *buffer_size);
77#endif 76#endif
78#include "misc.h" 77#include "misc.h"
79#include "pathfuncs.h" 78#include "pathfuncs.h"
80#if (CONFIG_CODEC == SWCODEC)
81#include "pcm_mixer.h" 79#include "pcm_mixer.h"
82#include "dsp-util.h" 80#include "dsp-util.h"
83#include "dsp_core.h" 81#include "dsp_core.h"
@@ -88,7 +86,6 @@ void* plugin_get_buffer(size_t *buffer_size);
88#ifdef HAVE_RECORDING 86#ifdef HAVE_RECORDING
89#include "recording.h" 87#include "recording.h"
90#endif 88#endif
91#endif /* CONFIG_CODEC == SWCODEC */
92#include "settings.h" 89#include "settings.h"
93#include "timer.h" 90#include "timer.h"
94#include "playlist.h" 91#include "playlist.h"
@@ -526,7 +523,6 @@ struct plugin_api {
526 unsigned int (*thread_self)(void); 523 unsigned int (*thread_self)(void);
527 void (*thread_exit)(void); 524 void (*thread_exit)(void);
528 void (*thread_wait)(unsigned int thread_id); 525 void (*thread_wait)(unsigned int thread_id);
529#if CONFIG_CODEC == SWCODEC
530 void (*thread_thaw)(unsigned int thread_id); 526 void (*thread_thaw)(unsigned int thread_id);
531#ifdef HAVE_PRIORITY_SCHEDULING 527#ifdef HAVE_PRIORITY_SCHEDULING
532 int (*thread_set_priority)(unsigned int thread_id, int priority); 528 int (*thread_set_priority)(unsigned int thread_id, int priority);
@@ -534,7 +530,6 @@ struct plugin_api {
534 void (*mutex_init)(struct mutex *m); 530 void (*mutex_init)(struct mutex *m);
535 void (*mutex_lock)(struct mutex *m); 531 void (*mutex_lock)(struct mutex *m);
536 void (*mutex_unlock)(struct mutex *m); 532 void (*mutex_unlock)(struct mutex *m);
537#endif
538#ifdef HAVE_SEMAPHORE_OBJECTS 533#ifdef HAVE_SEMAPHORE_OBJECTS
539 void (*semaphore_init)(struct semaphore *s, int max, int start); 534 void (*semaphore_init)(struct semaphore *s, int max, int start);
540 int (*semaphore_wait)(struct semaphore *s, int timeout); 535 int (*semaphore_wait)(struct semaphore *s, int timeout);
@@ -580,7 +575,6 @@ struct plugin_api {
580 void (*queue_post)(struct event_queue *q, long id, intptr_t data); 575 void (*queue_post)(struct event_queue *q, long id, intptr_t data);
581 void (*queue_wait_w_tmo)(struct event_queue *q, struct queue_event *ev, 576 void (*queue_wait_w_tmo)(struct event_queue *q, struct queue_event *ev,
582 int ticks); 577 int ticks);
583#if CONFIG_CODEC == SWCODEC
584 void (*queue_enable_queue_send)(struct event_queue *q, 578 void (*queue_enable_queue_send)(struct event_queue *q,
585 struct queue_sender_list *send, 579 struct queue_sender_list *send,
586 unsigned int thread_id); 580 unsigned int thread_id);
@@ -589,7 +583,6 @@ struct plugin_api {
589 intptr_t (*queue_send)(struct event_queue *q, long id, 583 intptr_t (*queue_send)(struct event_queue *q, long id,
590 intptr_t data); 584 intptr_t data);
591 void (*queue_reply)(struct event_queue *q, intptr_t retval); 585 void (*queue_reply)(struct event_queue *q, intptr_t retval);
592#endif /* CONFIG_CODEC == SWCODEC */
593 586
594#ifdef RB_PROFILE 587#ifdef RB_PROFILE
595 void (*profile_thread)(void); 588 void (*profile_thread)(void);
@@ -673,7 +666,7 @@ struct plugin_api {
673 int (*sound_enum_hw_eq_band_setting)(unsigned int band, 666 int (*sound_enum_hw_eq_band_setting)(unsigned int band,
674 unsigned int band_setting); 667 unsigned int band_setting);
675#endif /* AUDIOHW_HAVE_EQ */ 668#endif /* AUDIOHW_HAVE_EQ */
676#if ((CONFIG_CODEC == SWCODEC) && defined (HAVE_PITCHCONTROL)) 669#if defined (HAVE_PITCHCONTROL)
677 void (*sound_set_pitch)(int32_t pitch); 670 void (*sound_set_pitch)(int32_t pitch);
678#endif 671#endif
679#if (CONFIG_PLATFORM & PLATFORM_NATIVE) 672#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
@@ -682,11 +675,7 @@ struct plugin_api {
682 void (*mp3_play_pause)(bool play); 675 void (*mp3_play_pause)(bool play);
683 void (*mp3_play_stop)(void); 676 void (*mp3_play_stop)(void);
684 bool (*mp3_is_playing)(void); 677 bool (*mp3_is_playing)(void);
685#if CONFIG_CODEC != SWCODEC
686 void (*bitswap)(unsigned char *data, int length);
687#endif
688#endif /* PLATFORM_NATIVE */ 678#endif /* PLATFORM_NATIVE */
689#if CONFIG_CODEC == SWCODEC
690 const unsigned long *audio_master_sampr_list; 679 const unsigned long *audio_master_sampr_list;
691 const unsigned long *hw_freq_sampr; 680 const unsigned long *hw_freq_sampr;
692 void (*pcm_apply_settings)(void); 681 void (*pcm_apply_settings)(void);
@@ -752,7 +741,6 @@ struct plugin_api {
752 void (*pcmbuf_fade)(bool fade, bool in); 741 void (*pcmbuf_fade)(bool fade, bool in);
753 void (*system_sound_play)(enum system_sound sound); 742 void (*system_sound_play)(enum system_sound sound);
754 void (*keyclick_click)(bool rawbutton, int action); 743 void (*keyclick_click)(bool rawbutton, int action);
755#endif /* CONFIG_CODEC == SWCODEC */
756 744
757 /* metadata */ 745 /* metadata */
758 bool (*get_metadata)(struct mp3entry* id3, int fd, const char* trackname); 746 bool (*get_metadata)(struct mp3entry* id3, int fd, const char* trackname);
@@ -817,9 +805,6 @@ struct plugin_api {
817 struct mp3entry* (*audio_current_track)(void); 805 struct mp3entry* (*audio_current_track)(void);
818 void (*audio_flush_and_reload_tracks)(void); 806 void (*audio_flush_and_reload_tracks)(void);
819 int (*audio_get_file_pos)(void); 807 int (*audio_get_file_pos)(void);
820#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
821 unsigned long (*mpeg_get_last_header)(void);
822#endif
823 808
824 /* menu */ 809 /* menu */
825 struct menu_table *(*root_menu_get_options)(int *nb_options); 810 struct menu_table *(*root_menu_get_options)(int *nb_options);
@@ -902,7 +887,6 @@ struct plugin_api {
902#ifdef ROCKBOX_HAS_LOGF 887#ifdef ROCKBOX_HAS_LOGF
903 void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); 888 void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
904#endif 889#endif
905#if CONFIG_CODEC == SWCODEC
906 void (*codec_thread_do_callback)(void (*fn)(void), 890 void (*codec_thread_do_callback)(void (*fn)(void),
907 unsigned int *audio_thread_id); 891 unsigned int *audio_thread_id);
908 int (*codec_load_file)(const char* codec, struct codec_api *api); 892 int (*codec_load_file)(const char* codec, struct codec_api *api);
@@ -915,7 +899,6 @@ struct plugin_api {
915 const unsigned long list[], 899 const unsigned long list[],
916 int count, 900 int count,
917 bool signd); 901 bool signd);
918#endif /* CONFIG_CODEC == SWCODEC */
919 902
920#ifdef HAVE_LCD_BITMAP 903#ifdef HAVE_LCD_BITMAP
921 int (*read_bmp_file)(const char* filename, struct bitmap *bm, int maxsize, 904 int (*read_bmp_file)(const char* filename, struct bitmap *bm, int maxsize,
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index 197f58ef5c..96ad535863 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -46,17 +46,12 @@ remote_control.c
46lamp.c 46lamp.c
47#endif /* HAVE_BACKLIGHT */ 47#endif /* HAVE_BACKLIGHT */
48 48
49
50
51#if CONFIG_CODEC == SWCODEC
52#if defined(HAVE_RECORDING) && (defined(HAVE_LINE_IN) || defined(HAVE_MIC_IN)) 49#if defined(HAVE_RECORDING) && (defined(HAVE_LINE_IN) || defined(HAVE_MIC_IN))
53pitch_detector.c 50pitch_detector.c
54#endif 51#endif
55 52
56mp3_encoder.c 53mp3_encoder.c
57wav2wv.c 54wav2wv.c
58#endif /* CONFIG_CODEC */
59
60 55
61#if CONFIG_RTC 56#if CONFIG_RTC
62alarmclock.c 57alarmclock.c
@@ -99,15 +94,6 @@ pictureflow.c
99 94
100#endif /* PLUGIN_BUFFER_SIZE <= 0x20000 && HAVE_LCD_BITMAP */ 95#endif /* PLUGIN_BUFFER_SIZE <= 0x20000 && HAVE_LCD_BITMAP */
101 96
102
103#if CONFIG_CODEC != SWCODEC
104
105#if defined(HAVE_LCD_BITMAP)
106splitedit.c
107#endif
108
109#endif /* HWCODEC */
110
111#if defined(IRIVER_H100_SERIES) 97#if defined(IRIVER_H100_SERIES)
112iriver_flash.c 98iriver_flash.c
113#endif 99#endif
@@ -207,9 +193,7 @@ superdom.c
207#ifdef HAVE_ADJUSTABLE_CPU_FREQ 193#ifdef HAVE_ADJUSTABLE_CPU_FREQ
208test_boost.c 194test_boost.c
209#endif 195#endif
210#if CONFIG_CODEC == SWCODEC
211test_codec.c 196test_codec.c
212#endif
213#ifdef HAVE_JPEG 197#ifdef HAVE_JPEG
214test_core_jpeg.c 198test_core_jpeg.c
215#endif 199#endif
@@ -232,9 +216,7 @@ test_mem_jpeg.c
232#ifdef HAVE_LCD_COLOR 216#ifdef HAVE_LCD_COLOR
233test_resize.c 217test_resize.c
234#endif 218#endif
235#if CONFIG_CODEC == SWCODEC
236test_sampr.c 219test_sampr.c
237#endif
238#ifdef HAVE_TOUCHSCREEN 220#ifdef HAVE_TOUCHSCREEN
239test_touchscreen.c 221test_touchscreen.c
240#endif 222#endif
diff --git a/apps/plugins/SOURCES.app_build b/apps/plugins/SOURCES.app_build
index 89a8b0ede6..8cfc5881b2 100644
--- a/apps/plugins/SOURCES.app_build
+++ b/apps/plugins/SOURCES.app_build
@@ -23,9 +23,7 @@ test_fps.c
23#ifdef HAVE_ADJUSTABLE_CPU_FREQ 23#ifdef HAVE_ADJUSTABLE_CPU_FREQ
24test_boost.c 24test_boost.c
25#endif 25#endif
26#if CONFIG_CODEC == SWCODEC
27test_codec.c 26test_codec.c
28#endif
29#ifdef HAVE_JPEG 27#ifdef HAVE_JPEG
30test_core_jpeg.c 28test_core_jpeg.c
31#endif 29#endif
@@ -46,9 +44,7 @@ test_mem_jpeg.c
46#ifdef HAVE_LCD_COLOR 44#ifdef HAVE_LCD_COLOR
47test_resize.c 45test_resize.c
48#endif 46#endif
49#if CONFIG_CODEC == SWCODEC
50test_sampr.c 47test_sampr.c
51#endif
52test_viewports.c 48test_viewports.c
53#endif /* HAVE_TEST_PLUGINS */ 49#endif /* HAVE_TEST_PLUGINS */
54 50
diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS
index 5fd2d433c7..2c8e43c837 100644
--- a/apps/plugins/SUBDIRS
+++ b/apps/plugins/SUBDIRS
@@ -37,7 +37,7 @@ rockboy
37pictureflow 37pictureflow
38#endif 38#endif
39 39
40#if CONFIG_CODEC == SWCODEC && PLUGIN_BUFFER_SIZE > 0x20000 40#if PLUGIN_BUFFER_SIZE > 0x20000
41fft 41fft
42#endif 42#endif
43 43
@@ -70,9 +70,6 @@ pacbox
70doom 70doom
71#endif 71#endif
72 72
73/* For all the swcodec targets */
74#if CONFIG_CODEC == SWCODEC
75
76#if MEMORYSIZE > 2 /* we need a lot of RAM for instruments */ 73#if MEMORYSIZE > 2 /* we need a lot of RAM for instruments */
77midi 74midi
78mikmod 75mikmod
@@ -91,8 +88,6 @@ pdbox
91mpegplayer 88mpegplayer
92#endif 89#endif
93 90
94#endif /* CONFIG_CODEC == SWCODEC */
95
96/* Lua needs at least 160 KB to work in */ 91/* Lua needs at least 160 KB to work in */
97#if PLUGIN_BUFFER_SIZE >= 0x80000 92#if PLUGIN_BUFFER_SIZE >= 0x80000
98lua 93lua
diff --git a/apps/plugins/SUBDIRS.app_build b/apps/plugins/SUBDIRS.app_build
index 48a2d36d87..95b5e64639 100644
--- a/apps/plugins/SUBDIRS.app_build
+++ b/apps/plugins/SUBDIRS.app_build
@@ -10,7 +10,7 @@ lua
10lua_scripts 10lua_scripts
11#ifdef HAVE_LCD_BITMAP 11#ifdef HAVE_LCD_BITMAP
12 12
13#if CONFIG_CODEC == SWCODEC && PLUGIN_BUFFER_SIZE > 0x20000 13#if PLUGIN_BUFFER_SIZE > 0x20000
14fft 14fft
15#endif 15#endif
16 16
@@ -23,11 +23,8 @@ pictureflow
23#endif /* HAVE_LCD_BITMAP */ 23#endif /* HAVE_LCD_BITMAP */
24 24
25/* For all the swcodec targets */ 25/* For all the swcodec targets */
26#if CONFIG_CODEC == SWCODEC
27
28#if MEMORYSIZE > 2 /* we need a lot of RAM for instruments */ 26#if MEMORYSIZE > 2 /* we need a lot of RAM for instruments */
29mikmod 27mikmod
30#endif 28#endif
31 29
32#endif /* CONFIG_CODEC == SWCODEC */
33#endif /* HAVE_TOUCHSCREEN */ 30#endif /* HAVE_TOUCHSCREEN */
diff --git a/apps/plugins/bitmaps/mono/SOURCES b/apps/plugins/bitmaps/mono/SOURCES
index df1397d2e2..ad8b951e45 100644
--- a/apps/plugins/bitmaps/mono/SOURCES
+++ b/apps/plugins/bitmaps/mono/SOURCES
@@ -50,12 +50,10 @@ invadrox_fire.6x6x1.bmp
50#endif 50#endif
51#endif 51#endif
52 52
53#if CONFIG_CODEC == SWCODEC
54/* MPEGplayer */ 53/* MPEGplayer */
55mpegplayer_status_icons_8x8x1.bmp 54mpegplayer_status_icons_8x8x1.bmp
56mpegplayer_status_icons_12x12x1.bmp 55mpegplayer_status_icons_12x12x1.bmp
57mpegplayer_status_icons_16x16x1.bmp 56mpegplayer_status_icons_16x16x1.bmp
58#endif
59 57
60#if LCD_WIDTH == 160 && LCD_HEIGHT == 128 && LCD_DEPTH < 16 58#if LCD_WIDTH == 160 && LCD_HEIGHT == 128 && LCD_DEPTH < 16
61superdom_boarditems.160x128x1.bmp 59superdom_boarditems.160x128x1.bmp
diff --git a/apps/plugins/bitmaps/native/SOURCES b/apps/plugins/bitmaps/native/SOURCES
index 16df8a03d7..22f82800a7 100644
--- a/apps/plugins/bitmaps/native/SOURCES
+++ b/apps/plugins/bitmaps/native/SOURCES
@@ -957,7 +957,7 @@ rockboxlogo.91x32x1.bmp
957/* Pitch detector */ 957/* Pitch detector */
958/* The following preprocessor condition must match the condition */ 958/* The following preprocessor condition must match the condition */
959/* for pitch detector from plugins/SOURCES */ 959/* for pitch detector from plugins/SOURCES */
960#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && \ 960#if defined(HAVE_RECORDING) && \
961 (defined(HAVE_LINE_IN) || defined(HAVE_MIC_IN)) 961 (defined(HAVE_LINE_IN) || defined(HAVE_MIC_IN))
962#if (LCD_WIDTH >= 320) && (LCD_HEIGHT >= 240) && (LCD_DEPTH >= 16) 962#if (LCD_WIDTH >= 320) && (LCD_HEIGHT >= 240) && (LCD_DEPTH >= 16)
963pitch_notes.320x240x16.bmp 963pitch_notes.320x240x16.bmp
diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c
index f861d19caa..cb7b85786f 100644
--- a/apps/plugins/chip8.c
+++ b/apps/plugins/chip8.c
@@ -1331,39 +1331,11 @@ static byte chip8_keymap[16];
1331static unsigned long starttimer; /* Timer value at the beginning */ 1331static unsigned long starttimer; /* Timer value at the beginning */
1332static unsigned long cycles; /* Number of update cycles (50Hz) */ 1332static unsigned long cycles; /* Number of update cycles (50Hz) */
1333 1333
1334#if (CONFIG_CODEC != SWCODEC) && !defined(SIMULATOR)
1335static bool is_playing;
1336
1337/* one frame of bitswapped mp3 data */
1338static unsigned char beep[]={255,
1339223, 28, 35, 0,192,210, 35,226, 72,188,242, 1,128,166, 16, 68,146,252,151, 19,
1340 10,180,245,127, 96,184, 3,184, 30, 0,118, 59,128,121,102, 6,212, 0, 97, 6,
1341 42, 65, 28,134,192,145, 57, 38,136, 73, 29, 38,132, 15, 21, 70, 91,185, 99,198,
1342 15,192, 83, 6, 33,129, 20, 6, 97, 33, 4, 6,245,128, 92, 6, 24, 0, 86, 6,
1343 56,129, 44, 24,224, 25, 13, 48, 50, 82,180, 11,251,106,249, 59, 24, 82,175,223,
1344252,119, 76,134,120,236,149,250,247,115,254,145,173,174,168,180,255,107,195, 89,
1345 24, 25, 48,131,192, 61, 48, 64, 10,176, 49, 64, 1,152, 50, 32, 8,140, 48, 16,
1346 5,129, 51,196,187, 41,177, 23,138, 70, 50, 8, 10,242, 48,192, 3,248,226, 0,
1347 20,100, 18, 96, 41, 96, 78,102, 7,201,122, 76,119, 20,137, 37,177, 15,132,224,
1348 20, 17,191, 67,147,187,116,211, 41,169, 63,172,182,186,217,155,111,140,104,254,
1349111,181,184,144, 17,148, 21,101,166,227,100, 86, 85, 85, 85};
1350/* callback to request more mp3 data */
1351static void callback(const void** start, size_t* size)
1352{
1353 *start = beep; /* give it the same frame again */
1354 *size = sizeof(beep);
1355}
1356#endif /* PLATFORM_NATIVE */
1357
1358/****************************************************************************/ 1334/****************************************************************************/
1359/* Turn sound on */ 1335/* Turn sound on */
1360/****************************************************************************/ 1336/****************************************************************************/
1361static void chip8_sound_on (void) 1337static void chip8_sound_on (void)
1362{ 1338{
1363#if(CONFIG_CODEC != SWCODEC) && !defined(SIMULATOR)
1364 if (!is_playing)
1365 rb->mp3_play_pause(true); /* kickoff audio */
1366#endif
1367} 1339}
1368 1340
1369/****************************************************************************/ 1341/****************************************************************************/
@@ -1371,10 +1343,6 @@ static void chip8_sound_on (void)
1371/****************************************************************************/ 1343/****************************************************************************/
1372static void chip8_sound_off (void) 1344static void chip8_sound_off (void)
1373{ 1345{
1374#if (CONFIG_CODEC != SWCODEC) && !defined(SIMULATOR)
1375 if (!is_playing)
1376 rb->mp3_play_pause(false); /* pause audio */
1377#endif
1378} 1346}
1379 1347
1380/****************************************************************************/ 1348/****************************************************************************/
@@ -1576,27 +1544,12 @@ static bool chip8_run(const char* file)
1576 rb->lcd_drawrect(CHIP8_X-1,CHIP8_Y-1,CHIP8_LCDWIDTH+2,CHIP8_HEIGHT+2); 1544 rb->lcd_drawrect(CHIP8_X-1,CHIP8_Y-1,CHIP8_LCDWIDTH+2,CHIP8_HEIGHT+2);
1577#endif 1545#endif
1578 rb->lcd_update(); 1546 rb->lcd_update();
1579#if (CONFIG_CODEC != SWCODEC) && !defined(SIMULATOR)
1580 /* init sound */
1581 is_playing = rb->mp3_is_playing(); /* would we disturb playback? */
1582 if (!is_playing) /* no? then we can make sound */
1583 { /* prepare */
1584 rb->mp3_play_data(beep, sizeof(beep), callback);
1585 }
1586#endif
1587 starttimer = *rb->current_tick; 1547 starttimer = *rb->current_tick;
1588 1548
1589 chip8_iperiod=15; 1549 chip8_iperiod=15;
1590 cycles = 0; 1550 cycles = 0;
1591 chip8(); 1551 chip8();
1592 1552
1593#if (CONFIG_CODEC != SWCODEC) && !defined(SIMULATOR)
1594 if (!is_playing)
1595 { /* stop it if we used audio */
1596 rb->mp3_play_stop(); /* Stop audio playback */
1597 }
1598#endif
1599
1600 if (chip8_running == 3) { 1553 if (chip8_running == 3) {
1601 /* unsupported instruction */ 1554 /* unsupported instruction */
1602 rb->splash(HZ, "Error: Unsupported" 1555 rb->splash(HZ, "Error: Unsupported"
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c
index 4fa989da46..e6eb543eda 100644
--- a/apps/plugins/lua/rocklib.c
+++ b/apps/plugins/lua/rocklib.c
@@ -487,7 +487,7 @@ RB_WRAP(sound)
487 lua_pushstring (L, rb->sound_unit(setting)); 487 lua_pushstring (L, rb->sound_unit(setting));
488 return 1; 488 return 1;
489 break; 489 break;
490#if ((CONFIG_CODEC == SWCODEC) && defined (HAVE_PITCHCONTROL)) 490#if defined (HAVE_PITCHCONTROL)
491 case SOUND_SET_PITCH: 491 case SOUND_SET_PITCH:
492 rb->sound_set_pitch(setting); 492 rb->sound_set_pitch(setting);
493 return 1;/*nil*/ 493 return 1;/*nil*/
@@ -507,7 +507,6 @@ RB_WRAP(sound)
507 return 1; 507 return 1;
508} 508}
509 509
510#if CONFIG_CODEC == SWCODEC
511RB_WRAP(pcm) 510RB_WRAP(pcm)
512{ 511{
513 enum e_pcm {PCM_APPLYSETTINGS = 0, PCM_ISPLAYING, PCM_ISPAUSED, 512 enum e_pcm {PCM_APPLYSETTINGS = 0, PCM_ISPLAYING, PCM_ISPAUSED,
@@ -579,7 +578,6 @@ RB_WRAP(mixer_frequency)
579 lua_pushinteger(L, result); 578 lua_pushinteger(L, result);
580 return 1; 579 return 1;
581} 580}
582#endif /*CONFIG_CODEC == SWCODEC*/
583 581
584/* DEVICE LIGHTING CONTROL */ 582/* DEVICE LIGHTING CONTROL */
585RB_WRAP(backlight_onoff) 583RB_WRAP(backlight_onoff)
@@ -953,10 +951,8 @@ static const luaL_Reg rocklib[] =
953 RB_FUNC(audio), 951 RB_FUNC(audio),
954 RB_FUNC(playlist), 952 RB_FUNC(playlist),
955 RB_FUNC(sound), 953 RB_FUNC(sound),
956#if CONFIG_CODEC == SWCODEC
957 RB_FUNC(pcm), 954 RB_FUNC(pcm),
958 RB_FUNC(mixer_frequency), 955 RB_FUNC(mixer_frequency),
959#endif
960 956
961 /* DEVICE LIGHTING CONTROL */ 957 /* DEVICE LIGHTING CONTROL */
962 RB_FUNC(backlight_onoff), 958 RB_FUNC(backlight_onoff),
diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c
index 75947df618..eec8a92e78 100644
--- a/apps/plugins/metronome.c
+++ b/apps/plugins/metronome.c
@@ -123,143 +123,6 @@ const struct button_mapping *plugin_contexts[] =
123}; 123};
124#define PLA_ARRAY_COUNT sizeof(plugin_contexts)/sizeof(plugin_contexts[0]) 124#define PLA_ARRAY_COUNT sizeof(plugin_contexts)/sizeof(plugin_contexts[0])
125 125
126#if CONFIG_CODEC != SWCODEC
127#ifndef SIMULATOR
128/* MP3 tick sounds */
129static unsigned char tick_sound[] =
130{
131 255,251,112,196, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
132, 0, 73,110,102,111, 0, 0, 0, 15, 0, 0, 0, 3, 0, 0, 4,229, 0, 85, 85
133, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85
134, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,170,170,170,170,170,170,170,170,170
135,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170
136,170,170,170,170,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
137,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0
138, 57, 76, 65, 77, 69, 51, 46, 57, 57,114, 1,205, 0, 0, 0, 0, 46,102, 0, 0
139, 20, 96, 36, 3, 64, 66, 0, 0, 96, 0, 0, 4,229,101,175,184,232, 0, 0, 0
140, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
141, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
142, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
145, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,251,112,196, 0, 0, 13
147, 92,189,103, 52,194,128, 2,165,176,176,247, 51, 16, 2, 0, 0, 24, 32, 0, 12
148,204,204,204,204,207,215,221,121,229, 74,224,152, 1,128, 24, 19, 17,207,217,246
149,252,132,212,226,225,192, 16, 0, 0, 0, 0, 32,163,100,111,255, 66, 7, 0, 48
150, 12, 14, 31, 59,255,255,234,112,248,112, 56, 40,223,193, 0, 64, 16, 4, 1, 51
151,229, 29,234, 4,193,240,124, 31, 62, 15,135,255, 7,193, 0, 64, 16, 12, 9, 1
152, 15,168, 16, 1,131,224,254,254,146,224,254, 8, 28, 88,127,255,148, 4, 32,128
153, 32,196,182,166,245,242,214,222,214, 73, 45,110, 52,137, 81, 39,107,255, 44, 76
154,148,140, 8,250, 66,148,195, 43, 3, 41, 15, 18,163, 80, 5, 20,248,174,140,138
155,115, 1,146, 50, 49, 32, 44,201,152,157, 53, 32, 33,157, 8, 34, 85,135, 88,105
156,186,131,252, 48,143,168,162, 44,209,142, 16, 88,221, 10,214, 94, 51, 52, 46,148
157,133, 36, 38,129,165, 36,164,139, 64,211, 11,115,101, 49, 5,136, 33,157, 18,241
158,137, 50, 53,194,213,173, 78,241,108, 1, 24,172,129,146,141,136, 24,119, 73, 51
159, 85,162,138,146, 51, 20,101,163,242,129, 56,212, 84,233, 44, 94, 11, 97,117, 74
160, 73, 37,162, 58, 20,146, 95,203, 31,246, 50, 55,111,214,223,205,213,230, 31,232
161,122,143,183, 14, 39, 91, 57, 15,251,186, 21,185,149, 48, 1,100, 64,200, 16,121
162,155, 72,110, 24,130, 98,255,251,114,196, 7,128, 17,169,247, 95,221,152,128, 10
163, 80, 62,233,185,150,170,113,174,203,251, 59, 12,190,170, 98, 4,156,122,140, 97
164,155, 60, 39, 8,145,195,116, 22,164, 82,118,116, 42,116,157, 68, 88, 70, 64, 93
165, 17, 35, 39,163,118,118, 77, 75, 82,187,215, 89,140, 46,100,112,151, 75, 73,169
166,107,181,157,170,251, 45,140, 75, 34,122, 28,228,146,111,255,235,210, 81,124,114
167,199, 52,180,138,174,207,255,235, 82,210, 64,123, 34,197,101, 47,255,254,234, 91
168, 14, 74, 68,234,219,255,254,206,131,143,162,120,234,210,191,255,245, 93, 18,200
169,225, 42, 29,171,255,254,165,164,196, 24,137, 32,223, 90, 93, 96, 64,217, 78, 35
170, 32, 53,185,107,237, 43,113, 98, 80,107,161, 3,206, 60,192, 10, 78,226,219,199
171,158,146,158, 47, 59, 90,253,154,221,198,138,147,100,150,206,233, 32, 39,192, 73
172, 23, 76,150,201, 41,209,186,217, 37,250,233, 38,198, 34, 24, 18, 33,130, 38,158
173, 73, 54, 69,146, 91, 36,182, 75,235, 64,216,196,138, 9,201, 69,174,138,157,244
174,154,150,208,246, 57, 72, 71, 2,148, 23, 76,115, 83,255,210,218,161, 56, 3, 68
175, 81, 49,190,139,253,125, 81,205, 25, 13,202,146,156,173,255,250,234,194, 8, 69
176, 13,142,255,255,209, 88,136, 73, 6,145,235, 26,142,191,255, 85,100,154,104,178
177,131,213, 0, 34, 0, 17,132, 0, 7,227, 82,135, 11,113, 70,110,105, 94,118, 22
178,255,251,112,196, 9, 0, 17, 61,249, 41,128,101,163, 73,217,178,153, 88,147, 21
179, 48,158,206,220,162,156,221, 7,209, 69, 20,117,163, 69,146, 68,145, 26,131,150
180, 0, 4,132, 41, 8,214,202,209, 69, 30,191,116, 76,156,240, 41,194,118, 23,147
181, 67,173, 87,255,233, 29, 64,216, 73,129, 10, 28,227,197,217, 43,255,254,203, 40
182,140, 48,129, 5,201, 21, 58, 95,255,232,180,168, 70,136,131,201,146,255,254,182
183,169,206, 5,216,101, 36,146,217,109,255,250,169, 38, 96, 35, 69, 51,167,157,191
184,255, 82,158,152,225, 46, 14, 99,235,100,159,255,253, 22, 29,162, 98, 84,108,210
185,202,128, 74, 16, 23,220, 23, 96,152, 17, 5,129,242, 49,137, 75, 60, 81, 16, 80
186, 34,106, 74, 91,255,222, 53, 18, 64,160, 70, 1,195, 5,139,230, 84,118,254,236
187, 44, 29, 1,130,196,195,130,236,237,255,253,156, 84, 60, 17, 10, 10, 19, 35,179
188,255,254,206,198, 14,132,130,194,196, 14, 67,179,255,254,198, 40,144,136, 80, 80
189, 76, 64,228, 57, 29,191,251, 57, 76, 34, 18, 8,132, 66,132,200,114, 59, 63,255
190,220,166, 17, 18, 18, 26, 32,112,201,159,240,144,184,169, 23,127,197,133, 69, 85
191, 76, 65, 77, 69, 51, 46, 57, 57, 46, 53, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85
192, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85
193, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85
194};
195static unsigned char tock_sound[] =
196{
197 255,251,112,196, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
198, 0, 73,110,102,111, 0, 0, 0, 15, 0, 0, 0, 3, 0, 0, 4,229, 0, 85, 85
199, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85
200, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,170,170,170,170,170,170,170,170,170
201,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170
202,170,170,170,170,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
203,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, 0
204, 57, 76, 65, 77, 69, 51, 46, 57, 57,114, 1,205, 0, 0, 0, 0, 46,100, 0, 0
205, 20, 96, 36, 3, 64, 66, 0, 0, 96, 0, 0, 4,229,187,155,119, 17, 0, 0, 0
206, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
207, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
209, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
211, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
212, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,251,112,196, 0, 0, 13
213,105, 19,104,212,146,128, 10,164, 41,175,119, 51, 32, 0, 2, 32, 41, 84, 9,130
214, 96,152,109,228, 0, 16, 0, 6, 9,209,163,111,127,154, 48, 0, 0, 0, 0,129
215,194, 19,212,226, 97,240,248,187,255, 65, 0,248,124, 92,255,144,130, 1,192,225
216, 9,249,206,115,138, 16,158,132, 57,206,115,191,242, 16,132,111,212,231, 14, 7
217, 8, 70,243,156,231, 57,206,121,207,200, 66, 16, 92,231,255,134, 0, 0, 0,127
218,244, 60, 60, 51,255,192, 3,195,207,252, 0, 0, 0, 29, 39,244, 60, 48, 3,255
219,195,219,177,171,179,181, 8,157,251,239,155,104,162, 80, 5,194, 16,165,199, 42
220,104,133, 19,109, 88, 96, 61,104,242,117,118, 94,135, 29, 53, 72, 67, 85, 11, 54
221, 59, 64,154,155,128,195, 23,148, 98, 43,186, 43,139, 64,218, 82, 68,160,197,168
222,125, 10, 50, 41, 16,240, 30, 6,228, 52,117, 0, 51,130,146,122,152,109,162,201
223, 45,154, 30, 11, 66, 30, 76, 73,145,224, 52,149, 17, 55,138,112,105, 51, 36,147
224, 22,130, 89, 20,138, 36,114,212,145, 3,199,107,101,213, 25, 21,222,196,209,162
225, 40,168,168,165,162,100,142,163,220,186,250, 72,106, 54, 75, 48,243, 79,153, 54
226,163, 93,179,171,204,144,232,190,115, 19,208, 90,172,244, 40, 98,126, 35,161,234
227,122,143,221, 39,250,159, 61, 35,111,250,213,216, 6,252, 9,138, 17, 64, 1, 13
228, 56, 80, 58,104,184, 37,255,251,114,196, 7,128, 17,250, 1, 97,189,152, 0, 10
229, 44,192, 41,253,151,169,185,237, 56, 3,131,220, 24,180,204,165,221,129,107,210
230,192, 50,130, 26, 22, 26,180, 77, 81, 85,221,146, 33,197,224,198,197,228,146, 89
231,162,210, 69,100,233, 13, 25,145, 61, 19,206,151,232,172,212, 58,162,149, 53, 70
232,234,234, 81,176,186, 28, 39,145,253, 87, 33,130,150, 43, 36,187,245,169,141,200
233, 41,178,191,230, 68,233,170,255,230, 37,227,101,183,237, 49, 56,109,255,115,134
234,232,223,247,156, 62,191,250, 43, 42,169,127,245, 26,160,255,234,151,157,191,215
235, 46,164,223,235, 98,137,118,223,238,112,189,111,247, 56, 94,106, 16, 1, 77, 8
236, 25, 4,204, 0, 0,134, 96, 41,151,170, 74,147,135, 11,136, 28,220, 96,102,179
237, 16,145, 89,202, 11,197,114, 72, 0,241, 77, 88,211, 70,174,171, 10, 11, 84,163
238, 5, 53,191,241,191,106,245,209,114, 21,240,208, 75,172,190,150,103,205,178,252
239, 78, 36,166,139,132,106,231, 86,253,130, 80,178,201,254,193, 68, 20,207,254,206
240, 49, 19, 78,127,253,159,255, 33, 37, 37, 95,238,112,188, 89, 37, 79,238,165, 5
241,163,151,249,168,130,215,255,169,223,249,231, 15,149,191,161,227,209,235, 63,232
242,166, 10,198,183,232,150, 34,119,255,213, 17,255,231, 17, 44, 8, 2, 96, 1,101
243,184,243,226,216, 18, 60,216,132,105,150,250,101,165, 64,237,172,186, 35,114,126
244,255,251,112,196, 12,128,144,142, 3, 44,140,180,241, 1,207, 47,217, 72,244, 10
245, 48, 29, 88, 20, 21,128, 36,231,157,173,100,202, 35,136,119,133,228,209, 55,186
246,218,198,197,208,217, 11,233,178,254,186,137,128, 8,110, 71,253,212,136,138, 45
247,118,253,216, 34, 7, 74, 99,255, 60, 22,144,101,111,209, 72,136,196,175,254, 58
248, 15, 76, 71,249,184,138, 45, 30,127,234,199, 21, 35,191,245, 17, 75, 63,252,120
249,108, 58,223,209,199, 74,141, 91,254,131, 98, 70,255,212, 69, 42, 71,254,172, 54
250,127,252,116,107,255,168,212,194, 64, 61,126, 46,224,170, 52, 71,208,229, 19,209
251,148, 64,203,225,206,126, 29,230, 1,134,123,159,138,246, 67,199, 93,127,253, 50
252,148, 81, 37, 13, 40,145, 8, 37, 12, 6, 4, 49, 67,204,186,186,255,255,213,149
253,149,137, 16,132,162, 8,128, 90, 58, 93, 95,255,121,138, 96,161,131, 3, 33,200
254,118,127,255,238, 83, 5, 10, 8,228, 58, 47,255,252,197, 48, 96,104,116, 84, 84
255, 69,255,251, 24, 40, 80, 74, 69, 69, 64, 96,193, 7,141, 1, 89,203, 5,113, 81
256, 70,255,245,139, 85, 76, 65, 77, 69, 51, 46, 57, 57, 46, 53, 85, 85, 85, 85, 85
257, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85
258, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85
259, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85
260};
261#endif /* SIMULATOR */
262#else
263/* raw PCM */ 126/* raw PCM */
264static signed short tick_sound[] = 127static signed short tick_sound[] =
265{ 128{
@@ -641,7 +504,6 @@ static signed short tock_sound[] =
641,-3,2,-1,0,1,-1,0,0,1,-1,1 504,-3,2,-1,0,1,-1,0,0,1,-1,1
642,-2,3 505,-2,3
643}; 506};
644#endif
645 507
646/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 508/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
647 Utilities from pdbox plugin (Copyright (C) 2009 Wincent Balin) --- am I 509 Utilities from pdbox plugin (Copyright (C) 2009 Wincent Balin) --- am I
@@ -941,51 +803,6 @@ static int bpm_step_counter = 0;
941 803
942static bool sound_trigger = false; 804static bool sound_trigger = false;
943 805
944#if CONFIG_CODEC != SWCODEC
945
946#ifdef SIMULATOR
947
948/* No audio in HWCODEC simulator build. */
949#define MET_IS_PLAYING 0
950#define MET_PLAY_STOP do {} while(0)
951static void play_tick(void){ printf("tick\n"); }
952static void play_tock(void){ printf("tock\n"); }
953
954#else
955
956#define MET_IS_PLAYING rb->mp3_is_playing()
957#define MET_PLAY_STOP rb->mp3_play_stop()
958
959static void callback(const void** start, size_t* size)
960{
961 (void)start; /* unused parameter, avoid warning */
962 *size = 0; /* end of data */
963 sound_active = false;
964 rb->led(0);
965}
966
967/* Wondering: Should one prevent playing again while sound_active == true? */
968
969static void play_tick(void)
970{
971 sound_active = true;
972 rb->led(1);
973 rb->mp3_play_data(tick_sound, sizeof(tick_sound), callback);
974 rb->mp3_play_pause(true); /* kickoff audio */
975}
976
977static void play_tock(void)
978{
979 sound_active = true;
980 rb->led(1);
981 rb->mp3_play_data(tock_sound, sizeof(tock_sound), callback);
982 rb->mp3_play_pause(true); /* kickoff audio */
983}
984
985#endif /* SIMULATOR */
986
987#else /* CONFIG_CODEC == SWCODEC */
988
989#define MET_IS_PLAYING rb->pcm_is_playing() 806#define MET_IS_PLAYING rb->pcm_is_playing()
990#define MET_PLAY_STOP rb->audio_stop() 807#define MET_PLAY_STOP rb->audio_stop()
991 808
@@ -1014,8 +831,6 @@ static void play_tock(void)
1014 rb->pcm_play_data(NULL, NULL, tock_buf, sizeof(tock_buf)); 831 rb->pcm_play_data(NULL, NULL, tock_buf, sizeof(tock_buf));
1015} 832}
1016 833
1017#endif /* CONFIG_CODEC != SWCODEC */
1018
1019/* State: 0: blank/title, 1: tick, 2: tock 3: silent klick */ 834/* State: 0: blank/title, 1: tick, 2: tock 3: silent klick */
1020/* TODO: Could use more smart placement, using 835/* TODO: Could use more smart placement, using
1021 lcd_getstringsize() and such. */ 836 lcd_getstringsize() and such. */
@@ -1446,9 +1261,7 @@ static void cleanup(void)
1446 MET_PLAY_STOP; /* stop audio ISR */ 1261 MET_PLAY_STOP; /* stop audio ISR */
1447 tweak_volume(0); 1262 tweak_volume(0);
1448 rb->led(0); 1263 rb->led(0);
1449#if CONFIG_CODEC == SWCODEC
1450 rb->pcm_set_frequency(HW_SAMPR_DEFAULT); 1264 rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
1451#endif
1452} 1265}
1453 1266
1454/* 1267/*
@@ -1786,12 +1599,6 @@ enum plugin_status plugin_start(const void* file)
1786 1599
1787 if(MET_IS_PLAYING) MET_PLAY_STOP; /* stop audio IS */ 1600 if(MET_IS_PLAYING) MET_PLAY_STOP; /* stop audio IS */
1788 1601
1789#if (CONFIG_CODEC != SWCODEC)
1790#ifndef SIMULATOR
1791 rb->bitswap(tick_sound, sizeof(tick_sound));
1792 rb->bitswap(tock_sound, sizeof(tock_sound));
1793#endif
1794#else
1795 prepare_buffers(); 1602 prepare_buffers();
1796#if INPUT_SRC_CAPS != 0 1603#if INPUT_SRC_CAPS != 0
1797 /* Select playback */ 1604 /* Select playback */
@@ -1799,7 +1606,6 @@ enum plugin_status plugin_start(const void* file)
1799 rb->audio_set_output_source(AUDIO_SRC_PLAYBACK); 1606 rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
1800#endif 1607#endif
1801 rb->pcm_set_frequency(SAMPR_44); 1608 rb->pcm_set_frequency(SAMPR_44);
1802#endif /* CONFIG_CODEC != SWCODEC */
1803 1609
1804 if(file) 1610 if(file)
1805 { 1611 {
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index d5d7c7c019..25eb313591 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -1245,7 +1245,6 @@ static void display_options(void)
1245 } 1245 }
1246} 1246}
1247 1247
1248#if CONFIG_CODEC == SWCODEC
1249static void audio_options(void) 1248static void audio_options(void)
1250{ 1249{
1251 int selected = 0; 1250 int selected = 0;
@@ -1307,7 +1306,6 @@ static void audio_options(void)
1307 menu_quit = true; 1306 menu_quit = true;
1308 } 1307 }
1309} 1308}
1310#endif
1311 1309
1312static void resume_options(void) 1310static void resume_options(void)
1313{ 1311{
diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c
index 8e14f26bd5..2af70204a1 100644
--- a/apps/plugins/oscilloscope.c
+++ b/apps/plugins/oscilloscope.c
@@ -902,19 +902,11 @@ static int last_right;
902 902
903static void get_peaks(int *left, int *right) 903static void get_peaks(int *left, int *right)
904{ 904{
905#if CONFIG_CODEC == SWCODEC
906 static struct pcm_peaks peaks; 905 static struct pcm_peaks peaks;
907 rb->mixer_channel_calculate_peaks(PCM_MIXER_CHAN_PLAYBACK, 906 rb->mixer_channel_calculate_peaks(PCM_MIXER_CHAN_PLAYBACK,
908 &peaks); 907 &peaks);
909 *left = peaks.left; 908 *left = peaks.left;
910 *right = peaks.right; 909 *right = peaks.right;
911#elif defined (SIMULATOR)
912 *left = rand() % 0x8000;
913 *right = rand() % 0x8000;
914#else
915 *left = 0;
916 *right = 0;
917#endif
918} 910}
919 911
920static long get_next_delay(void) 912static long get_next_delay(void)
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index 686b4d6d1a..4c172ff108 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -112,13 +112,9 @@ static bool file_properties(const char* selected_file)
112 112
113 num_properties = 5; 113 num_properties = 5;
114 114
115#if (CONFIG_CODEC == SWCODEC)
116 int fd = rb->open(selected_file, O_RDONLY); 115 int fd = rb->open(selected_file, O_RDONLY);
117 if (fd >= 0 && 116 if (fd >= 0 &&
118 rb->get_metadata(&id3, fd, selected_file)) 117 rb->get_metadata(&id3, fd, selected_file))
119#else
120 if (!rb->mp3info(&id3, selected_file))
121#endif
122 { 118 {
123 long dur = id3.length / 1000; /* seconds */ 119 long dur = id3.length / 1000; /* seconds */
124 rb->snprintf(str_artist, sizeof str_artist, 120 rb->snprintf(str_artist, sizeof str_artist,
@@ -145,9 +141,7 @@ static bool file_properties(const char* selected_file)
145 num_properties++; 141 num_properties++;
146 } 142 }
147 } 143 }
148#if (CONFIG_CODEC == SWCODEC)
149 rb->close(fd); 144 rb->close(fd);
150#endif
151 found = true; 145 found = true;
152 break; 146 break;
153 } 147 }
diff --git a/apps/plugins/rockboy/rbsound.c b/apps/plugins/rockboy/rbsound.c
index 628879b4b7..c36e24b578 100644
--- a/apps/plugins/rockboy/rbsound.c
+++ b/apps/plugins/rockboy/rbsound.c
@@ -7,8 +7,6 @@ struct pcm pcm IBSS_ATTR;
7#define N_BUFS 2 7#define N_BUFS 2
8#define BUF_SIZE 2048 8#define BUF_SIZE 2048
9 9
10#if CONFIG_CODEC == SWCODEC
11
12bool doneplay=1; 10bool doneplay=1;
13bool bufnum=0; 11bool bufnum=0;
14 12
@@ -88,27 +86,3 @@ int rockboy_pcm_submit(void)
88 pcm.pos = 0; 86 pcm.pos = 0;
89 return 1; 87 return 1;
90} 88}
91
92#else
93
94void rockboy_pcm_init(void)
95{
96 pcm.hz = 44100;
97 pcm.stereo = 1;
98 pcm.buf = NULL;
99 pcm.len = 0;
100 pcm.pos = 0;
101}
102
103void rockboy_pcm_close(void)
104{
105 memset(&pcm, 0, sizeof pcm);
106}
107
108int rockboy_pcm_submit(void)
109{
110 pcm.pos =0;
111 return 0;
112}
113
114#endif
diff --git a/apps/plugins/splitedit.c b/apps/plugins/splitedit.c
deleted file mode 100644
index b698e2e18a..0000000000
--- a/apps/plugins/splitedit.c
+++ /dev/null
@@ -1,1231 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Philipp Pertermann
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "plugin.h"
23
24
25
26/* variable button definitions */
27#if CONFIG_KEYPAD == IRIVER_H100_PAD
28#define SPLITEDIT_QUIT BUTTON_OFF
29#define SPLITEDIT_PLAY BUTTON_ON
30#define SPLITEDIT_SAVE BUTTON_SELECT
31#define SPLITEDIT_LOOP_MODE BUTTON_MODE
32#define SPLITEDIT_SCALE (BUTTON_REC | BUTTON_UP)
33#define SPLITEDIT_SPEED50 (BUTTON_REC | BUTTON_LEFT)
34#define SPLITEDIT_SPEED100 (BUTTON_REC | BUTTON_DOWN)
35#define SPLITEDIT_SPEED150 (BUTTON_REC | BUTTON_RIGHT)
36#define SPLITEDIT_MENU_RUN BUTTON_RIGHT
37
38#elif (CONFIG_KEYPAD == SAMSUNG_YH820_PAD) || \
39 (CONFIG_KEYPAD == SAMSUNG_YH92X_PAD)
40#define SPLITEDIT_QUIT (BUTTON_REC | BUTTON_REW)
41#define SPLITEDIT_PLAY (BUTTON_REC | BUTTON_FFWD)
42#define SPLITEDIT_SAVE BUTTON_FFWD
43#define SPLITEDIT_LOOP_MODE BUTTON_REW
44#define SPLITEDIT_SCALE BUTTON_UP
45#define SPLITEDIT_SPEED50 BUTTON_LEFT
46#define SPLITEDIT_SPEED100 BUTTON_DOWN
47#define SPLITEDIT_SPEED150 BUTTON_RIGHT
48#define SPLITEDIT_MENU_RUN BUTTON_PLAY
49
50#define SPLITEDIT_RC_QUIT BUTTON_RC_STOP
51#endif
52
53#define BMPHEIGHT 7
54#define BMPWIDTH 13
55unsigned char LOOP_BMP[][13] =
56{
57 {0xfc,0x00,0x10,0x11,0x93,0x7f,0x13,0x11,0x7c,0x38,0x10,0x00,0x7c}, /*ALL */
58 {0x81,0x03,0x7f,0x03,0x91,0x10,0x10,0x10,0x7c,0x38,0x10,0x00,0x7c}, /*FROM*/
59 {0xfc,0x00,0x10,0x10,0x90,0x10,0x7c,0x38,0x11,0x03,0x7f,0x03,0x01}, /*TO */
60 {0x80,0x10,0x10,0x11,0x93,0x7f,0x13,0x11,0x10,0x7c,0x38,0x10,0x00}, /*FREE*/
61};
62
63unsigned char CUT_BMP[] =
64{
65 0xc1,0x63,0x63,0x36,0xb6,0x1c,0x1c,0x36,0x77,0x55,0x55,0x55,0x32,
66};
67
68unsigned char SCALE_BMP[][13] =
69{
70 {0x80,0x06,0x49,0x66,0xb0,0x18,0x0c,0x06,0x33,0x49,0x30,0x00,0x00}, /*lin*/
71 {0x80,0x30,0x78,0x48,0xff,0x7f,0x00,0x7f,0x7f,0x48,0x78,0x30,0x00}, /*db*/
72};
73
74#define TIMEBAR_Y 9
75#define TIMEBAR_HEIGHT 4
76
77#define OSCI_X 0
78#define OSCI_Y (TIMEBAR_Y + TIMEBAR_HEIGHT + 1)
79#define OSCI_WIDTH LCD_WIDTH
80#define OSCI_HEIGHT (LCD_HEIGHT - BMPHEIGHT - OSCI_Y - 1)
81
82/* Indices of the menu items in the save editor, see save_editor */
83#define SE_PART1_SAVE 0
84#define SE_PART1_NAME 1
85#define SE_PART2_SAVE 2
86#define SE_PART2_NAME 3
87#define SE_SAVE 4
88#define SE_COUNT 5
89
90/* contains the file name of the song that is to be split */
91static char path_mp3[MAX_PATH];
92
93/* Exit code of this plugin */
94static enum plugin_status splitedit_exit_code = PLUGIN_OK;
95
96/* The range in time that the displayed aerea comprises */
97static unsigned int range_start = 0;
98static unsigned int range_end = 0;
99
100/* The range in time that is being looped */
101static unsigned int play_start = 0;
102static unsigned int play_end = 0;
103
104/* Point in time (pixel) at which the split mark is set */
105static int split_x = OSCI_X + (OSCI_WIDTH / 2);
106
107/* Contains the peak values */
108static unsigned char osci_buffer[OSCI_WIDTH];
109
110/* if true peak values from a previous loop are only overwritten
111 if the new value is greater than the old value */
112static bool osci_valid = false;
113
114/**
115 * point in time from which on the osci_buffer is invalid
116 * if set to ~(unsigned int)0 the entire osci_buffer is invalid
117 */
118static unsigned int validation_start = ~(unsigned int)0;
119
120/* all the visible aerea is looped */
121#define LOOP_MODE_ALL 0
122
123/* loop starts at split point, ends at right visible border */
124#define LOOP_MODE_FROM 1
125
126/* loop start at left visible border, ends at split point */
127#define LOOP_MODE_TO 2
128
129/* let the song play without looping */
130#define LOOP_MODE_FREE 3
131
132/* see LOOP_MODE_XXX constants vor valid values */
133static int loop_mode = LOOP_MODE_FREE;
134
135/* minimal allowed timespan (ms) of the visible (and looped) aerea*/
136#define MIN_RANGE_SIZE 1000
137
138/* Format time into buf.
139 *
140 * buf - buffer to format to.
141 * buf_size - size of buffer.
142 * time - time to format, in milliseconds.
143 */
144static void format_time_ms(char* buf, int buf_size, int time)
145{
146 rb->snprintf(buf, buf_size, "%d:%02d:%03d", time / 60000,
147 time % 60000 / 1000, (time % 60000) % 1000);
148}
149
150/**
151 * converts screen coordinate (pixel) to time (ms)
152 */
153static int xpos_to_time(int xpos)
154{
155 int retval = 0;
156 int range = range_end - range_start;
157 retval = range_start + (((xpos - OSCI_X) * range) / OSCI_WIDTH);
158 return retval;
159}
160
161/**
162 * Converts time (ms) to screen coordinates (pixel).
163 */
164static int time_to_xpos(unsigned int time)
165{
166 int retval = OSCI_X;
167
168 /* clip the range */
169 if (time < range_start)
170 {
171 retval = OSCI_X;
172 }
173 else
174 if (time >= range_end)
175 {
176 retval = OSCI_X + OSCI_WIDTH;
177 }
178
179 /* do the calculation */
180 else
181 {
182 int range = range_end - range_start;
183 retval = OSCI_X + ((time - range_start) * OSCI_WIDTH) / range ;
184 }
185 return retval;
186}
187
188/**
189 * Updates the display of the textual data only.
190 */
191static void update_data(void)
192{
193 char buf[20];
194 char timebuf[10];
195 int w, h;
196
197 /* split point */
198 format_time_ms(timebuf, sizeof timebuf, xpos_to_time(split_x));
199 rb->snprintf(buf, sizeof buf, "Split at: %s", timebuf);
200
201 rb->lcd_getstringsize(buf, &w, &h);
202
203 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
204 rb->lcd_fillrect(0, 0, LCD_WIDTH, h);
205 rb->lcd_set_drawmode(DRMODE_SOLID);
206 rb->lcd_puts(0, 0, buf);
207 rb->lcd_update_rect(0, 0, LCD_WIDTH, h);
208}
209
210/**
211 * Displays which part of the song is visible
212 * in the osci.
213 */
214static void update_timebar(struct mp3entry *mp3)
215{
216 rb->gui_scrollbar_draw
217 (
218 rb->screens[SCREEN_MAIN],0, TIMEBAR_Y, LCD_WIDTH, TIMEBAR_HEIGHT,
219 mp3->length, range_start, range_end,
220 HORIZONTAL
221 );
222 rb->lcd_update_rect(0, TIMEBAR_Y, LCD_WIDTH, TIMEBAR_HEIGHT);
223}
224
225/**
226 * Marks the entire area of the osci buffer invalid.
227 * It will be drawn with new values in the next loop.
228 */
229static void splitedit_invalidate_osci(void)
230{
231 osci_valid = false;
232 validation_start = ~(unsigned int)0;
233}
234
235/**
236 * Returns the loop mode. See the LOOP_MODE_XXX constants above.
237 */
238static int splitedit_get_loop_mode(void)
239{
240 return loop_mode;
241}
242
243/**
244 * Updates the icons that display the Fn key hints.
245 */
246static void update_icons(void)
247{
248 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
249 rb->lcd_fillrect(0, LCD_HEIGHT - BMPHEIGHT, LCD_WIDTH, BMPHEIGHT);
250 rb->lcd_set_drawmode(DRMODE_SOLID);
251
252 /* The CUT icon */
253 rb->lcd_mono_bitmap(CUT_BMP,
254 LCD_WIDTH / 3 / 2 - BMPWIDTH / 2, LCD_HEIGHT - BMPHEIGHT,
255 BMPWIDTH, BMPHEIGHT);
256
257 /* The loop mode icon */
258 rb->lcd_mono_bitmap(LOOP_BMP[splitedit_get_loop_mode()],
259 LCD_WIDTH/3 + LCD_WIDTH/3 / 2 - BMPWIDTH/2, LCD_HEIGHT - BMPHEIGHT,
260 BMPWIDTH, BMPHEIGHT);
261
262 {
263 static int idx;
264 if (idx < 0 || idx > 1) idx = 0;
265 idx = 1 - idx;
266 rb->lcd_mono_bitmap(SCALE_BMP[idx],
267 2 *LCD_WIDTH/3 + LCD_WIDTH/3 / 2 - BMPWIDTH/2, LCD_HEIGHT - BMPHEIGHT,
268 BMPWIDTH, BMPHEIGHT);
269 }
270
271 rb->lcd_update_rect(0, LCD_HEIGHT - BMPHEIGHT, LCD_WIDTH, BMPHEIGHT);
272}
273
274/**
275 * Sets the loop mode. See the LOOP_MODE_XXX constants above.
276 */
277static void splitedit_set_loop_mode(int mode)
278{
279 int old_loop_mode = loop_mode;
280 /* range restriction */
281 loop_mode = mode % (LOOP_MODE_FREE + 1);
282 switch (loop_mode)
283 {
284 case LOOP_MODE_ALL:
285 play_start = range_start;
286 play_end = range_end;
287 break;
288
289 case LOOP_MODE_FROM:
290 play_start = xpos_to_time(split_x);
291 play_end = range_end;
292 break;
293
294 case LOOP_MODE_TO:
295 play_start = range_start;
296 play_end = xpos_to_time(split_x);
297 break;
298
299 case LOOP_MODE_FREE:
300 /* play_start is used when the song plays beyond its end */
301 play_start = range_start;
302 play_end = range_end;
303 break;
304 }
305
306 if (loop_mode != old_loop_mode)
307 {
308 update_icons();
309 }
310}
311
312/**
313 * Readraws the osci without clear.
314 */
315static void redraw_osci(void)
316{
317 int x;
318 for (x = 0; x < OSCI_WIDTH; x++)
319 {
320 if (osci_buffer[x] > 0)
321 {
322 rb->lcd_vline
323 (
324 OSCI_X + x, OSCI_Y + OSCI_HEIGHT - 1,
325 OSCI_Y + OSCI_HEIGHT - osci_buffer[x] - 1
326 );
327 }
328 }
329}
330
331/**
332 * Sets the range of time in which the user can finetune the split
333 * point. The split point is the center of the time range.
334 */
335static void set_range_by_time(
336 struct mp3entry *mp3,
337 unsigned int split_time,
338 unsigned int range)
339{
340 if (mp3 != NULL)
341 {
342 if (range < MIN_RANGE_SIZE)
343 {
344 range = MIN_RANGE_SIZE;
345 }
346 range_start = (split_time > range / 2) ? (split_time - range / 2) : 0;
347 range_end = MIN(range_start + range, mp3->length);
348 split_x = time_to_xpos(split_time);
349
350 splitedit_invalidate_osci();
351
352 /* this sets the play_start / play_end */
353 splitedit_set_loop_mode(splitedit_get_loop_mode());
354
355 update_data();
356 update_timebar(mp3);
357 }
358}
359
360/**
361 * Set the split point in screen coordinates
362 */
363static void splitedit_set_split_x(int newx)
364{
365 int minx = split_x - 2 > 0 ? split_x - 2: 0;
366
367 /* remove old split point from screen, only if moved */
368 if (split_x != newx)
369 {
370 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
371 rb->lcd_fillrect(minx, OSCI_Y, 5, 1);
372 rb->lcd_fillrect(split_x-1 > 0 ? split_x - 1: 0, OSCI_Y + 1, 3, 1);
373 rb->lcd_fillrect(split_x, OSCI_Y + 2, 1, OSCI_HEIGHT - 2);
374 rb->lcd_set_drawmode(DRMODE_SOLID);
375 rb->lcd_update_rect(minx, OSCI_Y, 5, OSCI_HEIGHT);
376 }
377
378 if (newx >= OSCI_X && newx < OSCI_X + OSCI_WIDTH)
379 {
380 split_x = newx;
381 /* in LOOP_FROM / LOOP_TO modes play_start /play_end must be updated */
382 splitedit_set_loop_mode(splitedit_get_loop_mode());
383
384 /* display new split time */
385 update_data();
386 }
387
388 /* display new split point */
389 minx = split_x - 2 > 0 ? split_x - 2: 0;
390 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
391 rb->lcd_fillrect(minx, OSCI_Y, 5, 1);
392 rb->lcd_fillrect(split_x - 1 > 0 ? split_x - 1: 0, OSCI_Y + 1, 3, 1);
393 rb->lcd_fillrect(split_x, OSCI_Y + 2, 1, OSCI_HEIGHT - 2);
394 rb->lcd_set_drawmode(DRMODE_SOLID);
395 rb->lcd_update_rect(minx, OSCI_Y, 5, OSCI_HEIGHT);
396}
397
398/**
399 * returns the split point in screen coordinates
400 */
401static int splitedit_get_split_x(void)
402{
403 return split_x;
404}
405
406/**
407 * Clears the osci area and redraws it
408 */
409static void update_osci(void)
410{
411 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
412 rb->lcd_fillrect(OSCI_X, OSCI_Y, OSCI_WIDTH, OSCI_HEIGHT);
413 rb->lcd_set_drawmode(DRMODE_SOLID);
414 redraw_osci();
415 splitedit_set_split_x(splitedit_get_split_x());
416 rb->lcd_update_rect(OSCI_X, OSCI_Y, OSCI_WIDTH, OSCI_HEIGHT);
417}
418
419/**
420 * Zooms the visable and loopable range by the factor
421 * (counter / denominator). The split point is used as
422 * center point of the new selected range.
423 */
424static void zoom(struct mp3entry *mp3, int counter, int denominator)
425{
426 unsigned char oldbuf[OSCI_WIDTH];
427 int oldrange = range_end - range_start;
428 int range = oldrange * counter / denominator;
429 int i;
430 int oldindex;
431 int oldsplitx;
432 int splitx;
433 int split;
434
435 /* for stretching / shrinking a second buffer is needed */
436 rb->memcpy(&oldbuf, &osci_buffer, sizeof osci_buffer);
437
438 /* recalculate the new range and split point */
439 oldsplitx = split_x;
440 split = xpos_to_time(split_x);
441
442 set_range_by_time(mp3, split, range);
443 range = range_end - range_start;
444
445 splitx = time_to_xpos(split);
446
447 /* strech / shrink the existing osci buffer */
448 for (i = 0; i < OSCI_WIDTH; i++)
449 {
450 /* oldindex = (i + OSCI_X - splitx) * range / oldrange + oldsplitx ;*/
451 oldindex = (i*range / oldrange) + oldsplitx - (splitx*range /oldrange);
452 if (oldindex >= 0 && oldindex < OSCI_WIDTH)
453 {
454 osci_buffer[i] = oldbuf[oldindex];
455 }
456 else
457 {
458 osci_buffer[i] = 0;
459 }
460 }
461
462 splitx = time_to_xpos(split);
463 splitedit_set_split_x(splitx);
464 splitedit_invalidate_osci();
465
466}
467
468static void scroll(struct mp3entry *mp3)
469{
470 zoom(mp3, 1, 1);
471 rb->lcd_update_rect(OSCI_X, OSCI_Y, LCD_WIDTH, OSCI_HEIGHT);
472 update_osci();
473 update_data();
474}
475
476/**
477 * Zooms in by 3/4
478 */
479static void splitedit_zoom_in(struct mp3entry *mp3)
480{
481 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
482 rb->lcd_fillrect(OSCI_X, OSCI_Y, OSCI_WIDTH, OSCI_HEIGHT);
483 rb->lcd_set_drawmode(DRMODE_SOLID);
484 zoom(mp3, 3, 4);
485 rb->lcd_update_rect(OSCI_X, OSCI_Y, LCD_WIDTH, OSCI_HEIGHT);
486 update_osci();
487 update_data();
488}
489
490/**
491 * Zooms out by 4/3
492 */
493static void splitedit_zoom_out(struct mp3entry *mp3)
494{
495 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
496 rb->lcd_fillrect(OSCI_X, OSCI_Y, LCD_WIDTH, OSCI_HEIGHT);
497 rb->lcd_set_drawmode(DRMODE_SOLID);
498 zoom(mp3, 4, 3);
499 rb->lcd_update_rect(OSCI_X, OSCI_Y, LCD_WIDTH, OSCI_HEIGHT);
500 update_osci();
501 update_data();
502}
503
504/**
505 * Append part_no to the file name.
506 */
507static void generateFileName(char* file_name, int part_no)
508{
509 if (rb->strlen(file_name) <MAX_PATH)
510 {
511 int len = rb->strlen(file_name);
512 int ext_len = rb->strlen(".mp3");
513 if (rb->strcasecmp(
514 &file_name[len - ext_len],
515 ".mp3") == 0)
516 {
517 int i = 0;
518 /* shift the extension one position to the right*/
519 for (i = len; i > len - ext_len; i--)
520 {
521 file_name[i] = file_name[i - 1];
522 }
523 file_name[len - ext_len] = '0' + part_no;
524 }
525 else
526 {
527 rb->splash(0, "wrong extension");
528 rb->button_get(true);
529 rb->button_get(true);
530 }
531 }
532 else
533 {
534 rb->splash(0, "name too long");
535 rb->button_get(true);
536 rb->button_get(true);
537
538 }
539
540}
541
542/**
543 * Copy bytes from src to dest while displaying a progressbar.
544 * The files must be already open.
545 */
546static int copy_file(
547 int dest,
548 int src,
549 unsigned int bytes,
550 int prg_y,
551 int prg_h)
552{
553 long button;
554 unsigned char *buffer;
555 unsigned int i = 0;
556 ssize_t bytes_read = 1; /* ensure the for loop is executed */
557 size_t buffer_size;
558 buffer = rb->plugin_get_buffer(&buffer_size);
559
560 for (i = 0; i < bytes && bytes_read > 0; i += bytes_read)
561 {
562 ssize_t bytes_written;
563 unsigned int bytes_to_read =
564 bytes - i > buffer_size ? buffer_size : bytes - i;
565 bytes_read = rb->read(src, buffer, bytes_to_read);
566 bytes_written = rb->write(dest, buffer, bytes_read);
567
568 if (bytes_written < 0) {
569 rb->splash(0, "Write failed in copy.");
570 rb->button_get(true);
571 rb->button_get(true);
572 return -1;
573 }
574
575 button = rb->button_get(false);
576
577 if (button == SPLITEDIT_QUIT
578#ifdef SPLITEDIT_RC_QUIT
579 || button == SPLITEDIT_RC_QUIT:
580#endif
581 ) {
582 rb->splash(0, "Aborting copy.");
583 rb->button_get(true);
584 rb->button_get(true);
585 return -1;
586 }
587
588 rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN],0, prg_y, LCD_WIDTH,
589 prg_h, bytes, 0, i, HORIZONTAL);
590 rb->lcd_update_rect(0, prg_y, LCD_WIDTH, prg_h);
591 }
592
593 return 0;
594}
595
596/**
597 * Save the files, if the file_name is not NULL
598 */
599static int save(
600 struct mp3entry *mp3,
601 char *file_name1,
602 char *file_name2,
603 int splittime)
604{
605 int file1, file2, src_file;
606 unsigned int end = 0;
607 int retval = 0;
608
609 /* Verify that file 1 doesn't exit yet */
610 if (file_name1 != NULL)
611 {
612 file1 = rb->open(file_name1, O_RDONLY);
613 if (file1 >= 0)
614 {
615 rb->close(file1);
616 rb->splash(0, "File 1 exists. Please rename.");
617 rb->button_get(true);
618 rb->button_get(true);
619 return -1;
620 }
621 }
622
623 /* Verify that file 2 doesn't exit yet */
624 if (file_name2 != NULL)
625 {
626 file2 = rb->open(file_name2, O_RDONLY);
627 if (file2 >= 0)
628 {
629 rb->close(file2);
630 rb->splash(0, "File 2 exists. Please rename.");
631 rb->button_get(true);
632 rb->button_get(true);
633 return -2;
634 }
635 }
636
637 /* find the file position of the split point */
638 rb->audio_pause();
639 rb->audio_ff_rewind(splittime);
640 rb->yield();
641 rb->yield();
642 end = rb->audio_get_file_pos();
643
644 /* open the source file */
645 src_file = rb->open(mp3->path, O_RDONLY);
646 if (src_file >= 0)
647 {
648 int close_stat = 0;
649 int x, y;
650 long offset;
651 unsigned long last_header = rb->mpeg_get_last_header();
652
653 rb->lcd_getstringsize("M", &x, &y);
654
655 /* Find the next frame boundary */
656 rb->lseek(src_file, end, SEEK_SET);
657 rb->find_next_frame(src_file, &offset, 8000, last_header);
658 rb->lseek(src_file, 0, SEEK_SET);
659 end += offset;
660
661 /* write the file 1 */
662 if (file_name1 != NULL)
663 {
664 file1 = rb->open (file_name1, O_WRONLY | O_CREAT, 0666);
665 if (file1 >= 0)
666 {
667 int rc = copy_file(file1, src_file, end, y*2 + 1, y -1);
668 close_stat = rb->close(file1);
669
670 if (close_stat != 0)
671 {
672 rb->splashf(0, "failed closing file1: error %d", close_stat);
673 rb->button_get(true);
674 rb->button_get(true);
675 } else {
676 /* If there was an error, cleanup */
677 if (rc) {
678 rb->remove(file_name1);
679 }
680 }
681 }
682 else
683 {
684 rb->splashf(0, "Can't write File1: error %d", file1);
685 rb->button_get(true);
686 rb->button_get(true);
687 retval = -1;
688 }
689 }
690 /* if file1 hasn't been written we're not at the split point yet */
691 else
692 {
693 if (rb->lseek(src_file, end, SEEK_SET) < (off_t)end)
694 {
695 rb->splashf(0, "Src file to short: error %d", src_file);
696 rb->button_get(true);
697 rb->button_get(true);
698 }
699 }
700
701 if (file_name2 != NULL)
702 {
703 /* write file 2 */
704 file2 = rb->open (file_name2, O_WRONLY | O_CREAT, 0666);
705 if (file2 >= 0)
706 {
707 end = mp3->filesize - end;
708 int rc = copy_file(file2, src_file, end, y * 5 + 1, y -1);
709 close_stat = rb->close(file2);
710
711 if (close_stat != 0)
712 {
713 rb->splashf(0, "failed: closing file2: error %d",
714 close_stat);
715 rb->button_get(true);
716 rb->button_get(true);
717 } else {
718 /* If there was an error, cleanup */
719 if (rc) {
720 rb->remove(file_name2);
721 }
722 }
723 }
724 else
725 {
726 rb->splashf(0, "Can't write File2: error %d", file2);
727 rb->button_get(true);
728 rb->button_get(true);
729 retval = -2;
730 }
731 }
732
733 close_stat = rb->close(src_file);
734 if (close_stat != 0)
735 {
736 rb->splashf(0, "failed: closing src: error %d", close_stat);
737 rb->button_get(true);
738 rb->button_get(true);
739 }
740 }
741 else
742 {
743 rb->splash(0, "Source file not found");
744 rb->button_get(true);
745 rb->button_get(true);
746 retval = -3;
747 }
748
749 rb->audio_resume();
750
751 return retval;
752}
753
754static void puts_wrapper(int x, int y, const char *str, bool scroll, bool selected)
755{
756 struct line_desc line = LINE_DESC_DEFINIT;
757 struct screen *lcd = rb->screens[SCREEN_MAIN];
758 int w = lcd->getcharwidth();
759 int h = lcd->getcharheight();
760
761 line.scroll = scroll;
762 line.style = selected ? STYLE_INVERT : STYLE_DEFAULT;
763
764 rb->screens[0]->put_line(x * w, y * h, &line, str);
765}
766
767/**
768 * Let the user choose which file to save with which name
769 */
770static void save_editor(struct mp3entry *mp3, int splittime)
771{
772 bool exit_request = false;
773 int choice = 0;
774 int button = BUTTON_NONE;
775 char part1_name [MAX_PATH];
776 char part2_name [MAX_PATH];
777 bool part1_save = true;
778 bool part2_save = true;
779
780 /* file name for left part */
781 rb->strlcpy(part1_name, mp3->path, MAX_PATH);
782 generateFileName(part1_name, 1);
783
784 /* file name for right part */
785 rb->strlcpy(part2_name, mp3->path, MAX_PATH);
786 generateFileName(part2_name, 2);
787
788 while (!exit_request)
789 {
790 int pos;
791 rb->lcd_clear_display();
792
793 /* Save file1? */
794 puts_wrapper(0, 0, "Save part 1?", false, choice == SE_PART1_SAVE);
795 puts_wrapper(7, 0, part1_save?"yes":"no", false, false);
796
797 /* trim to display the filename without path */
798 for (pos = rb->strlen(part1_name); pos > 0; pos--)
799 {
800 if (part1_name[pos] == '/')
801 break;
802 }
803 pos++;
804
805 /* File name 1 */
806 puts_wrapper(0, 1, &part1_name[pos], true, choice == SE_PART1_NAME);
807
808 /* Save file2? */
809 puts_wrapper(0, 3, "Save part 2?", false, choice == SE_PART2_SAVE);
810 puts_wrapper(7, 3, part2_save?"yes":"no", false, false);
811
812 /* trim to display the filename without path */
813 for (pos = rb->strlen(part2_name); pos > 0; pos --)
814 {
815 if (part2_name[pos] == '/')
816 break;
817 }
818 pos++;
819
820 /* File name 2 */
821 puts_wrapper(0, 4, &part2_name[pos], true, choice == SE_PART2_NAME);
822
823 /* Save */
824 puts_wrapper(0, 6, "Save", false, choice == SE_SAVE);
825
826 rb->lcd_update();
827
828
829 button = rb->button_get(true);
830 switch (button)
831 {
832 case BUTTON_UP:
833 choice = (choice + SE_COUNT - 1) % SE_COUNT;
834 break;
835
836 case BUTTON_DOWN:
837 choice = (choice + 1) % SE_COUNT;
838 break;
839
840 case SPLITEDIT_MENU_RUN:
841 switch (choice)
842 {
843 int saved;
844
845 case SE_PART1_SAVE:
846 part1_save = !part1_save;
847 break;
848
849 case SE_PART1_NAME:
850 rb->kbd_input(part1_name, MAX_PATH, NULL);
851 break;
852
853 case SE_PART2_SAVE:
854 part2_save = !part2_save;
855 break;
856
857 case SE_PART2_NAME:
858 rb->kbd_input(part2_name, MAX_PATH, NULL);
859 break;
860
861 case SE_SAVE:
862 rb->lcd_scroll_stop();
863 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
864 rb->lcd_fillrect(0, 6*8, LCD_WIDTH, LCD_HEIGHT);
865 rb->lcd_set_drawmode(DRMODE_SOLID);
866 saved = save
867 (
868 mp3,
869 part1_save?part1_name:NULL,
870 part2_save?part2_name:NULL,
871 splittime
872 );
873
874 /* if something failed the user may go on choosing */
875 if (saved >= 0)
876 {
877 exit_request = true;
878 }
879 break;
880 }
881 break;
882#ifdef SPLITEDIT_RC_QUIT
883 case SPLITEDIT_RC_QUIT:
884#endif
885 case SPLITEDIT_QUIT:
886 exit_request = true;
887 break;
888
889 default:
890 if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
891 {
892 splitedit_exit_code = PLUGIN_USB_CONNECTED;
893 exit_request = true;
894 }
895 break;
896 }
897 }
898}
899
900/**
901 * The main loop of the editor
902 */
903static unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
904 unsigned int split_time,
905 unsigned int range)
906{
907 int button = BUTTON_NONE;
908 int lastbutton = BUTTON_NONE;
909 struct mp3entry *mp3 = mp3_to_split;
910 unsigned int last_elapsed = 0;
911 int lastx = OSCI_X + (OSCI_WIDTH / 2);
912 int retval = -1;
913
914 if (mp3 != NULL)
915 {
916 /*unsigned short scheme = SCHEME_SPLIT_EDITOR;*/
917 bool exit_request = false;
918 set_range_by_time(mp3, split_time, range);
919 splitedit_set_loop_mode(LOOP_MODE_ALL);
920 update_icons();
921
922 /*while (scheme != SCHEME_RETURN) {*/
923 while (!exit_request)
924 {
925 unsigned int elapsed ;
926 int x ;
927
928 /* get position */
929 elapsed = mp3->elapsed;
930 x = time_to_xpos(elapsed);
931
932 /* are we still in the zoomed range? */
933 if (elapsed > play_start && elapsed < play_end)
934 {
935 /* read volume info */
936 unsigned short volume;
937 volume = OSCI_HEIGHT / 2;
938
939 /* update osci_buffer */
940 if (osci_valid || lastx == x)
941 {
942 int index = x - OSCI_X;
943 osci_buffer[index] = MAX(osci_buffer[index], volume);
944 }
945 else
946 {
947 int i;
948 osci_buffer[x - OSCI_X] = volume;
949 for (i = lastx + 1; i < x; i++)
950 {
951 osci_buffer[i - OSCI_X] = 0;
952 }
953 }
954
955 /* make room */
956 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
957 rb->lcd_fillrect(lastx + 1, OSCI_Y, x - lastx, OSCI_HEIGHT);
958 rb->lcd_set_drawmode(DRMODE_SOLID);
959 /* draw a value */
960 if (osci_buffer[x - OSCI_X] > 0)
961 {
962 int i;
963 for (i = lastx +1; i <= x; i++)
964 {
965 rb->lcd_vline
966 (
967 i, OSCI_Y + OSCI_HEIGHT - 1,
968 OSCI_Y + OSCI_HEIGHT - osci_buffer[i - OSCI_X]-1
969 );
970 }
971 }
972
973 /* mark the current position */
974 if (lastx != x)
975 {
976 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
977 rb->lcd_fillrect(lastx, OSCI_Y, 1, OSCI_HEIGHT);
978 rb->lcd_fillrect(x, OSCI_Y, 1, OSCI_HEIGHT);
979 rb->lcd_set_drawmode(DRMODE_SOLID);
980 }
981
982 /* mark the split point */
983 if ((x > split_x - 2) && (lastx < split_x + 3))
984 {
985 if ((lastx < split_x) && (x >= split_x))
986 {
987 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
988 rb->lcd_fillrect
989 (
990 split_x, OSCI_Y + 2,
991 1, OSCI_HEIGHT - 2
992 );
993 rb->lcd_set_drawmode(DRMODE_SOLID);
994 }
995 rb->lcd_hline(split_x -2, split_x + 2, OSCI_Y);
996 rb->lcd_hline(split_x-1, split_x +1,OSCI_Y+1);
997 }
998
999 /* make visible */
1000 if (lastx <= x)
1001 {
1002 rb->lcd_update_rect(lastx, OSCI_Y, x-lastx+1, OSCI_HEIGHT);
1003 }
1004 else
1005 {
1006 rb->lcd_update_rect
1007 (
1008 lastx, OSCI_Y,
1009 OSCI_X + OSCI_WIDTH - lastx, OSCI_HEIGHT
1010 );
1011 rb->lcd_update_rect(0, OSCI_Y, x + 1, OSCI_HEIGHT);
1012 }
1013
1014 lastx = x;
1015 }
1016
1017 /* we're not in the zoom range -> rewind */
1018 else
1019 {
1020 if (elapsed >= play_end)
1021 {
1022 switch (splitedit_get_loop_mode())
1023 {
1024 unsigned int range_width;
1025
1026 case LOOP_MODE_ALL:
1027 case LOOP_MODE_TO:
1028 rb->audio_pause();
1029 rb->audio_ff_rewind(range_start);
1030#if (CONFIG_STORAGE & STORAGE_MMC)
1031/* MMC is slow - wait some time to allow track reload to finish */
1032 rb->sleep(HZ/20);
1033 if (mp3->elapsed > play_end) /* reload in progress */
1034 rb->splash(10*HZ, "Wait - reloading");
1035#endif
1036 rb->audio_resume();
1037 break;
1038
1039 case LOOP_MODE_FROM:
1040 rb->audio_pause();
1041 rb->audio_ff_rewind(xpos_to_time(split_x));
1042#if (CONFIG_STORAGE & STORAGE_MMC)
1043/* MMC is slow - wait some time to allow track reload to finish */
1044 rb->sleep(HZ/20);
1045 if (mp3->elapsed > play_end) /* reload in progress */
1046 rb->splash(10*HZ, "Wait - reloading");
1047#endif
1048 rb->audio_resume();
1049 break;
1050
1051 case LOOP_MODE_FREE:
1052 range_width = range_end - range_start;
1053 set_range_by_time(mp3,
1054 range_end + range_width / 2, range_width);
1055
1056 /* play_end und play_start anpassen */
1057 splitedit_set_loop_mode(LOOP_MODE_FREE);
1058 rb->memset(osci_buffer, 0, sizeof osci_buffer);
1059 update_osci();
1060 rb->lcd_update();
1061 break;
1062 }
1063 }
1064 }
1065
1066 button = rb->button_get(false);
1067 rb->yield();
1068
1069 /* here the evaluation of the key scheme starts.
1070 All functions the user triggers are called from
1071 within execute_scheme */
1072 /* key_scheme_execute(button, &scheme); */
1073 switch (button)
1074 {
1075 case SPLITEDIT_PLAY:
1076#ifdef SPLITEDIT_PLAY_PRE
1077 if (lastbutton != SPLITEDIT_PLAY_PRE)
1078 break;
1079#endif
1080 rb->audio_pause();
1081 rb->audio_ff_rewind(xpos_to_time(split_x));
1082 rb->audio_resume();
1083 break;
1084
1085 case BUTTON_UP:
1086 splitedit_zoom_in(mp3);
1087 lastx = time_to_xpos(mp3->elapsed);
1088 break;
1089
1090 case BUTTON_DOWN:
1091 splitedit_zoom_out(mp3);
1092 lastx = time_to_xpos(mp3->elapsed);
1093 break;
1094
1095 case BUTTON_LEFT:
1096 case BUTTON_LEFT | BUTTON_REPEAT:
1097 if (splitedit_get_split_x() > OSCI_X + 2)
1098 {
1099 splitedit_set_split_x(splitedit_get_split_x() - 1);
1100 }
1101 else
1102 {
1103 scroll(mp3);
1104 lastx = time_to_xpos(mp3->elapsed);
1105 }
1106 break;
1107
1108 case BUTTON_RIGHT:
1109 case BUTTON_RIGHT | BUTTON_REPEAT:
1110 if (splitedit_get_split_x() < OSCI_X + OSCI_WIDTH-3)
1111 {
1112 splitedit_set_split_x(splitedit_get_split_x() + 1);
1113 }
1114 else
1115 {
1116 scroll(mp3);
1117 lastx = time_to_xpos(mp3->elapsed);
1118 }
1119 break;
1120
1121 case SPLITEDIT_SAVE:
1122 save_editor(mp3, xpos_to_time(split_x));
1123 rb->lcd_clear_display();
1124 update_osci();
1125 update_timebar(mp3);
1126 update_icons();
1127 break;
1128
1129 case SPLITEDIT_LOOP_MODE:
1130 splitedit_set_loop_mode(splitedit_get_loop_mode() + 1);
1131 update_icons();
1132 break;
1133
1134 case SPLITEDIT_SCALE:
1135 splitedit_invalidate_osci();
1136 update_icons();
1137 break;
1138
1139#ifdef SPLITEDIT_RC_QUIT
1140 case SPLITEDIT_RC_QUIT:
1141#endif
1142 case SPLITEDIT_QUIT:
1143 exit_request = true;
1144 break;
1145
1146 default:
1147 if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
1148 {
1149 splitedit_exit_code = PLUGIN_USB_CONNECTED;
1150 exit_request = true;
1151 }
1152 break;
1153
1154 }
1155 if (button != BUTTON_NONE)
1156 lastbutton = button;
1157
1158 if (validation_start == ~(unsigned int)0)
1159 {
1160 if (elapsed < range_end && elapsed > range_start)
1161 {
1162 validation_start = elapsed;
1163 }
1164 else
1165 {
1166 int endx = time_to_xpos(range_end);
1167 validation_start = xpos_to_time(endx - 2);
1168 }
1169 last_elapsed = elapsed + 1;
1170 }
1171 else
1172 {
1173 if ((last_elapsed <= validation_start) &&
1174 (elapsed > validation_start))
1175 {
1176 osci_valid = true;
1177 }
1178
1179 last_elapsed = elapsed;
1180 }
1181 update_data();
1182
1183 if (mp3 != rb->audio_current_track())
1184 {
1185 struct mp3entry *new_mp3 = rb->audio_current_track();
1186 if (rb->strncasecmp(path_mp3, new_mp3->path,
1187 sizeof (path_mp3)))
1188 {
1189 rb->splash(0, "Abort due to file change");
1190 rb->button_get(true);
1191 rb->button_get(true);
1192 exit_request = true;
1193 }
1194 else
1195 {
1196 mp3 = new_mp3;
1197 rb->audio_pause();
1198 rb->audio_flush_and_reload_tracks();
1199 rb->audio_ff_rewind(range_start);
1200 rb->audio_resume();
1201 }
1202 }
1203 }
1204 }
1205 return retval;
1206}
1207
1208enum plugin_status plugin_start(const void* parameter)
1209{
1210 struct mp3entry* mp3;
1211
1212 (void)parameter;
1213 rb->lcd_clear_display();
1214 rb->lcd_update();
1215 mp3 = rb->audio_current_track();
1216 if (mp3 != NULL)
1217 {
1218 if (rb->audio_status() & AUDIO_STATUS_PAUSE)
1219 {
1220 rb->audio_resume();
1221 }
1222 splitedit_editor(mp3, mp3->elapsed, MIN_RANGE_SIZE * 8);
1223 }
1224 else
1225 {
1226 rb->splash(0, "Play or pause a mp3 file first.");
1227 rb->button_get(true);
1228 rb->button_get(true);
1229 }
1230 return splitedit_exit_code;
1231}
diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c
index dff3c4b4d1..24e2e4c085 100644
--- a/apps/plugins/starfield.c
+++ b/apps/plugins/starfield.c
@@ -220,7 +220,6 @@ static int plugin_main(void)
220 rb->sleep(1); 220 rb->sleep(1);
221 rb->lcd_clear_display(); 221 rb->lcd_clear_display();
222 222
223#if (CONFIG_CODEC == SWCODEC)
224 /* This will make the stars pulse to the music */ 223 /* This will make the stars pulse to the music */
225 if(pulse){ 224 if(pulse){
226 225
@@ -255,7 +254,7 @@ static int plugin_main(void)
255 starfield.z_move = avg_peak; 254 starfield.z_move = avg_peak;
256 255
257 } /* if pulse */ 256 } /* if pulse */
258#endif 257
259 starfield_move_and_draw(&starfield); 258 starfield_move_and_draw(&starfield);
260 259
261#ifdef HAVE_LCD_COLOR 260#ifdef HAVE_LCD_COLOR
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c
index a4d639ede6..d2ba8c992c 100644
--- a/apps/plugins/vu_meter.c
+++ b/apps/plugins/vu_meter.c
@@ -469,10 +469,6 @@
469#endif 469#endif
470#endif 470#endif
471 471
472#if defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
473#define mas_codec_readreg(x) rand()%MAX_PEAK
474#endif
475
476/* Defines x positions on a logarithmic (dBfs) scale. */ 472/* Defines x positions on a logarithmic (dBfs) scale. */
477unsigned char analog_db_scale[LCD_WIDTH/2]; 473unsigned char analog_db_scale[LCD_WIDTH/2];
478 474
@@ -780,13 +776,11 @@ static void draw_digital_minimeters(void) {
780 776
781static void analog_meter(void) { 777static void analog_meter(void) {
782 778
783#if (CONFIG_CODEC == SWCODEC)
784 static struct pcm_peaks peaks; 779 static struct pcm_peaks peaks;
785 rb->mixer_channel_calculate_peaks(PCM_MIXER_CHAN_PLAYBACK, 780 rb->mixer_channel_calculate_peaks(PCM_MIXER_CHAN_PLAYBACK,
786 &peaks); 781 &peaks);
787 #define left_peak peaks.left 782 #define left_peak peaks.left
788 #define right_peak peaks.right 783 #define right_peak peaks.right
789#endif
790 784
791 if(vumeter_settings.analog_use_db_scale) { 785 if(vumeter_settings.analog_use_db_scale) {
792 left_needle_top_x = analog_db_scale[left_peak * half_width / MAX_PEAK]; 786 left_needle_top_x = analog_db_scale[left_peak * half_width / MAX_PEAK];
@@ -837,13 +831,11 @@ static void analog_meter(void) {
837} 831}
838 832
839static void digital_meter(void) { 833static void digital_meter(void) {
840#if (CONFIG_CODEC == SWCODEC)
841 static struct pcm_peaks peaks; 834 static struct pcm_peaks peaks;
842 rb->mixer_channel_calculate_peaks(PCM_MIXER_CHAN_PLAYBACK, 835 rb->mixer_channel_calculate_peaks(PCM_MIXER_CHAN_PLAYBACK,
843 &peaks); 836 &peaks);
844 #define left_peak peaks.left 837 #define left_peak peaks.left
845 #define right_peak peaks.right 838 #define right_peak peaks.right
846#endif
847 839
848 if(vumeter_settings.digital_use_db_scale) { 840 if(vumeter_settings.digital_use_db_scale) {
849 num_left_leds = digital_db_scale[left_peak * 44 / MAX_PEAK]; 841 num_left_leds = digital_db_scale[left_peak * 44 / MAX_PEAK];
diff --git a/apps/plugins/zxbox/spmain.c b/apps/plugins/zxbox/spmain.c
index e27770c70c..6c6b59c3fb 100644
--- a/apps/plugins/zxbox/spmain.c
+++ b/apps/plugins/zxbox/spmain.c
@@ -290,7 +290,7 @@ static void options_menu(void){
290 no_yes, 2, NULL); 290 no_yes, 2, NULL);
291 if (new_setting != settings.sound ) 291 if (new_setting != settings.sound )
292 settings.sound=new_setting; 292 settings.sound=new_setting;
293#if CONFIG_CODEC == SWCODEC && !defined SIMULATOR 293#if !defined SIMULATOR
294 rb->pcm_play_stop(); 294 rb->pcm_play_stop();
295#endif 295#endif
296 break; 296 break;
@@ -318,7 +318,7 @@ static void options_menu(void){
318/* menu */ 318/* menu */
319static bool zxbox_menu(void) 319static bool zxbox_menu(void)
320{ 320{
321#if CONFIG_CODEC == SWCODEC && !defined SIMULATOR 321#if !defined SIMULATOR
322 rb->pcm_play_stop(); 322 rb->pcm_play_stop();
323#endif 323#endif
324 int selected=0; 324 int selected=0;
diff --git a/apps/plugins/zxbox/zxbox.c b/apps/plugins/zxbox/zxbox.c
index d618243b92..4ebc0e0a9e 100644
--- a/apps/plugins/zxbox/zxbox.c
+++ b/apps/plugins/zxbox/zxbox.c
@@ -102,9 +102,9 @@ enum plugin_status plugin_start(const void* parameter)
102#ifdef USE_GREY 102#ifdef USE_GREY
103grey_show(false); 103grey_show(false);
104grey_release(); 104grey_release();
105#endif 105#endif
106 106
107#if CONFIG_CODEC == SWCODEC && !defined SIMULATOR 107#if !defined SIMULATOR
108 rb->pcm_play_stop(); 108 rb->pcm_play_stop();
109#endif 109#endif
110 110
diff --git a/apps/plugins/zxbox/zxconfig.h b/apps/plugins/zxbox/zxconfig.h
index 590da99f15..fb93dc5081 100644
--- a/apps/plugins/zxbox/zxconfig.h
+++ b/apps/plugins/zxbox/zxconfig.h
@@ -29,7 +29,7 @@ extern int intkeys[5];
29#define SPECT_MEM 1 29#define SPECT_MEM 1
30 30
31/* Define if sound driver is available. */ 31/* Define if sound driver is available. */
32#if CONFIG_CODEC == SWCODEC && !defined SIMULATOR 32#if !defined SIMULATOR
33#define HAVE_SOUND 33#define HAVE_SOUND
34#endif 34#endif
35 35
diff --git a/apps/radio/radio.c b/apps/radio/radio.c
index 362d10f9a3..6038d600a9 100644
--- a/apps/radio/radio.c
+++ b/apps/radio/radio.c
@@ -54,9 +54,7 @@
54#include "viewport.h" 54#include "viewport.h"
55#include "skin_engine/skin_engine.h" 55#include "skin_engine/skin_engine.h"
56#include "statusbar-skinned.h" 56#include "statusbar-skinned.h"
57#if CONFIG_CODEC == SWCODEC
58#include "playback.h" 57#include "playback.h"
59#endif
60#include "presets.h" 58#include "presets.h"
61 59
62#if CONFIG_TUNER 60#if CONFIG_TUNER
@@ -353,14 +351,6 @@ void radio_screen(void)
353 int lastbutton = BUTTON_NONE; 351 int lastbutton = BUTTON_NONE;
354 unsigned long rec_lastclick = 0; 352 unsigned long rec_lastclick = 0;
355#endif 353#endif
356#if CONFIG_CODEC != SWCODEC
357 int timeout = current_tick + HZ/10;
358#if !defined(SIMULATOR)
359 unsigned int last_seconds = 0;
360 unsigned int seconds = 0;
361 struct audio_recording_options rec_options;
362#endif /* SIMULATOR */
363#endif /* CONFIG_CODEC != SWCODEC */
364#ifndef HAVE_NOISY_IDLE_MODE 354#ifndef HAVE_NOISY_IDLE_MODE
365 int button_timeout = current_tick + (2*HZ); 355 int button_timeout = current_tick + (2*HZ);
366#endif 356#endif
@@ -383,29 +373,7 @@ void radio_screen(void)
383 373
384 fms_fix_displays(FMS_ENTER); 374 fms_fix_displays(FMS_ENTER);
385 375
386#ifndef SIMULATOR
387
388#if CONFIG_CODEC != SWCODEC
389 rec_create_directory();
390 audio_init_recording();
391
392 sound_settings_apply();
393 /* Yes, we use the D/A for monitoring */
394 peak_meter_playback(true);
395
396 peak_meter_enable(true);
397
398 rec_init_recording_options(&rec_options);
399 rec_options.rec_source = AUDIO_SRC_LINEIN;
400 rec_set_recording_options(&rec_options);
401
402 audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN),
403 sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN);
404
405#endif /* CONFIG_CODEC != SWCODEC */
406#endif /* ndef SIMULATOR */
407 /* turn on radio */ 376 /* turn on radio */
408#if CONFIG_CODEC == SWCODEC
409 /* This should be done before touching audio settings */ 377 /* This should be done before touching audio settings */
410 while (!pcm_is_initialized()) 378 while (!pcm_is_initialized())
411 sleep(0); 379 sleep(0);
@@ -413,10 +381,6 @@ void radio_screen(void)
413 audio_set_input_source(AUDIO_SRC_FMRADIO, 381 audio_set_input_source(AUDIO_SRC_FMRADIO,
414 (radio_status == FMRADIO_PAUSED) ? 382 (radio_status == FMRADIO_PAUSED) ?
415 SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING); 383 SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
416#else
417 if (radio_status == FMRADIO_OFF)
418 radio_start();
419#endif
420 384
421 if(radio_preset_count() < 1 && yesno_pop(ID2P(LANG_FM_FIRST_AUTOSCAN))) 385 if(radio_preset_count() < 1 && yesno_pop(ID2P(LANG_FM_FIRST_AUTOSCAN)))
422 presets_scan(NULL); 386 presets_scan(NULL);
@@ -468,13 +432,6 @@ void radio_screen(void)
468 switch(button) 432 switch(button)
469 { 433 {
470 case ACTION_FM_STOP: 434 case ACTION_FM_STOP:
471#if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
472 if(audio_status() == AUDIO_STATUS_RECORD)
473 {
474 audio_stop();
475 }
476 else
477#endif
478 { 435 {
479 done = true; 436 done = true;
480 if(presets_have_changed()) 437 if(presets_have_changed())
@@ -513,18 +470,11 @@ void radio_screen(void)
513 rec_command(RECORDING_CMD_START); 470 rec_command(RECORDING_CMD_START);
514 update_type = SKIN_REFRESH_ALL; 471 update_type = SKIN_REFRESH_ALL;
515 } 472 }
516#if CONFIG_CODEC != SWCODEC
517 last_seconds = 0;
518#endif
519#endif /* SIMULATOR */ 473#endif /* SIMULATOR */
520 break; 474 break;
521#endif /* #ifdef FM_RECORD */ 475#endif /* #ifdef FM_RECORD */
522 476
523 case ACTION_FM_EXIT: 477 case ACTION_FM_EXIT:
524#if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
525 if(audio_status() == AUDIO_STATUS_RECORD)
526 audio_stop();
527#endif
528 keep_playing = true; 478 keep_playing = true;
529 done = true; 479 done = true;
530 if(presets_have_changed()) 480 if(presets_have_changed())
@@ -629,10 +579,6 @@ void radio_screen(void)
629#endif /* FM_FREEZE */ 579#endif /* FM_FREEZE */
630 580
631 case SYS_USB_CONNECTED: 581 case SYS_USB_CONNECTED:
632#if CONFIG_CODEC != SWCODEC
633 /* Only accept USB connection when not recording */
634 if(audio_status() != AUDIO_STATUS_RECORD)
635#endif
636 { 582 {
637 default_event_handler(SYS_USB_CONNECTED); 583 default_event_handler(SYS_USB_CONNECTED);
638 screen_freeze = true; /* Cosmetic: makes sure the 584 screen_freeze = true; /* Cosmetic: makes sure the
@@ -688,10 +634,6 @@ void radio_screen(void)
688 default_event_handler(button); 634 default_event_handler(button);
689 if (!tuner_get(RADIO_PRESENT)) 635 if (!tuner_get(RADIO_PRESENT))
690 { 636 {
691#if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
692 if(audio_status() == AUDIO_STATUS_RECORD)
693 audio_stop();
694#endif
695 keep_playing = false; 637 keep_playing = false;
696 done = true; 638 done = true;
697 if(presets_have_changed()) 639 if(presets_have_changed())
@@ -713,21 +655,10 @@ void radio_screen(void)
713 lastbutton = button; 655 lastbutton = button;
714#endif 656#endif
715 657
716#if CONFIG_CODEC != SWCODEC
717 peak_meter_peek();
718#endif
719
720 if(!screen_freeze) 658 if(!screen_freeze)
721 { 659 {
722 /* Only display the peak meter when not recording */ 660 /* Only display the peak meter when not recording */
723#if CONFIG_CODEC != SWCODEC
724 if(TIME_AFTER(current_tick, timeout))
725 {
726 timeout = current_tick + HZ;
727#else /* SWCODEC */
728 { 661 {
729#endif /* CONFIG_CODEC == SWCODEC */
730
731 /* keep "mono" from always being displayed when paused */ 662 /* keep "mono" from always being displayed when paused */
732 if (radio_status != FMRADIO_PAUSED) 663 if (radio_status != FMRADIO_PAUSED)
733 { 664 {
@@ -742,15 +673,8 @@ void radio_screen(void)
742 } 673 }
743 } 674 }
744 675
745#if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
746 seconds = audio_recorded_time() / HZ;
747 if (update_type || seconds > last_seconds)
748 {
749 last_seconds = seconds;
750#else
751 if (update_type) 676 if (update_type)
752 { 677 {
753#endif
754 FOR_NB_SCREENS(i) 678 FOR_NB_SCREENS(i)
755 skin_update(FM_SCREEN, i, update_type); 679 skin_update(FM_SCREEN, i, update_type);
756 if (update_type == (int)SKIN_REFRESH_ALL) 680 if (update_type == (int)SKIN_REFRESH_ALL)
@@ -774,13 +698,6 @@ void radio_screen(void)
774 enqueue); 698 enqueue);
775 } 699 }
776 700
777#if CONFIG_CODEC != SWCODEC
778 if(audio_status() & AUDIO_STATUS_ERROR)
779 {
780 done = true;
781 }
782#endif
783
784#ifndef HAVE_NOISY_IDLE_MODE 701#ifndef HAVE_NOISY_IDLE_MODE
785 if (TIME_AFTER(current_tick, button_timeout)) 702 if (TIME_AFTER(current_tick, button_timeout))
786 { 703 {
@@ -790,23 +707,6 @@ void radio_screen(void)
790 } /*while(!done)*/ 707 } /*while(!done)*/
791 708
792#ifndef SIMULATOR 709#ifndef SIMULATOR
793#if CONFIG_CODEC != SWCODEC
794 if(audio_status() & AUDIO_STATUS_ERROR)
795 {
796 splash(0, str(LANG_DISK_FULL));
797 audio_error_clear();
798
799 while(1)
800 {
801 button = get_action(CONTEXT_FM|ALLOW_SOFTLOCK, TIMEOUT_BLOCK);
802 if(button == ACTION_FM_STOP)
803 break;
804 }
805 }
806
807 audio_init_playback();
808#endif /* CONFIG_CODEC != SWCODEC */
809
810 sound_settings_apply(); 710 sound_settings_apply();
811#endif /* SIMULATOR */ 711#endif /* SIMULATOR */
812 712
@@ -814,23 +714,12 @@ void radio_screen(void)
814 { 714 {
815/* Catch FMRADIO_PLAYING status for the sim. */ 715/* Catch FMRADIO_PLAYING status for the sim. */
816#ifndef SIMULATOR 716#ifndef SIMULATOR
817#if CONFIG_CODEC != SWCODEC
818 /* Enable the Left and right A/D Converter */
819 audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN),
820 sound_default(SOUND_RIGHT_GAIN),
821 AUDIO_GAIN_LINEIN);
822 mas_codec_writereg(6, 0x4000);
823#endif
824 end_search(); 717 end_search();
825#endif /* SIMULATOR */ 718#endif /* SIMULATOR */
826 } 719 }
827 else 720 else
828 { 721 {
829#if CONFIG_CODEC == SWCODEC
830 audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); 722 audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
831#else
832 radio_stop();
833#endif
834 } 723 }
835 724
836#ifndef HAVE_NOISY_IDLE_MODE 725#ifndef HAVE_NOISY_IDLE_MODE
diff --git a/apps/radio/radio_skin.c b/apps/radio/radio_skin.c
index 90aa977e56..4d90c4e241 100644
--- a/apps/radio/radio_skin.c
+++ b/apps/radio/radio_skin.c
@@ -41,7 +41,7 @@
41char* default_radio_skin(enum screen_type screen) 41char* default_radio_skin(enum screen_type screen)
42{ 42{
43 (void)screen; 43 (void)screen;
44 static char default_fms[] = 44 static char default_fms[] =
45 "%s%?Ti<%Ti. |>%?Tn<%Tn|%Tf>\n" 45 "%s%?Ti<%Ti. |>%?Tn<%Tn|%Tf>\n"
46 "%Sx(Station:) %tf MHz\n" 46 "%Sx(Station:) %tf MHz\n"
47 "%?St(force fm mono)<%Sx(Force Mono)|%?ts<%Sx(Stereo)|%Sx(Mono)>>\n" 47 "%?St(force fm mono)<%Sx(Force Mono)|%?ts<%Sx(Stereo)|%Sx(Mono)>>\n"
@@ -49,9 +49,6 @@ char* default_radio_skin(enum screen_type screen)
49#ifdef HAVE_RADIO_RSSI 49#ifdef HAVE_RADIO_RSSI
50 "%Sx(Signal strength:) %tr dBuV\n" 50 "%Sx(Signal strength:) %tr dBuV\n"
51#endif 51#endif
52#if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
53 "%?Rr<%Sx(Time:) %Rh:%Rn:%Rs|%?St(prerecording time)<%pm|%Sx(Prerecord Time) %Rs>>\n"
54#endif
55 "%pb\n" 52 "%pb\n"
56#ifdef HAVE_RDS_CAP 53#ifdef HAVE_RDS_CAP
57 "\n%s%ty\n" 54 "\n%s%ty\n"
diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c
index 03a88c9fdc..cc53716674 100644
--- a/apps/recorder/icons.c
+++ b/apps/recorder/icons.c
@@ -40,10 +40,6 @@ const unsigned char bitmap_icons_5x8[][5] =
40 {0x7f, 0x22, 0x1c, 0x22, 0x7f}, /* Stereo recording */ 40 {0x7f, 0x22, 0x1c, 0x22, 0x7f}, /* Stereo recording */
41 [Icon_Mono] = 41 [Icon_Mono] =
42 {0x00, 0x1c, 0x22, 0x7f, 0x00}, /* Mono recording */ 42 {0x00, 0x1c, 0x22, 0x7f, 0x00}, /* Mono recording */
43#if CONFIG_CODEC != SWCODEC
44 [Icon_q] =
45 {0x1e, 0x21, 0x31, 0x21, 0x5e} /* Q icon */
46#endif
47}; 43};
48 44
49const unsigned char bitmap_icons_7x8[][7] = 45const unsigned char bitmap_icons_7x8[][7] =
@@ -68,7 +64,7 @@ const unsigned char bitmap_icons_7x8[][7] =
68 {0x7f,0x04,0x4e,0x5f,0x44,0x38,0x7f} /* Repeat-AB playmode */ 64 {0x7f,0x04,0x4e,0x5f,0x44,0x38,0x7f} /* Repeat-AB playmode */
69}; 65};
70 66
71#if CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING) 67#if defined(HAVE_RECORDING)
72const unsigned char bitmap_glyphs_4x8[][4] = 68const unsigned char bitmap_glyphs_4x8[][4] =
73{ 69{
74 /* Keep digits together and first! */ 70 /* Keep digits together and first! */
@@ -116,7 +112,7 @@ const unsigned char bitmap_formats_18x8[Format_18x8Last][18]=
116 {0x00, 0x1e, 0x20, 0x18, 0x20, 0x1e, 0x00, 0x3c, 0x0a, 112 {0x00, 0x1e, 0x20, 0x18, 0x20, 0x1e, 0x00, 0x3c, 0x0a,
117 0x0a, 0x0a, 0x3c, 0x00, 0x0e, 0x10, 0x20, 0x10, 0x0e}, /* WAV */ 113 0x0a, 0x0a, 0x3c, 0x00, 0x0e, 0x10, 0x20, 0x10, 0x0e}, /* WAV */
118}; 114};
119#endif /* CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING) */ 115#endif /* defined(HAVE_RECORDING) */
120 116
121/* Disk/MMC activity */ 117/* Disk/MMC activity */
122const unsigned char bitmap_icon_disk[12] = 118const unsigned char bitmap_icon_disk[12] =
diff --git a/apps/recorder/icons.h b/apps/recorder/icons.h
index 3c955ffe5b..4faa757184 100644
--- a/apps/recorder/icons.h
+++ b/apps/recorder/icons.h
@@ -42,9 +42,6 @@ enum icons_5x8 {
42 Icon_Lock_Remote, 42 Icon_Lock_Remote,
43 Icon_Stereo, 43 Icon_Stereo,
44 Icon_Mono, 44 Icon_Mono,
45#if CONFIG_CODEC != SWCODEC
46 Icon_q,
47#endif
48 Icon5x8Last 45 Icon5x8Last
49}; 46};
50 47
@@ -70,7 +67,7 @@ enum icons_7x8 {
70 Icon7x8Last 67 Icon7x8Last
71}; 68};
72 69
73#if CONFIG_CODEC == SWCODEC && defined (HAVE_RECORDING) 70#if defined (HAVE_RECORDING)
74#define BM_GLYPH_WIDTH 4 71#define BM_GLYPH_WIDTH 4
75enum Glyphs_4x8 { 72enum Glyphs_4x8 {
76 Glyph_4x8_0 = 0, 73 Glyph_4x8_0 = 0,
@@ -100,7 +97,7 @@ enum rec_format_18x8 {
100}; 97};
101extern const unsigned char bitmap_formats_18x8[Format_18x8Last][18]; 98extern const unsigned char bitmap_formats_18x8[Format_18x8Last][18];
102 99
103#endif /* CONFIG_CODEC == SWCODEC && defined (HAVE_RECORDING) */ 100#endif /* defined (HAVE_RECORDING) */
104 101
105extern const unsigned char bitmap_icons_5x8[Icon5x8Last][5]; 102extern const unsigned char bitmap_icons_5x8[Icon5x8Last][5];
106extern const unsigned char bitmap_icons_7x8[Icon7x8Last][7]; 103extern const unsigned char bitmap_icons_7x8[Icon7x8Last][7];
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index 4b19287b7f..f735afe84d 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -1218,16 +1218,12 @@ static void kbd_move_cursor(struct edit_state *state, int dir)
1218 else if (state->editpos > state->len_utf8) 1218 else if (state->editpos > state->len_utf8)
1219 { 1219 {
1220 state->editpos = 0; 1220 state->editpos = 0;
1221 #if CONFIG_CODEC == SWCODEC
1222 if (global_settings.talk_menu) beep_play(1000, 150, 1500); 1221 if (global_settings.talk_menu) beep_play(1000, 150, 1500);
1223 #endif
1224 } 1222 }
1225 else if (state->editpos < 0) 1223 else if (state->editpos < 0)
1226 { 1224 {
1227 state->editpos = state->len_utf8; 1225 state->editpos = state->len_utf8;
1228 #if CONFIG_CODEC == SWCODEC
1229 if (global_settings.talk_menu) beep_play(1000, 150, 1500); 1226 if (global_settings.talk_menu) beep_play(1000, 150, 1500);
1230 #endif
1231 } 1227 }
1232} 1228}
1233 1229
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c
index 5ff2f21215..5a03534040 100644
--- a/apps/recorder/peakmeter.c
+++ b/apps/recorder/peakmeter.c
@@ -19,9 +19,6 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include "config.h" 21#include "config.h"
22#if defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
23#include <stdlib.h> /* sim uses rand for peakmeter simulation */
24#endif
25#include "thread.h" 22#include "thread.h"
26#include "kernel.h" 23#include "kernel.h"
27#include "settings.h" 24#include "settings.h"
@@ -42,7 +39,6 @@
42#endif 39#endif
43#include "action.h" 40#include "action.h"
44 41
45#if CONFIG_CODEC == SWCODEC
46#include "pcm.h" 42#include "pcm.h"
47#include "pcm_mixer.h" 43#include "pcm_mixer.h"
48 44
@@ -50,17 +46,12 @@
50#include "pcm_record.h" 46#include "pcm_record.h"
51#endif 47#endif
52 48
49#if !(CONFIG_PLATFORM & PLATFORM_HOSTED)
53static bool pm_playback = true; /* selects between playback and recording peaks */ 50static bool pm_playback = true; /* selects between playback and recording peaks */
54#endif 51#endif
55 52
56static struct meter_scales scales[NB_SCREENS]; 53static struct meter_scales scales[NB_SCREENS];
57 54
58#if !defined(SIMULATOR) && CONFIG_CODEC != SWCODEC
59/* Data source */
60static int pm_src_left = MAS_REG_DQPEAK_L;
61static int pm_src_right = MAS_REG_DQPEAK_R;
62#endif
63
64/* Current values and cumulation */ 55/* Current values and cumulation */
65static int pm_cur_left; /* current values (last peak_meter_peek) */ 56static int pm_cur_left; /* current values (last peak_meter_peek) */
66static int pm_cur_right; 57static int pm_cur_right;
@@ -554,16 +545,8 @@ void peak_meter_playback(bool playback)
554{ 545{
555#if (CONFIG_PLATFORM & PLATFORM_HOSTED) 546#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
556 (void)playback; 547 (void)playback;
557#elif CONFIG_CODEC == SWCODEC
558 pm_playback = playback;
559#else 548#else
560 if (playback) { 549 pm_playback = playback;
561 pm_src_left = MAS_REG_DQPEAK_L;
562 pm_src_right = MAS_REG_DQPEAK_R;
563 } else {
564 pm_src_left = MAS_REG_QPEAK_L;
565 pm_src_right = MAS_REG_QPEAK_R;
566 }
567#endif 550#endif
568 /* reset the scales just in case recording and playback 551 /* reset the scales just in case recording and playback
569 use different viewport sizes. Normally we should be checking viewport 552 use different viewport sizes. Normally we should be checking viewport
@@ -599,7 +582,10 @@ void peak_meter_peek(void)
599 bool was_clipping = pm_clip_left || pm_clip_right; 582 bool was_clipping = pm_clip_left || pm_clip_right;
600#endif 583#endif
601 /* read current values */ 584 /* read current values */
602#if CONFIG_CODEC == SWCODEC 585#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
586 pm_cur_left = left = 8000;
587 pm_cur_right = right = 9000;
588#else
603 if (pm_playback) 589 if (pm_playback)
604 { 590 {
605 static struct pcm_peaks chan_peaks; /* *MUST* be static */ 591 static struct pcm_peaks chan_peaks; /* *MUST* be static */
@@ -614,14 +600,6 @@ void peak_meter_peek(void)
614#endif 600#endif
615 left = pm_cur_left; 601 left = pm_cur_left;
616 right = pm_cur_right; 602 right = pm_cur_right;
617#else
618#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
619 pm_cur_left = left = mas_codec_readreg(pm_src_left);
620 pm_cur_right = right = mas_codec_readreg(pm_src_right);
621#else
622 pm_cur_left = left = 8000;
623 pm_cur_right = right = 9000;
624#endif
625#endif 603#endif
626 604
627 /* check for clips 605 /* check for clips
@@ -632,22 +610,12 @@ void peak_meter_peek(void)
632 a real clip. For software codecs, the peak is already 610 a real clip. For software codecs, the peak is already
633 the max of a bunch of samples, so use one max value 611 the max of a bunch of samples, so use one max value
634 or you fail to detect clipping! */ 612 or you fail to detect clipping! */
635#if CONFIG_CODEC == SWCODEC
636 if (left == MAX_PEAK - 1) { 613 if (left == MAX_PEAK - 1) {
637#else
638 if ((left == pm_max_left) &&
639 (left == MAX_PEAK - 1)) {
640#endif
641 pm_clip_left = true; 614 pm_clip_left = true;
642 pm_clip_timeout_l = current_tick + pm_clip_hold; 615 pm_clip_timeout_l = current_tick + pm_clip_hold;
643 } 616 }
644 617
645#if CONFIG_CODEC == SWCODEC
646 if (right == MAX_PEAK - 1) { 618 if (right == MAX_PEAK - 1) {
647#else
648 if ((right == pm_max_right) &&
649 (right == MAX_PEAK - 1)) {
650#endif
651 pm_clip_right = true; 619 pm_clip_right = true;
652 pm_clip_timeout_r = current_tick + pm_clip_hold; 620 pm_clip_timeout_r = current_tick + pm_clip_hold;
653 } 621 }
@@ -668,14 +636,12 @@ void peak_meter_peek(void)
668 pm_max_right = MAX(pm_max_right, right); 636 pm_max_right = MAX(pm_max_right, right);
669 637
670#ifdef HAVE_RECORDING 638#ifdef HAVE_RECORDING
671#if CONFIG_CODEC == SWCODEC
672 /* Ignore any unread peakmeter data */ 639 /* Ignore any unread peakmeter data */
673#define MAX_DROP_TIME HZ/7 /* this value may need tweaking. Increase if you are 640#define MAX_DROP_TIME HZ/7 /* this value may need tweaking. Increase if you are
674 getting trig events when you shouldn't with 641 getting trig events when you shouldn't with
675 trig_stp_hold = 0 */ 642 trig_stp_hold = 0 */
676 if (!trig_stp_hold) 643 if (!trig_stp_hold)
677 trig_stp_hold = MAX_DROP_TIME; 644 trig_stp_hold = MAX_DROP_TIME;
678#endif
679 645
680 switch (trig_status) { 646 switch (trig_status) {
681 case TRIG_READY: 647 case TRIG_READY:
@@ -735,11 +701,7 @@ void peak_meter_peek(void)
735 || (right > trig_stp_threshold)) { 701 || (right > trig_stp_threshold)) {
736 /* restart hold time countdown */ 702 /* restart hold time countdown */
737 trig_lowtime = current_tick; 703 trig_lowtime = current_tick;
738#if CONFIG_CODEC == SWCODEC
739 } else if (current_tick - trig_lowtime > MAX_DROP_TIME){ 704 } else if (current_tick - trig_lowtime > MAX_DROP_TIME){
740#else
741 } else {
742#endif
743 set_trig_status(TRIG_POSTREC); 705 set_trig_status(TRIG_POSTREC);
744 trig_hightime = current_tick; 706 trig_hightime = current_tick;
745 } 707 }
@@ -797,12 +759,10 @@ void peak_meter_peek(void)
797 } 759 }
798 break; 760 break;
799 } 761 }
800#if CONFIG_CODEC == SWCODEC
801 /* restore stop hold value */ 762 /* restore stop hold value */
802 if (trig_stp_hold == MAX_DROP_TIME) 763 if (trig_stp_hold == MAX_DROP_TIME)
803 trig_stp_hold = 0; 764 trig_stp_hold = 0;
804#endif 765#endif
805#endif
806 /* check levels next time peakmeter drawn */ 766 /* check levels next time peakmeter drawn */
807 level_check = true; 767 level_check = true;
808#ifdef PM_DEBUG 768#ifdef PM_DEBUG
@@ -822,11 +782,6 @@ static int peak_meter_read_l(void)
822 by peak_meter_peek since the last call of peak_meter_read_l */ 782 by peak_meter_peek since the last call of peak_meter_read_l */
823 int retval; 783 int retval;
824 784
825#if defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
826 srand(current_tick);
827 pm_max_left = rand()%MAX_PEAK;
828#endif
829
830 retval = pm_max_left; 785 retval = pm_max_left;
831 786
832#if defined(HAVE_HISTOGRAM) || defined(HAVE_AGC) 787#if defined(HAVE_HISTOGRAM) || defined(HAVE_AGC)
@@ -855,11 +810,6 @@ static int peak_meter_read_r(void)
855 by peak_meter_peek since the last call of peak_meter_read_r */ 810 by peak_meter_peek since the last call of peak_meter_read_r */
856 int retval; 811 int retval;
857 812
858#if defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
859 srand(current_tick);
860 pm_max_right = rand()%MAX_PEAK;
861#endif
862
863 retval = pm_max_right; 813 retval = pm_max_right;
864 814
865#if defined(HAVE_HISTOGRAM) || defined(HAVE_AGC) 815#if defined(HAVE_HISTOGRAM) || defined(HAVE_AGC)
@@ -1128,11 +1078,7 @@ static void peak_meter_draw(struct screen *display, struct meter_scales *scales,
1128 /* cliplight */ 1078 /* cliplight */
1129 if ((pm_clip_left || pm_clip_right) && 1079 if ((pm_clip_left || pm_clip_right) &&
1130 global_settings.cliplight && 1080 global_settings.cliplight &&
1131#if CONFIG_CODEC == SWCODEC
1132 !pm_playback) 1081 !pm_playback)
1133#else
1134 !(audio_status() & (AUDIO_STATUS_PLAY | AUDIO_STATUS_ERROR)))
1135#endif
1136 { 1082 {
1137 /* if clipping, cliplight setting on and in recording screen */ 1083 /* if clipping, cliplight setting on and in recording screen */
1138 if (global_settings.cliplight <= 2) 1084 if (global_settings.cliplight <= 2)
@@ -1375,16 +1321,7 @@ int peak_meter_draw_get_btn(int action_context, int x[], int y[],
1375 long next_refresh = current_tick; 1321 long next_refresh = current_tick;
1376 long next_big_refresh = current_tick + HZ / 10; 1322 long next_big_refresh = current_tick + HZ / 10;
1377 int i; 1323 int i;
1378#if (CONFIG_CODEC == SWCODEC)
1379 bool highperf = false; 1324 bool highperf = false;
1380#else
1381 /* On MAS targets, we need to poll as often as possible in order to not
1382 * miss a peak, as the MAS does only provide a quasi-peak. When the disk
1383 * is active, it must not draw too much CPU power or a buffer overrun can
1384 * happen when saving a recording. As a compromise, poll only once per tick
1385 * when the disk is active, otherwise spin around as fast as possible. */
1386 bool highperf = !storage_disk_is_active();
1387#endif
1388 bool dopeek = true; 1325 bool dopeek = true;
1389 1326
1390 while (TIME_BEFORE(current_tick, next_big_refresh)) { 1327 while (TIME_BEFORE(current_tick, next_big_refresh)) {
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 553f815e52..36331a72f3 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -31,17 +31,14 @@
31#include "lcd.h" 31#include "lcd.h"
32#include "led.h" 32#include "led.h"
33#include "audio.h" 33#include "audio.h"
34#if CONFIG_CODEC == SWCODEC
35#include "thread.h" 34#include "thread.h"
36#include "enc_config.h" 35#include "enc_config.h"
37#include "playback.h" 36#include "playback.h"
38#if defined(HAVE_SPDIF_IN) || defined(HAVE_SPDIF_OUT) 37#if defined(HAVE_SPDIF_IN) || defined(HAVE_SPDIF_OUT)
39#include "spdif.h" 38#include "spdif.h"
40#endif 39#endif
41#endif /* CONFIG_CODEC == SWCODEC */
42#include "pcm_record.h" 40#include "pcm_record.h"
43#include "recording.h" 41#include "recording.h"
44#include "mp3_playback.h"
45#include "button.h" 42#include "button.h"
46#include "kernel.h" 43#include "kernel.h"
47#include "settings.h" 44#include "settings.h"
@@ -166,19 +163,9 @@ static bool update_list = false; /* (GIU) list needs updating */
166static int file_number = -1; 163static int file_number = -1;
167#endif /* CONFIG_RTC */ 164#endif /* CONFIG_RTC */
168 165
169#if CONFIG_CODEC == SWCODEC
170
171#define REC_FILE_ENDING(rec_format) \ 166#define REC_FILE_ENDING(rec_format) \
172 (audio_formats[rec_format_afmt[rec_format]].ext_list) 167 (audio_formats[rec_format_afmt[rec_format]].ext_list)
173 168
174#else /* CONFIG_CODEC != SWCODEC */
175
176/* default record file extension for HWCODEC */
177#define REC_FILE_ENDING(rec_format) \
178 (audio_formats[AFMT_MPA_L3].ext_list)
179
180#endif /* CONFIG_CODEC == SWCODEC */
181
182/* path for current file */ 169/* path for current file */
183static char path_buffer[MAX_PATH]; 170static char path_buffer[MAX_PATH];
184 171
@@ -607,18 +594,12 @@ void rec_init_recording_options(struct audio_recording_options *options)
607 options->rec_frequency = global_settings.rec_frequency; 594 options->rec_frequency = global_settings.rec_frequency;
608 options->rec_channels = global_settings.rec_channels; 595 options->rec_channels = global_settings.rec_channels;
609 options->rec_prerecord_time = global_settings.rec_prerecord_time; 596 options->rec_prerecord_time = global_settings.rec_prerecord_time;
610#if CONFIG_CODEC == SWCODEC
611 options->rec_mono_mode = global_settings.rec_mono_mode; 597 options->rec_mono_mode = global_settings.rec_mono_mode;
612 options->rec_source_flags = 0; 598 options->rec_source_flags = 0;
613 options->enc_config.rec_format = global_settings.rec_format; 599 options->enc_config.rec_format = global_settings.rec_format;
614 global_to_encoder_config(&options->enc_config); 600 global_to_encoder_config(&options->enc_config);
615#else
616 options->rec_quality = global_settings.rec_quality;
617 options->rec_editable = global_settings.rec_editable;
618#endif
619} 601}
620 602
621#if CONFIG_CODEC == SWCODEC
622void rec_set_source(int source, unsigned flags) 603void rec_set_source(int source, unsigned flags)
623{ 604{
624 /* Set audio input source, power up/down devices */ 605 /* Set audio input source, power up/down devices */
@@ -628,14 +609,11 @@ void rec_set_source(int source, unsigned flags)
628 peak_meter_playback((flags & SRCF_RECORDING) == 0); 609 peak_meter_playback((flags & SRCF_RECORDING) == 0);
629 peak_meter_enable(true); 610 peak_meter_enable(true);
630} 611}
631#endif /* CONFIG_CODEC == SWCODEC */
632 612
633void rec_set_recording_options(struct audio_recording_options *options) 613void rec_set_recording_options(struct audio_recording_options *options)
634{ 614{
635#if CONFIG_CODEC == SWCODEC
636 rec_set_source(options->rec_source, 615 rec_set_source(options->rec_source,
637 options->rec_source_flags | SRCF_RECORDING); 616 options->rec_source_flags | SRCF_RECORDING);
638#endif
639 audio_set_recording_options(options); 617 audio_set_recording_options(options);
640} 618}
641 619
@@ -646,9 +624,7 @@ void rec_command(enum recording_command cmd)
646 case RECORDING_CMD_STOP_SHUTDOWN: 624 case RECORDING_CMD_STOP_SHUTDOWN:
647 pm_activate_clipcount(false); 625 pm_activate_clipcount(false);
648 audio_stop_recording(); 626 audio_stop_recording();
649#if CONFIG_CODEC == SWCODEC
650 audio_close_recording(); 627 audio_close_recording();
651#endif
652 sys_poweroff(); 628 sys_poweroff();
653 break; 629 break;
654 case RECORDING_CMD_STOP: 630 case RECORDING_CMD_STOP:
@@ -695,12 +671,6 @@ static void trigger_listener(int trigger_status)
695 if(!(audio_status() & AUDIO_STATUS_RECORD)) 671 if(!(audio_status() & AUDIO_STATUS_RECORD))
696 { 672 {
697 rec_status |= RCSTAT_HAVE_RECORDED; 673 rec_status |= RCSTAT_HAVE_RECORDED;
698 rec_command(RECORDING_CMD_START);
699#if CONFIG_CODEC != SWCODEC
700 /* give control to mpeg thread so that it can start
701 recording */
702 yield(); yield(); yield();
703#endif
704 } 674 }
705 675
706 /* if we're already recording this is a retrigger */ 676 /* if we're already recording this is a retrigger */
@@ -791,14 +761,9 @@ enum rec_list_items_mono {
791#ifdef HAVE_SPDIF_REC 761#ifdef HAVE_SPDIF_REC
792enum rec_list_items_spdif { 762enum rec_list_items_spdif {
793 ITEM_VOLUME_D = 0, 763 ITEM_VOLUME_D = 0,
794#if CONFIG_CODEC == SWCODEC
795 ITEM_SAMPLERATE_D = 6, 764 ITEM_SAMPLERATE_D = 6,
796 ITEM_FILENAME_D = 7, 765 ITEM_FILENAME_D = 7,
797 ITEM_COUNT_D = 3, 766 ITEM_COUNT_D = 3,
798#else
799 ITEM_FILENAME_D = 7,
800 ITEM_COUNT_D = 2,
801#endif
802}; 767};
803#endif 768#endif
804 769
@@ -892,14 +857,12 @@ static const char* reclist_get_name(int selected_item, void * data,
892 buf3, sizeof(buf3))); 857 buf3, sizeof(buf3)));
893 break; 858 break;
894#endif 859#endif
895#if CONFIG_CODEC == SWCODEC
896#ifdef HAVE_SPDIF_REC 860#ifdef HAVE_SPDIF_REC
897 case ITEM_SAMPLERATE_D: 861 case ITEM_SAMPLERATE_D:
898 snprintf(buffer, buffer_len, "%s: %lu", 862 snprintf(buffer, buffer_len, "%s: %lu",
899 str(LANG_FREQUENCY), pcm_rec_sample_rate()); 863 str(LANG_FREQUENCY), pcm_rec_sample_rate());
900 break; 864 break;
901#endif 865#endif
902#endif
903 case ITEM_FILENAME: 866 case ITEM_FILENAME:
904 { 867 {
905 if(audio_status() & AUDIO_STATUS_RECORD) 868 if(audio_status() & AUDIO_STATUS_RECORD)
@@ -973,16 +936,12 @@ bool recording_screen(bool no_source)
973 const unsigned long split_seconds = (unsigned) global_settings.rec_timesplit * 60; 936 const unsigned long split_seconds = (unsigned) global_settings.rec_timesplit * 60;
974 const unsigned long split_bytes = rec_sizesplit_bytes(); 937 const unsigned long split_bytes = rec_sizesplit_bytes();
975 938
976#if CONFIG_CODEC == SWCODEC
977 int warning_counter = 0; 939 int warning_counter = 0;
978 #define WARNING_PERIOD 7 940 #define WARNING_PERIOD 7
979#endif
980 941
981#if CONFIG_CODEC == SWCODEC
982#ifdef HAVE_SPDIF_REC 942#ifdef HAVE_SPDIF_REC
983 unsigned long prev_sample_rate = 0; 943 unsigned long prev_sample_rate = 0;
984#endif 944#endif
985#endif
986 945
987#ifdef HAVE_FMRADIO_REC 946#ifdef HAVE_FMRADIO_REC
988 /* Radio is left on if: 947 /* Radio is left on if:
@@ -1030,7 +989,6 @@ bool recording_screen(bool no_source)
1030 ata_set_led_enabled(false); 989 ata_set_led_enabled(false);
1031#endif 990#endif
1032 991
1033#if CONFIG_CODEC == SWCODEC
1034 /* hardware samplerate gets messed up so prevent mixer playing */ 992 /* hardware samplerate gets messed up so prevent mixer playing */
1035 int keyclick = global_settings.keyclick; 993 int keyclick = global_settings.keyclick;
1036 global_settings.keyclick = 0; 994 global_settings.keyclick = 0;
@@ -1039,11 +997,6 @@ bool recording_screen(bool no_source)
1039 talk_disable(true); 997 talk_disable(true);
1040 /* audio_init_recording stops anything playing when it takes the audio 998 /* audio_init_recording stops anything playing when it takes the audio
1041 buffer */ 999 buffer */
1042#else
1043 /* Yes, we use the D/A for monitoring */
1044 peak_meter_enable(true);
1045 peak_meter_playback(true);
1046#endif
1047 1000
1048#ifdef HAVE_AGC 1001#ifdef HAVE_AGC
1049 peak_meter_get_peakhold(&peak_l, &peak_r); 1002 peak_meter_get_peakhold(&peak_l, &peak_r);
@@ -1175,7 +1128,7 @@ bool recording_screen(bool no_source)
1175 goto rec_abort; 1128 goto rec_abort;
1176 } 1129 }
1177 1130
1178#if CONFIG_CODEC == SWCODEC && CONFIG_RTC == 0 1131#if CONFIG_RTC == 0
1179 /* If format changed, a new number is required */ 1132 /* If format changed, a new number is required */
1180 rec_init_filename(); 1133 rec_init_filename();
1181#endif 1134#endif
@@ -1202,12 +1155,8 @@ bool recording_screen(bool no_source)
1202 if(global_settings.rec_source == AUDIO_SRC_SPDIF) 1155 if(global_settings.rec_source == AUDIO_SRC_SPDIF)
1203 { 1156 {
1204 listid_to_enum[0] = ITEM_VOLUME_D; 1157 listid_to_enum[0] = ITEM_VOLUME_D;
1205#if CONFIG_CODEC == SWCODEC
1206 listid_to_enum[1] = ITEM_SAMPLERATE_D; 1158 listid_to_enum[1] = ITEM_SAMPLERATE_D;
1207 listid_to_enum[2] = ITEM_FILENAME_D; 1159 listid_to_enum[2] = ITEM_FILENAME_D;
1208#else
1209 listid_to_enum[1] = ITEM_FILENAME_D;
1210#endif
1211 1160
1212 gui_synclist_set_nb_items(&lists, ITEM_COUNT_D); /* spdif */ 1161 gui_synclist_set_nb_items(&lists, ITEM_COUNT_D); /* spdif */
1213 } 1162 }
@@ -1452,10 +1401,6 @@ bool recording_screen(bool no_source)
1452 } 1401 }
1453 else 1402 else
1454 { 1403 {
1455#if CONFIG_CODEC != SWCODEC
1456 peak_meter_playback(true);
1457 peak_meter_enable(false);
1458#endif
1459 done = 1; 1404 done = 1;
1460 } 1405 }
1461 update_countdown = 0; /* Update immediately */ 1406 update_countdown = 0; /* Update immediately */
@@ -1543,11 +1488,7 @@ bool recording_screen(bool no_source)
1543 update_countdown = 0; /* Update immediately */ 1488 update_countdown = 0; /* Update immediately */
1544 break; 1489 break;
1545 case ACTION_STD_MENU: 1490 case ACTION_STD_MENU:
1546#if CONFIG_CODEC == SWCODEC
1547 if(!(audio_stat & AUDIO_STATUS_RECORD)) 1491 if(!(audio_stat & AUDIO_STATUS_RECORD))
1548#else
1549 if(audio_stat != AUDIO_STATUS_RECORD)
1550#endif
1551 { 1492 {
1552#if (CONFIG_LED == LED_REAL) 1493#if (CONFIG_LED == LED_REAL)
1553 /* led is restored at begin of loop / end of function */ 1494 /* led is restored at begin of loop / end of function */
@@ -1622,7 +1563,6 @@ bool recording_screen(bool no_source)
1622 dsize = split_bytes; 1563 dsize = split_bytes;
1623 num_recorded_bytes = audio_num_recorded_bytes(); 1564 num_recorded_bytes = audio_num_recorded_bytes();
1624 1565
1625#if CONFIG_CODEC == SWCODEC
1626 if ((audio_stat & AUDIO_STATUS_WARNING) 1566 if ((audio_stat & AUDIO_STATUS_WARNING)
1627 && (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2) 1567 && (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2)
1628 { 1568 {
@@ -1635,7 +1575,6 @@ bool recording_screen(bool no_source)
1635 (unsigned long)pcm_rec_get_warnings()); 1575 (unsigned long)pcm_rec_get_warnings());
1636 } 1576 }
1637 else 1577 else
1638#endif /* CONFIG_CODEC == SWCODEC */
1639 if ((global_settings.rec_sizesplit) && 1578 if ((global_settings.rec_sizesplit) &&
1640 (global_settings.rec_split_method)) 1579 (global_settings.rec_split_method))
1641 { 1580 {
@@ -1657,16 +1596,11 @@ bool recording_screen(bool no_source)
1657 1596
1658 if(audio_stat & AUDIO_STATUS_PRERECORD) 1597 if(audio_stat & AUDIO_STATUS_PRERECORD)
1659 { 1598 {
1660#if CONFIG_CODEC == SWCODEC
1661 /* Tracks amount of prerecorded data in buffer */ 1599 /* Tracks amount of prerecorded data in buffer */
1662 snprintf(buf, sizeof(buf), "%s (%lu/%ds)...", 1600 snprintf(buf, sizeof(buf), "%s (%lu/%ds)...",
1663 str(LANG_RECORD_PRERECORD), 1601 str(LANG_RECORD_PRERECORD),
1664 audio_prerecorded_time() / HZ, 1602 audio_prerecorded_time() / HZ,
1665 global_settings.rec_prerecord_time); 1603 global_settings.rec_prerecord_time);
1666#else /* !SWCODEC */
1667 snprintf(buf, sizeof(buf), "%s...",
1668 str(LANG_RECORD_PRERECORD));
1669#endif /* CONFIG_CODEC == SWCODEC */
1670 } 1604 }
1671 else 1605 else
1672 { 1606 {
@@ -1782,7 +1716,6 @@ bool recording_screen(bool no_source)
1782 } 1716 }
1783#endif /* HAVE_AGC */ 1717#endif /* HAVE_AGC */
1784 1718
1785#if CONFIG_CODEC == SWCODEC
1786#ifdef HAVE_SPDIF_REC 1719#ifdef HAVE_SPDIF_REC
1787 if((global_settings.rec_source == AUDIO_SRC_SPDIF) && 1720 if((global_settings.rec_source == AUDIO_SRC_SPDIF) &&
1788 (prev_sample_rate != pcm_rec_sample_rate())) 1721 (prev_sample_rate != pcm_rec_sample_rate()))
@@ -1792,7 +1725,6 @@ bool recording_screen(bool no_source)
1792 update_list = true; 1725 update_list = true;
1793 } 1726 }
1794#endif 1727#endif
1795#endif
1796 1728
1797 if(update_list) 1729 if(update_list)
1798 { 1730 {
@@ -1824,11 +1756,9 @@ bool recording_screen(bool no_source)
1824 FOR_NB_SCREENS(i) 1756 FOR_NB_SCREENS(i)
1825 screens[i].update(); 1757 screens[i].update();
1826 1758
1827#if CONFIG_CODEC == SWCODEC
1828 /* stop recording first and try to finish saving whatever it can */ 1759 /* stop recording first and try to finish saving whatever it can */
1829 rec_command(RECORDING_CMD_STOP); 1760 rec_command(RECORDING_CMD_STOP);
1830 audio_close_recording(); 1761 audio_close_recording();
1831#endif
1832 1762
1833 audio_error_clear(); 1763 audio_error_clear();
1834 1764
@@ -1841,7 +1771,6 @@ bool recording_screen(bool no_source)
1841 1771
1842rec_abort: 1772rec_abort:
1843 1773
1844#if CONFIG_CODEC == SWCODEC
1845 rec_command(RECORDING_CMD_STOP); 1774 rec_command(RECORDING_CMD_STOP);
1846 audio_close_recording(); 1775 audio_close_recording();
1847 1776
@@ -1861,9 +1790,6 @@ rec_abort:
1861 1790
1862 /* restore keyclick */ 1791 /* restore keyclick */
1863 global_settings.keyclick = keyclick; 1792 global_settings.keyclick = keyclick;
1864#else /* !SWCODEC */
1865 audio_init_playback();
1866#endif /* CONFIG_CODEC == SWCODEC */
1867 1793
1868#ifdef HAVE_SPEAKER 1794#ifdef HAVE_SPEAKER
1869 /* Re-enable speaker */ 1795 /* Re-enable speaker */
@@ -1895,12 +1821,10 @@ rec_abort:
1895 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0; 1821 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
1896} /* recording_screen */ 1822} /* recording_screen */
1897 1823
1898#if CONFIG_CODEC == SWCODEC
1899void audio_beep(int duration) 1824void audio_beep(int duration)
1900{ 1825{
1901 /* dummy */ 1826 /* dummy */
1902 (void)duration; 1827 (void)duration;
1903} 1828}
1904#endif /* #ifdef CONFIG_CODEC == SWCODEC */
1905 1829
1906#endif /* HAVE_RECORDING */ 1830#endif /* HAVE_RECORDING */
diff --git a/apps/recorder/recording.h b/apps/recorder/recording.h
index 406986e8e0..12088f84f6 100644
--- a/apps/recorder/recording.h
+++ b/apps/recorder/recording.h
@@ -33,17 +33,14 @@ void settings_apply_trigger(void);
33/* If true, start recording automatically when recording_sreen() is entered */ 33/* If true, start recording automatically when recording_sreen() is entered */
34extern bool recording_start_automatic; 34extern bool recording_start_automatic;
35 35
36#if CONFIG_CODEC == SWCODEC
37/* handles device powerup, sets audio source and peakmeter mode */ 36/* handles device powerup, sets audio source and peakmeter mode */
38void rec_set_source(int source, unsigned flags); 37void rec_set_source(int source, unsigned flags);
39#endif /* CONFIG_CODEC == SW_CODEC */
40 38
41/* Initializes a recording_options structure with global settings. 39/* Initializes a recording_options structure with global settings.
42 pass returned data to audio_set_recording_options or 40 pass returned data to audio_set_recording_options or
43 rec_set_recording_options */ 41 rec_set_recording_options */
44void rec_init_recording_options(struct audio_recording_options *options); 42void rec_init_recording_options(struct audio_recording_options *options);
45/* steals mp3 buffer, sets source and then options */ 43/* steals mp3 buffer, sets source and then options */
46/* SRCF_RECORDING is implied for SWCODEC */
47void rec_set_recording_options(struct audio_recording_options *options); 44void rec_set_recording_options(struct audio_recording_options *options);
48 45
49enum recording_command 46enum recording_command
diff --git a/apps/screens.c b/apps/screens.c
index ecd406037d..47f110efd9 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -30,7 +30,6 @@
30#include "icons.h" 30#include "icons.h"
31#include "font.h" 31#include "font.h"
32#include "audio.h" 32#include "audio.h"
33#include "mp3_playback.h"
34#include "usb.h" 33#include "usb.h"
35#include "settings.h" 34#include "settings.h"
36#include "status.h" 35#include "status.h"
@@ -380,10 +379,8 @@ static const int id3_headers[]=
380 LANG_ID3_PLAYLIST, 379 LANG_ID3_PLAYLIST,
381 LANG_ID3_BITRATE, 380 LANG_ID3_BITRATE,
382 LANG_ID3_FREQUENCY, 381 LANG_ID3_FREQUENCY,
383#if CONFIG_CODEC == SWCODEC
384 LANG_ID3_TRACK_GAIN, 382 LANG_ID3_TRACK_GAIN,
385 LANG_ID3_ALBUM_GAIN, 383 LANG_ID3_ALBUM_GAIN,
386#endif
387 LANG_FILESIZE, 384 LANG_FILESIZE,
388 LANG_ID3_PATH, 385 LANG_ID3_PATH,
389}; 386};
@@ -423,7 +420,6 @@ static void say_number_and_spell(char *buf, bool year_style)
423 } 420 }
424} 421}
425 422
426#if CONFIG_CODEC == SWCODEC
427/* Say a replaygain ID3 value from its text form */ 423/* Say a replaygain ID3 value from its text form */
428static void say_gain(char *buf) 424static void say_gain(char *buf)
429{ 425{
@@ -479,7 +475,6 @@ static void say_gain(char *buf)
479 }else /* we didn't find a number, just spell everything */ 475 }else /* we didn't find a number, just spell everything */
480 talk_spell(buf, true); 476 talk_spell(buf, true);
481} 477}
482#endif
483 478
484static const char * id3_get_or_speak_info(int selected_item, void* data, 479static const char * id3_get_or_speak_info(int selected_item, void* data,
485 char *buffer, size_t buffer_len, 480 char *buffer, size_t buffer_len,
@@ -619,7 +614,6 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
619 if(say_it) 614 if(say_it)
620 talk_value(id3->frequency, UNIT_HERTZ, true); 615 talk_value(id3->frequency, UNIT_HERTZ, true);
621 break; 616 break;
622#if CONFIG_CODEC == SWCODEC
623 case LANG_ID3_TRACK_GAIN: 617 case LANG_ID3_TRACK_GAIN:
624 replaygain_itoa(buffer, buffer_len, id3->track_level); 618 replaygain_itoa(buffer, buffer_len, id3->track_level);
625 val=(id3->track_level) ? buffer : NULL; /* only show level!=0 */ 619 val=(id3->track_level) ? buffer : NULL; /* only show level!=0 */
@@ -632,12 +626,11 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
632 if(say_it && val) 626 if(say_it && val)
633 say_gain(val); 627 say_gain(val);
634 break; 628 break;
635#endif
636 case LANG_ID3_PATH: 629 case LANG_ID3_PATH:
637 val=id3->path; 630 val=id3->path;
638 if(say_it && val) 631 if(say_it && val)
639 talk_fullpath(val, true); 632 talk_fullpath(val, true);
640 break; 633 break;
641 case LANG_ID3_COMPOSER: 634 case LANG_ID3_COMPOSER:
642 val=id3->composer; 635 val=id3->composer;
643 if(say_it && val) 636 if(say_it && val)
diff --git a/apps/scrobbler.c b/apps/scrobbler.c
index 2793e70725..3622137a20 100644
--- a/apps/scrobbler.c
+++ b/apps/scrobbler.c
@@ -226,9 +226,7 @@ static void scrobbler_finish_event(unsigned short id, void *data)
226 226
227 /* add entry using the currently ending track */ 227 /* add entry using the currently ending track */
228 if (pending && (te->flags & TEF_CURRENT) 228 if (pending && (te->flags & TEF_CURRENT)
229#if CONFIG_CODEC == SWCODEC
230 && !(te->flags & TEF_REWIND) 229 && !(te->flags & TEF_REWIND)
231#endif
232 ) 230 )
233 { 231 {
234 pending = false; 232 pending = false;
diff --git a/apps/settings.c b/apps/settings.c
index 185e2c3576..17e200812e 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -77,14 +77,12 @@
77struct user_settings global_settings; 77struct user_settings global_settings;
78struct system_status global_status; 78struct system_status global_status;
79 79
80#if CONFIG_CODEC == SWCODEC
81#include "dsp_proc_settings.h" 80#include "dsp_proc_settings.h"
82#include "playback.h" 81#include "playback.h"
83#ifdef HAVE_RECORDING 82#ifdef HAVE_RECORDING
84#include "enc_config.h" 83#include "enc_config.h"
85#endif 84#endif
86#include "pcm_sampr.h" 85#include "pcm_sampr.h"
87#endif /* CONFIG_CODEC == SWCODEC */
88 86
89#define NVRAM_DATA_START 8 87#define NVRAM_DATA_START 8
90#ifdef HAVE_RTC_RAM 88#ifdef HAVE_RTC_RAM
@@ -589,12 +587,10 @@ static bool settings_write_config(const char* filename, int options)
589 continue; 587 continue;
590 break; 588 break;
591#endif 589#endif
592#if CONFIG_CODEC == SWCODEC
593 case SETTINGS_SAVE_EQPRESET: 590 case SETTINGS_SAVE_EQPRESET:
594 if ((settings[i].flags&F_EQSETTING) == 0) 591 if ((settings[i].flags&F_EQSETTING) == 0)
595 continue; 592 continue;
596 break; 593 break;
597#endif
598 } 594 }
599 595
600 cfg_to_string(i, value, MAX_PATH); 596 cfg_to_string(i, value, MAX_PATH);
@@ -675,12 +671,10 @@ bool settings_save_config(int options)
675 namebase = "recording"; 671 namebase = "recording";
676 break; 672 break;
677#endif 673#endif
678#if CONFIG_CODEC == SWCODEC
679 case SETTINGS_SAVE_EQPRESET: 674 case SETTINGS_SAVE_EQPRESET:
680 folder = EQS_DIR; 675 folder = EQS_DIR;
681 namebase = "eq"; 676 namebase = "eq";
682 break; 677 break;
683#endif
684 case SETTINGS_SAVE_SOUND: 678 case SETTINGS_SAVE_SOUND:
685 folder = ROCKBOX_DIR; 679 folder = ROCKBOX_DIR;
686 namebase = "sound"; 680 namebase = "sound";
@@ -982,7 +976,6 @@ void settings_apply(bool read_disk)
982 lcd_scroll_delay(global_settings.scroll_delay); 976 lcd_scroll_delay(global_settings.scroll_delay);
983 977
984 978
985#if CONFIG_CODEC == SWCODEC
986#ifdef HAVE_PLAY_FREQ 979#ifdef HAVE_PLAY_FREQ
987 /* before crossfade */ 980 /* before crossfade */
988 audio_set_playback_frequency(global_settings.play_frequency); 981 audio_set_playback_frequency(global_settings.play_frequency);
@@ -1016,7 +1009,6 @@ void settings_apply(bool read_disk)
1016 dsp_timestretch_enable(global_settings.timestretch_enabled); 1009 dsp_timestretch_enable(global_settings.timestretch_enabled);
1017#endif 1010#endif
1018 dsp_set_compressor(&global_settings.compressor_settings); 1011 dsp_set_compressor(&global_settings.compressor_settings);
1019#endif
1020 1012
1021#ifdef HAVE_SPDIF_POWER 1013#ifdef HAVE_SPDIF_POWER
1022 spdif_power_enable(global_settings.spdif_enable); 1014 spdif_power_enable(global_settings.spdif_enable);
@@ -1068,7 +1060,7 @@ void settings_apply(bool read_disk)
1068#endif 1060#endif
1069 1061
1070 /* This should stay last */ 1062 /* This should stay last */
1071#if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC 1063#if defined(HAVE_RECORDING)
1072 enc_global_settings_apply(); 1064 enc_global_settings_apply();
1073#endif 1065#endif
1074#ifdef HAVE_LCD_BITMAP 1066#ifdef HAVE_LCD_BITMAP
@@ -1114,7 +1106,7 @@ void settings_reset(void)
1114{ 1106{
1115 for(int i=0; i<nb_settings; i++) 1107 for(int i=0; i<nb_settings; i++)
1116 reset_setting(&settings[i], settings[i].setting); 1108 reset_setting(&settings[i], settings[i].setting);
1117#if defined (HAVE_RECORDING) && CONFIG_CODEC == SWCODEC 1109#if defined (HAVE_RECORDING)
1118 enc_global_settings_reset(); 1110 enc_global_settings_reset();
1119#endif 1111#endif
1120#ifdef HAVE_LCD_BITMAP 1112#ifdef HAVE_LCD_BITMAP
diff --git a/apps/settings.h b/apps/settings.h
index 4661966ad2..3d3939695c 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -30,10 +30,8 @@
30#include "statusbar.h" /* for the statusbar values */ 30#include "statusbar.h" /* for the statusbar values */
31#include "quickscreen.h" 31#include "quickscreen.h"
32#include "button.h" 32#include "button.h"
33#if CONFIG_CODEC == SWCODEC
34#include "audio.h" 33#include "audio.h"
35#include "dsp_proc_settings.h" 34#include "dsp_proc_settings.h"
36#endif
37#include "rbpaths.h" 35#include "rbpaths.h"
38 36
39struct opt_items { 37struct opt_items {
@@ -218,9 +216,7 @@ enum {
218#ifdef HAVE_RECORDING 216#ifdef HAVE_RECORDING
219 SETTINGS_SAVE_RECPRESETS, 217 SETTINGS_SAVE_RECPRESETS,
220#endif 218#endif
221#if CONFIG_CODEC == SWCODEC
222 SETTINGS_SAVE_EQPRESET, 219 SETTINGS_SAVE_EQPRESET,
223#endif
224}; 220};
225bool settings_save_config(int options); 221bool settings_save_config(int options);
226 222
@@ -307,17 +303,6 @@ struct user_settings
307 int channel_config; /* Stereo, Mono, Custom, Mono left, Mono right, Karaoke */ 303 int channel_config; /* Stereo, Mono, Custom, Mono left, Mono right, Karaoke */
308 int stereo_width; /* 0-255% */ 304 int stereo_width; /* 0-255% */
309 305
310#if CONFIG_CODEC != SWCODEC
311 int loudness; /* loudness eq: 0-100 0=off 100=max */
312 int avc; /* auto volume correct: 0=off, 1=20ms, 2=2s 3=4s 4=8s */
313 int mdb_strength; /* 0-127dB */
314 int mdb_harmonics; /* 0-100% */
315 int mdb_center; /* 20-300Hz */
316 int mdb_shape; /* 50-300Hz */
317 bool mdb_enable; /* true/false */
318 bool superbass; /* true/false */
319#endif
320
321#ifdef AUDIOHW_HAVE_BASS_CUTOFF 306#ifdef AUDIOHW_HAVE_BASS_CUTOFF
322 int bass_cutoff; 307 int bass_cutoff;
323#endif 308#endif
@@ -325,7 +310,6 @@ struct user_settings
325 int treble_cutoff; 310 int treble_cutoff;
326#endif 311#endif
327 312
328#if CONFIG_CODEC == SWCODEC
329#ifdef HAVE_CROSSFADE 313#ifdef HAVE_CROSSFADE
330 /* Crossfade */ 314 /* Crossfade */
331 int crossfade; /* Enable crossfade (0=off, 1=shuffle, 2=trackskip, 315 int crossfade; /* Enable crossfade (0=off, 1=shuffle, 2=trackskip,
@@ -360,10 +344,8 @@ struct user_settings
360#ifdef HAVE_PITCHCONTROL 344#ifdef HAVE_PITCHCONTROL
361 bool timestretch_enabled; 345 bool timestretch_enabled;
362#endif 346#endif
363#endif /* CONFIG_CODEC == SWCODEC */
364 347
365#ifdef HAVE_RECORDING 348#ifdef HAVE_RECORDING
366#if CONFIG_CODEC == SWCODEC
367 int rec_format; /* record format index */ 349 int rec_format; /* record format index */
368 int rec_mono_mode; /* how to create mono: L, R, L+R */ 350 int rec_mono_mode; /* how to create mono: L, R, L+R */
369 351
@@ -377,9 +359,6 @@ struct user_settings
377#endif 359#endif
378 /* Encoder Settings End */ 360 /* Encoder Settings End */
379 361
380#else
381 int rec_quality; /* 0-7 */
382#endif /* CONFIG_CODEC == SWCODEC */
383 int rec_source; /* 0=mic, 1=line, 2=S/PDIF, 2 or 3=FM Radio */ 362 int rec_source; /* 0=mic, 1=line, 2=S/PDIF, 2 or 3=FM Radio */
384 int rec_frequency; /* 0 = 44.1kHz (depends on target) 363 int rec_frequency; /* 0 = 44.1kHz (depends on target)
385 1 = 48kHz 364 1 = 48kHz
@@ -754,10 +733,8 @@ struct user_settings
754#ifdef HAVE_PITCHCONTROL 733#ifdef HAVE_PITCHCONTROL
755 /* pitch screen settings */ 734 /* pitch screen settings */
756 bool pitch_mode_semitone; 735 bool pitch_mode_semitone;
757#if CONFIG_CODEC == SWCODEC
758 bool pitch_mode_timestretch; 736 bool pitch_mode_timestretch;
759#endif 737#endif
760#endif
761 /* If values are just added to the end, no need to bump plugin API 738 /* If values are just added to the end, no need to bump plugin API
762 version. */ 739 version. */
763 /* new stuff to be added at the end */ 740 /* new stuff to be added at the end */
@@ -778,9 +755,7 @@ struct user_settings
778#endif 755#endif
779#endif 756#endif
780 757
781#if CONFIG_CODEC == SWCODEC
782 struct compressor_settings compressor_settings; 758 struct compressor_settings compressor_settings;
783#endif
784 759
785 int sleeptimer_duration; /* In minutes; 0=off */ 760 int sleeptimer_duration; /* In minutes; 0=off */
786 bool sleeptimer_on_startup; 761 bool sleeptimer_on_startup;
@@ -797,10 +772,8 @@ struct user_settings
797 int hotkey_tree; 772 int hotkey_tree;
798#endif 773#endif
799 774
800#if CONFIG_CODEC == SWCODEC
801 /* When resuming playback (after a stop), rewind this number of seconds */ 775 /* When resuming playback (after a stop), rewind this number of seconds */
802 int resume_rewind; 776 int resume_rewind;
803#endif
804 777
805#ifdef AUDIOHW_HAVE_DEPTH_3D 778#ifdef AUDIOHW_HAVE_DEPTH_3D
806 int depth_3d; 779 int depth_3d;
@@ -830,10 +803,8 @@ struct user_settings
830#endif /* AUDIOHW_HAVE_EQ */ 803#endif /* AUDIOHW_HAVE_EQ */
831 804
832#ifdef HAVE_HARDWARE_CLICK 805#ifdef HAVE_HARDWARE_CLICK
833#if CONFIG_CODEC == SWCODEC
834 bool keyclick_hardware; /* hardware piezo keyclick */ 806 bool keyclick_hardware; /* hardware piezo keyclick */
835#endif 807#endif
836#endif
837 808
838 char start_directory[MAX_PATHNAME+1]; 809 char start_directory[MAX_PATHNAME+1];
839 /* Has the root been customized from the .cfg file? false = no, true = loaded from cfg */ 810 /* Has the root been customized from the .cfg file? false = no, true = loaded from cfg */
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 348caec6e5..7f6f4fefc7 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -310,7 +310,6 @@ static const char graphic_numeric[] = "graphic,numeric";
310 310
311#ifdef HAVE_RECORDING 311#ifdef HAVE_RECORDING
312/* these should be in the config.h files */ 312/* these should be in the config.h files */
313#if CONFIG_CODEC == SWCODEC
314# ifdef HAVE_UDA1380 313# ifdef HAVE_UDA1380
315# define DEFAULT_REC_MIC_GAIN 16 314# define DEFAULT_REC_MIC_GAIN 16
316# define DEFAULT_REC_LEFT_GAIN 0 315# define DEFAULT_REC_LEFT_GAIN 0
@@ -332,7 +331,6 @@ static const char graphic_numeric[] = "graphic,numeric";
332# define DEFAULT_REC_LEFT_GAIN 0 331# define DEFAULT_REC_LEFT_GAIN 0
333# define DEFAULT_REC_RIGHT_GAIN 0 332# define DEFAULT_REC_RIGHT_GAIN 0
334# endif 333# endif
335#endif
336 334
337#endif /* HAVE_RECORDING */ 335#endif /* HAVE_RECORDING */
338 336
@@ -472,8 +470,6 @@ static const char* scanaccel_formatter(char *buffer, size_t buffer_size,
472} 470}
473#endif 471#endif
474 472
475#if CONFIG_CODEC == SWCODEC
476
477static const char* formatter_unit_0_is_off(char *buffer, size_t buffer_size, 473static const char* formatter_unit_0_is_off(char *buffer, size_t buffer_size,
478 int val, const char *unit) 474 int val, const char *unit)
479{ 475{
@@ -591,7 +587,6 @@ static void eq_set_default(void* setting, void* defaultval)
591{ 587{
592 memcpy(setting, defaultval, sizeof(struct eq_band_setting)); 588 memcpy(setting, defaultval, sizeof(struct eq_band_setting));
593} 589}
594#endif
595 590
596#ifdef HAVE_QUICKSCREEN 591#ifdef HAVE_QUICKSCREEN
597static int find_setting_by_name(char*name) 592static int find_setting_by_name(char*name)
@@ -1213,15 +1208,11 @@ const struct settings_list settings[] = {
1213 "seek acceleration", "very fast,fast,normal,slow,very slow", NULL, 5, 1208 "seek acceleration", "very fast,fast,normal,slow,very slow", NULL, 5,
1214 ID2P(LANG_VERY_FAST), ID2P(LANG_FAST), ID2P(LANG_NORMAL), 1209 ID2P(LANG_VERY_FAST), ID2P(LANG_FAST), ID2P(LANG_NORMAL),
1215 ID2P(LANG_SLOW) , ID2P(LANG_VERY_SLOW)), 1210 ID2P(LANG_SLOW) , ID2P(LANG_VERY_SLOW)),
1216#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_DISK_STORAGE) 1211#if defined(HAVE_DISK_STORAGE)
1217 TABLE_SETTING(F_TIME_SETTING | F_ALLOW_ARBITRARY_VALS, buffer_margin, 1212 TABLE_SETTING(F_TIME_SETTING | F_ALLOW_ARBITRARY_VALS, buffer_margin,
1218 LANG_MP3BUFFER_MARGIN, 5, "antiskip", NULL, UNIT_SEC, 1213 LANG_MP3BUFFER_MARGIN, 5, "antiskip", NULL, UNIT_SEC,
1219 NULL, NULL, 1214 NULL, NULL,
1220 NULL,8, 5,15,30,60,120,180,300,600), 1215 NULL,8, 5,15,30,60,120,180,300,600),
1221#elif defined(HAVE_DISK_STORAGE)
1222 INT_SETTING(F_TIME_SETTING, buffer_margin, LANG_MP3BUFFER_MARGIN, 0,
1223 "antiskip", UNIT_SEC, 0, 7, 1, formatter_time_unit_0_is_off,
1224 getlang_time_unit_0_is_off, audio_set_buffer_margin),
1225#endif 1216#endif
1226 /* disk */ 1217 /* disk */
1227#ifdef HAVE_DISK_STORAGE 1218#ifdef HAVE_DISK_STORAGE
@@ -1348,10 +1339,8 @@ const struct settings_list settings[] = {
1348 TALK_ID(1792, UNIT_MB)), 1339 TALK_ID(1792, UNIT_MB)),
1349 {F_T_INT|F_RECSETTING, &global_settings.rec_channels, LANG_CHANNELS, INT(0), 1340 {F_T_INT|F_RECSETTING, &global_settings.rec_channels, LANG_CHANNELS, INT(0),
1350 "rec channels","stereo,mono",UNUSED}, 1341 "rec channels","stereo,mono",UNUSED},
1351#if CONFIG_CODEC == SWCODEC
1352 {F_T_INT|F_RECSETTING, &global_settings.rec_mono_mode, 1342 {F_T_INT|F_RECSETTING, &global_settings.rec_mono_mode,
1353 LANG_RECORDING_MONO_MODE, INT(0), "rec mono mode","L+R,L,R",UNUSED}, 1343 LANG_RECORDING_MONO_MODE, INT(0), "rec mono mode","L+R,L,R",UNUSED},
1354#endif
1355 CHOICE_SETTING(F_RECSETTING, rec_split_type, LANG_SPLIT_TYPE, 0, 1344 CHOICE_SETTING(F_RECSETTING, rec_split_type, LANG_SPLIT_TYPE, 0,
1356 "rec split type", "Split,Stop,Shutdown", NULL, 3, 1345 "rec split type", "Split,Stop,Shutdown", NULL, 3,
1357 ID2P(LANG_START_NEW_FILE), ID2P(LANG_STOP_RECORDING),ID2P(LANG_STOP_RECORDING_AND_SHUTDOWN)), 1346 ID2P(LANG_START_NEW_FILE), ID2P(LANG_STOP_RECORDING),ID2P(LANG_STOP_RECORDING_AND_SHUTDOWN)),
@@ -1398,7 +1387,6 @@ const struct settings_list settings[] = {
1398 INT(DEFAULT_REC_RIGHT_GAIN), 1387 INT(DEFAULT_REC_RIGHT_GAIN),
1399 "rec right gain",NULL,UNUSED}, 1388 "rec right gain",NULL,UNUSED},
1400#endif /* DEFAULT_REC_RIGHT_GAIN */ 1389#endif /* DEFAULT_REC_RIGHT_GAIN */
1401#if CONFIG_CODEC == SWCODEC
1402 {F_T_INT|F_RECSETTING,&global_settings.rec_frequency, 1390 {F_T_INT|F_RECSETTING,&global_settings.rec_frequency,
1403 LANG_FREQUENCY,INT(REC_FREQ_DEFAULT), 1391 LANG_FREQUENCY,INT(REC_FREQ_DEFAULT),
1404 "rec frequency",REC_FREQ_CFG_VAL_LIST,UNUSED}, 1392 "rec frequency",REC_FREQ_CFG_VAL_LIST,UNUSED},
@@ -1417,7 +1405,6 @@ const struct settings_list settings[] = {
1417 /* wavpack_enc */ 1405 /* wavpack_enc */
1418 /* (no settings yet) */ 1406 /* (no settings yet) */
1419 /** Encoder settings end **/ 1407 /** Encoder settings end **/
1420#endif /* CONFIG_CODEC == SWCODEC */
1421 /* values for the trigger */ 1408 /* values for the trigger */
1422 INT_SETTING(F_RECSETTING, rec_start_thres_db, LANG_RECORD_START_THRESHOLD, -35, 1409 INT_SETTING(F_RECSETTING, rec_start_thres_db, LANG_RECORD_START_THRESHOLD, -35,
1423 "trigger start threshold dB", UNIT_DB, -89, 0, 1, NULL, NULL, NULL), 1410 "trigger start threshold dB", UNIT_DB, -89, 0, 1, NULL, NULL, NULL),
@@ -1465,7 +1452,6 @@ const struct settings_list settings[] = {
1465 LANG_SET_BOOL_YES, LANG_SET_BOOL_NO, NULL), 1452 LANG_SET_BOOL_YES, LANG_SET_BOOL_NO, NULL),
1466 1453
1467#ifdef HAVE_TAGCACHE 1454#ifdef HAVE_TAGCACHE
1468#if CONFIG_CODEC == SWCODEC
1469 BOOL_SETTING(0, autoresume_enable, LANG_AUTORESUME, false, 1455 BOOL_SETTING(0, autoresume_enable, LANG_AUTORESUME, false,
1470 "autoresume enable", off_on, 1456 "autoresume enable", off_on,
1471 LANG_SET_BOOL_YES, LANG_SET_BOOL_NO, NULL), 1457 LANG_SET_BOOL_YES, LANG_SET_BOOL_NO, NULL),
@@ -1478,7 +1464,6 @@ const struct settings_list settings[] = {
1478 ID2P(LANG_AUTORESUME_CUSTOM)), 1464 ID2P(LANG_AUTORESUME_CUSTOM)),
1479 TEXT_SETTING(0, autoresume_paths, "autoresume next track paths", 1465 TEXT_SETTING(0, autoresume_paths, "autoresume next track paths",
1480 "/podcast:/podcasts", NULL, NULL), 1466 "/podcast:/podcasts", NULL, NULL),
1481#endif
1482 1467
1483 OFFON_SETTING(0, runtimedb, LANG_RUNTIMEDB_ACTIVE, false, 1468 OFFON_SETTING(0, runtimedb, LANG_RUNTIMEDB_ACTIVE, false,
1484 "gather runtime data", NULL), 1469 "gather runtime data", NULL),
@@ -1486,7 +1471,6 @@ const struct settings_list settings[] = {
1486 DEFAULT_TAGCACHE_SCAN_PATHS, NULL, NULL), 1471 DEFAULT_TAGCACHE_SCAN_PATHS, NULL, NULL),
1487#endif 1472#endif
1488 1473
1489#if CONFIG_CODEC == SWCODEC
1490 /* replay gain */ 1474 /* replay gain */
1491 CHOICE_SETTING(F_SOUNDSETTING, replaygain_settings.type, 1475 CHOICE_SETTING(F_SOUNDSETTING, replaygain_settings.type,
1492 LANG_REPLAYGAIN_MODE, REPLAYGAIN_SHUFFLE, "replaygain type", 1476 LANG_REPLAYGAIN_MODE, REPLAYGAIN_SHUFFLE, "replaygain type",
@@ -1747,7 +1731,6 @@ const struct settings_list settings[] = {
1747 LANG_COMPRESSOR_RELEASE, 500, 1731 LANG_COMPRESSOR_RELEASE, 500,
1748 "compressor release time", UNIT_MS, 100, 1000, 1732 "compressor release time", UNIT_MS, 100, 1000,
1749 100, NULL, NULL, compressor_set), 1733 100, NULL, NULL, compressor_set),
1750#endif /* CONFIG_CODEC == SWCODEC */
1751 1734
1752#ifdef AUDIOHW_HAVE_BASS_CUTOFF 1735#ifdef AUDIOHW_HAVE_BASS_CUTOFF
1753 SOUND_SETTING(F_NO_WRAP, bass_cutoff, LANG_BASS_CUTOFF, 1736 SOUND_SETTING(F_NO_WRAP, bass_cutoff, LANG_BASS_CUTOFF,
@@ -2023,7 +2006,6 @@ const struct settings_list settings[] = {
2023 3, "list_accel_wait", UNIT_SEC, 1, 10, 1, 2006 3, "list_accel_wait", UNIT_SEC, 1, 10, 1,
2024 scanaccel_formatter, NULL, NULL), 2007 scanaccel_formatter, NULL, NULL),
2025#endif /* HAVE_WHEEL_ACCELERATION */ 2008#endif /* HAVE_WHEEL_ACCELERATION */
2026#if CONFIG_CODEC == SWCODEC
2027 /* keyclick */ 2009 /* keyclick */
2028#ifdef HAVE_HARDWARE_CLICK 2010#ifdef HAVE_HARDWARE_CLICK
2029 CHOICE_SETTING(0, keyclick, LANG_KEYCLICK_SOFTWARE, 0, 2011 CHOICE_SETTING(0, keyclick, LANG_KEYCLICK_SOFTWARE, 0,
@@ -2042,7 +2024,6 @@ const struct settings_list settings[] = {
2042 OFFON_SETTING(0, keyclick_repeats, LANG_KEYCLICK_REPEATS, false, 2024 OFFON_SETTING(0, keyclick_repeats, LANG_KEYCLICK_REPEATS, false,
2043 "keyclick repeats", NULL), 2025 "keyclick repeats", NULL),
2044#endif 2026#endif
2045#endif /* CONFIG_CODEC == SWCODEC */
2046 TEXT_SETTING(0, playlist_catalog_dir, "playlist catalog directory", 2027 TEXT_SETTING(0, playlist_catalog_dir, "playlist catalog directory",
2047 PLAYLIST_CATALOG_DEFAULT_DIR, NULL, NULL), 2028 PLAYLIST_CATALOG_DEFAULT_DIR, NULL, NULL),
2048 INT_SETTING(F_TIME_SETTING, sleeptimer_duration, LANG_SLEEP_TIMER_DURATION, 2029 INT_SETTING(F_TIME_SETTING, sleeptimer_duration, LANG_SLEEP_TIMER_DURATION,
@@ -2117,11 +2098,9 @@ const struct settings_list settings[] = {
2117#ifdef HAVE_PITCHCONTROL 2098#ifdef HAVE_PITCHCONTROL
2118 OFFON_SETTING(0, pitch_mode_semitone, LANG_SEMITONE, false, 2099 OFFON_SETTING(0, pitch_mode_semitone, LANG_SEMITONE, false,
2119 "Semitone pitch change", NULL), 2100 "Semitone pitch change", NULL),
2120#if CONFIG_CODEC == SWCODEC
2121 OFFON_SETTING(0, pitch_mode_timestretch, LANG_TIMESTRETCH, false, 2101 OFFON_SETTING(0, pitch_mode_timestretch, LANG_TIMESTRETCH, false,
2122 "Timestretch mode", NULL), 2102 "Timestretch mode", NULL),
2123#endif 2103#endif
2124#endif
2125 2104
2126#ifdef USB_ENABLE_HID 2105#ifdef USB_ENABLE_HID
2127 OFFON_SETTING(0, usb_hid, LANG_USB_HID, true, "usb hid", usb_set_hid), 2106 OFFON_SETTING(0, usb_hid, LANG_USB_HID, true, "usb hid", usb_set_hid),
@@ -2187,11 +2166,9 @@ const struct settings_list settings[] = {
2187 HOTKEY_OPEN_WITH, HOTKEY_DELETE, HOTKEY_INSERT, HOTKEY_INSERT_SHUFFLED), 2166 HOTKEY_OPEN_WITH, HOTKEY_DELETE, HOTKEY_INSERT, HOTKEY_INSERT_SHUFFLED),
2188#endif 2167#endif
2189 2168
2190#if CONFIG_CODEC == SWCODEC
2191 INT_SETTING(F_TIME_SETTING, resume_rewind, LANG_RESUME_REWIND, 0, 2169 INT_SETTING(F_TIME_SETTING, resume_rewind, LANG_RESUME_REWIND, 0,
2192 "resume rewind", UNIT_SEC, 0, 60, 5, 2170 "resume rewind", UNIT_SEC, 0, 60, 5,
2193 formatter_time_unit_0_is_off, getlang_time_unit_0_is_off, NULL), 2171 formatter_time_unit_0_is_off, getlang_time_unit_0_is_off, NULL),
2194#endif
2195 CUSTOM_SETTING(0, root_menu_customized, 2172 CUSTOM_SETTING(0, root_menu_customized,
2196 LANG_ROCKBOX_TITLE, /* lang string here is never actually used */ 2173 LANG_ROCKBOX_TITLE, /* lang string here is never actually used */
2197 NULL, "root menu order", 2174 NULL, "root menu order",
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 7265ce87b2..bff1550059 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -1779,7 +1779,6 @@ bool tagcache_fill_tags(struct mp3entry *id3, const char *filename)
1779 if (id3->bitrate == 0) 1779 if (id3->bitrate == 0)
1780 id3->bitrate = 1; 1780 id3->bitrate = 1;
1781 1781
1782#if CONFIG_CODEC == SWCODEC
1783 if (global_settings.autoresume_enable) 1782 if (global_settings.autoresume_enable)
1784 { 1783 {
1785 id3->elapsed = get_tag_numeric(entry, tag_lastelapsed, idx_id); 1784 id3->elapsed = get_tag_numeric(entry, tag_lastelapsed, idx_id);
@@ -1790,8 +1789,7 @@ bool tagcache_fill_tags(struct mp3entry *id3, const char *filename)
1790 logf("tagcache_fill_tags: Set offset for %s to %lX\n", 1789 logf("tagcache_fill_tags: Set offset for %s to %lX\n",
1791 id3->title, id3->offset); 1790 id3->title, id3->offset);
1792 } 1791 }
1793#endif 1792
1794
1795 return true; 1793 return true;
1796} 1794}
1797#endif /* defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) */ 1795#endif /* defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) */
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 0625e860ab..f006baa581 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -879,7 +879,6 @@ static void tagtree_buffer_event(unsigned short id, void *ev_data)
879 logf("-> %ld/%ld", id3->playcount, id3->playtime); 879 logf("-> %ld/%ld", id3->playcount, id3->playtime);
880 } 880 }
881 881
882 #if CONFIG_CODEC == SWCODEC
883 if (autoresume) 882 if (autoresume)
884 { 883 {
885 /* Load current file resume info if not already defined (by 884 /* Load current file resume info if not already defined (by
@@ -900,7 +899,6 @@ static void tagtree_buffer_event(unsigned short id, void *ev_data)
900 str_or_empty(id3->title), id3->offset); 899 str_or_empty(id3->title), id3->offset);
901 } 900 }
902 } 901 }
903 #endif
904 902
905 /* Store our tagcache index pointer. */ 903 /* Store our tagcache index pointer. */
906 id3->tagcache_idx = tcs.idx_id+1; 904 id3->tagcache_idx = tcs.idx_id+1;
@@ -922,25 +920,20 @@ static void tagtree_track_finish_event(unsigned short id, void *ev_data)
922 } 920 }
923 tagcache_idx--; 921 tagcache_idx--;
924 922
925#if CONFIG_CODEC == SWCODEC /* HWCODEC doesn't have automatic_skip */
926 bool auto_skip = te->flags & TEF_AUTO_SKIP; 923 bool auto_skip = te->flags & TEF_AUTO_SKIP;
927#endif
928 bool runtimedb = global_settings.runtimedb; 924 bool runtimedb = global_settings.runtimedb;
929 bool autoresume = global_settings.autoresume_enable; 925 bool autoresume = global_settings.autoresume_enable;
930 926
931 /* Don't process unplayed tracks, or tracks interrupted within the 927 /* Don't process unplayed tracks, or tracks interrupted within the
932 first 15 seconds but always process autoresume point */ 928 first 15 seconds but always process autoresume point */
933 if (runtimedb && (id3->elapsed == 0 929 if (runtimedb && (id3->elapsed == 0
934#if CONFIG_CODEC == SWCODEC
935 || (id3->elapsed < 15 * 1000 && !auto_skip) 930 || (id3->elapsed < 15 * 1000 && !auto_skip)
936#endif
937 )) 931 ))
938 { 932 {
939 logf("not db logging unplayed or skipped track"); 933 logf("not db logging unplayed or skipped track");
940 runtimedb = false; 934 runtimedb = false;
941 } 935 }
942 936
943#if CONFIG_CODEC == SWCODEC
944 /* 3s because that is the threshold the WPS uses to rewind instead 937 /* 3s because that is the threshold the WPS uses to rewind instead
945 of skip backwards */ 938 of skip backwards */
946 if (autoresume && (id3->elapsed == 0 939 if (autoresume && (id3->elapsed == 0
@@ -949,7 +942,6 @@ static void tagtree_track_finish_event(unsigned short id, void *ev_data)
949 logf("not logging autoresume"); 942 logf("not logging autoresume");
950 autoresume = false; 943 autoresume = false;
951 } 944 }
952#endif
953 945
954 /* Do not gather data unless proper setting has been enabled and at least 946 /* Do not gather data unless proper setting has been enabled and at least
955 one is still slated to be recorded */ 947 one is still slated to be recorded */
@@ -987,7 +979,6 @@ static void tagtree_track_finish_event(unsigned short id, void *ev_data)
987 tagcache_update_numeric(tagcache_idx, tag_lastplayed, lastplayed); 979 tagcache_update_numeric(tagcache_idx, tag_lastplayed, lastplayed);
988 } 980 }
989 981
990#if CONFIG_CODEC == SWCODEC
991 if (autoresume) 982 if (autoresume)
992 { 983 {
993 unsigned long elapsed = auto_skip ? 0 : id3->elapsed; 984 unsigned long elapsed = auto_skip ? 0 : id3->elapsed;
@@ -998,7 +989,6 @@ static void tagtree_track_finish_event(unsigned short id, void *ev_data)
998 logf("tagtree_track_finish_event: Save resume for %s: %lX %lX", 989 logf("tagtree_track_finish_event: Save resume for %s: %lX %lX",
999 str_or_empty(id3->title), elapsed, offset); 990 str_or_empty(id3->title), elapsed, offset);
1000 } 991 }
1001#endif
1002} 992}
1003 993
1004int tagtree_export(void) 994int tagtree_export(void)
diff --git a/apps/talk.c b/apps/talk.c
index 3aedaf34ec..4b65700a5d 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -32,11 +32,7 @@
32#include "settings.h" 32#include "settings.h"
33#include "settings_list.h" 33#include "settings_list.h"
34#include "splash.h" 34#include "splash.h"
35#if CONFIG_CODEC == SWCODEC
36#include "voice_thread.h" 35#include "voice_thread.h"
37#else
38#include "mp3_playback.h"
39#endif
40#include "audio.h" 36#include "audio.h"
41#include "lang.h" 37#include "lang.h"
42#include "talk.h" 38#include "talk.h"
@@ -107,7 +103,7 @@ struct voicefile_header /* file format of our voice file */
107 103
108/***************** Globals *****************/ 104/***************** Globals *****************/
109 105
110#if (CONFIG_CODEC == SWCODEC && MEMORYSIZE <= 2) 106#if MEMORYSIZE <= 2
111/* On low memory swcodec targets the entire voice file wouldn't fit in memory 107/* On low memory swcodec targets the entire voice file wouldn't fit in memory
112 * together with codecs, so we load clips each time they are accessed. */ 108 * together with codecs, so we load clips each time they are accessed. */
113#define TALK_PROGRESSIVE_LOAD 109#define TALK_PROGRESSIVE_LOAD
@@ -131,15 +127,10 @@ static bool force_enqueue_next; /* enqueue next utterance even if enqueue is fal
131static int queue_write; /* write index of queue, by application */ 127static int queue_write; /* write index of queue, by application */
132static int queue_read; /* read index of queue, by ISR context */ 128static int queue_read; /* read index of queue, by ISR context */
133static enum talk_status talk_status = TALK_STATUS_OK; 129static enum talk_status talk_status = TALK_STATUS_OK;
134#if CONFIG_CODEC == SWCODEC
135/* protects queue_read, queue_write and thumbnail_buf_used */ 130/* protects queue_read, queue_write and thumbnail_buf_used */
136static struct mutex queue_mutex SHAREDBSS_ATTR; 131static struct mutex queue_mutex SHAREDBSS_ATTR;
137#define talk_queue_lock() ({ mutex_lock(&queue_mutex); }) 132#define talk_queue_lock() ({ mutex_lock(&queue_mutex); })
138#define talk_queue_unlock() ({ mutex_unlock(&queue_mutex); }) 133#define talk_queue_unlock() ({ mutex_unlock(&queue_mutex); })
139#else
140#define talk_queue_lock() ({ })
141#define talk_queue_unlock() ({ })
142#endif /* CONFIG_CODEC */
143static int sent; /* how many bytes handed over to playback, owned by ISR */ 134static int sent; /* how many bytes handed over to playback, owned by ISR */
144static unsigned char curr_hd[3]; /* current frame header, for re-sync */ 135static unsigned char curr_hd[3]; /* current frame header, for re-sync */
145static unsigned char last_lang[MAX_FILENAME+1]; /* name of last used lang file (in talk_init) */ 136static unsigned char last_lang[MAX_FILENAME+1]; /* name of last used lang file (in talk_init) */
@@ -186,16 +177,8 @@ static int move_callback(int handle, void *current, void *new)
186 177
187static struct mutex read_buffer_mutex; 178static struct mutex read_buffer_mutex;
188 179
189 180static inline bool check_audio_status(void)
190/* on HWCODEC only voice xor audio can be active at a time */
191static bool check_audio_status(void)
192{ 181{
193#if CONFIG_CODEC != SWCODEC
194 if (audio_status()) /* busy, buffer in use */
195 return false;
196 /* ensure playback is given up on the buffer */
197 audio_hard_stop();
198#endif
199 return true; 182 return true;
200} 183}
201 184
@@ -670,20 +653,16 @@ static bool load_voicefile_data(int fd)
670 return true; 653 return true;
671} 654}
672 655
673/* Use a static buffer to avoid difficulties with buflib during DMA 656/* Use a static buffer to avoid difficulties with buflib during
674 * (hwcodec)/buffer passing to the voice_thread (swcodec). Clips 657 * buffer passing to the voice_thread (swcodec). Clips can be played
675 * can be played in chunks so the size is not that important */ 658 in chunks so the size is not that important */
676static unsigned char commit_buffer[2<<10]; 659static unsigned char commit_buffer[2<<10];
677 660
678static void* commit_transfer(struct queue_entry *qe, size_t *size) 661static void* commit_transfer(struct queue_entry *qe, size_t *size)
679{ 662{
680 void *buf = NULL; /* shut up gcc */ 663 void *buf = NULL; /* shut up gcc */
681 static unsigned char *bufpos = commit_buffer; 664 static unsigned char *bufpos = commit_buffer;
682#if CONFIG_CODEC != SWCODEC
683 sent = MIN(qe->remaining, 0xFFFF);
684#else
685 sent = qe->remaining; 665 sent = qe->remaining;
686#endif
687 sent = MIN((size_t)sent, sizeof(commit_buffer)); 666 sent = MIN((size_t)sent, sizeof(commit_buffer));
688 buf = buflib_get_data(&clip_ctx, qe->handle); 667 buf = buflib_get_data(&clip_ctx, qe->handle);
689 /* adjust buffer position to what has been played already */ 668 /* adjust buffer position to what has been played already */
@@ -706,13 +685,11 @@ static inline bool is_silence(struct queue_entry *qe)
706static void mp3_callback(const void** start, size_t* size) 685static void mp3_callback(const void** start, size_t* size)
707{ 686{
708 struct queue_entry *qe = &queue[queue_read]; 687 struct queue_entry *qe = &queue[queue_read];
709#if CONFIG_CODEC == SWCODEC
710 /* voice_thread.c hints us how many of the buffer we provided it actually 688 /* voice_thread.c hints us how many of the buffer we provided it actually
711 * consumed. Because buffers have to be frame-aligned for speex 689 * consumed. Because buffers have to be frame-aligned for speex
712 * it might be less than what we presented */ 690 * it might be less than what we presented */
713 if (*size) 691 if (*size)
714 sent = *size; 692 sent = *size;
715#endif
716 qe->remaining -= sent; /* we completed this */ 693 qe->remaining -= sent; /* we completed this */
717 694
718 if (qe->remaining > 0) /* current clip not finished? */ 695 if (qe->remaining > 0) /* current clip not finished? */
@@ -757,55 +734,7 @@ static void mp3_callback(const void** start, size_t* size)
757/* stop the playback and the pending clips */ 734/* stop the playback and the pending clips */
758void talk_force_shutup(void) 735void talk_force_shutup(void)
759{ 736{
760 /* Most of this is MAS only */ 737 /* Had nothing to do (was frame boundary or not our clip) */
761#if CONFIG_CODEC != SWCODEC
762#ifdef SIMULATOR
763 return;
764#endif
765 unsigned char* pos;
766 unsigned char* search;
767 unsigned char* end;
768 int len;
769 if (QUEUE_LEVEL == 0) /* has ended anyway */
770 return;
771
772 /* search next frame boundary and continue up to there */
773 pos = search = mp3_get_pos();
774 end = buflib_get_data(&clip_ctx, queue[queue_read].handle);
775 len = queue[queue_read].length;
776
777 if (pos >= end && pos <= (end+len)) /* really our clip? */
778 { /* (for strange reasons this isn't nesessarily the case) */
779 /* find the next frame boundary */
780 while (search < (end+len)) /* search the remaining data */
781 {
782 if (*search++ != 0xFF) /* quick search for frame sync byte */
783 continue; /* (this does the majority of the job) */
784
785 /* look at the (bitswapped) rest of header candidate */
786 if (search[0] == curr_hd[0] /* do the quicker checks first */
787 && search[2] == curr_hd[2]
788 && (search[1] & 0x30) == (curr_hd[1] & 0x30)) /* sample rate */
789 {
790 search--; /* back to the sync byte */
791 break; /* From looking at it, this is our header. */
792 }
793 }
794
795 if (search-pos)
796 { /* play old data until the frame end, to keep the MAS in sync */
797 sent = search-pos;
798
799 queue_write = (queue_read + 1) & QUEUE_MASK; /* will be empty after next callback */
800 queue[queue_read].length = sent; /* current one ends after this */
801
802 thumbnail_buf_used = 0;
803 return;
804 }
805 }
806#endif /* CONFIG_CODEC != SWCODEC */
807
808 /* Either SWCODEC, or MAS had nothing to do (was frame boundary or not our clip) */
809 mp3_play_stop(); 738 mp3_play_stop();
810 talk_queue_lock(); 739 talk_queue_lock();
811 queue_write = queue_read = 0; /* reset the queue */ 740 queue_write = queue_read = 0; /* reset the queue */
@@ -885,9 +814,7 @@ void talk_init(void)
885 814
886 if(!talk_initialized) 815 if(!talk_initialized)
887 { 816 {
888#if CONFIG_CODEC == SWCODEC
889 mutex_init(&queue_mutex); 817 mutex_init(&queue_mutex);
890#endif /* CONFIG_CODEC == SWCODEC */
891 mutex_init(&read_buffer_mutex); 818 mutex_init(&read_buffer_mutex);
892 } 819 }
893 820
@@ -957,11 +884,9 @@ void talk_init(void)
957 884
958 load_voicefile_data(filehandle); 885 load_voicefile_data(filehandle);
959 886
960#if CONFIG_CODEC == SWCODEC
961 /* Initialize the actual voice clip playback engine as well */ 887 /* Initialize the actual voice clip playback engine as well */
962 if (talk_voice_required()) 888 if (talk_voice_required())
963 voice_thread_init(); 889 voice_thread_init();
964#endif
965 890
966out: 891out:
967 close(filehandle); /* close again, this was just to detect presence */ 892 close(filehandle); /* close again, this was just to detect presence */
@@ -1062,9 +987,6 @@ static int _talk_file(const char* filename,
1062 int fd; 987 int fd;
1063 int size; 988 int size;
1064 int handle, oldest = -1; 989 int handle, oldest = -1;
1065#if CONFIG_CODEC != SWCODEC
1066 struct mp3entry info;
1067#endif
1068 990
1069 /* reload needed? */ 991 /* reload needed? */
1070 if (talk_temp_disable_count > 0) 992 if (talk_temp_disable_count > 0)
@@ -1080,13 +1002,6 @@ static int _talk_file(const char* filename,
1080 close(fd); 1002 close(fd);
1081 } 1003 }
1082 1004
1083#if CONFIG_CODEC != SWCODEC
1084 if(mp3info(&info, filename)) /* use this to find real start */
1085 {
1086 return 0; /* failed to open, or invalid */
1087 }
1088#endif
1089
1090 if (!enqueue) 1005 if (!enqueue)
1091 /* shutup now to free the thumbnail buffer */ 1006 /* shutup now to free the thumbnail buffer */
1092 talk_shutup(); 1007 talk_shutup();
@@ -1098,10 +1013,6 @@ static int _talk_file(const char* filename,
1098 } 1013 }
1099 size = filesize(fd); 1014 size = filesize(fd);
1100 1015
1101#if CONFIG_CODEC != SWCODEC
1102 size -= lseek(fd, info.first_frame_offset, SEEK_SET); /* behind ID data */
1103#endif
1104
1105 /* free clips from cache until this one succeeds to allocate */ 1016 /* free clips from cache until this one succeeds to allocate */
1106 while ((handle = buflib_alloc(&clip_ctx, size)) < 0) 1017 while ((handle = buflib_alloc(&clip_ctx, size)) < 0)
1107 oldest = free_oldest_clip(); 1018 oldest = free_oldest_clip();
@@ -1116,10 +1027,6 @@ static int _talk_file(const char* filename,
1116 struct queue_entry clip; 1027 struct queue_entry clip;
1117 clip.handle = handle; 1028 clip.handle = handle;
1118 clip.length = clip.remaining = size; 1029 clip.length = clip.remaining = size;
1119#if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
1120 /* bitswap doesnt yield() */
1121 bitswap(buflib_get_data(&clip_ctx, handle), size);
1122#endif
1123 if(prefix_ids) 1030 if(prefix_ids)
1124 /* prefix thumbnail by speaking these ids, but only now 1031 /* prefix thumbnail by speaking these ids, but only now
1125 that we know there's actually a thumbnail to be 1032 that we know there's actually a thumbnail to be
diff --git a/apps/tree.c b/apps/tree.c
index fb0d0a3ac5..e159c3465f 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -650,9 +650,7 @@ static int dirbrowse(void)
650 if (tc.dirlevel < 0) 650 if (tc.dirlevel < 0)
651 tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */ 651 tc.dirlevel = 0; /* shouldnt be needed.. this code needs work! */
652 652
653#if CONFIG_CODEC == SWCODEC
654 keyclick_set_callback(gui_synclist_keyclick_callback, &tree_lists); 653 keyclick_set_callback(gui_synclist_keyclick_callback, &tree_lists);
655#endif
656 button = get_action(CONTEXT_TREE, 654 button = get_action(CONTEXT_TREE,
657 list_do_action_timeout(&tree_lists, HZ/2)); 655 list_do_action_timeout(&tree_lists, HZ/2));
658#ifdef HAVE_LCD_BITMAP 656#ifdef HAVE_LCD_BITMAP
@@ -1175,11 +1173,6 @@ static void say_filetype(int attr)
1175 1173
1176static int ft_play_dirname(char* name) 1174static int ft_play_dirname(char* name)
1177{ 1175{
1178#if CONFIG_CODEC != SWCODEC
1179 if (audio_status() & AUDIO_STATUS_PLAY)
1180 return 0;
1181#endif
1182
1183 return talk_file(tc.currdir, name, dir_thumbnail_name, NULL, 1176 return talk_file(tc.currdir, name, dir_thumbnail_name, NULL,
1184 global_settings.talk_filetype ? 1177 global_settings.talk_filetype ?
1185 TALK_IDARRAY(VOICE_DIR) : NULL, 1178 TALK_IDARRAY(VOICE_DIR) : NULL,
@@ -1188,11 +1181,6 @@ static int ft_play_dirname(char* name)
1188 1181
1189static int ft_play_filename(char *dir, char *file, int attr) 1182static int ft_play_filename(char *dir, char *file, int attr)
1190{ 1183{
1191#if CONFIG_CODEC != SWCODEC
1192 if (audio_status() & AUDIO_STATUS_PLAY)
1193 return 0;
1194#endif
1195
1196 if (strlen(file) >= strlen(file_thumbnail_ext) 1184 if (strlen(file) >= strlen(file_thumbnail_ext)
1197 && strcasecmp(&file[strlen(file) - strlen(file_thumbnail_ext)], 1185 && strcasecmp(&file[strlen(file) - strlen(file_thumbnail_ext)],
1198 file_thumbnail_ext)) 1186 file_thumbnail_ext))