diff options
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/pcm_record.c | 3 | ||||
-rw-r--r-- | apps/recorder/radio.c | 143 | ||||
-rw-r--r-- | apps/recorder/radio.h | 4 |
3 files changed, 150 insertions, 0 deletions
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c index e5a5107603..2567b56ef3 100644 --- a/apps/recorder/pcm_record.c +++ b/apps/recorder/pcm_record.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "audio.h" | 31 | #include "audio.h" |
32 | #include "sound.h" | 32 | #include "sound.h" |
33 | #include "metadata.h" | 33 | #include "metadata.h" |
34 | #include "appevents.h" | ||
34 | #ifdef HAVE_SPDIF_IN | 35 | #ifdef HAVE_SPDIF_IN |
35 | #include "spdif.h" | 36 | #include "spdif.h" |
36 | #endif | 37 | #endif |
@@ -1127,6 +1128,7 @@ static void pcmrec_new_stream(const char *filename, /* next file name */ | |||
1127 | static void pcmrec_init(void) | 1128 | static void pcmrec_init(void) |
1128 | { | 1129 | { |
1129 | unsigned char *buffer; | 1130 | unsigned char *buffer; |
1131 | send_event(RECORDING_EVENT_START, NULL); | ||
1130 | 1132 | ||
1131 | /* warings and errors */ | 1133 | /* warings and errors */ |
1132 | warnings = | 1134 | warnings = |
@@ -1183,6 +1185,7 @@ static void pcmrec_close(void) | |||
1183 | pcm_close_recording(); | 1185 | pcm_close_recording(); |
1184 | reset_hardware(); | 1186 | reset_hardware(); |
1185 | audio_remove_encoder(); | 1187 | audio_remove_encoder(); |
1188 | send_event(RECORDING_EVENT_STOP, NULL); | ||
1186 | } /* pcmrec_close */ | 1189 | } /* pcmrec_close */ |
1187 | 1190 | ||
1188 | /* PCMREC_OPTIONS */ | 1191 | /* PCMREC_OPTIONS */ |
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 026579516b..5425e8a2ab 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c | |||
@@ -69,6 +69,7 @@ | |||
69 | #include "viewport.h" | 69 | #include "viewport.h" |
70 | #include "skin_engine/skin_engine.h" | 70 | #include "skin_engine/skin_engine.h" |
71 | #include "statusbar-skinned.h" | 71 | #include "statusbar-skinned.h" |
72 | #include "buffering.h" | ||
72 | 73 | ||
73 | #if CONFIG_TUNER | 74 | #if CONFIG_TUNER |
74 | 75 | ||
@@ -199,10 +200,18 @@ static bool yesno_pop(const char* text) | |||
199 | return ret; | 200 | return ret; |
200 | } | 201 | } |
201 | 202 | ||
203 | #if defined(HAVE_RECORDING) && defined(HAVE_ALBUMART) | ||
204 | static void recording_started_handler(void *data); | ||
205 | static void recording_stopped_handler(void *data); | ||
206 | #endif | ||
202 | void radio_init(void) | 207 | void radio_init(void) |
203 | { | 208 | { |
204 | tuner_init(); | 209 | tuner_init(); |
205 | radio_off(); | 210 | radio_off(); |
211 | #if defined(HAVE_RECORDING) && defined(HAVE_ALBUMART) | ||
212 | add_event(RECORDING_EVENT_START, false, recording_started_handler); | ||
213 | add_event(RECORDING_EVENT_STOP, false, recording_stopped_handler); | ||
214 | #endif | ||
206 | } | 215 | } |
207 | 216 | ||
208 | int get_radio_status(void) | 217 | int get_radio_status(void) |
@@ -504,6 +513,131 @@ static struct gui_wps fms_skin[NB_SCREENS] = {{ .data = NULL }}; | |||
504 | static struct wps_data fms_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }}; | 513 | static struct wps_data fms_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }}; |
505 | static struct wps_sync_data fms_skin_sync_data = { .do_full_update = false }; | 514 | static struct wps_sync_data fms_skin_sync_data = { .do_full_update = false }; |
506 | 515 | ||
516 | #ifdef HAVE_ALBUMART | ||
517 | #define MAX_RADIOART_IMAGES 10 | ||
518 | struct radioart { | ||
519 | int handle; | ||
520 | long last_tick; | ||
521 | struct dim dim; | ||
522 | char name[MAX_FMPRESET_LEN+1]; | ||
523 | }; | ||
524 | |||
525 | static struct radioart radioart[MAX_RADIOART_IMAGES]; | ||
526 | #ifdef HAVE_RECORDING | ||
527 | static bool allow_buffer_access = true; /* If we are recording dont touch the buffers! */ | ||
528 | #endif | ||
529 | static int find_oldest_image(void) | ||
530 | { | ||
531 | int i; | ||
532 | long oldest_tick = radioart[0].last_tick; | ||
533 | int oldest_idx = 0; | ||
534 | for(i=1;i<MAX_RADIOART_IMAGES;i++) | ||
535 | { | ||
536 | if (radioart[i].last_tick < oldest_tick) | ||
537 | { | ||
538 | oldest_tick = radioart[i].last_tick; | ||
539 | oldest_idx = i; | ||
540 | } | ||
541 | } | ||
542 | return oldest_idx; | ||
543 | } | ||
544 | static int load_radioart_image(struct radioart *ra, char* preset_name, struct dim *dim) | ||
545 | { | ||
546 | char path[MAX_PATH]; | ||
547 | #ifndef HAVE_NOISY_IDLE_MODE | ||
548 | cpu_idle_mode(false); | ||
549 | #endif | ||
550 | snprintf(path, sizeof(path), FMPRESET_PATH "/%s.bmp",preset_name); | ||
551 | if (!file_exists(path)) | ||
552 | snprintf(path, sizeof(path), FMPRESET_PATH "/%s.jpg",preset_name); | ||
553 | if (!file_exists(path)) | ||
554 | { | ||
555 | #ifndef HAVE_NOISY_IDLE_MODE | ||
556 | cpu_idle_mode(true); | ||
557 | #endif | ||
558 | return -1; | ||
559 | } | ||
560 | strlcpy(ra->name, preset_name, MAX_FMPRESET_LEN+1); | ||
561 | ra->dim.height = dim->height; | ||
562 | ra->dim.width = dim->width; | ||
563 | ra->last_tick = current_tick; | ||
564 | ra->handle = bufopen(path, 0, TYPE_BITMAP, &ra->dim); | ||
565 | if (ra->handle == ERR_BUFFER_FULL) | ||
566 | { | ||
567 | int i = find_oldest_image(); | ||
568 | bufclose(i); | ||
569 | ra->handle = bufopen(path, 0, TYPE_BITMAP, &ra->dim); | ||
570 | } | ||
571 | #ifndef HAVE_NOISY_IDLE_MODE | ||
572 | cpu_idle_mode(true); | ||
573 | #endif | ||
574 | return ra->handle; | ||
575 | } | ||
576 | int radio_get_art_hid(struct dim *requested_dim) | ||
577 | { | ||
578 | int preset = radio_current_preset(); | ||
579 | int i, free_idx = -1; | ||
580 | if ((radio_mode != RADIO_PRESET_MODE) || preset < 0) | ||
581 | return -1; | ||
582 | #ifdef HAVE_RECORDING | ||
583 | if (!allow_buffer_access) | ||
584 | return -1; | ||
585 | #endif | ||
586 | for(i=0;i<MAX_RADIOART_IMAGES;i++) | ||
587 | { | ||
588 | if (radioart[i].handle < 0) | ||
589 | { | ||
590 | free_idx = i; | ||
591 | } | ||
592 | else if (!strcmp(radioart[i].name, presets[preset].name) && | ||
593 | radioart[i].dim.width == requested_dim->width && | ||
594 | radioart[i].dim.height == requested_dim->height) | ||
595 | { | ||
596 | radioart[i].last_tick = current_tick; | ||
597 | return radioart[i].handle; | ||
598 | } | ||
599 | } | ||
600 | if (free_idx >= 0) | ||
601 | { | ||
602 | return load_radioart_image(&radioart[free_idx], | ||
603 | presets[preset].name, requested_dim); | ||
604 | } | ||
605 | else | ||
606 | { | ||
607 | int i = find_oldest_image(); | ||
608 | bufclose(radioart[i].handle); | ||
609 | return load_radioart_image(&radioart[i], | ||
610 | presets[preset].name, requested_dim); | ||
611 | } | ||
612 | |||
613 | return -1; | ||
614 | } | ||
615 | static void playback_restarting_handler(void *data) | ||
616 | { | ||
617 | (void)data; | ||
618 | int i; | ||
619 | for(i=0;i<MAX_RADIOART_IMAGES;i++) | ||
620 | { | ||
621 | if (radioart[i].handle >= 0) | ||
622 | bufclose(radioart[i].handle); | ||
623 | radioart[i].handle = -1; | ||
624 | radioart[i].name[0] = '\0'; | ||
625 | } | ||
626 | } | ||
627 | #ifdef HAVE_RECORDING | ||
628 | static void recording_started_handler(void *data) | ||
629 | { | ||
630 | (void)data; | ||
631 | allow_buffer_access = false; | ||
632 | playback_restarting_handler(NULL); | ||
633 | } | ||
634 | static void recording_stopped_handler(void *data) | ||
635 | { | ||
636 | (void)data; | ||
637 | allow_buffer_access = true; | ||
638 | } | ||
639 | #endif | ||
640 | #endif | ||
507 | 641 | ||
508 | void fms_data_load(enum screen_type screen, const char *buf, bool isfile) | 642 | void fms_data_load(enum screen_type screen, const char *buf, bool isfile) |
509 | { | 643 | { |
@@ -613,9 +747,18 @@ int radio_screen(void) | |||
613 | { | 747 | { |
614 | radio_load_presets(global_settings.fmr_file); | 748 | radio_load_presets(global_settings.fmr_file); |
615 | } | 749 | } |
750 | #ifdef HAVE_ALBUMART | ||
751 | for(i=0;i<MAX_RADIOART_IMAGES;i++) | ||
752 | { | ||
753 | radioart[i].handle = -1; | ||
754 | radioart[i].name[0] = '\0'; | ||
755 | } | ||
756 | add_event(PLAYBACK_EVENT_START_PLAYBACK, true, playback_restarting_handler); | ||
757 | #endif | ||
616 | 758 | ||
617 | if(radio_status == FMRADIO_OFF) | 759 | if(radio_status == FMRADIO_OFF) |
618 | audio_stop(); | 760 | audio_stop(); |
761 | |||
619 | #ifndef SIMULATOR | 762 | #ifndef SIMULATOR |
620 | 763 | ||
621 | #if CONFIG_CODEC != SWCODEC | 764 | #if CONFIG_CODEC != SWCODEC |
diff --git a/apps/recorder/radio.h b/apps/recorder/radio.h index 415de6f652..d0a60530ba 100644 --- a/apps/recorder/radio.h +++ b/apps/recorder/radio.h | |||
@@ -59,6 +59,10 @@ struct fmstation | |||
59 | char name[MAX_FMPRESET_LEN+1]; | 59 | char name[MAX_FMPRESET_LEN+1]; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | #ifdef HAVE_ALBUMART | ||
63 | int radio_get_art_hid(struct dim *requested_dim); | ||
64 | #endif | ||
65 | |||
62 | #endif /* CONFIG_TUNER */ | 66 | #endif /* CONFIG_TUNER */ |
63 | 67 | ||
64 | #endif /* RADIO_H */ | 68 | #endif /* RADIO_H */ |