FreeBSD Bugzilla – Attachment 114732 Details for
Bug 156433
[sound] [patch] OSS4/VPC is broken on 64-bit platforms
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
test_vol.c
test_vol.c (text/plain), 1.61 KB, created by
Test Rat
on 2011-07-29 01:25:37 UTC
(
hide
)
Description:
test_vol.c
Filename:
MIME Type:
Creator:
Test Rat
Created:
2011-07-29 01:25:37 UTC
Size:
1.61 KB
patch
obsolete
>#include <sys/ioctl.h> >#include <sys/soundcard.h> >#include <err.h> >#include <errno.h> >#include <fcntl.h> >#include <stdio.h> >#include <termios.h> >#include <unistd.h> > >int audio_fd; >int lvol, rvol; > >void >setplayvol(void) >{ > int mask = lvol | rvol << 8; > if(ioctl(audio_fd, SNDCTL_DSP_SETPLAYVOL, &mask) < 0) > err(errno, "SNDCTL_DSP_SETPLAYVOL failed"); >} > >void >getplayvol(void) >{ > int mask; > if(ioctl(audio_fd, SNDCTL_DSP_GETPLAYVOL, &mask) < 0) > err(errno, "SNDCTL_DSP_GETPLAYVOL failed"); > lvol = mask & 0x00ff; > rvol = (mask & 0xff00) >> 8; > printf("\rvol is %d:%d ", lvol, rvol); >} > >int >main(void) >{ > char ch, buf[] = "noise"; > struct termios t; > > if((audio_fd = open("/dev/dsp", O_WRONLY, 0)) < 0) > err(errno, "open failed"); > > printf("hit ^C to abort\n"); > getplayvol(); > > tcgetattr(0, &t); > t.c_lflag &= ~(ECHO|ICANON); > tcsetattr(0, TCSANOW, &t); > > while ((ch = getchar()) != EOF) { > switch(ch) { > case '+': > if(lvol < 100 && rvol < 100) { > lvol++; > rvol++; > } > break; > case '-': > if(lvol > 0 && rvol > 0) { > lvol--; > rvol--; > } > break; > case 'L': > case 'l': > if(lvol < 100) > lvol++; > break; > case 'R': > case 'r': > if(rvol < 100) > rvol++; > break; > case '\014': /* ^L */ > if(lvol > 0) > lvol--; > break; > case '\022': /* ^R */ > if(rvol > 0) > rvol--; > break; > case '\007': /* ^G */ > close(audio_fd); > if((audio_fd = open("/dev/dsp", O_WRONLY, 0)) < 0) > err(errno, "open failed"); > getplayvol(); > continue; > default: /* any other key produces noise */ > write(audio_fd, buf, sizeof(buf)); > continue; > } > setplayvol(); > getplayvol(); > } > > close(audio_fd); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 156433
:
114731
| 114732