summaryrefslogtreecommitdiffstats
path: root/apps/pcmbuf.c
diff options
context:
space:
mode:
authorJeffrey Goode <jeffg7@gmail.com>2009-11-01 19:39:23 +0000
committerJeffrey Goode <jeffg7@gmail.com>2009-11-01 19:39:23 +0000
commite8eefe98bfd3768a9f3962bc71f0ee0431bae8b1 (patch)
tree8ce274e93fe8882fc25ed61ce5890cbd76c20e5c /apps/pcmbuf.c
parentbcadf96066c20953ae6be7447f1ee2cd8742ab4f (diff)
downloadrockbox-e8eefe98bfd3768a9f3962bc71f0ee0431bae8b1.tar.gz
rockbox-e8eefe98bfd3768a9f3962bc71f0ee0431bae8b1.tar.bz2
rockbox-e8eefe98bfd3768a9f3962bc71f0ee0431bae8b1.zip
Code cleanup in codec_thread, playback and pcmbuf; more elegant solution to leftover samples
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23471 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/pcmbuf.c')
-rw-r--r--apps/pcmbuf.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index 4a338aa900..3ec0c114da 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -135,12 +135,13 @@ static void pcmbuf_under_watermark(bool under);
static bool pcmbuf_flush_fillpos(void);
#define CALL_IF_EXISTS(function, args...) if (function) function(args)
-/* This function has 2 major logical parts (separated by brackets both for
+/* This function has 3 major logical parts (separated by brackets both for
* readability and variable scoping). The first part performs the
- * operastions related to finishing off the last buffer we fed to the DMA.
- * The second part performs the operations involved in sending a new buffer
- * to the DMA. Finally the function checks the status of the buffer and
- * boosts if necessary */
+ * operations related to finishing off the last buffer we fed to the DMA.
+ * The second part detects the end of playlist condition when the pcm
+ * buffer is empty except for uncommitted samples. Then they are committed.
+ * The third part performs the operations involved in sending a new buffer
+ * to the DMA. */
static void pcmbuf_callback(unsigned char** start, size_t* size) ICODE_ATTR;
static void pcmbuf_callback(unsigned char** start, size_t* size)
{
@@ -164,6 +165,15 @@ static void pcmbuf_callback(unsigned char** start, size_t* size)
if (pcmbuf_current == crossfade_chunk)
crossfade_chunk = pcmbuf_read;
}
+
+ {
+ /* Commit last samples at end of playlist */
+ if (audiobuffer_fillpos && !pcmbuf_read)
+ {
+ logf("pcmbuf callback: commit last samples");
+ pcmbuf_flush_fillpos();
+ }
+ }
{
/* Send the new buffer to the pcm */
@@ -1109,11 +1119,3 @@ bool pcmbuf_is_crossfade_enabled(void)
return crossfade_enabled;
}
-
-/** PLAY LAST REMAINING SAMPLES AT END OF PLAYBACK
- * Commit any remaining samples in the PCM buffer for playback. */
-void pcmbuf_play_remainder(void)
-{
- if (audiobuffer_fillpos)
- pcmbuf_flush_fillpos();
-}