aligrudi / fbff

A small ffmpeg-based framebuffer media player
69 stars 12 forks source link

fbff: /dev/dsp busy? #3

Open anverb opened 3 years ago

anverb commented 3 years ago

Hi, when I try to open any file I recieve this: "fbff: /dev/dsp busy?". Any possible solutions?

aligrudi commented 3 years ago

Hi,

anverb @.***> wrote:

Hi, when I try to open any file I recieve this: "fbff: /dev/dsp busy?". Any possible solutions?

Some other program is probably using the OSS device. Try the following command to see which program:

$ fuser /dev/dsp

Is it a process that you have started yourself?

You can also pass -a- to fbff to disable audio.

Ali
m040601 commented 1 year ago

I have the same problem.

"fbff: /dev/dsp busy?"

Since this is almost 2 years old, I am not even sure if this "/dev/dsp" is suppose to exist on my modern up to date Archlinux

uname -a

Linux gigabyty 6.6.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 08 Nov 2023 16:05:38 +0000 x86_64 GNU/Linux

fuser /dev/dsp

Specified filename /dev/dsp does not exist.

I have installed fbff using, https://aur.archlinux.org/packages/fbff-git

Name            : fbff-git
Version         : 1:0.87.ae86d8e-1
Description     : A small ffmpeg-based framebuffer media player.
Architecture    : x86_64
URL             : http://repo.or.cz/w/fbff.git
Licenses        : GPL
Groups          : None
Provides        : fbff
Depends On      : ffmpeg
Optional Deps   : libmpeg3: alternative media backend
                  oss: sound support
Required By     : None
Optional For    : None
Conflicts With  : fbff
Replaces        : None
Installed Size  : 28.94 KiB
Packager        : Unknown Packager
Build Date      : Sat 18 Nov 2023 08:40:01 PM WET
Install Date    : Sat 18 Nov 2023 08:40:18 PM WET
Install Reason  : Explicitly installed
Install Script  : Yes
Validated By    : None
aligrudi commented 12 months ago

somename123 @.***> wrote:

I have the same problem.

"fbff: /dev/dsp busy?"

Since this is almost 2 years old, I am not even sure if this "/dev/dsp" is suppose to exist on my modern up to date Archlinux

uname -a

Linux gigabyty 6.6.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 08 Nov 2023 16:05:38 +0000 x86_64 GNU/Linux

fuser /dev/dsp

Specified filename /dev/dsp does not exist.

You need enable OSS emulation for alsa. This may help:

modprobe snd-pcm-oss snd-mixer-oss
Ali
wangtao13 commented 1 month ago

I am using SOC platform with kernel-5.10.180, and I also enabled OSS in kernel configuration as follows,

CONFIG_SOUND=y
CONFIG_SOUND_OSS_CORE=y
CONFIG_SOUND_OSS_CORE_PRECLAIM=y
CONFIG_SND=y
CONFIG_SND_TIMER=y
CONFIG_SND_PCM=y
CONFIG_SND_DMAENGINE_PCM=y
CONFIG_SND_JACK=y
CONFIG_SND_JACK_INPUT_DEV=y
CONFIG_SND_OSSEMUL=y
CONFIG_SND_MIXER_OSS=y
CONFIG_SND_PCM_OSS=y
CONFIG_SND_PCM_OSS_PLUGINS=y
CONFIG_SND_PCM_TIMER=y

When I tried to play a MP4 file, fbff returned following error.

/data/fbff /data/video_640_480_25fps_nob.mp4
fbff: /dev/dsp busy?

I ran lsof | grep dsp, no one is using it.

I changed fbff.c to use /dev/dsp1 and it worked, but NO sound played.

How to fix it and make fbff play the MP4??

Or is it possible to support ALSA of Linux?

aligrudi commented 1 month ago

wangtao13 @.***> wrote:

I am using SOC platform with kernel-5.10.180, and I also enabled OSS in kernel configuration as follows,

CONFIG_SOUND=y
CONFIG_SOUND_OSS_CORE=y
CONFIG_SOUND_OSS_CORE_PRECLAIM=y
CONFIG_SND=y
CONFIG_SND_TIMER=y
CONFIG_SND_PCM=y
CONFIG_SND_DMAENGINE_PCM=y
CONFIG_SND_JACK=y
CONFIG_SND_JACK_INPUT_DEV=y
CONFIG_SND_OSSEMUL=y
CONFIG_SND_MIXER_OSS=y
CONFIG_SND_PCM_OSS=y
CONFIG_SND_PCM_OSS_PLUGINS=y
CONFIG_SND_PCM_TIMER=y

