資源簡介
mp3 播放器的linux c代碼

代碼片段和文件信息
/*
?*?libmad?-?MPEG?audio?decoder?library
?*?Copyright?(C)?2000-2004?Underbit?Technologies?Inc.
?*
?*?This?program?is?free?software;?you?can?redistribute?it?and/or?modify
?*?it?under?the?terms?of?the?GNU?General?Public?License?as?published?by
?*?the?Free?Software?Foundation;?either?version?2?of?the?License?or
?*?(at?your?option)?any?later?version.
?*
?*?This?program?is?distributed?in?the?hope?that?it?will?be?useful
?*?but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
?*?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the
?*?GNU?General?Public?License?for?more?details.
?*
?*?You?should?have?received?a?copy?of?the?GNU?General?Public?License
?*?along?with?this?program;?if?not?write?to?the?Free?Software
?*?Foundation?Inc.?59?Temple?Place?Suite?330?Boston?MA??02111-1307??USA
?*
?*?$Id:?minimad.cv?1.4?2004/01/23?09:41:32?rob?Exp?$
?*/
#?include?
#?include?
#?include?
#?include?
#?include?“mad.h“
/*
?*?This?is?perhaps?the?simplest?example?use?of?the?MAD?high-level?API.
?*?Standard?input?is?mapped?into?memory?via?mmap()?then?the?high-level?API
?*?is?invoked?with?three?callbacks:?input?output?and?error.?The?output
?*?callback?converts?MAD‘s?high-resolution?PCM?samples?to?16?bits?then
?*?writes?them?to?standard?output?in?little-endian?stereo-interleaved
?*?format.
?*/
static?int?decode(unsigned?char?const?*?unsigned?long);
int?main(int?argc?char?*argv[])
{
??struct?stat?stat;
??void?*fdm;
??if?(argc?!=?1)
????return?1;
??if?(fstat(STDIN_FILENO?&stat)?==?-1?||
??????stat.st_size?==?0)
????return?2;
??fdm?=?mmap(0?stat.st_size?PROT_READ?MAP_SHARED?STDIN_FILENO?0);
??if?(fdm?==?MAP_FAILED)
????return?3;
??decode(fdm?stat.st_size);
??if?(munmap(fdm?stat.st_size)?==?-1)
????return?4;
??return?0;
}
/*
?*?This?is?a?private?message?structure.?A?generic?pointer?to?this?structure
?*?is?passed?to?each?of?the?callback?functions.?Put?here?any?data?you?need
?*?to?access?from?within?the?callbacks.
?*/
struct?buffer?{
??unsigned?char?const?*start;
??unsigned?long?length;
};
/*
?*?This?is?the?input?callback.?The?purpose?of?this?callback?is?to?(re)fill
?*?the?stream?buffer?which?is?to?be?decoded.?In?this?example?an?entire?file
?*?has?been?mapped?into?memory?so?we?just?call?mad_stream_buffer()?with?the
?*?address?and?length?of?the?mapping.?When?this?callback?is?called?a?second
?*?time?we?are?finished?decoding.
?*/
static
enum?mad_flow?input(void?*data
????struct?mad_stream?*stream)
{
??struct?buffer?*buffer?=?data;
??if?(!buffer->length)
????return?MAD_FLOW_STOP;
??mad_stream_buffer(stream?buffer->start?buffer->length);
??buffer->length?=?0;
??return?MAD_FLOW_CONTINUE;
}
/*
?*?The?following?utility?routine?performs?simple?rounding?clipping?and
?*?scaling?of?MAD‘s?high-resolution?samples?down?to?16?bits.?It?does?not
?*?perform?any?dithering?or?noise?shaping?which?would?be?recommended?to
?*?obtain?any?exceptional?audio?quality.?It?is?therefore?not?recommend
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????139??2012-07-01?00:41??mp3_test\Makefile
?????文件??????????61??2012-07-01?00:41??mp3_test\env.sh
?????文件???????27125??2012-07-01?00:41??mp3_test\mad.h
?????文件????????5935??2012-07-01?00:41??mp3_test\minimad.c
?????文件????????1577??2012-07-01?00:41??mp3_test\pcm_play.c
?????目錄???????????0??2005-05-20?16:20??mp3_test\
- 上一篇:簡易電子琴
- 下一篇:2012年數學建模全國一等獎論文
評論
共有 條評論