summaryrefslogtreecommitdiff
path: root/firmware/mpeg.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r--firmware/mpeg.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 8d2d13b6ee..9d1aa3b9d6 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -190,6 +190,7 @@ unsigned long record_start_time; /* Value of current_tick when recording
190 was started */ 190 was started */
191unsigned long pause_start_time; /* Value of current_tick when pause was 191unsigned long pause_start_time; /* Value of current_tick when pause was
192 started */ 192 started */
193static unsigned long last_rec_time;
193static unsigned long num_rec_bytes; 194static unsigned long num_rec_bytes;
194static unsigned long last_rec_bytes; 195static unsigned long last_rec_bytes;
195static unsigned long frame_count_start; 196static unsigned long frame_count_start;
@@ -1611,12 +1612,11 @@ static void mpeg_thread(void)
1611 /* Don't read more than until the end of the buffer */ 1612 /* Don't read more than until the end of the buffer */
1612 amount_to_read = MIN(audiobuflen - audiobuf_write, 1613 amount_to_read = MIN(audiobuflen - audiobuf_write,
1613 amount_to_read); 1614 amount_to_read);
1614#if MEM == 8
1615 amount_to_read = MIN(0x100000, amount_to_read);
1616#endif /* MEM == 8 */
1617#ifdef HAVE_MMC /* MMC is slow, so don't read too large chunks */ 1615#ifdef HAVE_MMC /* MMC is slow, so don't read too large chunks */
1618 amount_to_read = MIN(0x40000, amount_to_read); 1616 amount_to_read = MIN(0x40000, amount_to_read);
1619#endif /* HAVE_MMC */ 1617#elif MEM == 8
1618 amount_to_read = MIN(0x100000, amount_to_read);
1619#endif
1620 1620
1621 /* Read as much mpeg data as we can fit in the buffer */ 1621 /* Read as much mpeg data as we can fit in the buffer */
1622 if(mpeg_file >= 0) 1622 if(mpeg_file >= 0)
@@ -1810,7 +1810,7 @@ static void mpeg_thread(void)
1810 DEBUGF("MPEG_STOP\n"); 1810 DEBUGF("MPEG_STOP\n");
1811 1811
1812 stop_recording(); 1812 stop_recording();
1813 1813
1814 /* Save the remaining data in the buffer */ 1814 /* Save the remaining data in the buffer */
1815 save_endpos = audiobuf_write; 1815 save_endpos = audiobuf_write;
1816 saving_status = STOP_RECORDING; 1816 saving_status = STOP_RECORDING;
@@ -1848,7 +1848,7 @@ static void mpeg_thread(void)
1848 1848
1849 case MPEG_NEW_FILE: 1849 case MPEG_NEW_FILE:
1850 /* Bail out when a more important save is happening */ 1850 /* Bail out when a more important save is happening */
1851 if (saving_status > NEW_FILE) 1851 if (saving_status > NEW_FILE)
1852 break; 1852 break;
1853 1853
1854 /* Make sure we have at least one complete frame 1854 /* Make sure we have at least one complete frame
@@ -1865,6 +1865,11 @@ static void mpeg_thread(void)
1865 mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_FRAME_COUNT, 1865 mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_FRAME_COUNT,
1866 &frame_count_end, 1); 1866 &frame_count_end, 1);
1867 1867
1868 last_rec_time = current_tick - record_start_time;
1869 record_start_time = current_tick;
1870 if (paused)
1871 pause_start_time = record_start_time;
1872
1868 /* capture all values at one point */ 1873 /* capture all values at one point */
1869 level = set_irq_level(HIGHEST_IRQ_LEVEL); 1874 level = set_irq_level(HIGHEST_IRQ_LEVEL);
1870 save_endpos = audiobuf_write; 1875 save_endpos = audiobuf_write;
@@ -1916,11 +1921,10 @@ static void mpeg_thread(void)
1916 1921
1917 amount_to_save = MIN(amount_to_save, 1922 amount_to_save = MIN(amount_to_save,
1918 audiobuflen - audiobuf_read); 1923 audiobuflen - audiobuf_read);
1919#if MEM == 8
1920 amount_to_save = MIN(0x100000, amount_to_save);
1921#endif
1922#ifdef HAVE_MMC /* MMC is slow, so don't save too large chunks at once */ 1924#ifdef HAVE_MMC /* MMC is slow, so don't save too large chunks at once */
1923 amount_to_save = MIN(0x40000, amount_to_save); 1925 amount_to_save = MIN(0x40000, amount_to_save);
1926#elif MEM == 8
1927 amount_to_save = MIN(0x100000, amount_to_save);
1924#endif 1928#endif
1925 rc = write(mpeg_file, audiobuf + audiobuf_read, 1929 rc = write(mpeg_file, audiobuf + audiobuf_read,
1926 amount_to_save); 1930 amount_to_save);
@@ -2210,7 +2214,7 @@ void mpeg_record(const char *filename)
2210 2214
2211 strncpy(recording_filename, filename, MAX_PATH - 1); 2215 strncpy(recording_filename, filename, MAX_PATH - 1);
2212 recording_filename[MAX_PATH - 1] = 0; 2216 recording_filename[MAX_PATH - 1] = 0;
2213 2217
2214 queue_post(&mpeg_queue, MPEG_RECORD, NULL); 2218 queue_post(&mpeg_queue, MPEG_RECORD, NULL);
2215} 2219}
2216 2220
@@ -2274,7 +2278,8 @@ static void update_header(void)
2274 2278
2275 /* saved_header is saved right before stopping the MAS */ 2279 /* saved_header is saved right before stopping the MAS */
2276 framelen = create_xing_header(fd, 0, last_rec_bytes, xing_buffer, 2280 framelen = create_xing_header(fd, 0, last_rec_bytes, xing_buffer,
2277 frames, saved_header, NULL, false); 2281 frames, last_rec_time * (1000/HZ),
2282 saved_header, NULL, false);
2278 2283
2279 lseek(fd, MPEG_RESERVED_HEADER_SPACE - framelen, SEEK_SET); 2284 lseek(fd, MPEG_RESERVED_HEADER_SPACE - framelen, SEEK_SET);
2280 write(fd, xing_buffer, framelen); 2285 write(fd, xing_buffer, framelen);
@@ -2350,7 +2355,7 @@ static void start_recording(void)
2350 record_start_time = current_tick; 2355 record_start_time = current_tick;
2351 2356
2352 pause_start_time = 0; 2357 pause_start_time = 0;
2353 2358
2354 demand_irq_enable(true); 2359 demand_irq_enable(true);
2355} 2360}
2356 2361
@@ -2398,6 +2403,7 @@ static void stop_recording(void)
2398 2403
2399 last_rec_bytes = num_rec_bytes; 2404 last_rec_bytes = num_rec_bytes;
2400 mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_FRAME_COUNT, &frame_count_end, 1); 2405 mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_FRAME_COUNT, &frame_count_end, 1);
2406 last_rec_time = current_tick - record_start_time;
2401 2407
2402 /* Start monitoring */ 2408 /* Start monitoring */
2403 shadow_io_control_main |= (1 << 10); 2409 shadow_io_control_main |= (1 << 10);
@@ -2524,11 +2530,6 @@ void mpeg_new_file(const char *filename)
2524 strncpy(recording_filename, filename, MAX_PATH - 1); 2530 strncpy(recording_filename, filename, MAX_PATH - 1);
2525 recording_filename[MAX_PATH - 1] = 0; 2531 recording_filename[MAX_PATH - 1] = 0;
2526 2532
2527 /* Store the current time */
2528 record_start_time = current_tick;
2529 if(paused)
2530 pause_start_time = record_start_time;
2531
2532 queue_post(&mpeg_queue, MPEG_NEW_FILE, NULL); 2533 queue_post(&mpeg_queue, MPEG_NEW_FILE, NULL);
2533} 2534}
2534 2535