Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 57e8b3b in mainline for uspace/app/drec/drec.c


Ignore:
Timestamp:
2012-07-15T15:25:43Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial
Children:
5cd5079
Parents:
2cc5c835
Message:

Add frame count to event report.

This enables applications to detect underruns.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/drec/drec.c

    r2cc5c835 r57e8b3b  
    5252
    5353#define DEFAULT_DEVICE "/hw/pci0/00:01.0/sb16/pcm"
    54 #define SUBBUFFERS 2
     54#define BUFFER_PARTS 2
    5555
    5656const unsigned sampling_rate = 44100, channels = 2, sample_size = 16;
     
    8484        async_answer_0(iid, EOK);
    8585        record_t *rec = arg;
    86         const size_t buffer_part = rec->buffer.size / SUBBUFFERS;
     86        const size_t buffer_part = rec->buffer.size / BUFFER_PARTS;
    8787        while (1) {
    8888                ipc_call_t call;
    8989                ipc_callid_t callid = async_get_call(&call);
    9090                switch(IPC_GET_IMETHOD(call)) {
    91                 case PCM_EVENT_RECORDING_DONE:
    92                         printf("+");
     91                case PCM_EVENT_FRAMES_RECORDED:
     92                        printf("%u frames\n", IPC_GET_ARG1(call));
    9393                        async_answer_0(callid, EOK);
    9494                        break;
    9595                case PCM_EVENT_RECORDING_TERMINATED:
    96                         printf("\nRecording terminated\n");
     96                        printf("Recording terminated\n");
    9797                        return;
    9898                default:
     
    122122        printf("Recording: %dHz, %s, %d channel(s).\n",
    123123            sampling_rate, pcm_sample_format_str(format), channels);
     124        const unsigned frames = rec->buffer.size /
     125            (BUFFER_PARTS * channels * pcm_sample_format_size(format));
    124126        int ret = audio_pcm_start_record(rec->device,
    125             SUBBUFFERS, channels, sampling_rate, format);
     127            frames, channels, sampling_rate, format);
    126128        if (ret != EOK) {
    127129                printf("Failed to start recording: %s.\n", str_error(ret));
Note: See TracChangeset for help on using the changeset viewer.