使用的linux內(nèi)核為2.6.14.1 MPlayer版本為MPlayer-1.0pre7try2.bz2
目前雖然已經(jīng)添加了mad的mp3庫,但播放聲音文件回導(dǎo)致mplayer錯(cuò)誤,放視頻還得禁掉聲音.
下面介紹下整個(gè)移植過程,也是參考了網(wǎng)上很多文章綜合而來的
=================================================================
1)編譯器最好選擇3.3.2 ,我使用3.4.1會(huì)出現(xiàn)snow.c編譯錯(cuò)誤,找不到解決辦法
解壓3.3.2到/usr/local/arm/下
并export PATH=/usr/local/arm/3.3.2/bin:$PATH
echo $PATH看看3.3.2是不是在第一個(gè)?
2)播放mp3需要禁掉mp3lib 而使用madlib ,據(jù)說如果使用mp3lib會(huì)占用2000%的CPU,可能嘛?
安裝libmad
(1).交叉編譯libmad
下載libmad包(libmad-0.15.1b.tar.gz);
打開一個(gè)終端,進(jìn)入libmad的目錄,輸入配置命令:
./configure --enable-fpm=arm --host=arm-linux --disable-shared --disable-debugging --prefix=/usr/local/arm/3.3.2/lib
CC=arm-linux-gcc(要保證arm-linux-gcc的路徑已經(jīng)有 export過,否則給出完整路徑。)
make
make install
這樣就可以看到 /usr/local/arm/3.3.2/lib 目錄下多了include和lib目錄,這些就是libmad相關(guān)的庫。
(2).在 configure mplayer的時(shí)候,要加上以下幾個(gè)選項(xiàng):
--enable-mad
--with-extraincdir=/usr/local/arm/3.3.2/lib/include(這個(gè)指明 mad.h 這個(gè)文件所在的路徑)
--with-extralibdir=/usr/local/arm/3.3.2/lib/lib(這個(gè)指明libmad相關(guān)鏈接庫所在的路徑)
通過以上兩個(gè)步驟,就可以把libmad交叉編譯到 mplayer中。
3)解壓MPlayer-1.0pre7try2.bz2,改名為mplayer ,方便而已
在此目錄下配置
./configure?? --cc=arm-linux-gcc?? --target=arm-armv4-linux?? --enable-static?? --disable-win32???? --disable-dvdread?? --enable-fbdev?? --disable-mencoder?? --disable-live?? --disable-mp3lib?? --enable-mad?? --enable-libavcodec?? --with-extraincdir=/usr/local/arm/3.3.2/arm-linux/sys-include/:/usr/local/arm/3.3.2/lib/include --with-extralibdir=/usr/local/arm/3.3.2/arm-linux/lib:/usr/local/arm/3.3.2/lib/lib --prefix=/tmp/mplayer --host-cc=gcc
4)make
當(dāng)然會(huì)有錯(cuò)誤
排錯(cuò)
錯(cuò)誤(1)
./codec-cfg ./etc/codecs.conf > codecs.conf.h
./codec-cfg: 1: Syntax error: word unexpected (expecting ")")
網(wǎng)上有兩種解決方法
A 說在configure時(shí)添加 --host-cc=gcc就可以解決
可是會(huì)出現(xiàn)其他庫找不到的錯(cuò)誤
猜想是指定了庫--with-extralibdir導(dǎo)致的,所以還得采用笨笨的B方案
B 引用原話
“ 先把mplayer編譯成x86的代碼,于是重新配置,簡(jiǎn)單的?? ./configure,?? make,然后將生成的codec-cfg改名為codec-cfg.x86。
然后再按跨平臺(tái)方式配置,編譯,等編譯器出現(xiàn)錯(cuò)誤停止編譯時(shí),將codec-cfg.x86該名為codec-cfg,再make,OK,編譯就可以繼續(xù)進(jìn)行了。”
的確可行
錯(cuò)誤(2)vobsub.c錯(cuò)誤
這個(gè)錯(cuò)誤可能在B方案時(shí)就會(huì)出現(xiàn),
解決方法:修改vobsub.c 230行將getline函數(shù)名稱改為mygetline
5)make完畢后拷貝目錄下的mplayer文件到arm9linux文件系統(tǒng)運(yùn)行就好了,我是拷貝在u盤里面運(yùn)行的
>/mnt # mplayer
>MPlayer 1.0pre7try2-3.3.2 (C) 2000-2005 MPlayer Team
>CPU: ARM
>Usage:?? mplayer [options] [url|path/]filename
6)播放mp3的問題
A不帶參數(shù)運(yùn)行,如下
/mnt # mplayer 1.mp3
MPlayer 1.0pre7try2-3.3.2 (C) 2000-2005 MPlayer Team
CPU: ARM
Failed to open /dev/rtc: No such file or directory (it should be readable by the user.)
Playing 1.mp3.
Audio file detected.
Clip inf
Title: 高達(dá)一年戰(zhàn)爭(zhēng)秘聞錄
Artist: Taja
Album:
Year:
Comment:
Genre: Other
==========================================================================
Requested audio codec family [mp3] (afm=mp3lib) not available.
Enable it at compilation.
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDI 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (rati 16000->176400)
Selected audio codec: [ffmp3] afm:ffmpeg (FFmpeg MPEG layer-3 audio decoder)
==========================================================================
Checking audio filter chain for 44100Hz/2ch/s16le -> 44100Hz/2ch/s16le...
AF_pre: 44100Hz/2ch/s16le
[AO OSS] audio_setup: Can't open audio device /dev/dsp: No such file or directory
A [null] 44100Hz 2ch s16le (2 bps)
Building audio filter chain for 44100Hz/2ch/s16le -> 44100Hz/2ch/s16le...
Vide no video
Starting playback...
[Mixer] No hardware mixing, inserting volume filter.???????????????????????????
A:?? 0.3 (00.2) 47.4%??????????????????????????????????????????????????????????
A:?? 0.8 (00.8) 55.9%??????????????????????????????????????????????????????????
A:?? 1.2 (01.1) 57.2%??????????????????????????????????????????????????????????
No bind found for key l
打不開,因?yàn)闆]有安裝mp3lib庫
B加參數(shù)mad
/mnt # mplayer -ac mad 1.mp3
MPlayer 1.0pre7try2-3.3.2 (C) 2000-2005 MPlayer Team
CPU: ARM
Failed to open /dev/rtc: No such file or directory (it should be readable by the user.)
Playing 1.mp3.
Audio file detected.
Clip inf
Title: 高達(dá)一年戰(zhàn)爭(zhēng)秘聞錄
Artist: Taja
Album:
Year:
Comment:
Genre: Other
==========================================================================
Forced audio codec: mad
Opening audio decoder: [libmad] libmad mpeg audio decoder
AUDI 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (rati 16000->176400)
Selected audio codec: [mad] afm:libmad (libMAD MPEG layer 1-2-3)
==========================================================================
Checking audio filter chain for 44100Hz/2ch/s16le -> 44100Hz/2ch/s16le...
AF_pre: 44100Hz/2ch/s16le
[AO OSS] audio_setup: Can't open audio device /dev/dsp: No such file or directory
A [null] 44100Hz 2ch s16le (2 bps)
Building audio filter chain for 44100Hz/2ch/s16le -> 44100Hz/2ch/s16le...
Vide no video
Starting playback...
A:?? 3.9 (03.8) 46.9%
看似在播放了,但是完全沒有聲音
仔細(xì)看輸出,有個(gè)錯(cuò)誤[AO OSS] audio_setup: Can't open audio device /dev/dsp: No such file or directory
奇怪,我記得dsp應(yīng)該在sound下啊
既然它要找/dev/dsp,我做個(gè)鏈接好了
前天剛學(xué)過ln命令,現(xiàn)學(xué)現(xiàn)賣
ln -s /dev/sound/dsp /dev/dsp
再運(yùn)行看看
/mnt # mplayer -ac mad 1.mp3
MPlayer 1.0pre7try2-3.3.2 (C) 2000-2005 MPlayer Team
CPU: ARM
Failed to open /dev/rtc: No such file or directory (it should be readable by the user.)
Playing 1.mp3.
Audio file detected.
Clip inf
Title: 高達(dá)一年戰(zhàn)爭(zhēng)秘聞錄
Artist: Taja
Album:
Year:
Comment:
Genre: Other
==========================================================================
Forced audio codec: mad
Opening audio decoder: [libmad] libmad mpeg audio decoder
AUDI 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (rs3c2410-uda1341-superlp: audio_set_dsp_speed:44100 prescaler:66
ati 16000->176s3c2410-uda1341-superlp: audio_set_dsp_speed:44100 prescaler:66
400)
Selected audio codec: [mad] afm:libmad (libMAD MPEG layer 1-2-3)
==========================================================================
Checking audio filter chain for 44100Hz/2ch/s16le -> 44100Hz/2ch/s16le...
AF_pre: 44100Hz/2ch/s16le
A [oss] 44100Hz 2ch s16le (2 bps)
Building audio filter chain for 44100Hz/2ch/s16le -> 44100Hz/2ch/s16le...
Vide no video
Starting playback...
MPlayer interrupted by signal 8 in module: play_audio
- MPlayer crashed by bad usage of CPU/FPU/RAM.
Recompile MPlayer with --enable-debug and make a 'gdb' backtrace and
disassembly. Details in DOCS/HTML/en/bugreports_what.html#bugreports_crash.
- MPlayer crashed. This shouldn't happen.
It can be a bug in the MPlayer code _or_ in your drivers _or_ in your
gcc version. If you think it's MPlayer's fault, please read
DOCS/HTML/en/bugreports.html and follow the instructions there. We can't and
won't help unless you provide this information when reporting a possible bug.
還是有錯(cuò)誤,但AO的錯(cuò)誤解決了,我目前僅做到這一步,尚未解決聲音問題
6)播放視頻
我嘗試了avi mpg vcd的dat文件,都可以播放,速度有點(diǎn)滿,還得禁掉sound,2410也就這樣吧,放視頻還得DSP
mplayer 13.mpg -nosound -fs
fs是中央顯示
還有個(gè)錯(cuò)誤
Failed to open /dev/rtc: No such file or directory (it should be readable by the user.)
RTC的錯(cuò)誤?我找不到這個(gè)設(shè)備
暫時(shí)就這么多吧,聲音問題繼續(xù)研究中。。。。。。。。。。。。。。。。
最后轉(zhuǎn)一段解決聲音問題的方法,我按照如上做了,可惜還是沒解決
2.開始調(diào)試???
??????? 編譯出來的代碼能正常的在FS2410上跑嗎?心中還是有許多疑問。給板子上電,然后用自己編寫的一個(gè)網(wǎng)絡(luò)傳輸工具將代碼傳到板子的ramdisk,接著 再傳上一個(gè)10M左右的視頻,好了,先不帶參數(shù)運(yùn)行mplayer,不錯(cuò),中文的幫助信息彈出來了,說明程序基本編譯對(duì)了,這時(shí)輸入命令?? ./mplayer???? matrix.mpg?? ,?? 眼睛直盯著屏幕,期待著畫面的出現(xiàn),可惜,在出現(xiàn)了一些視頻剪輯的反饋信息后,程序再也不動(dòng)了,沒辦法,按CTRL+C結(jié)束程序,然后就提示出現(xiàn)段錯(cuò)誤。 以前聽說有l(wèi)inux嵌入式的愛好者移植時(shí)也出現(xiàn)這樣的錯(cuò)誤,但是如果不播放聲音時(shí),圖像可以出現(xiàn),于是輸入命令?? ./mplayer???? -nosound???? matrix.mpg,這時(shí)畫面出來了,這個(gè)320x240大小的從網(wǎng)上下載的視頻,播放起來相當(dāng)流暢,好像比平時(shí)看的影碟機(jī)解碼速度還快,那當(dāng)然了,畢 竟是320x240大小,又沒聲音解碼的。??
???
聲音這塊不解決,當(dāng)然是不能說移植成功的,因?yàn)閙player還支持那么多格式的音頻解碼。但是問題究竟出在哪里呢?用排除法吧!找一個(gè)未經(jīng)任何音頻壓縮 的WAV音頻文件,其時(shí)就是PCM文件,上傳到ramdisk,然后用mplayer播放,還是出現(xiàn)一樣的問題,程序死了。好了,這就說明問題并非出現(xiàn)在 音頻解碼部分,極有可能出現(xiàn)在音頻流的播放部分。現(xiàn)在市面上大多數(shù)的嵌入式開發(fā)板的音頻驅(qū)動(dòng)是oss規(guī)范的驅(qū)動(dòng),以前自己做過oss的編程,對(duì)這塊還是比 較熟悉。于是開始查看mpalyer,c源文件,看看它是如何實(shí)現(xiàn)音頻流播放的,??
???
在音頻播放部分它使用到了libao2庫的音頻播放/控制模塊,通過進(jìn)一步查看ao_oss.c源代碼進(jìn)一步獲知mplayer是如何與音頻的linux 驅(qū)動(dòng)工作的。這一步弄清楚后,重新編譯mplayer,打開debug選項(xiàng),打開調(diào)試字符串輸出,并在音頻播放處設(shè)置多處斷點(diǎn),并加上printf語句輸 出一些變量?jī)?nèi)容,最終發(fā)現(xiàn)在調(diào)用ao_oss.c的play()函數(shù)時(shí)出現(xiàn)除零出錯(cuò),??
???
這個(gè)問題產(chǎn)生的根源最終追溯到音頻的驅(qū)動(dòng)部分。現(xiàn)在大部分的嵌入式板子都使用菲利普uda1341音頻芯片,因而也都使用了相同一個(gè)音頻驅(qū)動(dòng),即MIZI 公司擁有版權(quán)的linux?? uda1341音頻驅(qū)動(dòng),這個(gè)驅(qū)動(dòng)基本上符合了oss的規(guī)范,但是當(dāng)使用到多段DMA音頻數(shù)據(jù)傳輸時(shí),出現(xiàn)了一個(gè)問題,即DMA緩沖的建立發(fā)生在第一次調(diào) 用write()函數(shù)將音頻數(shù)據(jù)傳送到設(shè)備描述符的時(shí)候,然而oss驅(qū)動(dòng)的調(diào)用者通常要在打開音頻設(shè)備描述時(shí)候,就期望獲取DMA緩沖的信息,然而因?yàn)榫?沖尚未建立,因而返回緩沖大小為0這個(gè)結(jié)果。??
???
解決的辦法是在音頻驅(qū)動(dòng)源碼的smdk2410_audio_open()函數(shù)體,加上如下一段代碼,??
???
if?? (!output_stream?? .buffers?? &&?? audio_setup_buf(&output_stream))??
????????????????????????????????????????????? return?? -ENOMEM;??
????? 添加的位置具體見以下代碼的粗體部分:??
????????????? static?? int?? smdk2410_audio_open(struct?? inode?? *inode,?? struct?? file?? *file)??
????? {??
??????????????????? int?? cold?? =?? !audio_active;??
??????????????????????????? DPRINTK("audio_open ");??
??????????????????????????? if?? ((file->f_flags?? &?? O_ACCMODE)?? ==?? O_RDONLY)?? {??
????????????????????????????????? if?? (audio_rd_refcount?? ||?? audio_wr_refcount)??
??????????????????????????????????????????????? return?? -EBUSY;??
????????????????????????????????? audio_rd_refcount++;??
??????????????????? }?? else?? if?? ((file->f_flags?? &?? O_ACCMODE)?? ==?? O_WRONLY)?? {??
????????????????????????????????? if?? (audio_wr_refcount)??
??????????????????????????????????????????????? return?? -EBUSY;??
????????????????????????????????? audio_wr_refcount++;??
??????????????????? }?? else?? if?? ((file->f_flags?? &?? O_ACCMODE)?? ==?? O_RDWR)?? {??
????????????????????????????????? if?? (audio_rd_refcount?? ||?? audio_wr_refcount)??
??????????????????????????????????????????????? return?? -EBUSY;??
????????????????????????????????? audio_rd_refcount++;??
????????????????????????????????? audio_wr_refcount++;??
??????????????????? }?? else??
????????????????????????????????? return?? -EINVAL;??
????????????????????????? if?? (cold)?? {??
????????????????????????????????? audio_rate?? =?? AUDIO_RATE_DEFAULT;??
????????????????????????????????? audio_channels?? =?? AUDIO_CHANNELS_DEFAULT;??
????????????????????????????????? audio_fragsize?? =?? AUDIO_FRAGSIZE_DEFAULT;??
????????????????????????????????? audio_nbfrags?? =?? AUDIO_NBFRAGS_DEFAULT;??
????????????????????????????????? if?? ((file->f_mode?? &?? FMODE_WRITE)){??
????????????????????????????????????????????????????????????? init_s3c2410_iis_bus_tx();??
????????????????????????????????????????????????????????????? audio_clear_buf(&output_stream);??
??????????????????????????????????? //?? 加上以下這行代碼??
??????????????????????????????????????? if?? (!output_stream?? .buffers?? &&?? audio_setup_buf(&output_stream))??
????????????????????????????????????????????? return?? -ENOMEM;??
????????????????????????????????? }??
????????????????????????????????? if?? ((file->f_mode?? &?? FMODE_READ)){??
????????????????????????????????????????????????????????????? init_s3c2410_iis_bus_rx();??
????????????????????????????????????????????????????????????? audio_clear_buf(&input_stream);??
????????????????????????????????? }??
??????????????? }??
??????????????? MOD_INC_USE_COUNT;??
?????????????? return?? 0;??
??? }??
??? 改完驅(qū)動(dòng)后,重新編譯內(nèi)核。
=====================================================
更新
解決Failed to open /dev/rtc: No such file or directory (it should be readable by the user.)問題
在configure時(shí)添加 --disable-rtc
評(píng)論
查看更多