diff options
author | Joel Bodenmann <joel@unormal.org> | 2014-04-30 13:41:34 +0200 |
---|---|---|
committer | Joel Bodenmann <joel@unormal.org> | 2014-04-30 13:41:34 +0200 |
commit | 33c721c009465dd30d4e96e055a051480c567b57 (patch) | |
tree | 5a6744a79b7469d80bae474d4314b47d4cd6d44d /demos/modules/gaudio/play-wave/main.c | |
parent | 58cf2d2b35542166f1a4e50a83bcf28ff33574a5 (diff) | |
parent | a394e2c35dde67241bea69409bcae9f46dcfc089 (diff) | |
download | uGFX-33c721c009465dd30d4e96e055a051480c567b57.tar.gz uGFX-33c721c009465dd30d4e96e055a051480c567b57.tar.bz2 uGFX-33c721c009465dd30d4e96e055a051480c567b57.zip |
Merge branch 'master' into freertos
Diffstat (limited to 'demos/modules/gaudio/play-wave/main.c')
-rw-r--r-- | demos/modules/gaudio/play-wave/main.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/demos/modules/gaudio/play-wave/main.c b/demos/modules/gaudio/play-wave/main.c index f15ec7a1..888e4c8e 100644 --- a/demos/modules/gaudio/play-wave/main.c +++ b/demos/modules/gaudio/play-wave/main.c @@ -52,7 +52,7 @@ int main(void) { uint32_t frequency; ArrayDataFormat datafmt; uint32_t len; - GAudioData *paud; + GDataBuffer *pd; // Initialise everything gfxInit(); @@ -64,11 +64,12 @@ int main(void) { // Allocate audio buffers - 4 x 512 byte buffers. // You may need to increase this for slower cpu's. // You may be able to decrease this for low latency operating systems. - if (!gaudioAllocBuffers(4, 512)) { + if (!gfxBufferAlloc(4, 512)) { errmsg = "Err: No Memory"; goto theend; } +repeatplay: // Open the wave file if (!(f = gfileOpen("allwrong.wav", "r"))) { errmsg = "Err: Open WAV"; @@ -164,20 +165,20 @@ int main(void) { gdispDrawString(0, gdispGetHeight()/2, "Playing...", font, Yellow); while(toplay) { // Get a buffer to put the data into - paud = gaudioGetBuffer(TIME_INFINITE); // This should never fail as we are waiting forever + pd = gfxBufferGet(TIME_INFINITE); // This should never fail as we are waiting forever // How much data can we put in - len = toplay > paud->size ? paud->size : toplay; - paud->len = len; + len = toplay > pd->size ? pd->size : toplay; + pd->len = len; toplay -= len; // Read the data - if (gfileRead(f, paud+1, len) != len) { + if (gfileRead(f, pd+1, len) != len) { errmsg = "Err: Read fail"; goto theend; } - gaudioPlay(paud); + gaudioPlay(pd); } gfileClose(f); @@ -185,6 +186,11 @@ int main(void) { gaudioPlayWait(TIME_INFINITE); gdispDrawString(0, gdispGetHeight()/2+10, "Done", font, Green); + // Repeat the whole thing + gfxSleepMilliseconds(1500); + gdispClear(Black); + goto repeatplay; + // The end theend: if (errmsg) |