コード例 #1
0
ファイル: gaudio_play_lld.c プロジェクト: bhdminh/uGFX
static bool_t senddata(WAVEHDR *pwh) {
	GDataBuffer *paud;

	// Get the next data block to send
	gfxSystemLock();
	paud = gaudioPlayGetDataBlockI();
	if (!paud && !nQueuedBuffers)
		gaudioPlayDoneI();
	gfxSystemUnlock();
	if (!paud)
		return FALSE;

	// Prepare the wave header for Windows
	pwh->dwUser = (DWORD_PTR)paud;
	pwh->lpData = (LPSTR)(paud+1);			// The data is on the end of the structure
	pwh->dwBufferLength = paud->len;
	pwh->dwFlags = 0;
	pwh->dwLoops = 0;
	if (waveOutPrepareHeader(ah, pwh, sizeof(WAVEHDR))) {
		fprintf(stderr, "GAUDIO: Failed to prepare a play buffer");
		exit(-1);
	}

	// Send it to windows
	if (waveOutWrite(ah, pwh, sizeof(WAVEHDR))) {
		fprintf(stderr, "GAUDIO: Failed to write the play buffer");
		exit(-1);
	}

	nQueuedBuffers++;
	return TRUE;
}
コード例 #2
0
ファイル: gqueue.c プロジェクト: bigzed/uGFX
	bool_t gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, delaytime_t ms) {
		if (!pitem) return;				// Safety
		gfxSemInit(&pitem->sem, 0, 1);

		gfxSystemLock();
		if (pafter && gfxQueueGSyncIsInI(pqueue, pafter)) {
			pitem->next = pafter->next;
			pafter->next = pitem;
			if (pqueue->tail == pafter)
				pqueue->tail = pitem;
		} else {
			pitem->next = 0;
			if (!pqueue->head) {
				pqueue->head = pqueue->tail = pitem;
			} else {
				pqueue->tail->next = pitem;
				pqueue->tail = pitem;
			}
		}
		gfxSystemUnlock();

		gfxSemSignal(&pqueue->sem);

		return gfxSemWait(&pitem->sem, ms);

	}
コード例 #3
0
static bool_t getbuffer(WAVEHDR *pwh) {
	GDataBuffer *paud;

	// Get the next data block to send
	gfxSystemLock();
	paud = gaudioRecordGetFreeBlockI();
	if (!paud && !nQueuedBuffers)
		gaudioRecordDoneI();
	gfxSystemUnlock();
	if (!paud)
		return FALSE;

	// Prepare the wave header for Windows
	pwh->dwUser = (DWORD_PTR)paud;
	pwh->lpData = (LPSTR)(paud+1);			// The data is on the end of the structure
	pwh->dwBufferLength = paud->size;
	pwh->dwFlags = 0;
	if (waveInPrepareHeader(ah, pwh, sizeof(WAVEHDR))) {
		fprintf(stderr, "GAUDIO: Failed to prepare a record buffer");
		exit(-1);
	}

	// Send it to windows
	if (waveInAddBuffer(ah, pwh, sizeof(WAVEHDR))) {
		fprintf(stderr, "GAUDIO: Failed to add the record buffer");
		exit(-1);
	}

	nQueuedBuffers++;
	return TRUE;
}
コード例 #4
0
ファイル: gqueue.c プロジェクト: bigzed/uGFX
	void gfxQueueFSyncRemove(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem) {
		gfxQueueFSyncItem *pi;

		if (!pitem) return;				// Safety
		gfxSystemLock();
		if (pqueue->head) {
			if (pqueue->head == pitem) {
				pqueue->head = pitem->next;
			found:
				pitem->next = 0;
				gfxSystemUnlock();
				gfxSemSignal(&pitem->sem);
				gfxSemDestroy(&pitem->sem);
				return;
			}
			for(pi = pqueue->head; pi->next; pi = pi->next) {
				if (pi->next == pitem) {
					pi->next = pitem->next;
					if (pqueue->tail == pitem)
						pqueue->tail = pi;
					goto found;
				}
			}
		}
		gfxSystemUnlock();
	}
コード例 #5
0
ファイル: gqueue.c プロジェクト: abhishek-kakkar/ChibiOS-GFX
	void gfxQueueASyncPush(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) {
		gfxSystemLock();
		pitem->next = pqueue->head;
		pqueue->head = pitem;
		if (!pitem->next)
			pqueue->tail = pitem;
		gfxSystemUnlock();
	}
