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

Configure Feed

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

Recording in FM screen, USB mode possible in FM and recording screen


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4046 a1c6a512-1295-4272-9138-f99709370657

+264 -90
+10
apps/lang/english.lang
··· 1817 1817 desc: in radio screen 1818 1818 eng: "The preset list is full" 1819 1819 new: 1820 + 1821 + id: LANG_FM_RADIO 1822 + desc: in main menu 1823 + eng: "FM Radio" 1824 + new: 1825 + 1826 + id: LANG_FM_BUTTONBAR_RECORD 1827 + desc: in main menu 1828 + eng: "Record" 1829 + new:
+7 -2
apps/main_menu.c
··· 252 252 return rockbox_browse(PLUGIN_DIR, SHOW_PLUGINS); 253 253 } 254 254 255 + static bool recording_settings(void) 256 + { 257 + return recording_menu(false); 258 + } 259 + 255 260 bool main_menu(void) 256 261 { 257 262 int m; ··· 262 267 { str(LANG_SOUND_SETTINGS), sound_menu }, 263 268 { str(LANG_GENERAL_SETTINGS), settings_menu }, 264 269 #ifdef HAVE_FMRADIO 265 - { "FM Radio", radio_screen }, 270 + { str(LANG_FM_RADIO), radio_screen }, 266 271 #endif 267 272 #ifdef HAVE_MAS3587F 268 273 { str(LANG_RECORDING), recording_screen }, 269 - { str(LANG_RECORDING_SETTINGS), recording_menu }, 274 + { str(LANG_RECORDING_SETTINGS), recording_settings}, 270 275 #endif 271 276 { str(LANG_PLAYLIST_MENU), playlist_menu }, 272 277 { str(LANG_MENU_SHOW_ID3_INFO), browse_id3 },
+138 -22
apps/recorder/radio.c
··· 43 43 #include "peakmeter.h" 44 44 #include "lang.h" 45 45 #include "font.h" 46 + #include "sound_menu.h" 47 + #include "recording.h" 46 48 47 49 #ifdef HAVE_FMRADIO 48 50 ··· 116 118 bool update_screen = true; 117 119 int timeout = current_tick + HZ/10; 118 120 bool screen_freeze = false; 121 + bool have_recorded = false; 122 + unsigned int seconds; 123 + unsigned int last_seconds = 0; 124 + int hours, minutes; 125 + bool keep_playing = false; 119 126 120 127 lcd_clear_display(); 121 128 lcd_setmargins(0, 8); ··· 133 140 134 141 mpeg_stop(); 135 142 136 - /* Enable the Left and right A/D Converter */ 137 - mas_codec_writereg(0x0, 0x2227); 143 + mpeg_init_recording(); 144 + 145 + mpeg_sound_set(SOUND_VOLUME, global_settings.volume); 146 + 147 + status_set_playmode(STATUS_STOP); 138 148 139 - mas_codec_writereg(6, 0x4000); 149 + /* Yes, we use the D/A for monitoring */ 150 + peak_meter_playback(true); 151 + 152 + peak_meter_enabled = true; 140 153 154 + mpeg_set_recording_options(global_settings.rec_frequency, 155 + global_settings.rec_quality, 156 + 1 /* Line In */, 157 + global_settings.rec_channels, 158 + global_settings.rec_editable); 159 + 160 + 161 + mpeg_set_recording_gain(mpeg_sound_default(SOUND_LEFT_GAIN), 162 + mpeg_sound_default(SOUND_RIGHT_GAIN), false); 163 + 141 164 fmradio_set(2, 0x140884); /* 5kHz, 7.2MHz crystal */ 142 165 radio_set_frequency(curr_freq); 143 166 curr_preset = find_preset(curr_freq); ··· 147 170 peak_meter_enabled = true; 148 171 149 172 buttonbar_set(str(LANG_BUTTONBAR_MENU), str(LANG_FM_BUTTONBAR_PRESETS), 150 - NULL); 173 + str(LANG_FM_BUTTONBAR_RECORD)); 151 174 152 175 while(!done) 153 176 { ··· 188 211 switch(button) 189 212 { 190 213 case BUTTON_OFF: 191 - radio_stop(); 214 + if(mpeg_status()) 215 + { 216 + mpeg_stop(); 217 + status_set_playmode(STATUS_STOP); 218 + } 219 + else 220 + { 221 + radio_stop(); 222 + done = true; 223 + } 224 + update_screen = true; 225 + break; 192 226 193 - /* Turn off the ADC gain */ 194 - mas_codec_writereg(6, 0x0000); 195 - 196 - done = true; 227 + case BUTTON_F3: 228 + /* Only act if the mpeg is stopped */ 229 + if(!mpeg_status()) 230 + { 231 + have_recorded = true; 232 + mpeg_record(rec_create_filename()); 233 + status_set_playmode(STATUS_RECORD); 234 + update_screen = true; 235 + } 236 + else 237 + { 238 + mpeg_new_file(rec_create_filename()); 239 + update_screen = true; 240 + } 241 + last_seconds = 0; 197 242 break; 198 - 243 + 199 244 case BUTTON_ON | BUTTON_REL: 200 245 done = true; 246 + keep_playing = true; 201 247 break; 202 248 203 249 case BUTTON_LEFT: ··· 257 303 lcd_setmargins(0, 8); 258 304 buttonbar_set(str(LANG_BUTTONBAR_MENU), 259 305 str(LANG_FM_BUTTONBAR_PRESETS), 260 - NULL); 306 + str(LANG_FM_BUTTONBAR_RECORD)); 261 307 update_screen = true; 262 308 break; 263 309 ··· 268 314 lcd_setmargins(0, 8); 269 315 buttonbar_set(str(LANG_BUTTONBAR_MENU), 270 316 str(LANG_FM_BUTTONBAR_PRESETS), 271 - NULL); 317 + str(LANG_FM_BUTTONBAR_RECORD)); 272 318 update_screen = true; 273 319 break; 274 320 275 - case BUTTON_F3: 321 + case BUTTON_PLAY: 276 322 if(!screen_freeze) 277 323 { 278 324 splash(0, 0, true, "Screen frozen"); ··· 287 333 break; 288 334 289 335 case SYS_USB_CONNECTED: 290 - usb_screen(); 291 - fmradio_set_status(0); 292 - return true; 336 + /* Only accept USB connection when not recording */ 337 + if(!mpeg_status()) 338 + { 339 + usb_screen(); 340 + fmradio_set_status(0); 341 + have_recorded = true; /* Refreshes the browser later on */ 342 + done = true; 343 + } 344 + break; 293 345 } 294 346 295 347 peak_meter_peek(); ··· 297 349 if(!screen_freeze) 298 350 { 299 351 lcd_setmargins(0, 8); 300 - lcd_clearrect(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh); 301 - peak_meter_draw(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh); 302 - lcd_update_rect(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh); 352 + if(!mpeg_status()) 353 + { 354 + lcd_clearrect(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh); 355 + peak_meter_draw(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh); 356 + lcd_update_rect(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh); 357 + } 303 358 304 359 if(TIME_AFTER(current_tick, timeout)) 305 360 { ··· 314 369 } 315 370 } 316 371 317 - if(update_screen) 372 + seconds = mpeg_recorded_time() / HZ; 373 + 374 + if(update_screen || seconds > last_seconds) 318 375 { 376 + last_seconds = seconds; 377 + 319 378 lcd_setfont(FONT_UI); 320 379 321 380 if(curr_preset >= 0) ··· 336 395 stereo?str(LANG_CHANNEL_STEREO): 337 396 str(LANG_CHANNEL_MONO)); 338 397 lcd_puts(0, top_of_screen + 2, buf); 398 + 399 + if(mpeg_status()) 400 + { 401 + hours = seconds / 3600; 402 + minutes = (seconds - (hours * 3600)) / 60; 403 + snprintf(buf, 32, "%s %02d:%02d:%02d", 404 + str(LANG_RECORDING_TIME), 405 + hours, minutes, seconds%60); 406 + lcd_puts(0, top_of_screen + 3, buf); 407 + } 339 408 340 409 /* Only force the redraw if update_screen is true */ 341 410 status_draw(update_screen); ··· 347 416 update_screen = false; 348 417 } 349 418 } 419 + 420 + if(mpeg_status() & MPEG_STATUS_ERROR) 421 + { 422 + done = true; 423 + } 350 424 } 351 425 426 + 427 + if(mpeg_status() & MPEG_STATUS_ERROR) 428 + { 429 + status_set_playmode(STATUS_STOP); 430 + splash(0, 0, true, str(LANG_DISK_FULL)); 431 + status_draw(true); 432 + lcd_update(); 433 + mpeg_error_clear(); 434 + 435 + while(1) 436 + { 437 + button = button_get(true); 438 + if(button == (BUTTON_OFF | BUTTON_REL)) 439 + break; 440 + } 441 + } 442 + 443 + mpeg_init_playback(); 444 + 445 + mpeg_sound_channel_config(global_settings.channel_config); 446 + mpeg_sound_set(SOUND_BASS, global_settings.bass); 447 + mpeg_sound_set(SOUND_TREBLE, global_settings.treble); 448 + mpeg_sound_set(SOUND_BALANCE, global_settings.balance); 449 + mpeg_sound_set(SOUND_VOLUME, global_settings.volume); 450 + mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness); 451 + mpeg_sound_set(SOUND_SUPERBASS, global_settings.bass_boost); 452 + mpeg_sound_set(SOUND_AVC, global_settings.avc); 453 + 352 454 fmradio_set_status(0); 353 - return false; 455 + 456 + if(keep_playing) 457 + { 458 + /* Enable the Left and right A/D Converter */ 459 + mpeg_set_recording_gain(mpeg_sound_default(SOUND_LEFT_GAIN), 460 + mpeg_sound_default(SOUND_RIGHT_GAIN), false); 461 + mas_codec_writereg(6, 0x4000); 462 + } 463 + return have_recorded; 354 464 } 355 465 356 466 static bool parseline(char* line, char** freq, char** name) ··· 556 666 return reload_dir; 557 667 } 558 668 669 + static bool fm_recording_settings(void) 670 + { 671 + return recording_menu(true); 672 + } 673 + 559 674 bool radio_menu(void) 560 675 { 561 676 struct menu_items radio_menu_items[] = { 562 677 { str(LANG_FM_SAVE_PRESET), radio_add_preset }, 563 - { str(LANG_FM_DELETE_PRESET), radio_delete_preset } 678 + { str(LANG_FM_DELETE_PRESET), radio_delete_preset }, 679 + { str(LANG_RECORDING_SETTINGS), fm_recording_settings } 564 680 }; 565 681 int m; 566 682 bool result;
+42 -53
apps/recorder/recording.c
··· 45 45 bool f2_rec_screen(void); 46 46 bool f3_rec_screen(void); 47 47 48 - extern int recording_peak_left; 49 - extern int recording_peak_right; 50 - 51 - extern int mp3buf_write; 52 - extern int mp3buf_read; 53 - extern bool recording; 54 - 55 - extern unsigned long record_start_frame; /* Frame number where 56 - recording started */ 57 - 58 48 #define SOURCE_MIC 0 59 49 #define SOURCE_LINE 1 60 50 #define SOURCE_SPDIF 2 ··· 89 79 "%d.%02d %s " /* 2 decimals */ 90 80 }; 91 81 92 - /* This array holds the record timer interval lengths, in seconds */ 93 - static unsigned long rec_timer_seconds[] = 94 - { 95 - 0, /* off */ 96 - 5*60, /* 00:05 */ 97 - 10*60, /* 00:10 */ 98 - 15*60, /* 00:15 */ 99 - 30*60, /* 00:30 */ 100 - 60*60, /* 01:00 */ 101 - 2*60*60, /* 02:00 */ 102 - 4*60*60, /* 04:00 */ 103 - 6*60*60, /* 06:00 */ 104 - 8*60*60, /* 08:00 */ 105 - 10*60*60, /* 10:00 */ 106 - 12*60*60, /* 12:00 */ 107 - 18*60*60, /* 18:00 */ 108 - 24*60*60 /* 24:00 */ 109 - }; 110 - 111 82 char *fmt_gain(int snd, int val, char *str, int len) 112 83 { 113 84 int tmp, i, d, numdec; ··· 169 140 int w, h; 170 141 int update_countdown = 1; 171 142 bool have_recorded = false; 172 - unsigned long seconds; 173 - unsigned long last_seconds = 0; 143 + unsigned int seconds; 144 + unsigned int last_seconds = 0; 174 145 int hours, minutes; 175 146 176 147 cursor = 0; ··· 225 196 mpeg_record(rec_create_filename()); 226 197 status_set_playmode(STATUS_RECORD); 227 198 update_countdown = 1; /* Update immediately */ 228 - last_seconds = 0; 229 199 } 230 200 else 231 201 { 232 202 mpeg_new_file(rec_create_filename()); 233 203 update_countdown = 1; /* Update immediately */ 234 204 } 205 + last_seconds = 0; 235 206 break; 236 207 237 208 case BUTTON_UP: ··· 331 302 break; 332 303 333 304 case BUTTON_F1: 334 - if (recording_menu()) 305 + if (recording_menu(false)) 335 306 return SYS_USB_CONNECTED; 336 307 settings_save(); 337 308 mpeg_set_recording_options(global_settings.rec_frequency, ··· 348 319 if(!mpeg_status()) 349 320 { 350 321 if (f2_rec_screen()) 351 - return SYS_USB_CONNECTED; 352 - update_countdown = 1; /* Update immediately */ 322 + { 323 + have_recorded = true; 324 + done = true; 325 + } 326 + else 327 + update_countdown = 1; /* Update immediately */ 353 328 } 354 329 break; 355 330 ··· 357 332 if(!mpeg_status()) 358 333 { 359 334 if (f3_rec_screen()) 360 - return SYS_USB_CONNECTED; 361 - update_countdown = 1; /* Update immediately */ 335 + { 336 + have_recorded = true; 337 + done = true; 338 + } 339 + else 340 + update_countdown = 1; /* Update immediately */ 362 341 } 363 342 break; 364 343 344 + case SYS_USB_CONNECTED: 345 + /* Only accept USB connection when not recording */ 346 + if(!mpeg_status()) 347 + { 348 + usb_screen(); 349 + have_recorded = true; /* Refreshes the browser later on */ 350 + done = true; 351 + } 352 + break; 365 353 } 366 354 367 355 peak_meter_peek(); ··· 377 365 update_countdown--; 378 366 if(update_countdown == 0 || seconds > last_seconds) 379 367 { 368 + unsigned int dseconds, dhours, dminutes; 380 369 int pos = 0; 381 370 382 371 update_countdown = 5; ··· 390 379 str(LANG_RECORDING_TIME), 391 380 hours, minutes, seconds%60); 392 381 lcd_puts(0, 0, buf); 393 - 394 - /* if the record timesplit is active */ 382 + 383 + dseconds = rec_timesplit_seconds(); 384 + 385 + /* Display the split interval if the record timesplit 386 + is active */ 395 387 if (global_settings.rec_timesplit) 396 388 { 397 - unsigned long dseconds, dhours, dminutes; 398 - int rti = global_settings.rec_timesplit; 399 - dseconds = rec_timer_seconds[rti]; 400 - 401 - if (mpeg_status() && (seconds >= dseconds)) 402 - { 403 - mpeg_new_file(rec_create_filename()); 404 - update_countdown = 1; 405 - last_seconds = 0; 406 - } 407 - 408 389 /* Display the record timesplit interval rather than 409 390 the file size if the record timer is active */ 410 391 dhours = dseconds / 3600; ··· 417 398 snprintf(buf, 32, "%s %s", str(LANG_RECORDING_SIZE), 418 399 num2max5(mpeg_num_recorded_bytes(), buf2)); 419 400 lcd_puts(0, 1, buf); 401 + 402 + /* We will do file splitting regardless, since the OFF 403 + setting really means 24 hours. This is to make sure 404 + that the recorded files don't get too big. */ 405 + if (mpeg_status() && (seconds >= dseconds)) 406 + { 407 + mpeg_new_file(rec_create_filename()); 408 + update_countdown = 1; 409 + last_seconds = 0; 410 + } 420 411 421 412 peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h); 422 413 ··· 518 509 mpeg_sound_set(SOUND_TREBLE, global_settings.treble); 519 510 mpeg_sound_set(SOUND_BALANCE, global_settings.balance); 520 511 mpeg_sound_set(SOUND_VOLUME, global_settings.volume); 521 - 522 - #ifdef HAVE_MAS3587F 523 512 mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness); 524 513 mpeg_sound_set(SOUND_SUPERBASS, global_settings.bass_boost); 525 514 mpeg_sound_set(SOUND_AVC, global_settings.avc); 526 - #endif 515 + 527 516 lcd_setfont(FONT_UI); 528 517 return have_recorded; 529 518 }
+26
apps/settings.c
··· 1988 1988 return false; 1989 1989 } 1990 1990 #endif 1991 + 1992 + #ifdef HAVE_MAS3587F 1993 + /* This array holds the record timer interval lengths, in seconds */ 1994 + static unsigned long rec_timer_seconds[] = 1995 + { 1996 + 24*60*60, /* OFF really means 24 hours, to avoid >2Gbyte files */ 1997 + 5*60, /* 00:05 */ 1998 + 10*60, /* 00:10 */ 1999 + 15*60, /* 00:15 */ 2000 + 30*60, /* 00:30 */ 2001 + 60*60, /* 01:00 */ 2002 + 2*60*60, /* 02:00 */ 2003 + 4*60*60, /* 04:00 */ 2004 + 6*60*60, /* 06:00 */ 2005 + 8*60*60, /* 08:00 */ 2006 + 10*60*60, /* 10:00 */ 2007 + 12*60*60, /* 12:00 */ 2008 + 18*60*60, /* 18:00 */ 2009 + 24*60*60 /* 24:00 */ 2010 + }; 2011 + 2012 + unsigned int rec_timesplit_seconds(void) 2013 + { 2014 + return rec_timer_seconds[global_settings.rec_timesplit]; 2015 + } 2016 + #endif
+4
apps/settings.h
··· 199 199 bool set_time(char* string, int timedate[]); 200 200 void set_file(char* filename, char* setting, int maxlen); 201 201 202 + #ifdef HAVE_MAS3587F 203 + unsigned int rec_timesplit_seconds(void); 204 + #endif 205 + 202 206 /* global settings */ 203 207 extern struct user_settings global_settings; 204 208 /* name of directory where configuration, fonts and other data
+20 -11
apps/sound_menu.c
··· 290 290 } 291 291 292 292 #ifdef HAVE_MAS3587F 293 - bool recording_menu(void) 293 + bool recording_menu(bool no_source) 294 294 { 295 295 int m; 296 + int i = 0; 297 + struct menu_items menu[6]; 296 298 bool result; 297 - struct menu_items items[] = { 298 - { str(LANG_RECORDING_QUALITY), recquality }, 299 - { str(LANG_RECORDING_FREQUENCY), recfrequency }, 300 - { str(LANG_RECORDING_SOURCE), recsource }, 301 - { str(LANG_RECORDING_CHANNELS), recchannels }, 302 - { str(LANG_RECORDING_EDITABLE), receditable }, 303 - { str(LANG_RECORD_TIMESPLIT), rectimesplit }, 304 - }; 305 - 306 - m=menu_init( items, sizeof items / sizeof(struct menu_items) ); 299 + 300 + menu[i].desc = str(LANG_RECORDING_QUALITY); 301 + menu[i++].function = recquality; 302 + menu[i].desc = str(LANG_RECORDING_FREQUENCY); 303 + menu[i++].function = recfrequency; 304 + if(!no_source) { 305 + menu[i].desc = str(LANG_RECORDING_SOURCE); 306 + menu[i++].function = recsource; 307 + } 308 + menu[i].desc = str(LANG_RECORDING_CHANNELS); 309 + menu[i++].function = recchannels; 310 + menu[i].desc = str(LANG_RECORDING_EDITABLE); 311 + menu[i++].function = receditable; 312 + menu[i].desc = str(LANG_RECORD_TIMESPLIT); 313 + menu[i++].function = rectimesplit; 314 + 315 + m=menu_init( menu, i ); 307 316 result = menu_run(m); 308 317 menu_exit(m); 309 318
+1 -1
apps/sound_menu.h
··· 22 22 #include "menu.h" 23 23 24 24 bool sound_menu(void); 25 - bool recording_menu(void); 25 + bool recording_menu(bool no_source); 26 26 27 27 #endif
+16 -1
firmware/mpeg.c
··· 167 167 0, /* AVC */ 168 168 0, /* Channels */ 169 169 8, /* Left gain */ 170 - 2, /* Right gain */ 170 + 8, /* Right gain */ 171 171 2, /* Mic gain */ 172 172 }; 173 173 ··· 2156 2156 case MPEG_INIT_PLAYBACK: 2157 2157 init_playback(); 2158 2158 init_playback_done = true; 2159 + break; 2160 + 2161 + case SYS_USB_CONNECTED: 2162 + is_playing = false; 2163 + paused = false; 2164 + stop_playing(); 2165 + #ifndef SIMULATOR 2166 + 2167 + /* Tell the USB thread that we are safe */ 2168 + DEBUGF("mpeg_thread got SYS_USB_CONNECTED\n"); 2169 + usb_acknowledge(SYS_USB_CONNECTED_ACK); 2170 + 2171 + /* Wait until the USB cable is extracted again */ 2172 + usb_wait_for_disconnect(&mpeg_queue); 2173 + #endif 2159 2174 break; 2160 2175 } 2161 2176 }