Changeset 346643c in mainline for uspace/app/drec/drec.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/drec/drec.c

    r94694a4 r346643c  
    4747#include <stdio.h>
    4848#include <macros.h>
     49#include <pcm_sample_format.h>
    4950
    5051#include "wave.h"
     
    5354#define SUBBUFFERS 2
    5455
    55 const unsigned sampling_rate = 44100, sample_size = 16, channels = 2;
    56 bool sign = true;
     56const unsigned sampling_rate = 44100, channels = 2, sample_size = 16;
     57const pcm_sample_format_t format = PCM_SAMPLE_SINT16_LE;
    5758
    5859typedef struct {
     
    104105
    105106
    106 static void record(record_t *rec, unsigned sampling_rate, unsigned sample_size,
    107     unsigned channels, bool sign)
     107static void record(record_t *rec, unsigned channels, unsigned sampling_rate,
     108    pcm_sample_format_t format)
    108109{
    109110        assert(rec);
    110111        assert(rec->device);
    111112        rec->buffer.position = rec->buffer.base;
    112         printf("Recording: %dHz, %d-bit %ssigned samples, %d channel(s).\n",
    113             sampling_rate, sample_size, sign ? "": "un", channels);
     113        printf("Recording: %dHz, %s, %d channel(s).\n",
     114            sampling_rate, pcm_sample_format_str(format), channels);
    114115        int ret = audio_pcm_start_record(rec->device, rec->buffer.id,
    115             SUBBUFFERS, sampling_rate, sample_size, channels, sign);
     116            SUBBUFFERS, channels, sampling_rate, format);
    116117        if (ret != EOK) {
    117118                printf("Failed to start recording: %s.\n", str_error(ret));
     
    201202                .sampling_rate = sampling_rate,
    202203                .sample_size = sample_size,
    203                 .byte_rate = (sampling_rate / 8) * channels,
    204                 .block_align = (sampling_rate / 8) * channels,
     204                .byte_rate = sampling_rate * (sample_size / 8) * channels,
     205                .block_align = (sample_size / 8) * channels,
    205206                .subchunk2_id = SUBCHUNK2_ID,
    206207        };
    207208        fwrite(&header, sizeof(header), 1, rec.file);
    208         record(&rec, sampling_rate, sample_size, channels, sign);
     209        record(&rec, sampling_rate, channels, format);
    209210        fclose(rec.file);
    210211
Note: See TracChangeset for help on using the changeset viewer.