Changeset ac149d5 in mainline


Ignore:
Timestamp:
2011-10-22T11:01:56Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b4857bc
Parents:
5984107
Message:

sb16: Fixes.

Fixes crash on initial data copy.
Fill the entire buffer if possible.

File:
1 edited

Legend:

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

    r5984107 rac149d5  
    196196        if (remain_size == 0) {
    197197                ddf_log_note("Nothing more to play");
    198                 sb_dsp_write(dsp, DMA_16B_EXIT);
     198                if (AUTO_DMA_MODE) {
     199                        sb_dsp_write(dsp, DMA_16B_EXIT);
     200                }
    199201                sb_clear_buffer(dsp);
    200202                return;
    201203        }
    202         if (remain_size < PLAY_BLOCK_SIZE) {
     204        if (remain_size <= PLAY_BLOCK_SIZE) {
    203205                ddf_log_note("Last %zu bytes to play.\n", remain_size);
    204206                /* This is the last block */
     
    264266        const size_t play_size =
    265267            size < PLAY_BLOCK_SIZE ? size : PLAY_BLOCK_SIZE;
    266         memcpy(dsp->buffer.data, dsp->playing.data, play_size);
    267 
    268         ddf_log_debug("Playing sound: %zu(%zu) bytes.\n", play_size, size);
     268        const size_t copy_size =
     269            size < BUFFER_SIZE ? size : BUFFER_SIZE;
     270
    269271
    270272        dsp->playing.data = data;
    271         dsp->playing.position = data + play_size;
     273        dsp->playing.position = data + copy_size;
    272274        dsp->playing.size = size;
    273275        dsp->playing.mode =
    274276            (bit_depth == 16 ? 0x10 : 0) | (channels == 2 ? 0x20 : 0);
    275 
    276277        ddf_log_debug("Setting mode %hhx.\n", dsp->playing.mode);
     278
     279        ddf_log_debug("Playing sound: %zu(%zu) bytes.\n", play_size, size);
     280        memcpy(dsp->buffer.data, dsp->playing.data, copy_size);
     281
    277282        sb_dsp_write(dsp, SET_SAMPLING_RATE_OUTPUT);
    278283        sb_dsp_write(dsp, sampling_rate >> 8);
Note: See TracChangeset for help on using the changeset viewer.