version 1.25, 2011/05/09 17:32:27 |
version 1.26, 2011/06/03 10:05:27 |
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
|
|
|
#include <fcntl.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <fcntl.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
#include "abuf.h" |
#include "abuf.h" |
|
|
} |
} |
|
|
/* |
/* |
|
* determine the header by the file name |
|
*/ |
|
unsigned |
|
wav_autohdr(char *name, unsigned hdr) |
|
{ |
|
size_t len; |
|
|
|
if (hdr != HDR_AUTO) |
|
return hdr; |
|
if (name == NULL) |
|
return HDR_RAW; |
|
len = strlen(name); |
|
if (len >= 4 && strcasecmp(name + len - 4, ".wav") == 0) |
|
return HDR_WAV; |
|
else |
|
return HDR_RAW; |
|
} |
|
|
|
/* |
* create a file reader in the ``INIT'' state |
* create a file reader in the ``INIT'' state |
*/ |
*/ |
struct wav * |
struct wav * |
|
|
int fd; |
int fd; |
struct wav *f; |
struct wav *f; |
|
|
|
hdr = wav_autohdr(name, hdr); |
if (name != NULL) { |
if (name != NULL) { |
fd = open(name, O_RDONLY | O_NONBLOCK, 0666); |
fd = open(name, O_RDONLY | O_NONBLOCK, 0666); |
if (fd < 0) { |
if (fd < 0) { |
|
|
f->join = join; |
f->join = join; |
f->mode = mode; |
f->mode = mode; |
f->hpar = *par; |
f->hpar = *par; |
f->hdr = 0; |
f->hdr = hdr; |
f->xrun = xrun; |
f->xrun = xrun; |
f->maxweight = MIDI_TO_ADATA(volctl); |
f->maxweight = MIDI_TO_ADATA(volctl); |
f->slot = ctl_slotnew(f->dev->midi, "play", &ctl_wavops, f, 1); |
f->slot = ctl_slotnew(f->dev->midi, "play", &ctl_wavops, f, 1); |
|
|
int fd; |
int fd; |
struct wav *f; |
struct wav *f; |
|
|
|
hdr = wav_autohdr(name, hdr); |
if (name == NULL) { |
if (name == NULL) { |
name = "stdout"; |
name = "stdout"; |
fd = STDOUT_FILENO; |
fd = STDOUT_FILENO; |