summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/pcm_record.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c
index b826763370..11020e0157 100644
--- a/firmware/pcm_record.c
+++ b/firmware/pcm_record.c
@@ -373,7 +373,7 @@ void pcm_rec_init(void)
373 queue_init(&pcmrec_queue, true); 373 queue_init(&pcmrec_queue, true);
374 queue_enable_queue_send(&pcmrec_queue, &pcmrec_queue_send); 374 queue_enable_queue_send(&pcmrec_queue, &pcmrec_queue_send);
375 create_thread(pcmrec_thread, pcmrec_stack, sizeof(pcmrec_stack), 375 create_thread(pcmrec_thread, pcmrec_stack, sizeof(pcmrec_stack),
376 pcmrec_thread_name, PRIORITY_RECORDING); 376 pcmrec_thread_name IF_PRIO(, PRIORITY_RECORDING));
377} /* pcm_rec_init */ 377} /* pcm_rec_init */
378 378
379/** audio_* group **/ 379/** audio_* group **/
@@ -801,7 +801,9 @@ static void pcmrec_flush(unsigned flush_num)
801 static unsigned long last_flush_tick = 0; 801 static unsigned long last_flush_tick = 0;
802 unsigned long start_tick; 802 unsigned long start_tick;
803 int num_ready, num; 803 int num_ready, num;
804#ifdef HAVE_PRIORITY_SCHEDULING
804 int prio; 805 int prio;
806#endif
805 int i; 807 int i;
806 808
807 num_ready = enc_wr_index - enc_rd_index; 809 num_ready = enc_wr_index - enc_rd_index;
@@ -849,7 +851,9 @@ static void pcmrec_flush(unsigned flush_num)
849 } 851 }
850 852
851 start_tick = current_tick; 853 start_tick = current_tick;
854#ifdef HAVE_PRIORITY_SCHEDULING
852 prio = -1; 855 prio = -1;
856#endif
853 857
854 logf("writing: %d (%d)", num_ready, flush_num); 858 logf("writing: %d (%d)", num_ready, flush_num);
855 859
@@ -857,6 +861,7 @@ static void pcmrec_flush(unsigned flush_num)
857 861
858 for (i = 0; i < num_ready; i++) 862 for (i = 0; i < num_ready; i++)
859 { 863 {
864#ifdef HAVE_PRIORITY_SCHEDULING
860 if (prio == -1 && (num >= panic_threshold || 865 if (prio == -1 && (num >= panic_threshold ||
861 current_tick - start_tick > 10*HZ)) 866 current_tick - start_tick > 10*HZ))
862 { 867 {
@@ -864,6 +869,7 @@ static void pcmrec_flush(unsigned flush_num)
864 logf("pcmrec: boost priority"); 869 logf("pcmrec: boost priority");
865 prio = thread_set_priority(NULL, thread_get_priority(NULL)-1); 870 prio = thread_set_priority(NULL, thread_get_priority(NULL)-1);
866 } 871 }
872#endif
867 873
868 rec_fdata.chunk = GET_ENC_CHUNK(enc_rd_index); 874 rec_fdata.chunk = GET_ENC_CHUNK(enc_rd_index);
869 rec_fdata.new_enc_size = rec_fdata.chunk->enc_size; 875 rec_fdata.new_enc_size = rec_fdata.chunk->enc_size;
@@ -889,7 +895,9 @@ static void pcmrec_flush(unsigned flush_num)
889 if (errors != 0) 895 if (errors != 0)
890 break; 896 break;
891 897
898#ifdef HAVE_PRIORITY_SCHEDULING
892 if (prio == -1) 899 if (prio == -1)
900#endif
893 { 901 {
894 num = enc_wr_index - enc_rd_index; 902 num = enc_wr_index - enc_rd_index;
895 if (num < 0) 903 if (num < 0)
@@ -903,14 +911,16 @@ static void pcmrec_flush(unsigned flush_num)
903 if (rec_fdata.rec_file >= 0) 911 if (rec_fdata.rec_file >= 0)
904 fsync(rec_fdata.rec_file); 912 fsync(rec_fdata.rec_file);
905 913
906 cpu_boost(false); 914 cpu_boost(false);
907 915
916#ifdef HAVE_PRIORITY_SCHEDULING
908 if (prio != -1) 917 if (prio != -1)
909 { 918 {
910 /* return to original priority */ 919 /* return to original priority */
911 logf("pcmrec: unboost priority"); 920 logf("pcmrec: unboost priority");
912 thread_set_priority(NULL, prio); 921 thread_set_priority(NULL, prio);
913 } 922 }
923#endif
914 924
915 last_flush_tick = current_tick; /* save tick when we left */ 925 last_flush_tick = current_tick; /* save tick when we left */
916 logf("done"); 926 logf("done");