Skip to contentSkip to conversation

ossaudio: do not enable by default

PATCH In review Anthony Liguori 4 participants 16 messages Nov 3, 2013 – Nov 7, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ossaudio: do not enable by default

Modern Linux's no longer support /dev/dsp so enabling it by default causes audio failures on newer Linux distros.

---
 audio/ossaudio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
audio/ossaudio.c +1 -1
index 007c641..3e04a58 100644
@@ -932,7 +932,7 @@ struct audio_driver oss_audio_driver = {
     .init           = oss_audio_init,
     .fini           = oss_audio_fini,
     .pcm_ops        = &oss_pcm_ops,
-    .can_be_default = 1,
+    .can_be_default = 0,
     .max_voices_out = INT_MAX,
     .max_voices_in  = INT_MAX,
     .voice_size_out = sizeof (OSSVoiceOut),
Signature · 1 line
1.8.3.1
Tested-by on v1 1/1
#1 lore raw

Am 03.11.2013 17:45, schrieb Anthony Liguori:

Quoted 7 lines

Modern Linux's no longer support /dev/dsp so enabling it by default causes audio failures on newer Linux distros.

---
 audio/ossaudio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

With my current config, this patch is not making a change. make check-qtest-arm succeeds on qom-next branch with and without it without any annoying output. So FWIW

Note that author and Sob differ, probably not intentionally.

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#2 lore raw
Quoted 9 lines · Andreas Färber

Am 03.11.2013 17:45, schrieb Anthony Liguori:

Quoted 7 lines

Modern Linux's no longer support /dev/dsp so enabling it by default causes audio failures on newer Linux distros.

---
 audio/ossaudio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 7 lines

With my current config, this patch is not making a change. make check-qtest-arm succeeds on qom-next branch with and without it without any annoying output. So FWIW

Note that author and Sob differ, probably not intentionally.

Nope, thanks.

Regards,

Anthony Liguori

Quoted 7 lines

Regards,
Andreas

--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

#3 lore raw
In reply to Anthony Liguori
Quoted 2 lines · Anthony Liguori

Modern Linux's no longer support /dev/dsp so enabling it by default causes audio failures on newer Linux distros.

That will break sound on BSD.

I think we should do something like this instead:

configure +1 -1
@@ -554,7 +554,7 @@ Haiku)
   LIBS="-lposix_error_mapper -lnetwork $LIBS"
 ;;
 *)
-  audio_drv_list="oss"
+  audio_drv_list="pa alsa oss"
   audio_possible_drivers="oss alsa sdl esd pa"
   linux="yes"
   linux_user="yes"

i.e. build pulseaudio and alsa by default on linux and prioritize them over oss.

cheers,
Gerd

#4 lore raw
Quoted 20 lines · Gerd Hoffmann
Quoted 2 lines · Anthony Liguori

Modern Linux's no longer support /dev/dsp so enabling it by default causes audio failures on newer Linux distros.

That will break sound on BSD.

I think we should do something like this instead:

configure +1 -1
@@ -554,7 +554,7 @@ Haiku)
   LIBS="-lposix_error_mapper -lnetwork $LIBS"
 ;;
 *)
-  audio_drv_list="oss"
+  audio_drv_list="pa alsa oss"
   audio_possible_drivers="oss alsa sdl esd pa"
   linux="yes"
   linux_user="yes"
Quoted 2 lines

i.e. build pulseaudio and alsa by default on linux and prioritize them over oss.

This patch just requires that you explicitly select oss so it's not breaking audio on BSD.

Since the oss code can fail to initialize without handling it gracefully, it really cannot be default on any platform.

Same problem would occur on BSD if the permissions on /dev/dsp were restrictive.

Regards,

Anthony Liguori

Quoted 3 lines

cheers,
Gerd

#5 lore raw
Quoted 2 lines · Anthony Liguori

Since the oss code can fail to initialize without handling it gracefully, it really cannot be default on any platform.

