summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2010-05-24 16:42:32 +0000
committerMichael Sevakis <jethead71@rockbox.org>2010-05-24 16:42:32 +0000
commitd56999890f2aacf197d9ae4383313271499509a9 (patch)
tree76a0177e2cf19bb15a065199b812ef20158422e1 /apps
parent6688988ec42aa2254c8e370ec1932033a258b6fa (diff)
downloadrockbox-d56999890f2aacf197d9ae4383313271499509a9.tar.gz
rockbox-d56999890f2aacf197d9ae4383313271499509a9.zip
Make PCM->driver interface about as simple as it will get. Registered callback, zero data, alignment and stops are handled entirely inside pcm.c; driver merely calls fixed pcm.c callback. Remove pcm_record_more and do it just like playback; the original reason behind it isn't very practical in general. Everything checks out on supported targets. There wer some compat changes I can't check out on many unsupoorted but if there's a problem it will be a minor oops. Plugins become incompatible due to recording tweak-- full update. Sorted API.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26253 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugin.c30
-rw-r--r--apps/plugin.h46
-rw-r--r--apps/plugins/pitch_detector.c7
-rw-r--r--apps/recorder/pcm_record.c10
-rw-r--r--apps/voice_thread.c4
5 files changed, 40 insertions, 57 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index b45220acdb..83f27ea249 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -177,6 +177,9 @@ static const struct plugin_api rockbox_api = {
177 &button_queue, 177 &button_queue,
178#endif 178#endif
179 bidi_l2v, 179 bidi_l2v,
180#ifdef HAVE_LCD_BITMAP
181 is_diacritic,
182#endif
180 font_get_bits, 183 font_get_bits,
181 font_load, 184 font_load,
182 font_get, 185 font_get,
@@ -461,6 +464,9 @@ static const struct plugin_api rockbox_api = {
461 sound_max, 464 sound_max,
462 sound_unit, 465 sound_unit,
463 sound_val2phys, 466 sound_val2phys,
467#ifdef AUDIOHW_HAVE_EQ
468 sound_enum_hw_eq_band_setting,
469#endif
464#ifndef SIMULATOR 470#ifndef SIMULATOR
465 mp3_play_data, 471 mp3_play_data,
466 mp3_play_pause, 472 mp3_play_pause,
@@ -491,7 +497,6 @@ static const struct plugin_api rockbox_api = {
491 pcm_init_recording, 497 pcm_init_recording,
492 pcm_close_recording, 498 pcm_close_recording,
493 pcm_record_data, 499 pcm_record_data,
494 pcm_record_more,
495 pcm_stop_recording, 500 pcm_stop_recording,
496 pcm_calculate_rec_peaks, 501 pcm_calculate_rec_peaks,
497 audio_set_recording_gain, 502 audio_set_recording_gain,
@@ -630,7 +635,12 @@ static const struct plugin_api rockbox_api = {
630 codec_thread_do_callback, 635 codec_thread_do_callback,
631 codec_load_file, 636 codec_load_file,
632 get_codec_filename, 637 get_codec_filename,
638 find_array_ptr,
639 remove_array_ptr,
640#if defined(HAVE_RECORDING) && (defined(HAVE_LINE_IN) || defined(HAVE_MIC_IN))
641 round_value_to_list32,
633#endif 642#endif
643#endif /* CONFIG_CODEC == SWCODEC */
634 get_metadata, 644 get_metadata,
635 mp3info, 645 mp3info,
636 count_mp3_frames, 646 count_mp3_frames,
@@ -711,24 +721,6 @@ static const struct plugin_api rockbox_api = {
711 appsversion, 721 appsversion,
712 /* new stuff at the end, sort into place next time 722 /* new stuff at the end, sort into place next time
713 the API gets incompatible */ 723 the API gets incompatible */
714
715#ifdef HAVE_LCD_BITMAP
716 is_diacritic,
717#endif
718
719#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && \
720 (defined(HAVE_LINE_IN) || defined(HAVE_MIC_IN))
721 round_value_to_list32,
722#endif
723
724#ifdef AUDIOHW_HAVE_EQ
725 sound_enum_hw_eq_band_setting,
726#endif
727
728#if CONFIG_CODEC == SWCODEC
729 find_array_ptr,
730 remove_array_ptr,
731#endif
732}; 724};
733 725
734int plugin_load(const char* plugin, const void* parameter) 726int plugin_load(const char* plugin, const void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index 6727ca4caf..7e198c97bd 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -144,12 +144,12 @@ void* plugin_get_buffer(size_t *buffer_size);
144#define PLUGIN_MAGIC 0x526F634B /* RocK */ 144#define PLUGIN_MAGIC 0x526F634B /* RocK */
145 145
146/* increase this every time the api struct changes */ 146/* increase this every time the api struct changes */
147#define PLUGIN_API_VERSION 186 147#define PLUGIN_API_VERSION 187
148 148
149/* update this to latest version if a change to the api struct breaks 149/* update this to latest version if a change to the api struct breaks
150 backwards compatibility (and please take the opportunity to sort in any 150 backwards compatibility (and please take the opportunity to sort in any
151 new function which are "waiting" at the end of the function table) */ 151 new function which are "waiting" at the end of the function table) */
152#define PLUGIN_MIN_API_VERSION 182 152#define PLUGIN_MIN_API_VERSION 187
153 153
154/* plugin return codes */ 154/* plugin return codes */
155enum plugin_status { 155enum plugin_status {
@@ -259,6 +259,9 @@ struct plugin_api {
259 struct event_queue *button_queue; 259 struct event_queue *button_queue;
260#endif 260#endif
261 unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation ); 261 unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
262#ifdef HAVE_LCD_BITMAP
263 bool (*is_diacritic)(const unsigned short char_code, bool *is_rtl);
264#endif
262 const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code ); 265 const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
263 int (*font_load)(struct font*, const char *path); 266 int (*font_load)(struct font*, const char *path);
264 struct font* (*font_get)(int font); 267 struct font* (*font_get)(int font);
@@ -577,6 +580,10 @@ struct plugin_api {
577 int (*sound_max)(int setting); 580 int (*sound_max)(int setting);
578 const char * (*sound_unit)(int setting); 581 const char * (*sound_unit)(int setting);
579 int (*sound_val2phys)(int setting, int value); 582 int (*sound_val2phys)(int setting, int value);
583#ifdef AUDIOHW_HAVE_EQ
584 int (*sound_enum_hw_eq_band_setting)(unsigned int band,
585 unsigned int band_setting);
586#endif /* AUDIOHW_HAVE_EQ */
580#ifndef SIMULATOR 587#ifndef SIMULATOR
581 void (*mp3_play_data)(const unsigned char* start, int size, 588 void (*mp3_play_data)(const unsigned char* start, int size,
582 void (*get_more)(unsigned char** start, size_t* size)); 589 void (*get_more)(unsigned char** start, size_t* size));
@@ -591,7 +598,7 @@ struct plugin_api {
591 const unsigned long *audio_master_sampr_list; 598 const unsigned long *audio_master_sampr_list;
592 const unsigned long *hw_freq_sampr; 599 const unsigned long *hw_freq_sampr;
593 void (*pcm_apply_settings)(void); 600 void (*pcm_apply_settings)(void);
594 void (*pcm_play_data)(pcm_more_callback_type get_more, 601 void (*pcm_play_data)(pcm_play_callback_type get_more,
595 unsigned char* start, size_t size); 602 unsigned char* start, size_t size);
596 void (*pcm_play_stop)(void); 603 void (*pcm_play_stop)(void);
597 void (*pcm_set_frequency)(unsigned int frequency); 604 void (*pcm_set_frequency)(unsigned int frequency);
@@ -610,9 +617,8 @@ struct plugin_api {
610 const unsigned long *rec_freq_sampr; 617 const unsigned long *rec_freq_sampr;
611 void (*pcm_init_recording)(void); 618 void (*pcm_init_recording)(void);
612 void (*pcm_close_recording)(void); 619 void (*pcm_close_recording)(void);
613 void (*pcm_record_data)(pcm_more_callback_type2 more_ready, 620 void (*pcm_record_data)(pcm_rec_callback_type more_ready,
614 void *start, size_t size); 621 void *start, size_t size);
615 void (*pcm_record_more)(void *start, size_t size);
616 void (*pcm_stop_recording)(void); 622 void (*pcm_stop_recording)(void);
617 void (*pcm_calculate_rec_peaks)(int *left, int *right); 623 void (*pcm_calculate_rec_peaks)(int *left, int *right);
618 void (*audio_set_recording_gain)(int left, int right, int type); 624 void (*audio_set_recording_gain)(int left, int right, int type);
@@ -774,7 +780,15 @@ struct plugin_api {
774 unsigned int *audio_thread_id); 780 unsigned int *audio_thread_id);
775 int (*codec_load_file)(const char* codec, struct codec_api *api); 781 int (*codec_load_file)(const char* codec, struct codec_api *api);
776 const char *(*get_codec_filename)(int cod_spec); 782 const char *(*get_codec_filename)(int cod_spec);
783 void ** (*find_array_ptr)(void **arr, void *ptr);
784 int (*remove_array_ptr)(void **arr, void *ptr);
785#if defined(HAVE_RECORDING) && (defined(HAVE_LINE_IN) || defined(HAVE_MIC_IN))
786int (*round_value_to_list32)(unsigned long value,
787 const unsigned long list[],
788 int count,
789 bool signd);
777#endif 790#endif
791#endif /* CONFIG_CODEC == SWCODEC */
778 bool (*get_metadata)(struct mp3entry* id3, int fd, const char* trackname); 792 bool (*get_metadata)(struct mp3entry* id3, int fd, const char* trackname);
779 bool (*mp3info)(struct mp3entry *entry, const char *filename); 793 bool (*mp3info)(struct mp3entry *entry, const char *filename);
780 int (*count_mp3_frames)(int fd, int startpos, int filesize, 794 int (*count_mp3_frames)(int fd, int startpos, int filesize,
@@ -874,28 +888,6 @@ struct plugin_api {
874 const char *appsversion; 888 const char *appsversion;
875 /* new stuff at the end, sort into place next time 889 /* new stuff at the end, sort into place next time
876 the API gets incompatible */ 890 the API gets incompatible */
877
878#ifdef HAVE_LCD_BITMAP
879 bool (*is_diacritic)(const unsigned short char_code, bool *is_rtl);
880#endif
881
882#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && \
883 (defined(HAVE_LINE_IN) || defined(HAVE_MIC_IN))
884int (*round_value_to_list32)(unsigned long value,
885 const unsigned long list[],
886 int count,
887 bool signd);
888#endif
889
890#ifdef AUDIOHW_HAVE_EQ
891 int (*sound_enum_hw_eq_band_setting)(unsigned int band,
892 unsigned int band_setting);
893#endif /* AUDIOHW_HAVE_EQ */
894
895#if CONFIG_CODEC == SWCODEC
896 void ** (*find_array_ptr)(void **arr, void *ptr);
897 int (*remove_array_ptr)(void **arr, void *ptr);
898#endif
899}; 891};
900 892
901/* plugin header */ 893/* plugin header */
diff --git a/apps/plugins/pitch_detector.c b/apps/plugins/pitch_detector.c
index 538e0886fa..208b146c4e 100644
--- a/apps/plugins/pitch_detector.c
+++ b/apps/plugins/pitch_detector.c
@@ -982,7 +982,7 @@ uint32_t ICODE_ATTR buffer_magnitude(int16_t *input)
982 982
983/* Stop the recording when the buffer is full */ 983/* Stop the recording when the buffer is full */
984#ifndef SIMULATOR 984#ifndef SIMULATOR
985int recording_callback(int status) 985void recording_callback(int status, void **start, size_t *size)
986{ 986{
987 int tail = audio_tail ^ 1; 987 int tail = audio_tail ^ 1;
988 988
@@ -991,10 +991,9 @@ int recording_callback(int status)
991 audio_tail = tail; 991 audio_tail = tail;
992 992
993 /* Always record full buffer, even if not required */ 993 /* Always record full buffer, even if not required */
994 rb->pcm_record_more(audio_data[tail], 994 *start = audio_data[tail];
995 BUFFER_SIZE * sizeof (int16_t)); 995 *size = BUFFER_SIZE * sizeof (int16_t);
996 996
997 return 0;
998 (void)status; 997 (void)status;
999} 998}
1000#endif 999#endif
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c
index 2567b56ef3..687a70664d 100644
--- a/apps/recorder/pcm_record.c
+++ b/apps/recorder/pcm_record.c
@@ -256,7 +256,7 @@ enum
256/*******************************************************************/ 256/*******************************************************************/
257 257
258/* Callback for when more data is ready - called in interrupt context */ 258/* Callback for when more data is ready - called in interrupt context */
259static int pcm_rec_have_more(int status) 259static void pcm_rec_have_more(int status, void **start, size_t *size)
260{ 260{
261 if (status < 0) 261 if (status < 0)
262 { 262 {
@@ -265,9 +265,9 @@ static int pcm_rec_have_more(int status)
265 { 265 {
266 /* Flush recorded data to disk and stop recording */ 266 /* Flush recorded data to disk and stop recording */
267 queue_post(&pcmrec_queue, PCMREC_STOP, 0); 267 queue_post(&pcmrec_queue, PCMREC_STOP, 0);
268 return -1; 268 return;
269 } 269 }
270 /* else try again next transmission */ 270 /* else try again next transmission - frame is invalid */
271 } 271 }
272 else if (!dma_lock) 272 else if (!dma_lock)
273 { 273 {
@@ -282,8 +282,8 @@ static int pcm_rec_have_more(int status)
282 dma_wr_pos = next_pos; 282 dma_wr_pos = next_pos;
283 } 283 }
284 284
285 pcm_record_more(GET_PCM_CHUNK(dma_wr_pos), PCM_CHUNK_SIZE); 285 *start = GET_PCM_CHUNK(dma_wr_pos);
286 return 0; 286 *size = PCM_CHUNK_SIZE;
287} /* pcm_rec_have_more */ 287} /* pcm_rec_have_more */
288 288
289static void reset_hardware(void) 289static void reset_hardware(void)
diff --git a/apps/voice_thread.c b/apps/voice_thread.c
index 076bd2ea1b..a65ec566d1 100644
--- a/apps/voice_thread.c
+++ b/apps/voice_thread.c
@@ -89,7 +89,7 @@ enum voice_thread_messages
89/* Structure to store clip data callback info */ 89/* Structure to store clip data callback info */
90struct voice_info 90struct voice_info
91{ 91{
92 pcm_more_callback_type get_more; /* Callback to get more clips */ 92 pcm_play_callback_type get_more; /* Callback to get more clips */
93 unsigned char *start; /* Start of clip */ 93 unsigned char *start; /* Start of clip */
94 size_t size; /* Size of clip */ 94 size_t size; /* Size of clip */
95}; 95};
@@ -117,7 +117,7 @@ static inline bool playback_is_playing(void)
117 117
118/* Stop any current clip and start playing a new one */ 118/* Stop any current clip and start playing a new one */
119void mp3_play_data(const unsigned char* start, int size, 119void mp3_play_data(const unsigned char* start, int size,
120 pcm_more_callback_type get_more) 120 pcm_play_callback_type get_more)
121{ 121{
122 /* Shared struct to get data to the thread - once it replies, it has 122 /* Shared struct to get data to the thread - once it replies, it has
123 * safely cached it in its own private data */ 123 * safely cached it in its own private data */