This commit is contained in:
zeromus 2006-07-28 05:08:13 +00:00
parent 364650988e
commit ad4f663177
8 changed files with 0 additions and 20795 deletions

View File

@ -1,14 +0,0 @@
#include "sexyal.h"
#include "convert.h"
static inline uint16_t FLIP16(uint16_t b)
{
return((b<<8)|((b>>8)&0xFF));
}
static inline uint32_t FLIP32(uint32_t b)
{
return( (b<<24) | ((b>>8)&0xFF00) | ((b<<8)&0xFF0000) | ((b>>24)&0xFF) );
}
#include "convert.inc"

View File

@ -1,2 +0,0 @@
void SexiALI_Convert(SexyAL_format *srcformat, SexyAL_format *destformat, void *vdest, void *vsrc, uint32_t frames);

File diff suppressed because it is too large Load Diff

View File

@ -1,155 +0,0 @@
#include <stdio.h>
char *check[]={"SEXYAL_FMT_PCMS8","SEXYAL_FMT_PCMU8","SEXYAL_FMT_PCMS16",
"SEXYAL_FMT_PCMU16","SEXYAL_FMT_PCMS32S16","SEXYAL_FMT_PCMU32U16","SEXYAL_FMT_PCMS32S24","SEXYAL_FMT_PCMU32U24"};
char *str[]={"int8_t","uint8_t","int16_t","uint16_t","int32_t","uint32_t","int32_t","uint32_t"};
int bitss[]={8,8,16,16,16,16,24,24};
int bitsreal[]={8,8,16,16,32,32,32,32};
void Fetch(int x,char *wt)
{
//printf(" int32_t tmp%s=*src;\n",wt);
printf("tmp%s=*src;\n",wt);
printf(" src++;\n");
}
void BitConv(int src, int dest, char *wt)
{
if((src^dest)&1) /* signed/unsigned change. */
if(src&1) /* Source unsigned, dest signed. */
{
if(src==1) printf(" tmp%s-=128;\n",wt);
else if(src==3) printf(" tmp%s-=32768;\n",wt);
else if(src==5) printf(" tmp%s-=32768;\n",wt);
else if(src==7) printf(" tmp%s-=(1<<23);\n",wt);
}
else /* Source signed, dest unsigned */
{
if(src==0) printf(" tmp%s+=128;\n",wt);
else if(src==2) printf(" tmp%s+=32768;\n",wt);
else if(src==4) printf(" tmp%s+=32768;\n",wt);
else if(src==6) printf(" tmp%s+=(1<<23);\n",wt);
}
if((src>>1) != (dest>>1))
{
int shifty=bitss[src]-bitss[dest];
if(shifty>0)
printf(" tmp%s >>= %d;\n",wt,shifty);
else
printf(" tmp%s <<= %d;\n",wt,-shifty);
}
}
void Save(int x, char *wt)
{
printf(" *dest=tmp%s;\n",wt);
printf(" dest++;\n");
}
main()
{
int srcbits,destbits,srcchannels,destchannels;
int srcbo,destbo;
puts("void SexiALI_Convert(SexyAL_format *srcformat, SexyAL_format *destformat, void *vdest, void *vsrc, uint32_t frames)");
puts("{");
for(srcbits=0;srcbits<8;srcbits++)
{
printf("if(srcformat->sampformat == %s)\n{\n",check[srcbits]);
printf("%s* src=vsrc;\n",str[srcbits]);
for(destbits=0;destbits<8;destbits++)
{
printf("if(destformat->sampformat == %s)\n{\n",check[destbits]);
printf("%s* dest=vdest;\n",str[destbits]);
for(srcchannels=0;srcchannels<2;srcchannels++)
{
printf("if(srcformat->channels == %c)\n{\n",'1'+srcchannels);
for(destchannels=0;destchannels<2;destchannels++)
{
printf("if(destformat->channels == %c)\n{\n",'1'+destchannels);
for(srcbo=0;srcbo<2;srcbo++)
{
printf("if(srcformat->byteorder == %d)\n{\n",srcbo);
for(destbo=0;destbo<2;destbo++)
{
printf("if(destformat->byteorder == %d)\n{\n",destbo);
//printf("if(srcformat->sampformat==%s && destformat->sameck[srcbits],check[destbits]);
printf("while(frames--)\n{\n");
puts("int32_t tmp;");
if(srcchannels)
puts("int32_t tmp2;");
Fetch(srcbits,"");
if(srcbo)
{
if(bitsreal[srcbits]==16)
puts("FLIP16(tmp);");
else
puts("FLIP32(tmp);");
}
if(srcchannels)
{
Fetch(srcbits,"2");
if(srcbo)
{
if(bitsreal[srcbits]==16)
puts("FLIP16(tmp2);");
else
puts("FLIP32(tmp2);");
}
}
BitConv(srcbits,destbits,"");
if(srcchannels) BitConv(srcbits,destbits,"2");
if(destbo)
{
if(bitsreal[srcbits]==16)
puts("FLIP16(tmp);");
else
puts("FLIP32(tmp);");
if(srcchannels && destchannels && destbo)
{
if(bitsreal[srcbits]==16)
puts("FLIP16(tmp2);");
else
puts("FLIP32(tmp2);");
}
}
if(srcchannels && !destchannels)
printf("tmp = (tmp+tmp2)>>1;\n");
Save(destbits,"");
if(!srcchannels && destchannels)
Save(destbits,"");
if(srcchannels && destchannels)
Save(destbits,"2");
puts("}");
puts("}");
} // destbo
puts("}");
} // srcbo
puts("}");
}
puts("}");
}
puts("}");
}
puts("}");
}
puts("}");
}

