Mercurial > mplayer.hg
comparison libao2/ao_oss.c @ 4788:d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
author | anders |
---|---|
date | Thu, 21 Feb 2002 16:02:26 +0000 |
parents | f648f699eda6 |
children | 5b4fd881200a |
comparison
equal
deleted
inserted
replaced
4787:1ee5574d67d6 | 4788:d678ce495a75 |
---|---|
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 //#include <sys/soundcard.h> | 10 //#include <sys/soundcard.h> |
11 | 11 |
12 #include "../config.h" | 12 #include "../config.h" |
13 #include "../mixer.h" | |
13 | 14 |
14 #include "afmt.h" | 15 #include "afmt.h" |
15 | 16 |
16 #include "audio_out.h" | 17 #include "audio_out.h" |
17 #include "audio_out_internal.h" | 18 #include "audio_out_internal.h" |
33 static char *dsp="/dev/dsp"; | 34 static char *dsp="/dev/dsp"; |
34 static audio_buf_info zz; | 35 static audio_buf_info zz; |
35 static int audio_fd=-1; | 36 static int audio_fd=-1; |
36 | 37 |
37 char *oss_mixer_device = "/dev/mixer"; | 38 char *oss_mixer_device = "/dev/mixer"; |
38 int oss_mixer_usemaster = 0; | |
39 | 39 |
40 // to set/get/query special features/parameters | 40 // to set/get/query special features/parameters |
41 static int control(int cmd,int arg){ | 41 static int control(int cmd,int arg){ |
42 switch(cmd){ | 42 switch(cmd){ |
43 case AOCONTROL_SET_DEVICE: | 43 case AOCONTROL_SET_DEVICE: |
52 int fd, v, mcmd, devs; | 52 int fd, v, mcmd, devs; |
53 | 53 |
54 if(ao_data.format == AFMT_AC3) | 54 if(ao_data.format == AFMT_AC3) |
55 return CONTROL_TRUE; | 55 return CONTROL_TRUE; |
56 | 56 |
57 if ((fd = open("/dev/mixer", O_RDONLY)) > 0) | 57 if ((fd = open(oss_mixer_device, O_RDONLY)) > 0) |
58 { | 58 { |
59 ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs); | 59 ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs); |
60 if ((devs & SOUND_MASK_PCM) && (oss_mixer_usemaster == 0)) | 60 if (devs & SOUND_MASK_PCM) |
61 { | |
61 if (cmd == AOCONTROL_GET_VOLUME) | 62 if (cmd == AOCONTROL_GET_VOLUME) |
62 mcmd = SOUND_MIXER_READ_PCM; | 63 { |
64 ioctl(fd, SOUND_MIXER_READ_PCM, &v); | |
65 vol->right = (v & 0xFF00) >> 8; | |
66 vol->left = v & 0x00FF; | |
67 } | |
63 else | 68 else |
64 mcmd = SOUND_MIXER_WRITE_PCM; | 69 { |
65 else if ((devs & SOUND_MASK_VOLUME) && (oss_mixer_usemaster == 1)) | 70 v = ((int)vol->right << 8) | (int)vol->left; |
66 if (cmd == AOCONTROL_GET_VOLUME) | 71 ioctl(fd, SOUND_MIXER_WRITE_PCM, &v); |
67 mcmd = SOUND_MIXER_READ_VOLUME; | 72 } |
68 else | 73 } |
69 mcmd = SOUND_MIXER_WRITE_VOLUME; | |
70 else | 74 else |
71 { | 75 { |
72 close(fd); | 76 close(fd); |
73 return CONTROL_ERROR; | 77 return CONTROL_ERROR; |
74 } | |
75 | |
76 if (cmd == AOCONTROL_GET_VOLUME) | |
77 { | |
78 ioctl(fd, cmd, &v); | |
79 vol->right = (v & 0xFF00) >> 8; | |
80 vol->left = v & 0x00FF; | |
81 } | |
82 else | |
83 { | |
84 v = ((int)vol->right << 8) | (int)vol->left; | |
85 ioctl(fd, cmd, &v); | |
86 } | 78 } |
87 close(fd); | 79 close(fd); |
88 return CONTROL_OK; | 80 return CONTROL_OK; |
89 } | 81 } |
90 } | 82 } |
100 printf("ao2: %d Hz %d chans %s\n",rate,channels, | 92 printf("ao2: %d Hz %d chans %s\n",rate,channels, |
101 audio_out_format_name(format)); | 93 audio_out_format_name(format)); |
102 | 94 |
103 if (ao_subdevice) | 95 if (ao_subdevice) |
104 dsp = ao_subdevice; | 96 dsp = ao_subdevice; |
97 | |
98 if(mixer_device) | |
99 oss_mixer_device=mixer_device; | |
105 | 100 |
106 if (verbose) | 101 if (verbose) |
107 printf("audio_setup: using '%s' dsp device\n", dsp); | 102 printf("audio_setup: using '%s' dsp device\n", dsp); |
108 | 103 |
109 audio_fd=open(dsp, O_WRONLY); | 104 audio_fd=open(dsp, O_WRONLY); |