[Live-devel] wis-streamer: Unable to find emulated OSS device

DZ di.mailorama at gmail.com
Sat Jun 7 18:59:10 PDT 2008


I saw a couple of posts back in 2006 about the same problem:

http://lists.live555.com/pipermail/live-devel/2006-October/005313.html
http://lists.live555.com/pipermail/live-devel/2006-October/005244.html

I dunno if wis-streamer is still maintained or not.

In the original post the poster had the following in his
/proc/asound/oss/devices:

  0: [0- 0]: mixer
  1:       : sequencer
  2: [0- 0]: raw midi
  3: [0- 0]: digital audio
  4: [0- 0]: digital audio
  8:       : sequencer
  9: [0- 0]: raw midi
12: [0- 1]: digital audio
13: [0- 1]: raw midi
14: [0- 1]: raw midi
16: [1- 0]: mixer		<------------1
19: [1- 0]: digital audio	<------------2
20: [1- 0]: digital audio

The code snippet that seems to misbehave is:

WISInput.cpp line 195:

// Find the OSS emulation minor number for this ALSA device:
    char const* ossFileName = "/proc/asound/oss/devices";
    FILE* file = fopen(ossFileName, "r");
    if (file == NULL) {
      err(env) << "Unable to open \"" << ossFileName << "\""; printErr(env);
      env << "Is the snd_pcm_oss module loaded?\n";
      break;
    }
    int minor = -1;
    char line[128];
    while (fgets(line, sizeof line, file) != NULL) {
      int m, n;

line 207:
      if (sscanf(line, "%d: [%u-%*u]: digital audio\n", &m, &n) != 2) 
continue;

line 208:
      if (n == i) {
	minor = m;
	break;
      }
    }

The problem is that sscanf's return result will be 2 for every line 
except line 2 (1: : sequencer)
in the above example of the "devices" file regardless of whether the 
line ends with "digital audio" or not.
This is not a bug in sscanf, but an actual behavior. It will simply 
return the number of arguments
that it managed to match before it failed.

In the above example the guy's major number "i" was 1, so all the lines 
up to "16: [1-..." were rejected
by comparison on line 208. For that particular line "16: [- 0]: mixer" 
sscanf will return 2 as soon as it
fails to match ": digital audio" and comparison on line 208 will yield 
true and minor will be assigned 16.
Whereas it should be 19.

There is similar comparison being done in the original wis-go7007 driver 
package (apps/gorecord.c) and they
have an additional check:

	while ((fgets(line, sizeof(line), file)) != NULL) {
		unsigned int n;
		int m;
		char *c;

		if ((c = strrchr(line, ':')) == NULL ||
				strcmp(c, ": digital audio\n") ||
				sscanf(line, "%d: [%u-%*u]:", &m, &n) != 2)
			continue;
		if (n == i) {
			minor = m;
			break;
		}
	}

TJ


-- 
  One man's "magic" is another man's engineering. "Supernatural" is a
null word. (Robert A. Heinlein)


More information about the live-devel mailing list