Date: Thu, 15 Jun 2006 09:38:53 GMT From: Ryan Beasley <ryanb@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 99294 for review Message-ID: <200606150938.k5F9crRR019892@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=99294 Change 99294 by ryanb@ryanb_yuki on 2006/06/15 09:38:35 Provide FreeBSD-specific vendor/version information (instead of example 4Front strings) via SNDCTL_SYSINFO ioctl. Fixed string termination bug (really!) in SNDCTL_SYSINFO handler (shouldn't assume static strings are shorter than fields, implying the terminating NUL would be included). Now keeping rough count of mixer devices in a global variable instead of iterating over mixer_cdevsw child devices. Affected files ... .. //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/mixer.c#3 edit .. //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/mixer.h#3 edit .. //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/sound.c#4 edit Differences ... ==== //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/mixer.c#3 (text+ko) ==== @@ -83,6 +83,13 @@ .d_name = "mixer", }; +#ifdef OSSV4_EXPERIMENT +/** + * Keeps a count of mixer devices; used only by OSSv4 SNDCTL_SYSINFO ioctl. + */ +int mixer_count = 0; +#endif + #ifdef USING_DEVFS static eventhandler_tag mixer_ehtag; #endif @@ -256,6 +263,10 @@ snddev = device_get_softc(dev); snddev->mixer_dev = pdev; +#ifdef OSSV4_EXPERIMENT + ++mixer_count; +#endif + return 0; bad: @@ -300,6 +311,10 @@ d->mixer_dev = NULL; +#ifdef OSSV4_EXPERIMENT + --mixer_count; +#endif + return 0; } @@ -558,25 +573,3 @@ SYSINIT(mixer_sysinit, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, mixer_sysinit, NULL); SYSUNINIT(mixer_sysuninit, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, mixer_sysuninit, NULL); #endif - -#ifdef OSSV4_EXPERIMENT -/** - * @brief Counts the number of mixers in the system. - * @returns Number of mixer devices - * - * Used for SNDCTL_SYSINFO. Return the number of mixer devices in the - * system. Gross hack! (There has to be a better way.) - */ -int -mixer_get_num_mixers(void) -{ - struct cdev *mdev; - int count = 0; - - LIST_FOREACH(mdev, &mixer_cdevsw.d_devs, si_list) { - ++count; - } - - return count; -} -#endif /* !OSSV4_EXPERIMENT */ ==== //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/mixer.h#3 (text+ko) ==== @@ -42,7 +42,7 @@ void *mix_getdevinfo(struct snd_mixer *m); #ifdef OSSV4_EXPERIMENT -int mixer_get_num_mixers(void); +extern int mixer_count; #endif /* !OSSV4_EXPERIMENT */ /* ==== //depot/projects/soc2006/rbeasley_sound/sys/dev/sound/pcm/sound.c#4 (text+ko) ==== @@ -1137,11 +1137,13 @@ void sound_oss_sysinfo(oss_sysinfo *si) { - static char si_product[] = "OSS/FreeBSD"; - static char si_version[] = "4.0.0a"; + static char si_product[] = "FreeBSD native OSS ABI"; + static char si_version[] = __XSTRING(__FreeBSD_version); strncpy(si->product, si_product, sizeof(si->product) - 1); + si->product[sizeof(si->product) - 1] = '\0'; strncpy(si->version, si_version, sizeof(si->version) - 1); + si->product[sizeof(si->product) - 1] = '\0'; si->versionnum = SOUND_VERSION; si->numaudios = (pcm_devclass != NULL) ? devclass_get_count(pcm_devclass) : @@ -1160,7 +1162,7 @@ */ si->nummidis = 0; si->numtimers = 0; - si->nummixers = mixer_get_num_mixers(); + si->nummixers = mixer_count; si->numcards = 0; /* OSSv4 docs: Intended only for test apps; API doesn't really have much of a concept of cards. Shouldn't be used by
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606150938.k5F9crRR019892>