This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch by Zhi-Qiang Lei. See also http://sourceforge.net/p/cmusphinx/bugs/389/ git-svn-id: svn+ssh://svn.code.sf.net/p/cmusphinx/code/trunk/sphinxbase@12610 94700074-3cef-4d97-a70e-9c8c206c02f5
- Loading branch information
nshmyrev
committed
Sep 23, 2014
1 parent
961e928
commit 5cc55c4
Showing
8 changed files
with
116 additions
and
576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include <config.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
#include "ad.h" | ||
|
||
ad_rec_t * | ||
ad_open_dev(const char * dev, int32 samples_per_sec) | ||
{ | ||
ad_rec_t * handle = malloc(sizeof(ad_rec_t)); | ||
|
||
if (handle == NULL) { | ||
fprintf(stderr, "%s\n", "failed to allocate memory"); | ||
abort(); | ||
} | ||
|
||
handle -> device = alcCaptureOpenDevice(dev, samples_per_sec, AL_FORMAT_MONO16, samples_per_sec * 10); | ||
|
||
if (handle -> device == NULL) { | ||
free(handle); | ||
fprintf(stderr, "%s\n", "failed to open capture device"); | ||
abort(); | ||
} | ||
|
||
return handle; | ||
} | ||
|
||
|
||
ad_rec_t * | ||
ad_open_sps(int32 samples_per_sec) | ||
{ | ||
return ad_open_dev(NULL, samples_per_sec); | ||
} | ||
|
||
ad_rec_t * | ||
ad_open(void) | ||
{ | ||
return ad_open_sps(DEFAULT_SAMPLES_PER_SEC); | ||
} | ||
|
||
|
||
int32 | ||
ad_start_rec(ad_rec_t * r) | ||
{ | ||
alcCaptureStart(r -> device); | ||
return 0; | ||
} | ||
|
||
|
||
int32 | ||
ad_stop_rec(ad_rec_t * r) | ||
{ | ||
alcCaptureStop(r -> device); | ||
return 0; | ||
} | ||
|
||
|
||
int32 | ||
ad_read(ad_rec_t * r, int16 * buf, int32 max) | ||
{ | ||
ALCint number; | ||
|
||
alcGetIntegerv(r -> device, ALC_CAPTURE_SAMPLES, sizeof(number), &number); | ||
if (number >= 0) { | ||
number = (number < max ? number : max); | ||
alcCaptureSamples(r -> device, buf, number); | ||
} | ||
|
||
return number; | ||
} | ||
|
||
|
||
int32 | ||
ad_close(ad_rec_t * r) | ||
{ | ||
ALCboolean isClosed; | ||
|
||
isClosed = alcCaptureCloseDevice(r -> device); | ||
|
||
if (isClosed) { | ||
return 0; | ||
} else { | ||
return -1; | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.