When I tried to play a MP4 file, fbff returned following error.

/data/fbff /data/video_640_480_25fps_nob.mp4
fbff: /dev/dsp busy?

I ran lsof | grep dsp, no one is using it. How to fix it and make fbff play the MP4??

Please define the OSSDSP environment variable to point to the OSS device (fbff tries /dev/dsp by default). This may work:

OSSDSP=/dev/dsp1 fbff ...

Ali
wangtao13 commented 1 month ago

Ali, I am not familiar with Audio stack in Linux, what is the format of audio decoded from the media file in your fbff, is it possible to play the audio with other device/interface? As I said in my question, I changed to use /dev/dsp1 in the fbff.c, there was no error reported, but NO sound played.

Thanks, -Tao

aligrudi commented 1 month ago

wangtao13 @.***> wrote:

I am not familiar with Audio stack in Linux, what is the format of audio decoded from the media file in your fbff, is it possible to play

Fbff uses the ffmpeg library for decoding the input file; it supports various audio/video formats.

the audio with other device/interface? As I said in my question, I changed to use /dev/dsp1 in the fbff.c, there was no error reported, but NO sound played.

Please check that the output device is not muted; you can do so in alsamixer, for instance, or minmix. Also, please check if you are sending the audio to the correct device, if you have multiple devices. Try "ls /dev/dsp*" to see the list.

Ali
wangtao13 commented 1 month ago

I checked the DSP device in my system (I reconfigured my kernel with OSS emulation enabled), there are 2 DSP devices.

# ls /dev/dsp* -l
crw-------    1 root     root       14,   3 Jan  1 00:49 /dev/dsp
crw-------    1 root     root       14,  19 Jan  1 00:49 /dev/dsp1

I ran fbff ./test.mp4, it said fbff: /dev/dsp busy? Then, as you suggested, I set OSSDSP=/dev/dsp1, the fbff ./test.mp4 can work, video is shown in the LCD, but no sound played.

Then, I ran aplay ./test.pcm, the sound is played well.
So by default, the speaker is working in ALSA, but it seemed not working with OSS /dev/dsp1. What should I do or try to figure out the reason of fbff failing to play the sound??

Thanks,

aligrudi commented 1 month ago

wangtao13 @.***> wrote:

I checked the DSP device in my system (I reconfigured my kernel with OSS emulation enabled), there are 2 DSP devices.

ls /dev/dsp* -l

crw------- 1 root root 14, 3 Jan 1 00:49 /dev/dsp crw------- 1 root root 14, 19 Jan 1 00:49 /dev/dsp1

I ran fbff ./test.mp4, it said fbff: /dev/dsp busy? Then, as you suggested, I set OSSDSP=/dev/dsp1, the fbff ./test.mp4 can work, video is shown in the LCD, but no sound played.

Then, I ran aplay ./test.pcm, the sound is played well.
So by default, the speaker is working in ALSA, but it seemed not working with OSS /dev/dsp1. What should I do or try to figure out the reason of fbff failing to play the sound??

Very good. One possibility is that the device is used by by another process; ALSA OSS device cannot be shared between processes (try fuser /dev/dsp).

Also, please try minmix:

git clone https://github.com/aligrudi/minmix cd minmix make OSSMIXER="/dev/mixer1" ./minmix /

It lists OSS mixer controls. If the value of an output control is zero, try increasing its volume, like this (if vol is reported to be zero):

OSSMIXER="/dev/mixer1" ./minmix vol=90

Note that the OSSMIXER environment variable specifies the mixer device; if it is not set, minmix tries /dev/mixer.

Ali
wangtao13 commented 1 month ago

Hi Ali,

Thanks alot for your reply.

Here are list of audio devices in my system

# ls /dev/ | grep 'dsp\|audio\|mix'
adsp
adsp1
audio
audio1
dsp
dsp1
mixer
mixer1

# ls /dev/snd/
controlC0  pcmC0D0c   pcmC0D1p   pcmC0D3c   pcmC1D0c   pcmC1D1c   timer
controlC1  pcmC0D1c   pcmC0D2c   pcmC0D4p   pcmC1D0p   pcmC1D1p

