diff options
-rw-r--r-- | firmware/export/pcm_playback.h | 13 | ||||
-rw-r--r-- | firmware/export/pcm_record.h | 12 | ||||
-rw-r--r-- | firmware/pcm_record.c | 34 | ||||
-rw-r--r-- | firmware/target/coldfire/pcm-coldfire.c | 11 |
4 files changed, 54 insertions, 16 deletions
diff --git a/firmware/export/pcm_playback.h b/firmware/export/pcm_playback.h index 9c3e96ba63..e7c00edeed 100644 --- a/firmware/export/pcm_playback.h +++ b/firmware/export/pcm_playback.h | |||
@@ -47,4 +47,17 @@ void pcm_play_pause(bool play); | |||
47 | bool pcm_is_paused(void); | 47 | bool pcm_is_paused(void); |
48 | bool pcm_is_playing(void); | 48 | bool pcm_is_playing(void); |
49 | 49 | ||
50 | /** The following are for internal use between pcm_playback.c and target- | ||
51 | specific portion **/ | ||
52 | |||
53 | /* the registered callback function to ask for more mp3 data */ | ||
54 | extern volatile pcm_more_callback_type pcm_callback_for_more; | ||
55 | extern volatile bool pcm_playing; | ||
56 | extern volatile bool pcm_paused; | ||
57 | |||
58 | extern void pcm_play_dma_start(const void *addr, size_t size); | ||
59 | extern void pcm_play_dma_stop(void); | ||
60 | extern void pcm_play_pause_pause(void); | ||
61 | extern void pcm_play_pause_unpause(void); | ||
62 | |||
50 | #endif /* PCM_PLAYBACK_H */ | 63 | #endif /* PCM_PLAYBACK_H */ |
diff --git a/firmware/export/pcm_record.h b/firmware/export/pcm_record.h index 38ec202cdc..30d2dc7e6f 100644 --- a/firmware/export/pcm_record.h +++ b/firmware/export/pcm_record.h | |||
@@ -60,4 +60,16 @@ int pcm_get_num_unprocessed(void); | |||
60 | 60 | ||
61 | /* audio.h contains audio_* recording functions */ | 61 | /* audio.h contains audio_* recording functions */ |
62 | 62 | ||
63 | |||
64 | /** The following are for internal use between pcm_record.c and target- | ||
65 | specific portion **/ | ||
66 | /* the registered callback function for when more data is available */ | ||
67 | extern volatile pcm_more_callback_type pcm_callback_more_ready; | ||
68 | /* DMA transfer in is currently active */ | ||
69 | extern volatile bool pcm_recording; | ||
70 | |||
71 | /* APIs implemented in the target-specific portion */ | ||
72 | extern void pcm_rec_dma_start(const void *addr, size_t size); | ||
73 | extern void pcm_rec_dma_stop(void); | ||
74 | |||
63 | #endif /* PCM_RECORD_H */ | 75 | #endif /* PCM_RECORD_H */ |
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c index f7059dc40b..bc39c8979a 100644 --- a/firmware/pcm_record.c +++ b/firmware/pcm_record.c | |||
@@ -74,8 +74,10 @@ static size_t num_rec_bytes; /* Num bytes recorded */ | |||
74 | static unsigned long num_rec_samples; /* Number of PCM samples recorded */ | 74 | static unsigned long num_rec_samples; /* Number of PCM samples recorded */ |
75 | 75 | ||
76 | /** Stats on encoded data for all files from start to stop **/ | 76 | /** Stats on encoded data for all files from start to stop **/ |
77 | #if 0 | ||
77 | static unsigned long long accum_rec_bytes; /* total size written to chunks */ | 78 | static unsigned long long accum_rec_bytes; /* total size written to chunks */ |
78 | static unsigned long long accum_pcm_samples; /* total pcm count processed */ | 79 | static unsigned long long accum_pcm_samples; /* total pcm count processed */ |
80 | #endif | ||
79 | 81 | ||
80 | /* Keeps data about current file and is sent as event data for codec */ | 82 | /* Keeps data about current file and is sent as event data for codec */ |
81 | static struct enc_file_event_data rec_fdata IDATA_ATTR = | 83 | static struct enc_file_event_data rec_fdata IDATA_ATTR = |
@@ -272,6 +274,7 @@ unsigned long pcm_rec_status(void) | |||
272 | return ret; | 274 | return ret; |
273 | } /* pcm_rec_status */ | 275 | } /* pcm_rec_status */ |
274 | 276 | ||
277 | #if 0 | ||
275 | int pcm_rec_current_bitrate(void) | 278 | int pcm_rec_current_bitrate(void) |
276 | { | 279 | { |
277 | if (accum_pcm_samples == 0) | 280 | if (accum_pcm_samples == 0) |
@@ -279,17 +282,23 @@ int pcm_rec_current_bitrate(void) | |||
279 | 282 | ||
280 | return (int)(8*accum_rec_bytes*enc_sample_rate / (1000*accum_pcm_samples)); | 283 | return (int)(8*accum_rec_bytes*enc_sample_rate / (1000*accum_pcm_samples)); |
281 | } /* pcm_rec_current_bitrate */ | 284 | } /* pcm_rec_current_bitrate */ |
285 | #endif | ||
282 | 286 | ||
287 | #if 0 | ||
283 | int pcm_rec_encoder_afmt(void) | 288 | int pcm_rec_encoder_afmt(void) |
284 | { | 289 | { |
285 | return enc_config.afmt; | 290 | return enc_config.afmt; |
286 | } /* pcm_rec_encoder_afmt */ | 291 | } /* pcm_rec_encoder_afmt */ |
292 | #endif | ||
287 | 293 | ||
294 | #if 0 | ||
288 | int pcm_rec_rec_format(void) | 295 | int pcm_rec_rec_format(void) |
289 | { | 296 | { |
290 | return afmt_rec_format[enc_config.afmt]; | 297 | return afmt_rec_format[enc_config.afmt]; |
291 | } /* pcm_rec_rec_format */ | 298 | } /* pcm_rec_rec_format */ |
299 | #endif | ||
292 | 300 | ||
301 | #ifdef HAVE_SPDIF_IN | ||
293 | unsigned long pcm_rec_sample_rate(void) | 302 | unsigned long pcm_rec_sample_rate(void) |
294 | { | 303 | { |
295 | /* Which is better ?? */ | 304 | /* Which is better ?? */ |
@@ -298,6 +307,7 @@ unsigned long pcm_rec_sample_rate(void) | |||
298 | #endif | 307 | #endif |
299 | return sample_rate; | 308 | return sample_rate; |
300 | } /* audio_get_sample_rate */ | 309 | } /* audio_get_sample_rate */ |
310 | #endif | ||
301 | 311 | ||
302 | /** | 312 | /** |
303 | * Creates pcmrec_thread | 313 | * Creates pcmrec_thread |
@@ -332,7 +342,7 @@ void audio_close_recording(void) | |||
332 | unsigned long audio_recorded_time(void) | 342 | unsigned long audio_recorded_time(void) |
333 | { | 343 | { |
334 | if (!is_recording || enc_sample_rate == 0) | 344 | if (!is_recording || enc_sample_rate == 0) |
335 | return 0; | 345 | return 0; |
336 | 346 | ||
337 | /* return actual recorded time a la encoded data even if encoder rate | 347 | /* return actual recorded time a la encoded data even if encoder rate |
338 | doesn't match the pcm rate */ | 348 | doesn't match the pcm rate */ |
@@ -589,14 +599,18 @@ static inline void pcmrec_update_sizes_inl(size_t prev_enc_size, | |||
589 | { | 599 | { |
590 | ssize_t size_diff = rec_fdata.new_enc_size - prev_enc_size; | 600 | ssize_t size_diff = rec_fdata.new_enc_size - prev_enc_size; |
591 | num_rec_bytes += size_diff; | 601 | num_rec_bytes += size_diff; |
602 | #if 0 | ||
592 | accum_rec_bytes += size_diff; | 603 | accum_rec_bytes += size_diff; |
604 | #endif | ||
593 | } | 605 | } |
594 | 606 | ||
595 | if (rec_fdata.new_num_pcm != prev_num_pcm) | 607 | if (rec_fdata.new_num_pcm != prev_num_pcm) |
596 | { | 608 | { |
597 | unsigned long pcm_diff = rec_fdata.new_num_pcm - prev_num_pcm; | 609 | unsigned long pcm_diff = rec_fdata.new_num_pcm - prev_num_pcm; |
598 | num_rec_samples += pcm_diff; | 610 | num_rec_samples += pcm_diff; |
611 | #if 0 | ||
599 | accum_pcm_samples += pcm_diff; | 612 | accum_pcm_samples += pcm_diff; |
613 | #endif | ||
600 | } | 614 | } |
601 | } /* pcmrec_update_sizes_inl */ | 615 | } /* pcmrec_update_sizes_inl */ |
602 | 616 | ||
@@ -980,11 +994,11 @@ static void pcmrec_new_stream(const char *filename, /* next file name */ | |||
980 | 994 | ||
981 | start->flags |= CHUNKF_START_FILE; | 995 | start->flags |= CHUNKF_START_FILE; |
982 | 996 | ||
983 | /* flush one file out if full and adding */ | 997 | /* flush all pending files out if full and adding */ |
984 | if (fnq_add_fn == pcmrec_fnq_add_filename && pcmrec_fnq_is_full()) | 998 | if (fnq_add_fn == pcmrec_fnq_add_filename && pcmrec_fnq_is_full()) |
985 | { | 999 | { |
986 | logf("fnq full: flushing 1"); | 1000 | logf("fnq full"); |
987 | pcmrec_flush(1); | 1001 | pcmrec_flush(-1); |
988 | } | 1002 | } |
989 | 1003 | ||
990 | fnq_add_fn(filename); | 1004 | fnq_add_fn(filename); |
@@ -1014,8 +1028,10 @@ static void pcmrec_init(void) | |||
1014 | /* stats */ | 1028 | /* stats */ |
1015 | num_rec_bytes = 0; | 1029 | num_rec_bytes = 0; |
1016 | num_rec_samples = 0; | 1030 | num_rec_samples = 0; |
1031 | #if 0 | ||
1017 | accum_rec_bytes = 0; | 1032 | accum_rec_bytes = 0; |
1018 | accum_pcm_samples = 0; | 1033 | accum_pcm_samples = 0; |
1034 | #endif | ||
1019 | 1035 | ||
1020 | pcm_thread_unsignal_event(PCMREC_CLOSE); | 1036 | pcm_thread_unsignal_event(PCMREC_CLOSE); |
1021 | is_recording = false; | 1037 | is_recording = false; |
@@ -1059,8 +1075,10 @@ static void pcmrec_start(const char *filename) | |||
1059 | /* reset stats */ | 1075 | /* reset stats */ |
1060 | num_rec_bytes = 0; | 1076 | num_rec_bytes = 0; |
1061 | num_rec_samples = 0; | 1077 | num_rec_samples = 0; |
1078 | #if 0 | ||
1062 | accum_rec_bytes = 0; | 1079 | accum_rec_bytes = 0; |
1063 | accum_pcm_samples = 0; | 1080 | accum_pcm_samples = 0; |
1081 | #endif | ||
1064 | spinup_time = -1; | 1082 | spinup_time = -1; |
1065 | 1083 | ||
1066 | rd_start = enc_wr_index; | 1084 | rd_start = enc_wr_index; |
@@ -1103,8 +1121,10 @@ static void pcmrec_start(const char *filename) | |||
1103 | break; | 1121 | break; |
1104 | } | 1122 | } |
1105 | 1123 | ||
1124 | #if 0 | ||
1106 | accum_rec_bytes = num_rec_bytes; | 1125 | accum_rec_bytes = num_rec_bytes; |
1107 | accum_pcm_samples = num_rec_samples; | 1126 | accum_pcm_samples = num_rec_samples; |
1127 | #endif | ||
1108 | } | 1128 | } |
1109 | 1129 | ||
1110 | enc_rd_index = rd_start; | 1130 | enc_rd_index = rd_start; |
@@ -1513,9 +1533,13 @@ void enc_finish_chunk(void) | |||
1513 | if (enc_rd_index != enc_wr_index) | 1533 | if (enc_rd_index != enc_wr_index) |
1514 | { | 1534 | { |
1515 | num_rec_bytes += chunk->enc_size; | 1535 | num_rec_bytes += chunk->enc_size; |
1536 | #if 0 | ||
1516 | accum_rec_bytes += chunk->enc_size; | 1537 | accum_rec_bytes += chunk->enc_size; |
1538 | #endif | ||
1517 | num_rec_samples += chunk->num_pcm; | 1539 | num_rec_samples += chunk->num_pcm; |
1540 | #if 0 | ||
1518 | accum_pcm_samples += chunk->num_pcm; | 1541 | accum_pcm_samples += chunk->num_pcm; |
1542 | #endif | ||
1519 | } | 1543 | } |
1520 | else if (is_recording) /* buffer full */ | 1544 | else if (is_recording) /* buffer full */ |
1521 | { | 1545 | { |
diff --git a/firmware/target/coldfire/pcm-coldfire.c b/firmware/target/coldfire/pcm-coldfire.c index 2936cf5621..917800d0b8 100644 --- a/firmware/target/coldfire/pcm-coldfire.c +++ b/firmware/target/coldfire/pcm-coldfire.c | |||
@@ -41,17 +41,6 @@ | |||
41 | #define ac_set_frequency tlv320_set_frequency | 41 | #define ac_set_frequency tlv320_set_frequency |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | /** Semi-private shared symbols **/ | ||
45 | |||
46 | /* the registered callback function to ask for more pcm data */ | ||
47 | extern volatile pcm_more_callback_type pcm_callback_for_more; | ||
48 | extern volatile bool pcm_playing; | ||
49 | extern volatile bool pcm_paused; | ||
50 | |||
51 | /* the registered callback function for when more data is available */ | ||
52 | extern volatile pcm_more_callback_type pcm_callback_more_ready; | ||
53 | extern volatile bool pcm_recording; | ||
54 | |||
55 | /* peaks */ | 44 | /* peaks */ |
56 | static int play_peak_left, play_peak_right; | 45 | static int play_peak_left, play_peak_right; |
57 | static unsigned long *rec_peak_addr; | 46 | static unsigned long *rec_peak_addr; |