Changeset aef1799 in mainline
- Timestamp:
- 2012-07-17T10:57:41Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1f7da3b
- Parents:
- cd8f19d
- Files:
-
- 1 added
- 3 deleted
- 4 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/amd64/Makefile.inc
rcd8f19d raef1799 63 63 RD_APPS_ESSENTIAL += \ 64 64 $(USPACE_PATH)/app/edit/edit \ 65 $(USPACE_PATH)/app/dplay/dplay \66 $(USPACE_PATH)/app/drec/drec \67 65 $(USPACE_PATH)/app/mixerctl/mixerctl \ 68 66 $(USPACE_PATH)/app/wavplay/wavplay \ -
uspace/Makefile
rcd8f19d raef1799 38 38 app/bnchmark \ 39 39 app/devctl \ 40 app/dplay \41 40 app/drec \ 42 41 app/edit \ -
uspace/app/wavplay/Makefile
rcd8f19d raef1799 31 31 32 32 LIBS = \ 33 $(LIBHOUND_PREFIX)/libhound.a 33 $(LIBHOUND_PREFIX)/libhound.a \ 34 $(LIBDRV_PREFIX)/libdrv.a 34 35 35 36 EXTRA_CFLAGS = \ 36 -I$(LIBHOUND_PREFIX)/include -I$(LIBPCM_PREFIX)/include 37 -I$(LIBDRV_PREFIX)/include \ 38 -I$(LIBHOUND_PREFIX)/include \ 39 -I$(LIBPCM_PREFIX)/include 37 40 38 41 SOURCES = \ 39 wavplay.c \ 42 dplay.c \ 43 main.c \ 40 44 wave.c 41 45 -
uspace/app/wavplay/dplay.c
rcd8f19d raef1799 49 49 50 50 #include "wave.h" 51 #include "dplay.h" 51 52 52 53 #define DEFAULT_DEVICE "/hw/pci0/00:01.0/sb16/pcm" … … 153 154 } 154 155 155 int main(int argc, char *argv[]) 156 { 157 const char *device = DEFAULT_DEVICE; 158 const char *file; 159 switch (argc) { 160 case 2: 161 file = argv[1]; 162 break; 163 case 3: 164 device = argv[1]; 165 file = argv[2]; 166 break; 167 default: 168 printf("Usage: %s [device] file.\n", argv[0]); 169 return 1; 170 } 171 156 int dplay(const char *device, const char *file) 157 { 158 if (str_cmp(device, "default") == 0) 159 device = DEFAULT_DEVICE; 172 160 audio_pcm_sess_t *session = audio_pcm_open(device); 173 161 if (!session) { 174 printf("Failed to connect to device .\n");162 printf("Failed to connect to device %s.\n", device); 175 163 return 1; 176 164 } 165 printf("Playing on device: %s.\n", device); 177 166 178 167 const char* info = NULL; -
uspace/app/wavplay/main.c
rcd8f19d raef1799 41 41 #include <hound/client.h> 42 42 #include <pcm/sample_format.h> 43 43 #include <getopt.h> 44 45 #include "dplay.h" 44 46 #include "wave.h" 45 47 … … 119 121 } 120 122 123 static const struct option opts[] = { 124 {"device", required_argument, 0, 'd'}, 125 {"record", no_argument, 0, 'r'}, 126 {0, 0, 0, 0} 127 }; 128 129 121 130 int main(int argc, char *argv[]) 122 131 { 123 if (argc != 2) 124 return 1; 125 const char *file = argv[1]; 132 const char *device = "default"; 133 int idx = 0; 134 bool direct = false, record = false; 135 optind = 0; 136 int ret = 0; 137 while (ret != -1) { 138 ret = getopt_long(argc, argv, "d:r", opts, &idx); 139 switch (ret) { 140 case 'd': 141 direct = true; 142 device = optarg; 143 break; 144 case 'r': 145 record = true; 146 break; 147 }; 148 } 149 150 if (optind == argc) { 151 printf("Not enough arguments.\n"); 152 return 1; 153 } 154 const char *file = argv[optind]; 155 156 printf("%s %s\n", record ? "Recording" : "Playing", file); 157 if (record) { 158 printf("Recording is not supported yet.\n"); 159 return 1; 160 } 161 if (direct) 162 return dplay(device, file); 126 163 127 164 task_id_t tid = task_get_id(); … … 149 186 pcm_sample_format_t format; 150 187 const char *error; 151 const intret = wav_parse_header(&header, NULL, NULL, &channels, &rate,188 ret = wav_parse_header(&header, NULL, NULL, &channels, &rate, 152 189 &format, &error); 153 190 if (ret != EOK) { -
uspace/lib/pcm/src/format.c
rcd8f19d raef1799 219 219 { 220 220 assert(f); 221 assert(buffer); 221 222 if (channel >= f->channels) 222 223 return 0.0f; … … 232 233 /* This makes it positive */ \ 233 234 sample -= (float)(type)low; \ 234 if (sample < 0.0f) { \235 printf("SUB MIN failed\n"); \236 } \237 235 /* This makes it <0,2> */ \ 238 236 sample /= (((float)(type)high - (float)(type)low) / 2.0f); \ 239 if (sample > 2.0) { \240 printf("DIV RANGE failed\n"); \241 } \242 237 return sample - 1.0f; \ 243 238 } while (0)
Note:
See TracChangeset
for help on using the changeset viewer.