summaryrefslogtreecommitdiff
path: root/firmware/mpeg.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r--firmware/mpeg.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 727e81b16e..b834e5deac 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -1598,13 +1598,13 @@ static void mpeg_thread(void)
1598 { 1598 {
1599 case MPEG_RECORD: 1599 case MPEG_RECORD:
1600 DEBUGF("Recording...\n"); 1600 DEBUGF("Recording...\n");
1601 reset_mp3_buffer();
1602 start_recording();
1603 demand_irq_enable(true);
1601 mpeg_file = open((char *)ev.data, 1604 mpeg_file = open((char *)ev.data,
1602 O_WRONLY | O_TRUNC | O_CREAT); 1605 O_WRONLY | O_TRUNC | O_CREAT);
1603 if(mpeg_file < 0) 1606 if(mpeg_file < 0)
1604 panicf("recfile: %d", mpeg_file); 1607 panicf("recfile: %d", mpeg_file);
1605 reset_mp3_buffer();
1606 start_recording();
1607 demand_irq_enable(true);
1608 break; 1608 break;
1609 1609
1610 case MPEG_STOP: 1610 case MPEG_STOP:
@@ -1648,7 +1648,9 @@ static void mpeg_thread(void)
1648 { 1648 {
1649 amount_to_save += mp3buflen; 1649 amount_to_save += mp3buflen;
1650 } 1650 }
1651 1651
1652 DEBUGF("r: %x w: %x\n", mp3buf_read, mp3buf_write);
1653 DEBUGF("ats: %x\n", amount_to_save);
1652 /* Save data only if the buffer is getting full, 1654 /* Save data only if the buffer is getting full,
1653 or if we should stop recording */ 1655 or if we should stop recording */
1654 if(amount_to_save) 1656 if(amount_to_save)
@@ -1656,12 +1658,16 @@ static void mpeg_thread(void)
1656 if(mp3buflen - amount_to_save < MPEG_LOW_WATER || 1658 if(mp3buflen - amount_to_save < MPEG_LOW_WATER ||
1657 stop_pending) 1659 stop_pending)
1658 { 1660 {
1661 int rc;
1662
1659 /* Only save up to the end of the buffer */ 1663 /* Only save up to the end of the buffer */
1660 writelen = MIN(amount_to_save, 1664 writelen = MIN(amount_to_save,
1661 mp3buflen - mp3buf_read); 1665 mp3buflen - mp3buf_read);
1662 1666
1663 write(mpeg_file, mp3buf + mp3buf_read, 1667 DEBUGF("wrl: %x\n", writelen);
1664 writelen); 1668 rc = write(mpeg_file, mp3buf + mp3buf_read,
1669 writelen);
1670 DEBUGF("rc: %x\n", rc);
1665 1671
1666 mp3buf_read += amount_to_save; 1672 mp3buf_read += amount_to_save;
1667 if(mp3buf_read >= mp3buflen) 1673 if(mp3buf_read >= mp3buflen)