コード例 #6
0
ファイル: gqueue.c プロジェクト: bigzed/uGFX
	bool_t gfxQueueFSyncIsIn(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem) {
		bool_t	res;

		gfxSystemLock();
		res = gfxQueueFSyncIsInI(pqueue, pitem);
		gfxSystemUnlock();

		return res;
	}
コード例 #7
0
ファイル: gqueue.c プロジェクト: abhishek-kakkar/ChibiOS-GFX
	gfxQueueGSyncItem *gfxQueueGSyncGet(gfxQueueGSync *pqueue, delaytime_t ms) {
		gfxQueueGSyncItem	*pi;

		if (!gfxSemWait(&pqueue->sem, ms)) return 0;
		gfxSystemLock();
		pi = pqueue->head;
		pqueue->head = pi->next;
		gfxSytemUnlock();
		return pi;
	}
コード例 #8
0
ファイル: gqueue.c プロジェクト: abhishek-kakkar/ChibiOS-GFX
	gfxQueueASyncItem *gfxQueueASyncGet(gfxQueueASync *pqueue) {
		gfxQueueASyncItem	*pi;

		if (!pqueue->head) return 0;
		gfxSystemLock();
		if ((pi = pqueue->head))
			pqueue->head = pi->next;
		gfxSytemUnlock();
		return pi;
	}
コード例 #9
0
ファイル: gqueue.c プロジェクト: abhishek-kakkar/ChibiOS-GFX
	bool_t gfxQueueASyncIsIn(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) {
		gfxSystemLock();
		for(gfxQueueASyncItem *pi = pqueue->head; pi; pi = pi->next) {
			if (pi == pitem) {
				gfxSystemUnlock();
				return TRUE;
			}
		}
		gfxSystemUnlock();
		return FALSE;
	}
コード例 #10
0
static DWORD WINAPI waveProc(LPVOID arg) {
	MSG			msg;
	WAVEHDR		*pwh;
	GDataBuffer	*paud;
	(void)		arg;

	while (GetMessage(&msg, 0, 0, 0)) {
		switch (msg.message) {
			case MM_WIM_DATA:
				pwh = (WAVEHDR *)msg.lParam;

				// Windows - Let go!
				waveInUnprepareHeader(ah, pwh, sizeof(WAVEHDR));

				// Save the buffer in the audio record list
				paud = (GDataBuffer *)pwh->dwUser;
				paud->len = pwh->dwBytesRecorded;
				gfxSystemLock();
				gaudioRecordSaveDataBlockI(paud);
				gfxSystemUnlock();
				pwh->lpData = 0;
				nQueuedBuffers--;

				// Are we stopping?
				if (!isRunning) {
					// Have we finished yet?
					if (!nQueuedBuffers) {
						gfxSystemLock();
						gaudioRecordDoneI();
						gfxSystemUnlock();
					}
	                break;
				}

				// Try and get a new block
				getbuffer(pwh);
                break;
		}
	}
	return 0;
}
コード例 #11
0
ファイル: gqueue.c プロジェクト: abhishek-kakkar/ChibiOS-GFX
	void gfxQueueASyncPut(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) {
		pitem->next = 0;

		gfxSystemLock();
		if (!pqueue->head) {
			pqueue->head = pqueue->tail = pitem;
		} else {
			pqueue->tail->next = pitem;
			pqueue->tail = pitem;
		}
		gfxSystemUnlock();
	}
コード例 #12
0
ファイル: gqueue.c プロジェクト: abhishek-kakkar/ChibiOS-GFX
	bool_t gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms) {
		gfxSemInit(&pitem->sem, 0, 1);

		gfxSystemLock();
		pitem->next = pqueue->head;
		pqueue->head = pitem;
		if (!pitem->next)
			pqueue->tail = pitem;
		gfxSystemUnlock();

		gfxSemSignal(&pqueue->sem);
		return gfxSemWait(&pitem->sem, ms);
	}
コード例 #13
0
ファイル: gqueue.c プロジェクト: bigzed/uGFX
	gfxQueueASyncItem *gfxQueueASyncGet(gfxQueueASync *pqueue) {
		gfxQueueASyncItem	*pi;

		// This is just a shortcut to speed execution
		if (!pqueue->head)
			return 0;

		gfxSystemLock();
		pi = gfxQueueASyncGetI(pqueue);
		gfxSystemUnlock();

		return pi;
	}
