Changeset 0a4ad7d in mainline
- Timestamp:
- 2013-04-10T18:14:40Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 76e863c
- Parents:
- e1d2f0e
- Location:
- uspace/app/wavplay
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/wavplay/Makefile
re1d2f0e r0a4ad7d 42 42 SOURCES = \ 43 43 dplay.c \ 44 drec.c \ 44 45 main.c \ 45 46 wave.c -
uspace/app/wavplay/main.c
re1d2f0e r0a4ad7d 45 45 46 46 #include "dplay.h" 47 #include "drec.h" 47 48 #include "wave.h" 48 49 … … 252 253 i - optind + 1, argc - optind, file); 253 254 if (record) { 254 printf("Recording is not supported yet.\n"); 255 return 1; 255 if (direct) { 256 drecord(device, file); 257 } else { 258 printf("Indirect recording is not supported " 259 "yet.\n"); 260 break; 261 } 256 262 } 257 263 if (direct) { -
uspace/app/wavplay/wave.c
re1d2f0e r0a4ad7d 39 39 #include "wave.h" 40 40 41 int wav_parse_header(void *file, const void **data, size_t *data_size, 41 /** 42 * Parse wav header data. 43 * @param[in] hdata Header data to parse. 44 * @param[out] data Pointer to audio data. 45 * @param[out] data_size Size of the data after the header. 46 * @param[out] channels Number of channels in stored audio format. 47 * @param[out] sampling_rate Sampling rate of the store data. 48 * @param[out] format Sample format. 49 * @param[out] error String representatoin of error, if any. 50 * @return Error code. 51 * 52 * Does sanity checks and endian conversion. 53 */ 54 int wav_parse_header(const void *hdata, const void **data, size_t *data_size, 42 55 unsigned *channels, unsigned *sampling_rate, pcm_sample_format_t *format, 43 56 const char **error) 44 57 { 45 if (! file) {58 if (!hdata) { 46 59 if (error) 47 *error = " file not present";60 *error = "no header"; 48 61 return EINVAL; 49 62 } 50 63 51 const wave_header_t *header = file;64 const wave_header_t *header = hdata; 52 65 if (str_lcmp(header->chunk_id, CHUNK_ID, 4) != 0) { 53 66 if (error) … … 113 126 return EOK; 114 127 } 128 129 /** 130 * Initialize wave fromat ehader structure. 131 * @param header Structure to initialize. 132 * @param format Desired PCM format 133 * @param size Size of the stored data. 134 * 135 * Initializes format specific elements and covnerts endian 136 */ 137 void wav_init_header(wave_header_t *header, pcm_format_t format, size_t size) 138 { 139 assert(header); 140 #define COPY_STR(dst, src) memcpy(dst, src, str_size(src)) 141 142 COPY_STR(&header->chunk_id, CHUNK_ID); 143 COPY_STR(&header->format, FORMAT_STR); 144 COPY_STR(&header->subchunk1_id, SUBCHUNK1_ID); 145 header->subchunk1_size = host2uint16_t_le(PCM_SUBCHUNK1_SIZE); 146 header->audio_format = host2uint16_t_le(FORMAT_LINEAR_PCM); 147 148 COPY_STR(&header->subchunk2_id, SUBCHUNK2_ID); 149 header->subchunk2_size = host2uint32_t_le(size); 150 header->sampling_rate = host2uint32_t_le(format.sampling_rate); 151 header->channels = host2uint32_t_le(format.channels); 152 header->sample_size = 153 host2uint32_t_le(pcm_sample_format_size(format.sample_format)); 154 } 115 155 /** 116 156 * @} -
uspace/app/wavplay/wave.h
re1d2f0e r0a4ad7d 36 36 37 37 #include <stdint.h> 38 #include <pcm/format.h> 38 39 #include <pcm/sample_format.h> 39 40 … … 89 90 } wave_header_t; 90 91 91 int wav_parse_header( void *, const void**, size_t *, unsigned*, unsigned *,92 pcm_sample_format_t *, const char **);92 int wav_parse_header(const void *, const void**, size_t *, unsigned *, 93 unsigned *, pcm_sample_format_t *, const char **); 93 94 95 void wav_init_header(wave_header_t *, pcm_format_t , size_t); 94 96 #endif 95 97 /**
Note:
See TracChangeset
for help on using the changeset viewer.