mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alistair John Strachan <s0348365@sms.ed.ac.uk>
To: Heikki Orsila <shd@modeemi.cs.tut.fi>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [OT] ALSA userspace API complexity
Date: Thu, 5 Jan 2006 14:49:36 +0000	[thread overview]
Message-ID: <200601051449.36083.s0348365@sms.ed.ac.uk> (raw)
In-Reply-To: <20060105140155.GC757@jolt.modeemi.cs.tut.fi>

Firstly, trimming CCs is quite rude and makes it very difficult for others to 
address your problems.

On Thursday 05 January 2006 14:01, Heikki Orsila wrote:
> Alistair John Strachan <s0348365@sms.ed.ac.uk> wrote:
> > On Tuesday 03 January 2006 23:10, Tomasz K?oczko wrote:
> > 2) ALSA API is to complicated: most applications opens single sound
> >    stream.
> >
> > FUD and nonsense. I've written many DSP applications and very often I can
> > recycle the same code for use in them.
>
> It's not FUD and it's very true. I've written ALSA support for many
> programs and I still can't remember the tricks that are needed to get
> even basic things working.

They're not really tricks, they're allowing developers to flexibly handle 
cases that they may care about, such as momentary communication problems 
(think USB soundcards, headsets), versus unrecoverable errors. For example, 
the code I wrote handles your example below somewhat more easily:

	// try to play data
	for (i = 0; i < PLAYBACK_RETRIES; i++) {
		if ((err = snd_pcm_writei (card->playback.fd, card->buffer, card->frames)) < 
0) {
			adebug ("Had to re-init playback.\n");
			if ((err = snd_pcm_prepare (card->playback.fd)) < 0)
				return -PCM_PREPARATION_FAILED;
		}
		break;
	}

	// we couldn't reprepare
	if (i == PLAYBACK_RETRIES)
		return -PCM_WRITE_FAILED;

	return ALSA_SUCCESS;

PLAYBACK_RETRIES is arbitrary. Less robust software, or programs that were 
very sensitive to any sort of intermittent unavailability would error out 
immediately, without the for loop.

However, the documentation makes it fairly clear that in the case where a 
writei() fails, you must "re-prepare" the card for PCM IO. This can be 
attempted numerous times before giving up.

I agree that some sort of layman's wrapper might be helpful here, but please 
don't go back to the ways of a crippled OSS API by preventing us from 
handling these cases

> alsa_error_recovery() expands to 30 lines of more logic. This is pretty
> insane considering that libao _only_ writes data to device and does
> nothing else. If ALSA was done properly, the main loop would simply be:

This is ridiculous. Why bother? If libao is so simple, just break out if 
re-preparation fails.

>
>                 err = internal->writei(internal->pcm_handle, ptr, len);
>
>                 /* it's possible that no data was transferred */
>                 if (err == -EAGAIN || err == -EINTR) {
>                         continue;
>                 }
>
> 		if (err < 0) {
> 			/* BAD BAD */
> 		}

This looks suspiciously like what I have above. Clear, simple, non-broken. 
ALSA does it already.

> 	err = alsa_simple_pcm_open(nchannels, sampleformat, samplingrate,
> frames_in_period /* 0 for automated default */ ); err =
> alsa_simple_writei(); /* handless signal brokeness automagically */
> alsa_simple_close();

simple_{open,setup}() I agree with. There's no reason for that to have to be a 
whole stack of separate functions. Use return codes to indicate the type of 
failure.

simple_writei() might be okay, but it's pretty inflexible for even mildly 
complex problems requiring more than "just write data". The old mechanisms 
need to persist.

simple_close(), uhm.. snd_pcm_close (fd). Don't need it. I'm not sure why you 
think that is necessary.

-- 
Cheers,
Alistair.

