Changeset 57e8b3b in mainline for uspace/app


Ignore:
Timestamp:
2012-07-15T15:25:43Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5cd5079
Parents:
2cc5c835
Message:

Add frame count to event report.

This enables applications to detect underruns.

Location:
uspace/app
Files:
2 edited

Legend:

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

    r2cc5c835 r57e8b3b  
    5151
    5252#define DEFAULT_DEVICE "/hw/pci0/00:01.0/sb16/pcm"
    53 #define SUBBUFFERS 2
     53#define BUFFER_PARTS 2
    5454
    5555typedef struct {
     
    8585        async_answer_0(iid, EOK);
    8686        playback_t *pb = arg;
    87         const size_t buffer_part = pb->buffer.size / SUBBUFFERS;
     87        const size_t buffer_part = pb->buffer.size / BUFFER_PARTS;
    8888        while (1) {
    8989                ipc_call_t call;
    9090                ipc_callid_t callid = async_get_call(&call);
    9191                switch(IPC_GET_IMETHOD(call)) {
    92                 case PCM_EVENT_PLAYBACK_DONE:
    93                         printf("+");
     92                case PCM_EVENT_FRAMES_PLAYED:
     93                        printf("%u frames\n", IPC_GET_ARG1(call));
    9494                        async_answer_0(callid, EOK);
    9595                        break;
    9696                case PCM_EVENT_PLAYBACK_TERMINATED:
    97                         printf("\nPlayback terminated\n");
     97                        printf("Playback terminated\n");
    9898                        fibril_mutex_lock(&pb->mutex);
    9999                        pb->playing = false;
     
    136136        printf("Buffer data ready.\n");
    137137        fibril_mutex_lock(&pb->mutex);
     138        const unsigned frames = pb->buffer.size /
     139            (BUFFER_PARTS * channels * pcm_sample_format_size(format));
    138140        int ret = audio_pcm_start_playback(pb->device,
    139             SUBBUFFERS, channels, sampling_rate, format);
     141            frames, channels, sampling_rate, format);
    140142        if (ret != EOK) {
    141143                fibril_mutex_unlock(&pb->mutex);
  • 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.