Can you describe what the actual problem is we're trying to fix here, please? I can't see a description of it in any of the mailing list threads (there are references to irc conversations but it's really not clear what the actual symptoms are).

I have a system with no /dev/dsp, and it can build and run systems fine (including passing 'make check') with the oss backend as the (default-by-configure) only backend. The only thing that happens is that there are a bunch of warnings from ossaudio, like this:
oss: Could not initialize ADC
oss: Failed to open `/dev/dsp'
oss: Reason: No such file or directory
oss: Could not initialize ADC
oss: Failed to open `/dev/dsp'
oss: Reason: No such file or directory
audio: Failed to create voice `mm_ac97.in'

but they don't prevent make check from working,
they don't prevent systems from booting, and they
have been present for *years*.

I really don't see why you suddenly needed to
apply this patch despite the fact that most of
the response you got to it was negative.

thanks
-- PMM

#6 lore raw
In reply to Anthony Liguori
Quoted 2 lines · Anthony Liguori

This patch just requires that you explicitly select oss so it's not breaking audio on BSD.

That sounds to me like it's breaking audio for all the users for whom it previously worked out of the box without any particular configure or command line options. In fact I suspect it also breaks audio for all the *linux* users for whom it previously worked without special options.

-- PMM

#7 lore raw
Quoted 9 lines · Peter Maydell
Quoted 2 lines · Anthony Liguori

This patch just requires that you explicitly select oss so it's not breaking audio on BSD.

That sounds to me like it's breaking audio for all the users for whom it previously worked out of the box without any particular configure or command line options. In fact I suspect it also breaks audio for all the *linux* users for whom it previously worked without special options.

Yes, it does. Sound is broken by default now. Only oss is compiled by default, but it isn't used any more unless you explicitly request that.

My suggestion has it problems too, when adding alsa that way without having alsa-devel package installed the build breaks.

I think the audio backend handling needs a serious makeover. Detect sound libraries (pulse, esd, alsa, ...) via configure like any other library. Zap the whole can_be_default logic. Replace it by walking the list of backends, sorted by priority, take the first which initializes successfully.

That is clearly 1.8 material though. I think for 1.7 we should simply leave things as-is. I have a custom --audio-drv-list in my build scripts for ages, and I suspect all distros and anyone who compiles itself and cares about audio has.

cheers,
Gerd

#8 lore raw
Quoted 5 lines · Gerd Hoffmann

I think the audio backend handling needs a serious makeover. Detect sound libraries (pulse, esd, alsa, ...) via configure like any other library. Zap the whole can_be_default logic. Replace it by walking the list of backends, sorted by priority, take the first which initializes successfully.

I agree on the need for a serious overhaul. I think the thing we're actually hitting at the moment is that none of the backends are quiet when they fail to initialize, which is bad since we already have "loop through and take first which initializes" logic.

Quoted 2 lines

That is clearly 1.8 material though. I think for 1.7 we should simply leave things as-is.

Do you mean "as-is with Anthony's patch applied", or "as it was before that patch was applied" ? I would suggest the latter (ie revert this patch), because that's the safest choice this close to release.

thanks
-- PMM

#9 lore raw
Quoted 5 lines · Peter Maydell
Quoted 2 lines

That is clearly 1.8 material though. I think for 1.7 we should simply leave things as-is.

Do you mean "as-is with Anthony's patch applied", or "as it was before that patch was applied" ?

Oh, it is in?

Quoted 3 lines

I would suggest the latter
(ie revert this patch), because that's the safest choice this close to release.

Agree.

cheers,
Gerd

#10 lore raw
Quoted 8 lines · Gerd Hoffmann
Quoted 5 lines · Peter Maydell
Quoted 2 lines

That is clearly 1.8 material though. I think for 1.7 we should simply leave things as-is.

Do you mean "as-is with Anthony's patch applied", or "as it was before that patch was applied" ?

Quoted 7 lines

Oh, it is in?

Quoted 3 lines

I would suggest the latter
(ie revert this patch), because that's the safest choice this close to release.

Agree.

I don't think you guys understand what is happening.

As ossaudio is able to be default, it *will be selected* as the audio output backend unconditionally. You aren't seeing errors during probing, you're seeing errors post-initialization.

The ossaudio init function is simply:

static void *oss_audio_init (void)

{
    return &conf;
}

It never fails. So audio is broken on Linux by default today. This patch unbreaks it. If you compare this to the pulseaudio backend where init can actually fail, you can see why it can be default but ossaudio really can't.

Regards,

Anthony Liguori

Quoted 4 lines

cheers,
Gerd

#11 lore raw
Quoted 6 lines · Anthony Liguori

I don't think you guys understand what is happening.

As ossaudio is able to be default, it *will be selected* as the audio output backend unconditionally. You aren't seeing errors during probing, you're seeing errors post-initialization.

Quoted 8 lines

The ossaudio init function is simply:

static void *oss_audio_init (void)

{
    return &conf;
}

It never fails.

OK, that's a bug. (I'd misread the calling function audio_driver_init() as also checking that the init_in and init_out functions succeeded, which it does not.)

Quoted 2 lines

So audio is broken on Linux by default today. This patch unbreaks it.

No, this patch is papering over the problem by giving us a default config where audio works for nobody.

If you want to fix that problem you need to do it by making the oss_audio_init() function return failure on init.

I think the major point is still the same:
* there is a bug here
* this patch doesn't fix it
* this bug has been present for years
* we should leave 1.7 behaving like 1.6 & earlier, and fix properly for 1.8

-- PMM

#12 lore raw

Hi,

Quoted 14 lines
Quoted 6 lines

static void *oss_audio_init (void)

{
    return &conf;
}

It never fails.

OK, that's a bug. (I'd misread the calling function audio_driver_init() as also checking that the init_in and init_out functions succeeded, which it does not.)

Quoted 2 lines

So audio is broken on Linux by default today. This patch unbreaks it.

Quoted 6 lines

No, this patch is papering over the problem by giving us a default config where audio works for nobody.

If you want to fix that problem you need to do it by making the oss_audio_init() function return failure on init.

And that is actually simple enough that we can consider it for 1.7:

static void *oss_audio_init (void)
{
+ if (access(conf.devpath_in, R_OK | W_OK) < 0 ||
+ access(conf.devpath_out, R_OK | W_OK) < 0) {
+ return NULL;
+ }

     return &conf;

}

cheers,
Gerd

#13 lore raw
Quoted 27 lines · Gerd Hoffmann

Hi,

Quoted 14 lines
Quoted 6 lines

static void *oss_audio_init (void)

{
    return &conf;
}

It never fails.

OK, that's a bug. (I'd misread the calling function audio_driver_init() as also checking that the init_in and init_out functions succeeded, which it does not.)

Quoted 2 lines

So audio is broken on Linux by default today. This patch unbreaks it.

Quoted 6 lines

No, this patch is papering over the problem by giving us a default config where audio works for nobody.

If you want to fix that problem you need to do it by making the oss_audio_init() function return failure on init.

And that is actually simple enough that we can consider it for 1.7:

static void *oss_audio_init (void)
{

Review

Quoted 3 lines
(quoted diff) +3 -0
+    if (access(conf.devpath_in, R_OK | W_OK) < 0 ||
+        access(conf.devpath_out, R_OK | W_OK) < 0) {
+        return NULL;

That would be reasonable. Can you add a SoB and submit as a patch?

Regards,

Anthony Liguori

Quoted 8 lines

+ }

     return &conf;

}

cheers,
Gerd

#14 lore raw

Hi,

Quoted 9 lines

And that is actually simple enough that we can consider it for 1.7:

Review

Quoted 6 lines

static void *oss_audio_init (void)
{

(quoted diff) +3 -0
+    if (access(conf.devpath_in, R_OK | W_OK) < 0 ||
+        access(conf.devpath_out, R_OK | W_OK) < 0) {
+        return NULL;

That would be reasonable. Can you add a SoB and submit as a patch?

Pull req sent.

cheers,
Gerd

#15 lore raw
In reply to Anthony Liguori
Quoted 13 lines · Anthony Liguori

Modern Linux's no longer support /dev/dsp so enabling it by default causes audio failures on newer Linux distros.

---
 audio/ossaudio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
audio/ossaudio.c +0 -0
index 007c641..3e04a58 100644

audio/ossaudio.c struct audio_driver oss_audio_driver = { · line 938

Quoted 8 lines
audio/ossaudio.c +1 -1
@@ -932,7 +932,7 @@ struct audio_driver oss_audio_driver = {
     .init           = oss_audio_init,
     .fini           = oss_audio_fini,
     .pcm_ops        = &oss_pcm_ops,
-    .can_be_default = 1,
+    .can_be_default = 0,
     .max_voices_out = INT_MAX,
     .max_voices_in  = INT_MAX,
     .voice_size_out = sizeof (OSSVoiceOut),

This doesn't look like the right fix for the problem given in the commit message. If the oss init function doesn't cleanly return a failure so we can loop round and try another driver then the init function should be fixed. If QEMU code itself is printing warnings then we should silence them. If you're just seeing warnings from some system audio library (ALSA/pulse/etc) then either file upstream bugs or just pass configure the correct audio driver option for your distro.

thanks
-- PMM