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


Ignore:
Timestamp:
2012-07-15T15:25:43Z (13 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.

File:
1 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);
Note: See TracChangeset for help on using the changeset viewer.