aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-03-05 13:45:37 +1000
committerinmarket <andrewh@inmarket.com.au>2014-03-05 13:45:37 +1000
commite762e91bd5d5347071c3b43fbdb021376584c267 (patch)
treefdb17e76a67cc9eb163735dd7adf5d2911fd27ee /drivers
parent68a0be8110d2dea408890f819bae443b9b476f84 (diff)
downloaduGFX-e762e91bd5d5347071c3b43fbdb021376584c267.tar.gz
uGFX-e762e91bd5d5347071c3b43fbdb021376584c267.tar.bz2
uGFX-e762e91bd5d5347071c3b43fbdb021376584c267.zip
Updates to GAUDOUT.
Add Events to the GAUDOUT api.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/audio/Win32/gaudout_lld.c17
-rw-r--r--drivers/audio/Win32/gaudout_lld_config.h19
2 files changed, 15 insertions, 21 deletions
diff --git a/drivers/audio/Win32/gaudout_lld.c b/drivers/audio/Win32/gaudout_lld.c
index fd70c80b..4fa6d605 100644
--- a/drivers/audio/Win32/gaudout_lld.c
+++ b/drivers/audio/Win32/gaudout_lld.c
@@ -77,16 +77,14 @@ static bool_t senddata(WAVEHDR *pwh) {
pwh->dwFlags = 0;
pwh->dwLoops = 0;
if (waveOutPrepareHeader(ah, pwh, sizeof(WAVEHDR))) {
- pwh->lpData = 0;
fprintf(stderr, "GAUDOUT: Failed to prepare a buffer");
- return FALSE;
+ exit(-1);
}
// Send it to windows
if (waveOutWrite(ah, pwh, sizeof(WAVEHDR))) {
- pwh->lpData = 0;
fprintf(stderr, "GAUDOUT: Failed to write the buffer");
- return FALSE;
+ exit(-1);
}
nQueuedBuffers++;
@@ -114,8 +112,11 @@ static DWORD WINAPI waveProc(LPVOID arg) {
nQueuedBuffers--;
// Try and get a new block
- if (isRunning)
- senddata(pwh);
+ if ((!isRunning || !senddata(pwh)) && !nQueuedBuffers) {
+ gfxSystemLock();
+ gaudoutDoneI();
+ gfxSystemUnlock();
+ }
break;
}
}
@@ -145,7 +146,7 @@ bool_t gaudout_lld_init(uint16_t channel, uint32_t frequency, ArrayDataFormat fo
if (!waveThread) {
if (!(waveThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)waveProc, 0, 0, &threadID))) {
fprintf(stderr, "GAUDOUT: Can't create WAVE play-back thread\n");
- return FALSE;
+ exit(-1);
}
CloseHandle(waveThread);
}
@@ -160,7 +161,7 @@ bool_t gaudout_lld_init(uint16_t channel, uint32_t frequency, ArrayDataFormat fo
if (waveOutOpen(&ah, WAVE_MAPPER, &wfx, (DWORD_PTR)threadID, 0, CALLBACK_THREAD)) {
fprintf(stderr, "GAUDOUT: Can't open WAVE play-back device\n");
- return FALSE;
+ exit(-1);
}
return TRUE;
diff --git a/drivers/audio/Win32/gaudout_lld_config.h b/drivers/audio/Win32/gaudout_lld_config.h
index 157f33f0..0fb90508 100644
--- a/drivers/audio/Win32/gaudout_lld_config.h
+++ b/drivers/audio/Win32/gaudout_lld_config.h
@@ -23,27 +23,20 @@
/*===========================================================================*/
/**
- * @brief The audio input sample type
- */
-//typedef uint8_t audout_sample_t;
-typedef int16_t audout_sample_t;
-
-/**
* @brief The maximum sample frequency supported by this audio device
*/
-#define GAUDOUT_MAX_SAMPLE_FREQUENCY 44100
+#define GAUDOUT_MAX_SAMPLE_FREQUENCY 44100
/**
- * @brief The number of bits in a sample
+ * @brief The number of audio formats supported by this driver
*/
-//#define GAUDOUT_BITS_PER_SAMPLE 8
-#define GAUDOUT_BITS_PER_SAMPLE 16
+#define GAUDOUT_NUM_FORMATS 2
/**
- * @brief The format of an audio sample
+ * @brief The available audio sample formats in order of preference
*/
-//#define GAUDOUT_SAMPLE_FORMAT ARRAY_DATA_8BITUNSIGNED
-#define GAUDOUT_SAMPLE_FORMAT ARRAY_DATA_16BITSIGNED
+#define GAUDOUT_FORMAT1 ARRAY_DATA_16BITSIGNED
+#define GAUDOUT_FORMAT2 ARRAY_DATA_8BITUNSIGNED
/**
* @brief The number of audio channels supported by this driver