Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ALSA / Mythtv problems (underrun)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
Nate_S
Guru
Guru


Joined: 18 Mar 2004
Posts: 414

PostPosted: Sun Oct 03, 2004 7:16 pm    Post subject: ALSA / Mythtv problems (underrun) Reply with quote

I posted this on the mythtv mailing list, but didn't get any response. (more alsa than myth really)

The problem is, audio is crackly and sounds
horriable in mythtv. I'm using a
loopback cable to the soundcard (onboard audio, though I threw in a
sblive to test and it didn't make a difference) If I simply unmute
the line input, such as for watching tvtime, the sound is crystal clear.

If I run aplay /dev/dsp, it sounds crackly like in myth, and gives:

Playing raw data '/dev/dsp' : Unsigned 8 bit, Rate 8000 Hz, Mono
underrun!!! (at least 23.270 ms long)
underrun!!! (at least 24.247 ms long)
underrun!!! (at least 24.245 ms long)
underrun!!! (at least 24.471 ms long)
underrun!!! (at least 24.475 ms long)
underrun!!! (at least 24.485 ms long)
underrun!!! (at least 24.245 ms long)
underrun!!! (at least 24.475 ms long)
underrun!!! (at least 26.497 ms long)
underrun!!! (at least 22.243 ms long)
(underruns continue, one each second or so, until I stop it)

I have googled around for this, and found a few others with the same
problem, but no solution posted.

Anyone have any ideas?

Thanks in advance,
-Nate
Back to top
View user's profile Send private message
pactoo
Guru
Guru


Joined: 18 Jul 2004
Posts: 553

PostPosted: Mon Oct 04, 2004 9:22 am    Post subject: Reply with quote

Disclaimer: I do not know myth-tv, I just used to have general problem with underruns using alsa, too.

I fixed those with using a soundserver (artsd and jackd) instead of direct alsa, both running in realtime mode. That made my sound rock-solid, even under load.

I am not sure wether myth-tv can output to arts or jack, if it can, I would try either.
Back to top
View user's profile Send private message
Nate_S
Guru
Guru


Joined: 18 Mar 2004
Posts: 414

PostPosted: Mon Oct 04, 2004 5:00 pm    Post subject: Reply with quote

Hmm, I don't know about jack, but I do think it supports arts and esd.

Would that add overhead?

I think I'll try to solve the problem first, but if I give up I'll give that a try, thanks for the suggestion.

All mythtv is doing is recording and playing simultaneously, with a delay, and as I said I think mine is a general problem as well.

more info:

my mythtv log says "opening OSS device" which puzzles me, because I compiled it with -oss alsa, but maybe for some reason it's using the OSS emulation instead of native alsa? could that cause the problem?

-Nate
Back to top
View user's profile Send private message
zaai
Apprentice
Apprentice


Joined: 24 Jul 2004
Posts: 175

PostPosted: Wed Oct 06, 2004 8:40 am    Post subject: Reply with quote

Similar problem here, although with xawtv. If I run xawtv, mute line-in and "aplay /dev/dsp" then I do get sound but very thin and crackly.
Mythtv v0.16 doesn't give any sound; the log says /dev/dsp busy.

Kernel is linux-2.6.8-gentoo-r3. OSS is disabled in kernel. ALSA is compiled as modules. Desktop is KDE 3.3. USE="-directfb -oss -dvb alsa arts". Tv card is avermedia tv studio with the audio output connected to the line-in.

lspci gives:
Quote:
0000:00:05.0 Multimedia audio controller: C-Media Electronics Inc CM8738 (rev 10)
0000:00:09.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
0000:00:09.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)


lsmod video and sound modules:
Quote:

bt878 11444 0
snd_bt87x 14536 3
snd_cmipci 33700 5
snd_opl3_lib 10880 1 snd_cmipci
snd_hwdep 9476 1 snd_opl3_lib
snd_mpu401_uart 8064 1 snd_cmipci
snd_rawmidi 24868 1 snd_mpu401_uart
snd_seq_oss 33536 0
snd_seq_midi_event 7808 1 snd_seq_oss
snd_seq 52496 4 snd_seq_oss,snd_seq_midi_event
snd_seq_device 8328 4 snd_opl3_lib,snd_rawmidi,snd_seq_oss,snd_seq
snd_pcm_oss 53160 1
snd_pcm 95496 4 snd_bt87x,snd_cmipci,snd_pcm_oss
snd_page_alloc 11656 2 snd_bt87x,snd_pcm
snd_timer 25220 3 snd_opl3_lib,snd_seq,snd_pcm
snd_mixer_oss 19712 1 snd_pcm_oss
snd 54372 27 snd_bt87x,snd_cmipci,snd_opl3_lib,snd_hwdep,snd_mpu401_uart,snd_rawmidi,snd_seq_oss,snd_seq_midi_event,snd_seq,snd_seq_device,snd_pcm_oss,snd_pcm,snd_timer,snd_mixer_oss
soundcore 10336 2 snd
tuner 19216 0
tvaudio 22028 0
bttv 150860 2 bt878,lirc_gpio
video_buf 21508 1 bttv
i2c_algo_bit 9480 1 bttv
v4l2_common 6400 1 bttv
btcx_risc 5000 1 bttv
i2c_core 23824 4 tuner,tvaudio,bttv,i2c_algo_bit
videodev 10112 1 bttv
nvidia 4818964 20