View File

@ -1,115 +0,0 @@
#include <stdlib.h>
#include <string.h>
#include "sexyal.h"
#include "convert.h"
#ifdef WIN32
#else
#include "drivers/oss.h"
#endif
static uint32_t FtoB(const SexyAL_format *format, uint32_t frames)
{
return(frames*format->channels*(format->sampformat>>4));
}
/*
static uint32_t BtoF(const SexyAL_format *format, uint32_t bytes)
{
return(bytes / (format->channels * (format->sampformat>>4)));
}
*/
static uint32_t CanWrite(SexyAL_device *device)
{
uint32_t bytes,frames;
#ifdef WIN32
bytes=SexyALI_DSound_RawCanWrite(device);
#else
bytes=SexyALI_OSS_RawCanWrite(device);
#endif
frames=bytes / device->format.channels / (device->format.sampformat>>4);
return(frames);
}
static uint32_t Write(SexyAL_device *device, void *data, uint32_t frames)
{
uint8_t buffer[2048*4];
while(frames)
{
int32_t tmp;
tmp=frames;
if(tmp>2048)
{
tmp=2048;
frames-=2048;
}
else frames-=tmp;
SexiALI_Convert(&device->srcformat, &device->format, buffer, data, tmp);
//printf("%02x, %02x, %02x\n", device->srcformat.sampformat, device->srcformat.byteorder, device->srcformat.channels);
//printf("buffer: %d\n",buffer[0]);
/* FIXME: Return the actual number of frame written. It should always equal
the number of frames requested to be written, except in cases of sound device
failures.
*/
#ifdef WIN32
SexyALI_DSound_RawWrite(device,buffer,FtoB(&device->format,tmp));
#else
SexyALI_OSS_RawWrite(device,buffer,FtoB(&device->format,tmp));
#endif
}
return(frames);
}
static int Close(SexyAL_device *device)
{
#ifdef WIN32
return(SexyALI_DSound_Close(device));
#else
return(SexyALI_OSS_Close(device));
#endif
}
int SetConvert(struct __SexyAL_device *device, SexyAL_format *format)
{
memcpy(&device->srcformat,format,sizeof(SexyAL_format));
return(1);
}
static SexyAL_device *Open(SexyAL *iface, uint64_t id, SexyAL_format *format, SexyAL_buffering *buffering)
{
SexyAL_device *ret;
#ifdef WIN32
if(!(ret=SexyALI_DSound_Open(id,format,buffering))) return(0);
#else
if(!(ret=SexyALI_OSS_Open(id,format,buffering))) return(0);
#endif
ret->Write=Write;
ret->Close=Close;
ret->CanWrite=CanWrite;
ret->SetConvert=SetConvert;
return(ret);
}
void Destroy(SexyAL *iface)
{
free(iface);
}
void *SexyAL_Init(int version)
{
SexyAL *iface;
if(!version != 1) return(0);
iface=malloc(sizeof(SexyAL));
iface->Open=Open;
iface->Destroy=Destroy;
return((void *)iface);
}