I downloaded and built the minmix. There is nothing shown with minmix /, I am checking why this happen.

aligrudi commented 1 month ago

Hi,

wangtao13 @.***> wrote:

ls /dev/snd/

controlC0 pcmC0D0c pcmC0D1p pcmC0D3c pcmC1D0c pcmC1D1c timer controlC1 pcmC0D1c pcmC0D2c pcmC0D4p pcmC1D0p pcmC1D1p


I downloaded and built the minmix. 
There is nothing shown with `minmix /`, I am checking why this happen.

Does it return nothing for both /dev/mixer and /dev/mixer1?

Ali
wangtao13 commented 1 month ago

Hi, wangtao13 @.***> wrote: ls /dev/snd/ controlC0 pcmC0D0c pcmC0D1p pcmC0D3c pcmC1D0c pcmC1D1c timer controlC1 pcmC0D1c pcmC0D2c pcmC0D4p pcmC1D0p pcmC1D1p `` I downloaded and built the minmix. There is nothing shown withminmix /`, I am checking why this happen. Does it return nothing for both /dev/mixer and /dev/mixer1? Ali

You are right, setting to either /dev/mixer or /dev/mixer1 returns nothing..... I think there must be something wrong in the system, maybe in the kernel configuration???

And is it possible to change the fbff to use ALSA instead of OSS? Thanks,

aligrudi commented 4 weeks ago

wangtao13 @.***> wrote:

Hi, wangtao13 @.***> wrote: ls /dev/snd/ controlC0 pcmC0D0c pcmC0D1p pcmC0D3c pcmC1D0c pcmC1D1c timer controlC1 pcmC0D1c pcmC0D2c pcmC0D4p pcmC1D0p pcmC1D1p `` I downloaded and built the minmix. There is nothing shown withminmix /`, I am checking why this happen. Does it return nothing for both /dev/mixer and /dev/mixer1? Ali

You are right, setting to either /dev/mixer or /dev/mixer1 returns nothing..... I think there must be something wrong in the system, maybe in the kernel configuration???

For audio cards, OSS emulation usually provides a number of mixer controls. Is it a common audio card? Also, I suggest disabling OSS (not its ALSA emulation), if it is enabled.

And is it possible to change the fbff to use ALSA instead of OSS?

Yes. However, I do not use alsa myself. It should not be difficult though; you need to change the audio-related sections of fbff.c. And there is a tinyalsa branch, but I think it is very old and may not work.

Ali
wangtao13 commented 4 weeks ago

Ali, The audio card in my system is built-in a SOC, and it can work with ALSA, I can play .PCM file using aplay well. I am NOT familiar with FFMPEG interfaces, and your fbff is an excellent example for me to leart FFMPEG. To support ALSA, I read the fbff.c and got sound playing is using write(afd, a_buf[a_cons], a_len[a_cons]);, so what is the data in a_buf and what is its format?

wangtao13 commented 2 weeks ago

Ali, I tried to add audio playing through ALSA, it seemed to work. But now there is another problem, I cannot play video and audio together with default parameter, e.g. fbff -u -s mytest.mp4. It only plays audio, NO video output on the LCD. I have to use fbff -a - mytest.mp4 to disable playing audio and I can see the video played on LCD. I think the problem is in the mainloop() function,

389         while (audio && !eof && !a_prodwait()) {
390             int ret = ffs_adec(affs, a_buf[a_prod], ABUFLEN);
391             if (ret < 0)
392                 eof++;
393             if (ret > 0) {
394                 a_len[a_prod] = ret;
395                 a_prod = (a_prod + 1) & (ABUFCNT - 1);
396             }
397         }
398         if (video && (!audio || eof || vsync())) {
399             int ignore = jump && (vnum % (jump + 1));
400             void *buf;
401             int ret = ffs_vdec(vffs, ignore ? NULL : &buf);
402             vnum++;
403             if (ret < 0)
404                 eof++;
405             if (ret > 0)
406                 draw_frame((void *) buf, ret);
407             sub_print();
408         } else {

It looped in the line 389, and did NOT go to line 398 when the MP4 file has both video and audio.

The MP4 file info dumped is as follows,

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/20241021-081848.mp4':
  Metadata:
    copyright       : 94e0f595f84f80eaf42a401b05ca3119
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    major_brand     : mp42
    encoder         : bytevehwavc
  Duration: 00:00:14.77, start: 0.000000, bitrate: 1984 kb/s
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 540x960, 1856 kb/s, 30 fps, 30 tbr, 1000k tbn, 2000k tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]

So, how to play both audio and video together??

wangtao13 commented 2 weeks ago

Ali, I tried to add audio playing through ALSA, it seemed to work. But now there is another problem, I cannot play video and audio together with default settings, e.g. fbff -u -s mytest.mp4. It only plays audio, NO video output on the LCD. I have to use fbff -a - mytest.mp4 to disable playing audio and I can see the video played on LCD. I think the problem is in the mainloop() function,

389         while (audio && !eof && !a_prodwait()) {
390             int ret = ffs_adec(affs, a_buf[a_prod], ABUFLEN);
391             if (ret < 0)
392                 eof++;
393             if (ret > 0) {
394                 a_len[a_prod] = ret;
395                 a_prod = (a_prod + 1) & (ABUFCNT - 1);
396             }
397         }
398         if (video && (!audio || eof || vsync())) {
399             int ignore = jump && (vnum % (jump + 1));
400             void *buf;
401             int ret = ffs_vdec(vffs, ignore ? NULL : &buf);
402             vnum++;
403             if (ret < 0)
404                 eof++;
405             if (ret > 0)
406                 draw_frame((void *) buf, ret);
407             sub_print();
408         } else {

It looped in the line 389, and did NOT go to line 398 when the MP4 file has both video and audio.

The MP4 file info dumped is as follows,

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mytest.mp4':
  Metadata:
    copyright       : 94e0f595f84f80eaf42a401b05ca3119
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    major_brand     : mp42
    encoder         : bytevehwavc
  Duration: 00:00:14.77, start: 0.000000, bitrate: 1984 kb/s
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 540x960, 1856 kb/s, 30 fps, 30 tbr, 1000k tbn, 2000k tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]

So, how to play both audio and video together??

aligrudi commented 1 week ago

wangtao13 @.***> wrote:

I tried to add audio playing through ALSA, it seemed to work. But now there is another problem, I cannot play video and audio together with default settings, e.g. fbff -u -s mytest.mp4. It only plays audio, NO video output on the LCD. I have to use fbff -a - mytest.mp4 to disable playing audio and I can see the video played on LCD. I think the problem is in the mainloop() function,

389         while (audio &amp;&amp; !eof &amp;&amp; !a_prodwait()) {
390             int ret = ffs_adec(affs, a_buf[a_prod], ABUFLEN);
391             if (ret &lt; 0)
392                 eof++;
393             if (ret &gt; 0) {
394                 a_len[a_prod] = ret;
395                 a_prod = (a_prod + 1) &amp; (ABUFCNT - 1);
396             }
397         }
398         if (video &amp;&amp; (!audio || eof || vsync())) {
399             int ignore = jump &amp;&amp; (vnum % (jump + 1));
400             void *buf;
401             int ret = ffs_vdec(vffs, ignore ? NULL : &amp;buf);
402             vnum++;
403             if (ret &lt; 0)
404                 eof++;
405             if (ret &gt; 0)
406                 draw_frame((void *) buf, ret);
407             sub_print();
408         } else {

It looped in the line 389, and did NOT go to line 398 when the MP4 file has both video and audio.

The MP4 file info dumped is as follows,

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#39;/mytest.mp4&#39;:
  Metadata:
    copyright       : 94e0f595f84f80eaf42a401b05ca3119
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    major_brand     : mp42
    encoder         : bytevehwavc
  Duration: 00:00:14.77, start: 0.000000, bitrate: 1984 kb/s
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 540x960, 1856 kb/s, 30 fps, 30 tbr, 1000k tbn, 2000k tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]

So, how to play both audio and video together??

Just remembered: before switching to OSS, fbff used to use ALSA in its early versions. Although the code has probably changed very much since then, it may help.

Ali
wangtao13 commented 1 week ago

Oh, why changed from ALSA to OSS, OSS is deprecated for about 20 years? I changed the codes, it can play both video and audio together.
But video and audio are out of sync even with fbff -u -s ./test.mp4. I tested with other 2 MP4, fbff worked perfectly.