d25c9c8168
The CELT codec is an experimental audio codec for use in low-delay speech and audio communication. It's meant to close the gap between Vorbis and Speex for applications where both high quality audio and low delay are desired. This package contains the celt 0.7 API. A requirement for the upcoming audio/mumble port.
82 lines
2.3 KiB
Plaintext
82 lines
2.3 KiB
Plaintext
$OpenBSD: patch-tools_celtdec_c,v 1.1.1.1 2013/10/01 10:09:51 dcoppa Exp $
|
|
|
|
Use sndio for audio
|
|
|
|
--- tools/celtdec.c.orig Sun Oct 18 03:37:21 2009
|
|
+++ tools/celtdec.c Fri May 31 07:41:29 2013
|
|
@@ -70,6 +70,9 @@
|
|
#include <fcntl.h>
|
|
#include <sys/ioctl.h>
|
|
|
|
+#elif defined USE_SNDIO
|
|
+#include <sndio.h>
|
|
+
|
|
#elif defined HAVE_SYS_AUDIOIO_H
|
|
#include <sys/types.h>
|
|
#include <fcntl.h>
|
|
@@ -92,6 +95,10 @@
|
|
((buf[base+1]<<8)&0xff00)| \
|
|
(buf[base]&0xff))
|
|
|
|
+#ifdef USE_SNDIO
|
|
+struct sio_hdl *hdl;
|
|
+#endif
|
|
+
|
|
static void print_comments(char *comments, int length)
|
|
{
|
|
char *c=comments;
|
|
@@ -187,6 +194,32 @@ FILE *out_file_open(char *outFile, int rate, int *chan
|
|
exit(1);
|
|
}
|
|
fout = fdopen(audio_fd, "w");
|
|
+#elif defined USE_SNDIO
|
|
+ struct sio_par par;
|
|
+
|
|
+ hdl = sio_open(NULL, SIO_PLAY, 0);
|
|
+ if (!hdl)
|
|
+ {
|
|
+ fprintf(stderr, "Cannot open sndio device\n");
|
|
+ exit(1);
|
|
+ }
|
|
+
|
|
+ sio_initpar(&par);
|
|
+ par.sig = 1;
|
|
+ par.bits = 16;
|
|
+ par.rate = rate;
|
|
+ par.pchan = *channels;
|
|
+
|
|
+ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) ||
|
|
+ par.sig != 1 || par.bits != 16 || par.rate != rate) {
|
|
+ fprintf(stderr, "could not set sndio parameters\n");
|
|
+ exit(1);
|
|
+ }
|
|
+ *channels = par.pchan;
|
|
+ if (!sio_start(hdl)) {
|
|
+ fprintf(stderr, "could not start sndio\n");
|
|
+ exit(1);
|
|
+ }
|
|
#elif defined HAVE_SYS_AUDIOIO_H
|
|
audio_info_t info;
|
|
int audio_fd;
|
|
@@ -615,6 +648,10 @@ int main(int argc, char **argv)
|
|
if (strlen(outFile)==0)
|
|
WIN_Play_Samples (out+frame_offset*channels, sizeof(short) * new_frame_size*channels);
|
|
else
|
|
+#elif defined USE_SNDIO
|
|
+ if (strlen(outFile)==0)
|
|
+ sio_write (hdl, out+frame_offset*channels, sizeof(short) * new_frame_size*channels);
|
|
+ else
|
|
#endif
|
|
fwrite(out+frame_offset*channels, sizeof(short), new_frame_size*channels, fout);
|
|
|
|
@@ -671,6 +708,9 @@ int main(int argc, char **argv)
|
|
fclose(fin);
|
|
if (fout != NULL)
|
|
fclose(fout);
|
|
+
|
|
+ if (print_bitrate)
|
|
+ fprintf (stderr, "\n");
|
|
|
|
return 0;
|
|
}
|