OSS is not completely broken on FreeBSD. I was surprised when I noticed that the port unconditionally switched to pulse audio yesterday. I am running version 2.1.0_1,4 of the multimedia/vlc port on my 9-STABLE machine and OSS is working. I did have to manually specify the path to the dsp device in VLC's settings after upgrading to 2.1.0. Ever since I did that, sound has been working correctly.
I am 100% sure you're equivocated. There are dozens of reports of OSS broken with VLC 2.1.0.
Please make sure you've selected "OSS" under Tools->Preferences->Audio. It must have reverted to another approach once you had run it once with another backend. (A restart is required)
No, the output module selected still is "Open Sound System audio output". I restart VLC many times a day and sound always works.
My port is compiled without pulse audio support. I do have jack compiled in but there is no jack daemon running on my machine. OSS is the only system that VLC can use and produce sound.
In 2.0.8, the block size is being adjusted from 4604 to 2048 by aout_OutputSlice in src/audio_output/output.c.
In 2.1.0, packet oriented audio output seems to have been deprecated at
c086f181, and removed later.
The 4604 byte writes occur when playing an .mp3 audio file. When playing a .wav file, 4096 byte buffers are written to /dev/dsp, and the playback sounds fine.
I can confirm the problem. I can also confirm that it does not appear for every type of audio output straight away.
Playing an .mp3 causes the problem to appear immediately at my end.
When I convert a problematic .mp3 file into .wav, the .wav exhibits the same problem,
which is beyond my understanding.
.ogg seems to work, at least I could not make the problem appear, here. H264 audio seems to work fine for the most part, but I can notice some noticeable jitter when skipping through the audio file. Sometimes, skipping seems to make the problem appear, but not for all audio types.
I can only think of three situaton where write() would return EINVAL, but given that I cannot find a proper FreeBSD dsp documentation, this is just guessting:
the write() size is not a multiple of the frame size,
When Vlc stops playing with "cannot write samples" error message, this appears in /var/log/messages:
{{{
kernel: pcm0: chn_write(): pcm0:virtual:dsp0.vp1: play interrupt timeout, channel dead
}}}
Is audio broken before that? For the .mp3 files I have tested, audio is very jittery for the mp3-files right from the start, but I get no error messages, initially. Then, after a timeout, the sound system decides that the virtual channel is dead and kills it, after which the EINVAL errors appear:
pcm0: chn_write(): pcm0:play:dsp0.p2: play interrupt timeout, channel dead
From what I understand from the source, this happens when the sound system finds out it (a) has no data to copy to the hardware output buffer and (b) the hardware output buffer has no room for some time.
This also seems not to be related to particular sizing of the output buffer, because those are all over the spectrum (I had write buffer sizes from 512 to 8200) even with good audio.
I'll try to verify if the problem also exists with the 4front OSS drivers that are also available instead of FreeBSD's native drivers.
From what I understand from the source, this happens when the sound system finds out it (a) has no data to copy to the hardware output buffer and (b) the hardware output buffer has no room for some time.
This could be symptomatic of VLC and FreeBSD disagreeing on what the sample format is, e.g. signed-16 vs float, in which case VLC will write either way too little or way too much data to the DSP character device.
When playing a .mp3, sound is fine for the first couple of seconds.
[0x80848a110] main input debug: Buffering 0%[0x80848a110] main input debug: Buffering 2%[0x80848a110] main input debug: Buffering 5%[0x80848a110] main input debug: Buffering 7%[0x80848a110] main input debug: Buffering 10%[0x80848a110] main input debug: Buffering 13%[0x80848a110] main input debug: Buffering 15%[0x80848a110] main input debug: Buffering 18%[0x80848a110] main input debug: Buffering 20%[0x80848a110] main input debug: Buffering 23%[0x80848a110] main input debug: Buffering 26%[0x80848a110] main input debug: Buffering 28%[0x80848a110] main input debug: Buffering 31%[0x80848a110] main input debug: Buffering 33%[0x80848a110] main input debug: Buffering 36%[0x80848a110] main input debug: Buffering 39%[0x80848a110] main input debug: Buffering 41%[0x80848a110] main input debug: Buffering 44%[0x80848a110] main input debug: Buffering 47%[0x80848a110] main input debug: Buffering 49%[0x80848a110] main input debug: Buffering 52%[0x80848a110] main input debug: Buffering 54%[0x80848a110] main input debug: Buffering 57%[0x80848a110] main input debug: Buffering 60%[0x80848a110] main input debug: Buffering 62%[0x80848a110] main input debug: Buffering 65%[0x80848a110] main input debug: Buffering 67%[0x80848a110] main input debug: Buffering 70%[0x80848a110] main input debug: Buffering 73%[0x80848a110] main input debug: Buffering 75%[0x80848a110] main input debug: Buffering 78%[0x80848a110] main input debug: Buffering 80%[0x80848a110] main input debug: Buffering 83%[0x80848a110] main input debug: Buffering 86%[0x80848a110] main input debug: Buffering 88%[0x80848a110] main input debug: Buffering 91%[0x80848a110] main input debug: Buffering 94%[0x80848a110] main input debug: Buffering 96%[0x80848a110] main input debug: Buffering 99%[0x80848a110] main input debug: Stream buffering done (1018 ms in 3 ms)[0x8022b6850] mpeg_audio decoder debug: MPGA channels:2 samplerate:44100 bitrate:320[0x8020ac590] main playlist debug: reusing audio output[0x802150a50] oss audio output debug: using OSS device: /dev/dsp[0x802150a50] main audio output debug: output 's16l' 44100 Hz Stereo frame=1 samples/4 bytes[0x807da1950] main volume debug: looking for audio volume module matching "any": 2 candidates[0x807da1950] main volume debug: using audio volume module "integer_mixer"[0x802150a50] main audio output debug: input 'mpga' 44100 Hz Stereo frame=1152 samples/1053 bytes[0x807e56850] main audio filter debug: looking for audio filter module matching "scaletempo": 14 candidates[0x807e56850] scaletempo audio filter debug: format: 44100 rate, 2 nch, 4 bps, fl32[0x807e56850] scaletempo audio filter debug: params: 30 stride, 0.200 overlap, 14 search[0x807e56850] scaletempo audio filter debug: 1.000 scale, 1323.000 stride_in, 1323 stride_out, 1059 standing, 264 overlap, 617 search, 2204 queue, fl32 mode[0x807e56850] main audio filter debug: using audio filter module "scaletempo"[0x802150a50] main audio output debug: conversion: 'mpga'->'f32l' 44100 Hz->44100 Hz Stereo->Stereo[0x807e56c50] main audio converter debug: looking for audio converter module matching "any": 11 candidates[0x807e56c50] main audio converter debug: no audio converter modules matched[0x807e56c50] main audio converter debug: looking for audio converter module matching "any": 11 candidates[0x807e56c50] mpgatofixed32 audio converter debug: mpga->f32l, bits per sample: 32[0x807e56c50] main audio converter debug: using audio converter module "mpgatofixed32"[0x802150a50] main audio output debug: conversion pipeline complete[0x802150a50] main audio output debug: conversion: 'f32l'->'s16l' 44100 Hz->44100 Hz Stereo->Stereo[0x807e57050] main audio converter debug: looking for audio converter module matching "any": 11 candidates[0x807e57050] audio_format audio converter debug: f32l->s16l, bits per sample: 0->16[0x807e57050] main audio converter debug: using audio converter module "audio_format"[0x802150a50] main audio output debug: conversion pipeline complete[0x807e57450] main audio resampler debug: looking for audio resampler module matching "any": 2 candidates[0x807e57450] main audio resampler debug: using audio resampler module "ugly_resampler"[0x8022b6850] main decoder debug: End of audio preroll[0x80848a110] main input debug: Decoder buffering done in 6 ms[0x802150a50] main audio output debug: inserting 422 zeroes[0x802150a50] main audio output warning: playback too late (120755): up-sampling[0x802150a50] main audio output warning: playback way too late (209221): flushing buffers[0x802150a50] main audio output warning: playback too late (209394): up-sampling[0x802150a50] main audio output warning: playback way too late (297812): flushing buffers[0x802150a50] main audio output warning: playback too late (297902): up-sampling[0x802150a50] main audio output warning: playback way too late (386299): flushing buffers[0x802150a50] main audio output warning: playback too late (386385): up-sampling[0x802150a50] main audio output warning: playback way too late (474777): flushing buffers[0x802150a50] main audio output warning: playback too late (474952): up-sampling[0x802150a50] main audio output warning: playback way too late (563386): flushing buffers[0x802150a50] main audio output warning: playback too late (563480): up-sampling[0x802150a50] main audio output warning: playback way too late (651896): flushing buffers[0x802150a50] main audio output warning: playback too late (651982): up-sampling[0x802150a50] main audio output warning: playback way too late (740363): flushing buffers[0x802150a50] main audio output warning: playback too late (740551): up-sampling[0x802150a50] main audio output warning: playback way too late (828953): flushing buffers[0x802150a50] main audio output warning: playback too late (829040): up-sampling[0x802150a50] main audio output warning: playback way too late (917425): flushing buffers[0x802150a50] main audio output warning: playback too late (917510): up-sampling[0x802150a50] main audio output warning: playback way too late (1005905): flushing buffers[0x802150a50] main audio output warning: playback too late (1006063): up-sampling[0x802150a50] main audio output warning: playback way too late (1094451): flushing buffers[0x802150a50] main audio output warning: playback too late (1094533): up-sampling[0x802150a50] main audio output warning: playback way too late (1182910): flushing buffers[0x802150a50] main audio output warning: playback too late (1183007): up-sampling[0x802150a50] main audio output warning: playback way too late (1226285): flushing buffers[0x802150a50] main audio output warning: playback too late (1226541): up-sampling[0x802150a50] main audio output warning: playback way too late (1242367): flushing buffers[0x802150a50] main audio output warning: playback too late (1242521): up-sampling[0x802150a50] main audio output warning: playback way too late (1222432): flushing buffers[0x802150a50] main audio output warning: playback too late (1222583): up-sampling[0x802150a50] main audio output warning: playback way too late (1238498): flushing buffers[0x802150a50] main audio output warning: playback too late (1238748): up-sampling[0x802150a50] main audio output warning: playback way too late (1218547): flushing buffers[0x802150a50] main audio output warning: playback too late (1218702): up-sampling[0x802150a50] main audio output warning: playback way too late (1234631): flushing buffers[0x802150a50] main audio output warning: playback too late (1234779): up-sampling[0x802150a50] main audio output warning: playback way too late (1214695): flushing buffers[0x802150a50] main audio output warning: playback too late (1214972): up-sampling[0x802150a50] main audio output warning: playback way too late (1230727): flushing buffers[0x802150a50] main audio output warning: playback too late (1230880): up-sampling[0x802150a50] main audio output warning: playback way too late (1246881): flushing buffers[0x802150a50] main audio output warning: playback too late (1247038): up-sampling[0x802150a50] main audio output warning: playback way too late (1226861): flushing buffers[0x802150a50] main audio output warning: playback too late (1227115): up-sampling[0x802150a50] main audio output warning: playback way too late (1242997): flushing buffers[0x802150a50] main audio output warning: playback too late (1243159): up-sampling[0x802150a50] main audio output warning: playback way too late (1222967): flushing buffers[0x802150a50] main audio output warning: playback too late (1223128): up-sampling[0x802150a50] main audio output warning: playback way too late (1239135): flushing buffers[0x802150a50] main audio output warning: playback too late (1239292): up-sampling[0x802150a50] main audio output warning: playback way too late (1219124): flushing buffers[0x802150a50] main audio output warning: playback too late (1219274): up-sampling[0x802150a50] main audio output warning: playback way too late (1235274): flushing buffers[0x802150a50] main audio output warning: playback too late (1235422): up-sampling[0x802150a50] main audio output warning: playback way too late (1215233): flushing buffers[0x802150a50] main audio output warning: playback too late (1215382): up-sampling[0x802150a50] main audio output warning: playback way too late (1231384): flushing buffers[0x802150a50] main audio output warning: playback too late (1231552): up-sampling[0x802150a50] main audio output warning: playback way too late (1247417): flushing buffers[0x802150a50] main audio output warning: playback too late (1247566): up-sampling[0x802150a50] main audio output warning: playback way too late (1227489): flushing buffers[0x802150a50] main audio output warning: playback too late (1227641): up-sampling[0x802150a50] main audio output warning: playback way too late (1243548): flushing buffers[0x802150a50] main audio output warning: playback too late (1243703): up-sampling[0x802150a50] main audio output warning: playback way too late (1223622): flushing buffers[0x802150a50] main audio output warning: playback too late (1223776): up-sampling[0x802150a50] main audio output warning: playback way too late (1239660): flushing buffers[0x802150a50] main audio output warning: playback too late (1239829): up-sampling[0x802150a50] main audio output warning: playback way too late (1219755): flushing buffers[0x802150a50] main audio output warning: playback too late (1219907): up-sampling[0x802150a50] main audio output warning: playback way too late (1235802): flushing buffers[0x802150a50] main audio output warning: playback too late (1235957): up-sampling[0x802150a50] main audio output warning: playback way too late (1215885): flushing buffers[0x802150a50] main audio output warning: playback too late (1216049): up-sampling[0x802150a50] main audio output warning: playback way too late (1231937): flushing buffers[0x802150a50] main audio output warning: playback too late (1232093): up-sampling[0x802150a50] main audio output warning: playback way too late (1247974): flushing buffers[0x802150a50] main audio output warning: playback too late (1248127): up-sampling[0x802150a50] main audio output warning: playback way too late (1228042): flushing buffers[0x802150a50] main audio output warning: playback too late (1228205): up-sampling[0x802150a50] main audio output warning: playback way too late (1244116): flushing buffers[0x802150a50] main audio output warning: playback too late (1244276): up-sampling[0x802150a50] main audio output warning: playback way too late (1224201): flushing buffers[0x802150a50] main audio output warning: playback too late (1224346): up-sampling[0x802150a50] main audio output warning: playback way too late (1240306): flushing buffers[0x802150a50] main audio output warning: playback too late (1240438): up-sampling[0x802150a50] main audio output warning: playback way too late (1220308): flushing buffers[0x802150a50] main audio output warning: playback too late (1220464): up-sampling[0x802150a50] main audio output warning: playback way too late (1236358): flushing buffers[0x802150a50] main audio output warning: playback too late (1236540): up-sampling[0x802150a50] main audio output warning: playback way too late (1216419): flushing buffers[0x802150a50] main audio output warning: playback too late (1216570): up-sampling[0x802150a50] main audio output warning: playback way too late (1232493): flushing buffers[0x802150a50] main audio output warning: playback too late (1232641): up-sampling[0x802150a50] main audio output warning: playback way too late (1248536): flushing buffers[0x802150a50] main audio output warning: playback too late (1248694): up-sampling[0x802150a50] main audio output warning: playback way too late (1228627): flushing buffers[0x802150a50] main audio output warning: playback too late (1228763): up-sampling[0x802150a50] main audio output warning: playback way too late (1244675): flushing buffers[0x802150a50] main audio output warning: playback too late (1244833): up-sampling[0x802150a50] main audio output warning: playback way too late (1224741): flushing buffers[0x802150a50] main audio output warning: playback too late (1224913): up-sampling[0x802150a50] main audio output warning: playback way too late (1241197): flushing buffers[0x802150a50] main audio output warning: playback too late (1241330): up-sampling[0x802150a50] main audio output warning: playback way too late (1220870): flushing buffers[0x802150a50] main audio output warning: playback too late (1221019): up-sampling[0x802150a50] main audio output warning: playback way too late (1236909): flushing buffers[0x802150a50] main audio output warning: playback too late (1237056): up-sampling[0x802150a50] main audio output warning: playback way too late (1216974): flushing buffers[0x802150a50] main audio output warning: playback too late (1217121): up-sampling[0x802150a50] main audio output warning: playback way too late (1233026): flushing buffers[0x802150a50] main audio output warning: playback too late (1233190): up-sampling[0x802150a50] main audio output warning: playback way too late (1249083): flushing buffers[0x802150a50] main audio output warning: playback too late (1249328): up-sampling[0x802150a50] main audio output warning: playback way too late (1229172): flushing buffers[0x802150a50] main audio output warning: playback too late (1229319): up-sampling[0x802150a50] main audio output warning: playback way too late (1245211): flushing buffers[0x802150a50] main audio output warning: playback too late (1245346): up-sampling[0x802150a50] main audio output warning: playback way too late (1225294): flushing buffers[0x802150a50] main audio output warning: playback too late (1225528): up-sampling[0x802150a50] main audio output warning: playback way too late (1241337): flushing buffers[0x802150a50] main audio output warning: playback too late (1241496): up-sampling[0x802150a50] main audio output warning: playback way too late (1221411): flushing buffers[0x802150a50] main audio output warning: playback too late (1221577): up-sampling[0x802150a50] main audio output warning: playback way too late (1237455): flushing buffers[0x802150a50] main audio output warning: playback too late (1237707): up-sampling[0x802150a50] main audio output warning: playback way too late (1217555): flushing buffers[0x802150a50] main audio output warning: playback too late (1217703): up-sampling[0x802150a50] main audio output warning: playback way too late (1233578): flushing buffers[0x802150a50] main audio output warning: playback too late (1233729): up-sampling[0x802150a50] main audio output warning: playback way too late (1213669): flushing buffers[0x802150a50] main audio output warning: playback too late (1213912): up-sampling[0x802150a50] main audio output warning: playback way too late (1229718): flushing buffers[0x802150a50] main audio output warning: playback too late (1229870): up-sampling[0x802150a50] main audio output warning: playback way too late (1245863): flushing buffers[0x802150a50] main audio output warning: playback too late (1246021): up-sampling[0x802150a50] main audio output warning: playback way too late (1225835): flushing buffers[0x802150a50] main audio output warning: playback too late (1226090): up-sampling[0x802150a50] main audio output warning: playback way too late (1241984): flushing buffers[0x802150a50] main audio output warning: playback too late (1242135): up-sampling[0x802150a50] main audio output warning: playback way too late (1221951): flushing buffers[0x802150a50] main audio output warning: playback too late (1222115): up-sampling[0x802150a50] main audio output warning: playback way too late (1238119): flushing buffers[0x802150a50] main audio output warning: playback too late (1238375): up-sampling[0x802150a50] main audio output warning: playback way too late (1218112): flushing buffers[0x802150a50] main audio output warning: playback too late (1218271): up-sampling[0x802150a50] main audio output warning: playback way too late (1234257): flushing buffers[0x802150a50] main audio output warning: playback too late (1234392): up-sampling[0x802150a50] main audio output warning: playback way too late (1214229): flushing buffers[0x802150a50] main audio output warning: playback too late (1214473): up-sampling
Interesting, when I compile Vlc with '--disable-mad', the "playback too late" messages stop appearing and the playback of an .mp3 file seems to be working fine.