.asoundrc (see http://alsa-project.org/alsa-doc/doc-php/template.php?company=C-Media&card=CMI8738&chip=CMI8738&module=cmipci):
Quote:

pcm.cmipci {
type hw
card 0
}

ctl.cmipci {
type hw
card 0
}


According to the mythtv doc here http://www.mythtv.org/docs/mythtv-HOWTO-20.html#ss20.4 mythtv can use artsd. (not sure if this is already in v0.16)
Quote:
NOTE: The CVS version of MythTV now has support for using artsd. This is a compile-time option, so you will need to edit the settings.pro file in the mythtv directory then perform a make distclean; make, and re-run make install as root to add this support. Otherwise, check your window manager documentation for instructions on disabling the sound manager. If you wish to see what application is grabbing a resource, you can use the fuser command:
# fuser -v /dev/dsp


fuser -v /dev/dsp returns nothing in my case, which makes me wonder why mythtv says device is busy. There are no other sound applications running so arts should release any locks after 60 seconds.

--- rant ---
I've been trying over three days to get mythtv to work, and jeez it is a nightmare. The worst problem was caused by directfb that crashed the system (using nvidia - ti4200) until I disabled it in the kernel and USE="-directfb". Now using xv the video part works fine.
It would be nice if applications that choose to add all these dependencies would also have code to configure them properly. :wink:
--- end rant ---

I'm lost and about to give up (or maybe get a Hauppage PVR 250)
Why the /dev/dsp device busy error?
So how can we tell mythtv to use artsd?
Would adding oss back in solve the problem?

Any light on the matter would be appreciated. :D
Back to top
View user's profile Send private message
Nate_S
Guru
Guru


Joined: 18 Mar 2004
Posts: 414

PostPosted: Wed Oct 06, 2004 7:38 pm    Post subject: Reply with quote

have you tried killing artsd?

or you can make mythtv use arts by doing USE="arts" emerge mythtv

( I believe that the docs are old ant that the cvs version is now .16, if not, the mythtv mailing list has a mythtv cve ebuild I believe )

I too am about to give up and get a pvr250, as mine works, and is great, but the sound is crap.

Also, more info on my problem, I found that doing arecord /dev/dsp produces clear sound. same with doing arecord soundfile, then aplay soundfile. Now why is myth not doing this...

-Nate
Back to top
View user's profile Send private message
pactoo
Guru
Guru


Joined: 18 Jul 2004
Posts: 553

PostPosted: Thu Oct 07, 2004 1:15 pm    Post subject: Reply with quote

As for solving the problem: For me I had to raise the PCI Latency in my BIOS from 32 to 64 to get somewhat continuous sound without crackling using pure alsa with my hammerfall. For some reason, alsa (or the application) did not feed the card fast enough.
Running a soundserver with realtime priority fixed this problem.

So maybe your problem is not configuration related. Can't comment on mythTV, as said before
Back to top
View user's profile Send private message
Nate_S
Guru
Guru


Joined: 18 Mar 2004
Posts: 414

PostPosted: Thu Oct 07, 2004 5:11 pm    Post subject: Reply with quote

Thanks, I'll try that.

I suspect it's not config related, as I've tried some of the most basic configs possiable, and no one else has had any ideas.

I was wrong about the esd support, and as I use gnome rather than kde, i'd rather not use arts, but i'll try it if nothing else works.

-Nate
Back to top
View user's profile Send private message
Nate_S
Guru
Guru


Joined: 18 Mar 2004
Posts: 414

PostPosted: Thu Oct 07, 2004 5:41 pm    Post subject: Reply with quote

my bios doesn't seem to have this setting...
Back to top
View user's profile Send private message
zaai
Apprentice
Apprentice


Joined: 24 Jul 2004
Posts: 175

PostPosted: Fri Oct 08, 2004 6:58 am    Post subject: Reply with quote

Well, I got a PVR-250.
Still working on getting it to work... nothing is ever easy.
... more later ...
Back to top
View user's profile Send private message
pactoo
Guru
Guru


Joined: 18 Jul 2004
Posts: 553

PostPosted: Fri Oct 08, 2004 11:49 am    Post subject: Reply with quote

I do not know, wether esd has an realtime option, too. Running the soundserver with realtime priority is important, otherwise you do not gain any advantage over plain alsa.
But - this is just wild speculation - if you prefer gnome, could you not use gstreamer and let gstreamer output to jackd ? Up to my limited experience avoiding esd only has advantages, YMMV.

Just an idea, never really used gstreamer or gnome.
Back to top
View user's profile Send private message
Nate_S
Guru
Guru


Joined: 18 Mar 2004
Posts: 414

PostPosted: Fri Oct 08, 2004 5:58 pm    Post subject: Reply with quote

well I tried arts (with the artswrappersuid flag, which makes it realtime, right?) but it didn't work.

atrsd gives me this

ALSA lib pcm_hw.c:549:(snd_pcm_hw_start) SNDRV_PCM_IOCTL_START failed: Broken pipe
ALSA lib pcm_hw.c:549:(snd_pcm_hw_start) SNDRV_PCM_IOCTL_START failed: Broken pipe

and mythtv seems unable to connect to or use it. (in fact, now that I compiled myth with arts support, it doesn't have working sound at all...)

I think i'm just going to get a pvr250

Thanks for all the help though

-Nate
Back to top
View user's profile Send private message
zaai
Apprentice
Apprentice


Joined: 24 Jul 2004
Posts: 175

PostPosted: Sat Oct 09, 2004 9:35 am    Post subject: Reply with quote

Finally figured out the missing link on getting MythTv to work with ALSA. :P
After searching the web for days I found it here: http://www.thepenguin.org.uk/alsa/

You need to use "ALSA:default" as your audio device, not /dev/dsp

Maybe you think its obvious but I don't know ALSA and especially configuring MythTv is still a bit of a dark art. I don't understand why the guide doesn't say so more clearly. There is no clue because the drop-down menu only show the /dev/... audio devices.

For MythTv 0.16:
- Startup MythFrontEnd,
- navigate to utilities/setup -> General
- fill-in "ALSA:default" in the Audio Output device field

I didn't use the .asoundrc config file from the example (which is for an nForce card, I have a C-Media CM8738 onboard) and kept to my *very* basic config. The simpler the less can go wrong.
Quote:
# ~/.asoundrc
pcm.cmipci {
type hw
card 0
}

ctl.cmipci {
type hw
card 0
}


Once this works you might want to try something more advanced like the example in the first like, or go bananas with: http://www.mythtv.info/moin.cgi/DigitalSoundHowTo
The link mentioned above has a far more complex example using dmix but I haven't tried it yet.

Note that some of the other MythTv audio components do work with /dev/dsp (the audio device is filled-in at 3 places - what a mess) so I would just leave those as is. If it works don't touch it.

The PVR-250 TV and video playback also works now. Watching live TV was the hard part and only worked after using the latest ivtv drivers ivtv-0.1.10-pre2-ck114j, from here: http://67.18.1.101/~ckennedy/ivtv/
Do read the instructions very carefully, especially on the msp3400 module. The 114j version seems a bit unstable - locks up my computer on occasion - so experiment a bit.
Furthermore the video quality isn't that great. Moving objects seem blurred and the even/uneven lines shift apart now and then. I hope there is an option somewhere to adjust it but I haven't found it yet.
Now I'm going to put the avermedia tv studio card back in and see if it plays nicely together with the pvr-250.

Last, for tvtime fans - PVR 250 doesn't work on tvtime because it provides mpeg2 encoded video, which tvtime can't handle. Too bad since tvtime has the best video quality of all players.

Hope this helps someone. :wink:
Back to top
View user's profile Send private message
Nate_S
Guru
Guru


Joined: 18 Mar 2004
Posts: 414

PostPosted: Sat Oct 09, 2004 5:13 pm    Post subject: Reply with quote

Thank you so much!

Sound is crystal clear now

Wow, that's crazy, I didn't even realize you could type in a different value there; I thought that you just had to choose between them.

I think that is sort of a glaring error in the mythtv docs. That should really be more obvious.

Anyways, Thanks for all the help

-Nate
Back to top
View user's profile Send private message
zaai
Apprentice
Apprentice


Joined: 24 Jul 2004
Posts: 175

PostPosted: Sat Oct 09, 2004 6:01 pm    Post subject: Reply with quote

Heh glad I could help. :P
The best thing about Gentoo are these forums.

I'll ask the writers of a couple of these guides out there to include it in their documentation.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum