summaryrefslogtreecommitdiff
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.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);
135static bool pcmbuf_flush_fillpos(void); 135static bool pcmbuf_flush_fillpos(void);
136 136
137#define CALL_IF_EXISTS(function, args...) if (function) function(args) 137#define CALL_IF_EXISTS(function, args...) if (function) function(args)
138/* This function has 2 major logical parts (separated by brackets both for 138/* This function has 3 major logical parts (separated by brackets both for
139 * readability and variable scoping). The first part performs the 139 * readability and variable scoping). The first part performs the
140 * operastions related to finishing off the last buffer we fed to the DMA. 140 * operations related to finishing off the last buffer we fed to the DMA.
141 * The second part performs the operations involved in sending a new buffer 141 * The second part detects the end of playlist condition when the pcm
142 * to the DMA. Finally the function checks the status of the buffer and 142 * buffer is empty except for uncommitted samples. Then they are committed.
143 * boosts if necessary */ 143 * The third part performs the operations involved in sending a new buffer
144 * to the DMA. */
144static void pcmbuf_callback(unsigned char** start, size_t* size) ICODE_ATTR; 145static void pcmbuf_callback(unsigned char** start, size_t* size) ICODE_ATTR;
145static void pcmbuf_callback(unsigned char** start, size_t* size) 146static void pcmbuf_callback(unsigned char** start, size_t* size)
146{ 147{
@@ -164,6 +165,15 @@ static void pcmbuf_callback(unsigned char** start, size_t* size)
164 if (pcmbuf_current == crossfade_chunk) 165 if (pcmbuf_current == crossfade_chunk)
165 crossfade_chunk = pcmbuf_read; 166 crossfade_chunk = pcmbuf_read;
166 } 167 }
168
169 {
170 /* Commit last samples at end of playlist */
171 if (audiobuffer_fillpos && !pcmbuf_read)
172 {
173 logf("pcmbuf callback: commit last samples");
174 pcmbuf_flush_fillpos();
175 }
176 }
167 177
168 { 178 {
169 /* Send the new buffer to the pcm */ 179 /* Send the new buffer to the pcm */
@@ -1109,11 +1119,3 @@ bool pcmbuf_is_crossfade_enabled(void)
1109 1119
1110 return crossfade_enabled; 1120 return crossfade_enabled;
1111} 1121}
1112
1113/** PLAY LAST REMAINING SAMPLES AT END OF PLAYBACK
1114 * Commit any remaining samples in the PCM buffer for playback. */
1115void pcmbuf_play_remainder(void)
1116{
1117 if (audiobuffer_fillpos)
1118 pcmbuf_flush_fillpos();
1119}