首页 > > 详细

调试C编程、C调试、解析C、C程序辅导留学生、辅导留学生C编程

# include
# include
# include
# include
# include
# include
# include
# include
# include
# include "mad.h"
struct buffer {
unsigned char const *start;
unsigned long length;
};
static int sfd; /* */
static int decode(unsigned char const *, unsigned long);
int main(int argc, char *argv[])
{
struct stat stat;
void *fdm;
char const *file;
int fd;
file = argv[1];
fd = open(file, O_RDONLY);
if ((sfd = open("/dev/dsp", O_WRONLY)) length)
return MAD_FLOW_STOP;
mad_stream_buffer(stream, buffer->start, buffer->length);
buffer->length = 0;
return MAD_FLOW_CONTINUE;
}
/*pcm */
static inline signed int scale(mad_fixed_t sample)
{
sample += (1L = MAD_F_ONE)
sample = MAD_F_ONE - 1;
else if (sample > (MAD_F_FRACBITS + 1 - 16);
}
static
enum mad_flow output(void *data,
struct mad_header const *header, struct mad_pcm *pcm)
{
unsigned int nchannels, nsamples, n;
mad_fixed_t const *left_ch, *right_ch;
unsigned char Output[6912], *OutputPtr;
int fmt, wrote, speed;

nchannels = pcm->channels;
n = nsamples = pcm->length;
left_ch = pcm->samples[0];
right_ch = pcm->samples[1];

fmt = AFMT_S16_LE;
speed = pcm->samplerate * 2; /* */
ioctl(sfd, SNDCTL_DSP_SPEED, (speed));
ioctl(sfd, SNDCTL_DSP_SETFMT, fmt);
ioctl(sfd, SNDCTL_DSP_CHANNELS, (pcm->channels));
utputPtr = Output;
while (nsamples--) {
signed int sample;
sample = scale(*left_ch++);
*(OutputPtr++) = sample >> 0;
*(OutputPtr++) = sample >> 8;
if (nchannels == 2) {
sample = scale(*right_ch++);
*(OutputPtr++) = sample >> 0;
*(OutputPtr++) = sample >> 8;
}
}
n *= 4; /*pcm4 */
utputPtr = Output;
while (n) {
wrote = write(sfd, OutputPtr, n);
OutputPtr += wrote;
n -= wrote;
}
utputPtr = Output;
return MAD_FLOW_CONTINUE;
}

static
enum mad_flow error(void *data,
struct mad_stream *stream, struct mad_frame. *frame)
{
return MAD_FLOW_CONTINUE;
}

static
int decode(unsigned char const *start, unsigned long length)
{
struct buffer buffer;
struct mad_decoder decoder;
int resu<
buffer.start = start;
buffer.length = length;
mad_decoder_init(decoder, buffer, input, 0, 0, output, error, 0);
mad_decoder_options(decoder, 0);
result = mad_decoder_run(decoder, MAD_DECODER_MODE_SYNC);
mad_decoder_finish(decoder);
return resu<
}

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!