Changeset 0387b92 in mainline for uspace/drv/audio/sb16/dsp.c


Ignore:
Timestamp:
2012-08-20T14:52:54Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e7bf5f6
Parents:
c04ff9f
Message:

ab16: Improve event reporting, and state checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/sb16/dsp.c

    rc04ff9f r0387b92  
    187187}
    188188
     189static inline void dsp_report_event(sb_dsp_t *dsp, pcm_event_t event)
     190{
     191        assert(dsp);
     192        if (!dsp->event_exchange)
     193                ddf_log_warning("No one listening for event %u", event);
     194        async_msg_1(dsp->event_exchange, event, dsp->active.frame_count);
     195}
     196
    189197static inline size_t sample_count(pcm_sample_format_t format, size_t byte_count)
    190198{
     
    235243        {
    236244        case DSP_PLAYBACK_ACTIVE_EVENTS:
    237                 async_msg_1(dsp->event_exchange,
    238                     PCM_EVENT_FRAMES_PLAYED, dsp->active.frame_count);
     245                dsp_report_event(dsp, PCM_EVENT_FRAMES_PLAYED);
    239246        case DSP_PLAYBACK_NOEVENTS:
    240247#ifndef AUTO_DMA_MODE
     
    243250                break;
    244251        case DSP_CAPTURE_ACTIVE_EVENTS:
    245                 async_msg_1(dsp->event_exchange,
    246                     PCM_EVENT_FRAMES_CAPTURED, dsp->active.frame_count);
     252                dsp_report_event(dsp, PCM_EVENT_FRAMES_CAPTURED);
    247253        case DSP_CAPTURE_NOEVENTS:
    248254#ifndef AUTO_DMA_MODE
     
    418424        sb_dsp_change_state(dsp,
    419425            frames ? DSP_PLAYBACK_ACTIVE_EVENTS : DSP_PLAYBACK_NOEVENTS);
     426        if (dsp->state == DSP_PLAYBACK_ACTIVE_EVENTS)
     427                dsp_report_event(dsp, PCM_EVENT_PLAYBACK_STARTED);
    420428
    421429        return EOK;
     
    425433{
    426434        assert(dsp);
     435        if (dsp->state != DSP_PLAYBACK_NOEVENTS &&
     436            dsp->state != DSP_PLAYBACK_ACTIVE_EVENTS)
     437                return EINVAL;
     438
    427439        sb_dsp_write(dsp, DMA_16B_EXIT);
    428440        ddf_log_debug("Stopping playback on buffer.");
    429         async_msg_0(dsp->event_exchange, PCM_EVENT_PLAYBACK_TERMINATED);
     441        if (dsp->state == DSP_PLAYBACK_ACTIVE_EVENTS)
     442                dsp_report_event(dsp, PCM_EVENT_PLAYBACK_TERMINATED);
    430443        async_exchange_end(dsp->event_exchange);
    431444        dsp->event_exchange = NULL;
     
    475488        sb_dsp_change_state(dsp,
    476489            frames ? DSP_CAPTURE_ACTIVE_EVENTS : DSP_CAPTURE_NOEVENTS);
     490        if (dsp->state == DSP_CAPTURE_ACTIVE_EVENTS)
     491                dsp_report_event(dsp, PCM_EVENT_CAPTURE_STARTED);
    477492        return EOK;
    478493}
     
    481496{
    482497        assert(dsp);
     498        if (dsp->state != DSP_CAPTURE_NOEVENTS &&
     499            dsp->state != DSP_CAPTURE_ACTIVE_EVENTS)
     500                return EINVAL;
     501
    483502        sb_dsp_write(dsp, DMA_16B_EXIT);
    484503        ddf_log_debug("Stopped capture");
    485         async_msg_0(dsp->event_exchange, PCM_EVENT_CAPTURE_TERMINATED);
     504        if (dsp->state == DSP_CAPTURE_ACTIVE_EVENTS)
     505                dsp_report_event(dsp, PCM_EVENT_CAPTURE_TERMINATED);
    486506        async_exchange_end(dsp->event_exchange);
    487507        dsp->event_exchange = NULL;
Note: See TracChangeset for help on using the changeset viewer.