View File

@ -1,52 +0,0 @@
#include <inttypes.h>
typedef struct
{
uint32_t sampformat;
uint32_t channels; /* 1 = mono, 2 = stereo */
uint32_t rate; /* Number of frames per second, 22050, 44100, etc. */
uint32_t byteorder; /* 0 = Native(to CPU), 1 = Reversed. PDP can go to hell. */
} SexyAL_format;
typedef struct
{
uint32_t fragcount;
uint32_t fragsize;
uint32_t totalsize; /* Shouldn't be filled in by application code. */
uint32_t ms; /* Milliseconds of buffering, approximate. */
} SexyAL_buffering;
#define SEXYAL_ID_DEFAULT 0
#define SEXYAL_ID_UNUSED 1
#define SEXYAL_FMT_PCMU8 0x10
#define SEXYAL_FMT_PCMS8 0x11
#define SEXYAL_FMT_PCMU16 0x20
#define SEXYAL_FMT_PCMS16 0x21
#define SEXYAL_FMT_PCMU32U24 0x40
#define SEXYAL_FMT_PCMS32S24 0x41
#define SEXYAL_FMT_PCMU32U16 0x42
#define SEXYAL_FMT_PCMS32S16 0x43
typedef struct __SexyAL_device {
int (*SetConvert)(struct __SexyAL_device *, SexyAL_format *);
uint32_t (*Write)(struct __SexyAL_device *, void *data, uint32_t frames);
uint32_t (*CanWrite)(struct __SexyAL_device *);
int (*Close)(struct __SexyAL_device *);
SexyAL_format format;
SexyAL_format srcformat;
SexyAL_buffering buffering;
void *private;
} SexyAL_device;
typedef struct __SexyAL {
SexyAL_device * (*Open)(struct __SexyAL *, uint64_t id, SexyAL_format *, SexyAL_buffering *buffering);
void (*Enumerate)(struct __SexyAL *, int (*func)(uint8_t *name, uint64_t id, void *udata));
void (*Destroy)(struct __SexyAL *);
} SexyAL;
/* Initializes the library, requesting the interface of the version specified. */
void *SexyAL_Init(int version);

View File

@ -1,63 +0,0 @@
#include "smallc.h"
void sal_memcpy(void *dest, const void *src, uint32_t n)
{
while(n--)
{
*(uint8_t*)dest=*(uint8_t *)src;
(uint8_t*)dest++;
(uint8_t*)src++;
}
}
uint32_t sal_strlen(const char *buf)
{
uint32_t size=0;
while(*buf++) size++;
return(size);
}
void sal_strcpy(char *dest, const char *src)
{
while(*src)
*dest++ = *src++;
*dest=0;
}
void sal_strcat(char *dest, const char *src)
{
while(*dest)
dest++;
while(*src)
*dest++ = *src++;
*dest=0;
}
const char *sal_uinttos(int value)
{
static char buf[64],buf2[64];
char *tmp;
int len=0;
tmp=buf;
while(value)
{
*tmp='0'+(value%10);
len++;
tmp++;
value/=10;
}
tmp=buf2;
while(len-- >= 0)
{
*tmp=buf[len];
tmp++;
}
*tmp=0;
return(buf2);
}

View File

@ -1,7 +0,0 @@
#include <inttypes.h>
void sal_memcpy(void *dest, const void *src, uint32_t n);
void sal_strcpy(char *dest, const char *src);
const char *sal_uinttos(int value);
void sal_strcat(char *dest, const char *src);