Changeset abaef81 in mainline
- Timestamp:
- 2013-03-16T23:47:27Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 36774cf
- Parents:
- 89d3946f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/wavplay/main.c
r89d3946f rabaef81 46 46 #include "wave.h" 47 47 48 #define BUFFER_SIZE (4 * 1024) 49 50 51 static int hplay(const char *filename) 52 { 53 FILE *source = fopen(filename, "rb"); 54 if (!source) 55 return EINVAL; 56 wave_header_t header; 57 size_t read = fread(&header, sizeof(header), 1, source); 58 if (read != sizeof(header)) { 59 fclose(source); 60 return EIO; 61 } 62 unsigned rate, channels; 63 pcm_sample_format_t format; 64 const char *error; 65 int ret = wav_parse_header(&header, NULL, NULL, &channels, &rate, 66 &format, &error); 67 if (ret != EOK) { 68 printf("Error parsing wav header: %s.\n", error); 69 fclose(source); 70 return EINVAL; 71 } 72 hound_context_t *hound = hound_context_create_playback(filename, 73 channels, rate, format, 0); 74 if (!hound) { 75 printf("Failed to create HOUND context\n"); 76 fclose(source); 77 return ENOMEM; 78 } 79 80 ret = hound_context_connect_target(hound, "default"); 81 if (ret != EOK) { 82 printf("Failed to connect to default target: %s\n", 83 str_error(ret)); 84 fclose(source); 85 return ENOMEM; 86 } 87 static char buffer[BUFFER_SIZE]; 88 size_t size = 0; 89 while ((size = fread(buffer, sizeof(buffer), 1, source)) > 0) { 90 ret = hound_write_main_stream(hound, buffer, size); 91 if (ret != EOK) { 92 printf("Failed to write to context main stream: %s\n", 93 str_error(ret)); 94 break; 95 } 96 } 97 fclose(source); 98 return ret; 99 } 100 48 101 typedef struct { 49 FILE *source;102 FILE *source; 50 103 volatile bool playing; 51 104 fibril_mutex_t mutex; … … 205 258 else 206 259 return play_hound(file); 260 (void)hplay; 207 261 } 208 262 /**
Note:
See TracChangeset
for help on using the changeset viewer.