コード例 #14
0
ファイル: gaudio_play_lld.c プロジェクト: bhdminh/uGFX
static DWORD WINAPI waveProc(LPVOID arg) {
	MSG			msg;
	WAVEHDR		*pwh;
	(void)		arg;

	while (GetMessage(&msg, 0, 0, 0)) {
		switch (msg.message) {
			case MM_WOM_DONE:
				pwh = (WAVEHDR *)msg.lParam;

				// Windows - Let go!
				waveOutUnprepareHeader(ah, pwh, sizeof(WAVEHDR));

				// Give the buffer back to the Audio Free List
				gfxSystemLock();
				gaudioPlayReleaseDataBlockI((GDataBuffer *)pwh->dwUser);
				gfxSystemUnlock();
				pwh->lpData = 0;
				nQueuedBuffers--;

				// Are we stopping?
				if (!isRunning) {
					// Have we finished yet?
					if (!nQueuedBuffers) {
						gfxSystemLock();
						gaudioPlayDoneI();
						gfxSystemUnlock();
					}
	                break;
				}

				// Try and get a new block
				senddata(pwh);
				break;
		}
	}
	return 0;
}
コード例 #15
0
ファイル: gqueue.c プロジェクト: bigzed/uGFX
	gfxQueueFSyncItem *gfxQueueFSyncGet(gfxQueueFSync *pqueue, delaytime_t ms) {
		gfxQueueFSyncItem	*pi;

		if (!gfxSemWait(&pqueue->sem, ms))
			return 0;

		gfxSystemLock();
		pi = pqueue->head;
		pqueue->head = pi->next;
		pi->next = 0;
		gfxSystemUnlock();

		gfxSemSignal(&pi->sem);
		gfxSemDestroy(&pi->sem);

		return pi;
	}
コード例 #16
0
ファイル: gqueue.c プロジェクト: bigzed/uGFX
	bool_t gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms) {
		if (!pitem) return;				// Safety
		gfxSemInit(&pitem->sem, 0, 1);
		pitem->next = 0;

		gfxSystemLock();
		if (!pqueue->head) {
			pqueue->head = pqueue->tail = pitem;
		} else {
			pqueue->tail->next = pitem;
			pqueue->tail = pitem;
		}
		gfxSystemUnlock();

		gfxSemSignal(&pqueue->sem);

		return gfxSemWait(&pitem->sem, ms);
	}
コード例 #17
0
ファイル: gqueue.c プロジェクト: abhishek-kakkar/ChibiOS-GFX
	void gfxQueueASyncRemove(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) {
		if (!pitem) return;
		gfxSystemLock();
		if (pqueue->head) {
			if (pqueue->head == pitem) {
				pqueue->head = pitem->next;
			} else {
				for(gfxQueueASyncItem *pi = pqueue->head; pi->next; pi = pi->next) {
					if (pi->next == pitem) {
						pi->next = pitem->next;
						if (pqueue->tail == pitem)
							pqueue->tail = pi;
						break;
					}
				}
			}
		}
		gfxSystemUnlock();
	}
コード例 #18
0
ファイル: gqueue.c プロジェクト: bigzed/uGFX
	void gfxQueueGSyncPut(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem) {
		gfxSystemLock();
		gfxQueueGSyncPutI(pqueue, pitem);
		gfxSystemUnlock();
	}
コード例 #19
0
ファイル: gqueue.c プロジェクト: bigzed/uGFX
	void gfxQueueGSyncRemove(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem) {
		gfxSystemLock();
		gfxQueueGSyncRemoveI(pqueue, pitem);
		gfxSystemUnlock();
	}
コード例 #20
0
ファイル: gaudin.c プロジェクト: abhishek-kakkar/ChibiOS-GFX
void gaudinSetBSem(gfxSem *pbsem, GEventAudioIn *pEvent) {
	gfxSystemLock();
	paudSem = pbsem;
	paudEvent = pEvent;
	gfxSystemUnlock();
}
コード例 #21
0
ファイル: gqueue.c プロジェクト: bigzed/uGFX
	void gfxQueueASyncInsert(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem, gfxQueueASyncItem *pafter) {
		gfxSystemLock();
		gfxQueueASyncInsertI(pqueue, pitem, pafter);
		gfxSystemUnlock();
	}
コード例 #22
0
ファイル: gqueue.c プロジェクト: bigzed/uGFX
	void gfxQueueASyncPush(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) {
		gfxSystemLock();
		gfxQueueASyncPushI(pqueue, pitem);
		gfxSystemUnlock();
	}