Changeset 346643c in mainline for uspace/app/dplay/wave.c


Ignore:
Timestamp:
2012-07-11T12:05:30Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
039337e8
Parents:
94694a4
Message:

audio: Use enum for sample format.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/dplay/wave.c

    r94694a4 r346643c  
    4040
    4141int wav_parse_header(void *file, const void **data, size_t *data_size,
    42     unsigned *sampling_rate, unsigned *sample_size, unsigned *channels,
    43     bool *sign, const char **error)
     42    unsigned *channels, unsigned *sampling_rate, pcm_sample_format_t *format,
     43    const char **error)
    4444{
    4545        if (!file) {
     
    8686        }
    8787
     88
    8889        if (data)
    8990                *data = header->data;
     
    9394        if (sampling_rate)
    9495                *sampling_rate = uint32_t_le2host(header->sampling_rate);
    95         if (sample_size)
    96                 *sample_size = uint32_t_le2host(header->sample_size);
    9796        if (channels)
    9897                *channels = uint16_t_le2host(header->channels);
    99         if (sign)
    100                 *sign = uint32_t_le2host(header->sample_size) == 16
    101                     ? true : false;
     98        if (format) {
     99                const unsigned size = uint32_t_le2host(header->sample_size);
     100                switch (size) {
     101                case 8: *format = PCM_SAMPLE_UINT8; break;
     102                case 16: *format = PCM_SAMPLE_SINT16_LE; break;
     103                case 24: *format = PCM_SAMPLE_SINT24_LE; break;
     104                case 32: *format = PCM_SAMPLE_SINT32_LE; break;
     105                default:
     106                        *error = "Unknown format";
     107                        return ENOTSUP;
     108                }
     109        }
    102110        if (error)
    103111                *error = "no error";
Note: See TracChangeset for help on using the changeset viewer.