summaryrefslogtreecommitdiffstats
path: root/apps/pcmbuf.c
diff options
context:
space:
mode:
authorJeffrey Goode <jeffg7@gmail.com>2009-11-09 06:53:22 +0000
committerJeffrey Goode <jeffg7@gmail.com>2009-11-09 06:53:22 +0000
commit73c4791da0018c1fbe366cf21836d1d719f7e9a0 (patch)
treed993c24666f7864be06ced737396019b6a040c7c /apps/pcmbuf.c
parent6008c29e5e18a6978690685f2c0d645bc1ab92f9 (diff)
downloadrockbox-73c4791da0018c1fbe366cf21836d1d719f7e9a0.tar.gz
rockbox-73c4791da0018c1fbe366cf21836d1d719f7e9a0.tar.bz2
rockbox-73c4791da0018c1fbe366cf21836d1d719f7e9a0.zip
pcmbuf: eliminate add_chunk as a separate function
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23582 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/pcmbuf.c')
-rw-r--r--apps/pcmbuf.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index 6cbd4556b6..a39a69a21c 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -184,10 +184,27 @@ static bool show_desc(char *caller)
/* Commit PCM data */
-/* This is really just part of commit_chunk, but is easier to keep
- * in a separate function for the moment */
-static inline void pcmbuf_add_chunk(void)
+/**
+ * Commit samples waiting to the pcm buffer.
+ */
+static void commit_chunk(void)
{
+ if (!pcmbuffer_fillpos)
+ return;
+
+ /* Never use the last buffer descriptor */
+ while (write_chunk == write_end_chunk) {
+ /* If this happens, something is being stupid */
+ if (!pcm_is_playing()) {
+ logf("commit_chunk error");
+ pcmbuf_play_start();
+ }
+ /* Let approximately one chunk of data playback */
+ sleep(HZ*PCMBUF_TARGET_CHUNK/(NATIVE_FREQUENCY*4));
+ }
+
+ /* commit the chunk */
+
register size_t size = pcmbuffer_fillpos;
/* Grab the next description to write, and change the write pointer */
register struct chunkdesc *pcmbuf_current = write_chunk;
@@ -198,9 +215,13 @@ static inline void pcmbuf_add_chunk(void)
pcmbuf_current->end_of_track = end_of_track;
pcmbuf_current->link = NULL;
end_of_track = false; /* This is single use only */
- if (read_chunk != NULL) {
+
+ if (read_chunk != NULL)
+ {
if (flush_pcmbuf)
{
+ /* flush! discard all data after the currently playing chunk,
+ and make the current chunk play next */
write_end_chunk->link = read_chunk->link;
read_chunk->link = pcmbuf_current;
while (write_end_chunk->link)
@@ -213,10 +234,13 @@ static inline void pcmbuf_add_chunk(void)
/* If there is already a read buffer setup, add to it */
else
read_end_chunk->link = pcmbuf_current;
- } else {
+ }
+ else
+ {
/* Otherwise create the buffer */
read_chunk = pcmbuf_current;
}
+
/* This is now the last buffer to read */
read_end_chunk = pcmbuf_current;
@@ -228,29 +252,7 @@ static inline void pcmbuf_add_chunk(void)
pcmbuffer_pos -= pcmbuf_size;
pcmbuffer_fillpos = 0;
- DISPLAY_DESC("add_chunk");
-}
-
-/**
- * Commit samples waiting to the pcm buffer.
- */
-static bool commit_chunk(void)
-{
- if (pcmbuffer_fillpos) {
- /* Never use the last buffer descriptor */
- while (write_chunk == write_end_chunk) {
- /* If this happens, something is being stupid */
- if (!pcm_is_playing()) {
- logf("commit_chunk error");
- pcmbuf_play_start();
- }
- /* Let approximately one chunk of data playback */
- sleep(HZ*PCMBUF_TARGET_CHUNK/(NATIVE_FREQUENCY*4));
- }
- pcmbuf_add_chunk();
- return true;
- }
- return false;
+ DISPLAY_DESC("commit_chunk");
}
#ifdef HAVE_PRIORITY_SCHEDULING