'No sense being pessimistic, it probably wouldn't work anyway.'
Third year Computer Science undergraduate.
1F2 55 South Clerk Street, Edinburgh, UK.

  parent reply	other threads:[~2006-01-05 14:52 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5rdrx-4Yl-43@gated-at.bofh.it>
2006-01-05 14:01 ` Heikki Orsila
2006-01-05 14:24   ` Jaroslav Kysela
2006-01-05 14:45     ` Heikki Orsila
2006-01-10  9:22       ` Jaroslav Kysela
2006-01-10 11:50         ` Heikki Orsila
2006-01-05 14:51     ` Olivier Galibert
2006-01-05 15:26       ` Alexander E. Patrakov
2006-01-05 15:30         ` Jaroslav Kysela
2006-01-05 16:01           ` Alexander E. Patrakov
2006-01-05 18:11         ` Florian Schmidt
2006-01-05 15:33       ` Jaroslav Kysela
2006-01-05 16:48         ` Marcin Dalecki
2006-01-05 15:27     ` Heikki Orsila
2006-01-05 14:49   ` Alistair John Strachan [this message]
2006-01-08  7:19 linux
2006-01-08 22:08 ` Hannu Savolainen
     [not found] <4uzow-1g5-13@gated-at.bofh.it>
     [not found] ` <5r0aY-2If-41@gated-at.bofh.it>
     [not found]   ` <5r3Ca-88G-81@gated-at.bofh.it>
     [not found]     ` <5reGV-6YD-23@gated-at.bofh.it>
     [not found]       ` <5reGV-6YD-21@gated-at.bofh.it>
     [not found]         ` <5rf9X-7yf-25@gated-at.bofh.it>
2006-01-04 11:56           ` Patrizio Bassi
2006-01-04 18:07             ` Florian Schmidt
2006-01-04 18:46               ` Alistair John Strachan
2006-01-05 18:59             ` Lee Revell
2006-01-05 20:06               ` Patrizio Bassi
2006-01-05 20:11                 ` Lee Revell
2006-01-05 20:47               ` Patrizio Bassi
  -- strict thread matches above, loose matches on Subject: below --
2005-07-26 15:08 [2.6 patch] schedule obsolete OSS drivers for removal Adrian Bunk
2006-01-03 19:37 ` Adrian Bunk
2006-01-03 23:10   ` Tomasz Kłoczko
2006-01-04  9:37     ` [OT] ALSA userspace API complexity Alistair John Strachan
     [not found]     ` <mailman.1136368805.14661.linux-kernel2news@redhat.com>
2006-01-04 11:00       ` Pete Zaitcev
2006-01-04 11:35         ` Jaroslav Kysela
2006-01-04 11:47           ` Pete Zaitcev
2006-01-04 14:23           ` Alistair John Strachan
2006-01-05 11:41             ` Olivier Galibert
2006-01-05 12:01           ` Tomasz Kłoczko
2006-01-05 12:23             ` Jaroslav Kysela
2006-01-05 14:21               ` Olivier Galibert
2006-01-05 15:07               ` Tomasz Kłoczko
2006-01-05 16:14                 ` Takashi Iwai
2006-01-05 17:19                   ` Marcin Dalecki
2006-01-05 20:13                   ` Tomasz Kłoczko
2006-01-07 14:32                     ` Takashi Iwai
2006-01-08  2:03                       ` Olivier Galibert
2006-01-08  2:26                         ` Martin Drab
2006-01-08 13:21                           ` Olivier Galibert
2006-01-08 13:32                             ` Jaroslav Kysela
2006-01-08 23:18                               ` Pavel Machek
2006-01-08  9:42                         ` Jaroslav Kysela
2006-01-08 13:04                           ` Olivier Galibert
2006-01-08 13:23                             ` Jaroslav Kysela
2006-01-08 13:38                           ` Marcin Dalecki
2006-01-05 23:06                   ` Hannu Savolainen
2006-01-05 23:39                     ` Lee Revell
2006-01-05 23:56                       ` Hannu Savolainen
2006-01-06  0:03                         ` Lee Revell
2006-01-05 23:40                     ` Lee Revell
2006-01-05 23:59                       ` Hannu Savolainen
2006-01-06 15:03                         ` Stefan Smietanowski
2006-01-06 15:48                           ` Erik Mouw
2006-01-06 18:37                           ` Lee Revell
2006-01-10  9:43                         ` Jaroslav Kysela
2006-01-10 13:42                           ` Hannu Savolainen
2006-01-10 14:08                             ` Jaroslav Kysela
2006-01-10 14:17                               ` Hannu Savolainen
2006-01-10 20:13                               ` Marcin Dalecki
2006-01-06  0:14                       ` Marcin Dalecki
2006-01-06  0:29                         ` Martin Drab
2006-01-06  0:57                           ` Marcin Dalecki
2006-01-06  1:49                             ` Martin Drab
2006-01-06  1:21                         ` Zan Lynx
2006-01-06 15:17                           ` Stefan Smietanowski
2006-01-09 23:55                             ` jerome lacoste
2006-01-10  2:29                               ` Stefan Smietanowski
2006-01-06  3:14                     ` Edgar Toernig
2006-01-06  3:33                       ` Hannu Savolainen
2006-01-06 11:34                         ` Florian Schmidt
2006-01-06  7:47                     ` Jan Engelhardt
2006-01-07 14:45                     ` Takashi Iwai
2006-01-05 18:56                 ` Lee Revell
2006-01-05 22:39                 ` Joern Nettingsmeier
2006-01-05 23:44                   ` Tomasz Kłoczko
2006-01-05 23:49                   ` Olivier Galibert
2006-01-06  0:22                     ` Joern Nettingsmeier
2006-01-06  1:30                       ` Olivier Galibert
2006-01-06  2:20                       ` Hannu Savolainen
2006-01-10  9:54                         ` Jaroslav Kysela
2006-01-10 13:50                           ` Hannu Savolainen
2006-01-06  0:00                   ` Marcin Dalecki
2006-01-05 12:47             ` Leonard Milcin Jr.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200601051449.36083.s0348365@sms.ed.ac.uk \
    --to=s0348365@sms.ed.ac.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shd@modeemi.cs.tut.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®