diff options
Diffstat (limited to 'firmware/pcm_record.c')
-rw-r--r-- | firmware/pcm_record.c | 34 |
1 files changed, 29 insertions, 5 deletions
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 | { |