summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/appevents.h8
-rw-r--r--apps/buffering.c1
-rw-r--r--apps/gui/skin_engine/skin_display.c11
-rw-r--r--apps/gui/skin_engine/skin_tokens.c14
-rw-r--r--apps/playback.c1
-rw-r--r--apps/recorder/pcm_record.c3
-rw-r--r--apps/recorder/radio.c143
-rw-r--r--apps/recorder/radio.h4
8 files changed, 179 insertions, 6 deletions
diff --git a/apps/appevents.h b/apps/appevents.h
index 91c45c59b3..fd578b90a2 100644
--- a/apps/appevents.h
+++ b/apps/appevents.h
@@ -31,7 +31,8 @@
31 31
32/** Playback events **/ 32/** Playback events **/
33enum { 33enum {
34 PLAYBACK_EVENT_TRACK_BUFFER = (EVENT_CLASS_PLAYBACK|1), 34 PLAYBACK_EVENT_START_PLAYBACK = (EVENT_CLASS_PLAYBACK|1),
35 PLAYBACK_EVENT_TRACK_BUFFER,
35 PLAYBACK_EVENT_TRACK_FINISH, 36 PLAYBACK_EVENT_TRACK_FINISH,
36 PLAYBACK_EVENT_TRACK_CHANGE, 37 PLAYBACK_EVENT_TRACK_CHANGE,
37 PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, 38 PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE,
@@ -53,6 +54,11 @@ enum {
53 GUI_EVENT_THEME_CHANGED, 54 GUI_EVENT_THEME_CHANGED,
54}; 55};
55 56
57/** Recording events **/
58enum {
59 RECORDING_EVENT_START = (EVENT_CLASS_RECORDING|1),
60 RECORDING_EVENT_STOP,
61};
56#endif 62#endif
57 63
58 64
diff --git a/apps/buffering.c b/apps/buffering.c
index f194e2b82d..371cf22103 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -1007,7 +1007,6 @@ int bufopen(const char *file, size_t offset, enum data_type type,
1007 } 1007 }
1008 1008
1009 /* Other cases: there is a little more work. */ 1009 /* Other cases: there is a little more work. */
1010
1011 int fd = open(file, O_RDONLY); 1010 int fd = open(file, O_RDONLY);
1012 if (fd < 0) 1011 if (fd < 0)
1013 return ERR_FILE_ERROR; 1012 return ERR_FILE_ERROR;
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index f7bc14db20..5c2b11866a 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -443,8 +443,15 @@ static void wps_display_images(struct gui_wps *gwps, struct viewport* vp)
443 if (data->albumart && data->albumart->vp == vp 443 if (data->albumart && data->albumart->vp == vp
444 && data->albumart->draw) 444 && data->albumart->draw)
445 { 445 {
446 draw_album_art(gwps, playback_current_aa_hid(data->playback_aa_slot), 446 int handle = playback_current_aa_hid(data->playback_aa_slot);
447 false); 447#if CONFIG_TUNER
448 if (in_radio_screen())
449 {
450 struct dim dim = {data->albumart->width, data->albumart->height};
451 handle = radio_get_art_hid(&dim);
452 }
453#endif
454 draw_album_art(gwps, handle, false);
448 data->albumart->draw = false; 455 data->albumart->draw = false;
449 } 456 }
450#endif 457#endif
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index 3d944a5315..538f385e44 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -577,8 +577,18 @@ const char *get_token_value(struct gui_wps *gwps,
577 return buf; 577 return buf;
578#ifdef HAVE_ALBUMART 578#ifdef HAVE_ALBUMART
579 case WPS_TOKEN_ALBUMART_FOUND: 579 case WPS_TOKEN_ALBUMART_FOUND:
580 if (data->albumart) { 580 if (data->albumart)
581 if (playback_current_aa_hid(data->playback_aa_slot) >= 0) 581 {
582 int handle = -1;
583 handle = playback_current_aa_hid(data->playback_aa_slot);
584#if CONFIG_TUNER
585 if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF))
586 {
587 struct dim dim = {data->albumart->width, data->albumart->height};
588 handle = radio_get_art_hid(&dim);
589 }
590#endif
591 if (handle >= 0)
582 return "C"; 592 return "C";
583 } 593 }
584 return NULL; 594 return NULL;
diff --git a/apps/playback.c b/apps/playback.c
index 390dd19846..0be45b035a 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -1709,6 +1709,7 @@ static void audio_play_start(size_t offset)
1709{ 1709{
1710 int i; 1710 int i;
1711 1711
1712 send_event(PLAYBACK_EVENT_START_PLAYBACK, NULL);
1712#if INPUT_SRC_CAPS != 0 1713#if INPUT_SRC_CAPS != 0
1713 audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); 1714 audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
1714 audio_set_output_source(AUDIO_SRC_PLAYBACK); 1715 audio_set_output_source(AUDIO_SRC_PLAYBACK);
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 */
1127static void pcmrec_init(void) 1128static 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)
204static void recording_started_handler(void *data);
205static void recording_stopped_handler(void *data);
206#endif
202void radio_init(void) 207void 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
208int get_radio_status(void) 217int get_radio_status(void)
@@ -504,6 +513,131 @@ static struct gui_wps fms_skin[NB_SCREENS] = {{ .data = NULL }};
504static struct wps_data fms_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }}; 513static struct wps_data fms_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }};
505static struct wps_sync_data fms_skin_sync_data = { .do_full_update = false }; 514static struct wps_sync_data fms_skin_sync_data = { .do_full_update = false };
506 515
516#ifdef HAVE_ALBUMART
517#define MAX_RADIOART_IMAGES 10
518struct radioart {
519 int handle;
520 long last_tick;
521 struct dim dim;
522 char name[MAX_FMPRESET_LEN+1];
523};
524
525static struct radioart radioart[MAX_RADIOART_IMAGES];
526#ifdef HAVE_RECORDING
527static bool allow_buffer_access = true; /* If we are recording dont touch the buffers! */
528#endif
529static 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}
544static 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}
576int 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}
615static 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
628static void recording_started_handler(void *data)
629{
630 (void)data;
631 allow_buffer_access = false;
632 playback_restarting_handler(NULL);
633}
634static void recording_stopped_handler(void *data)
635{
636 (void)data;
637 allow_buffer_access = true;
638}
639#endif
640#endif
507 641
508void fms_data_load(enum screen_type screen, const char *buf, bool isfile) 642void 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
63int 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 */