Changeset 68e005d in mainline for uspace/app/dplay/dplay.c


Ignore:
Timestamp:
2012-07-05T23:31:46Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6be06d0
Parents:
2afae0e
Message:

dplay: There is one more event after sending the stop command.

File:
1 edited

Legend:

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

    r2afae0e r68e005d  
    8484static void device_event_callback(ipc_callid_t iid, ipc_call_t *icall, void* arg)
    8585{
    86         static unsigned wait = SUBBUFFERS;
     86        async_answer_0(iid, EOK);
     87        playback_t *pb = arg;
     88        const size_t buffer_part = pb->buffer.size / SUBBUFFERS;
    8789        while (1) {
    8890                ipc_call_t call;
     
    9092                if (IPC_GET_IMETHOD(call) != IPC_FIRST_USER_METHOD) {
    9193                        printf("Unknown event.\n");
    92                         async_answer_0(callid,EOK);
    9394                        break;
    9495                }
    95                 playback_t *pb = arg;
    96 //              printf("Got device event!!!\n");
    97                 const size_t buffer_part = pb->buffer.size / SUBBUFFERS;
     96                printf("Got device event!!!\n");
    9897                const size_t bytes = fread(pb->buffer.position, sizeof(uint8_t),
    9998                   buffer_part, pb->source);
     
    104103                if (pb->buffer.position >= (pb->buffer.base + pb->buffer.size))
    105104                        pb->buffer.position = pb->buffer.base;
    106                 async_answer_0(callid,EOK);
    107                 if (bytes == 0 && (wait-- == 0)) {
     105                async_answer_0(callid, EOK);
     106                if (bytes == 0) {
    108107                        pb->playing = false;
    109108                        fibril_condvar_signal(&pb->cv);
    110                         return;
    111109                }
    112110        }
     
    137135
    138136        for (pb->playing = true; pb->playing;
    139           fibril_condvar_wait(&pb->cv, &pb->mutex));
     137            fibril_condvar_wait(&pb->cv, &pb->mutex));
    140138
    141139        audio_pcm_buffer_stop_playback(pb->device, pb->buffer.id);
     140        fibril_condvar_wait(&pb->cv, &pb->mutex);
    142141}
    143142
Note: See TracChangeset for help on using the changeset viewer.