Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c891eaca in mainline


Ignore:
Timestamp:
2011-12-07T14:04:34Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
46d9d13
Parents:
7a5ab20
Message:

dplay: Use octo buffering instead of double buffering.

Improves sound quality on qemu.

File:
1 edited

Legend:

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

    r7a5ab20 rc891eaca  
    5656{
    5757        assert(device);
    58         const size_t half_buf = size / 2;
     58        const size_t update_size = size / 8;
    5959
    6060        /* Time to play half the buffer. */
    6161        const suseconds_t interval = 1000000 /
    62             (sampling_rate /  (half_buf / (channels * (sample_size / 8))));
     62            (sampling_rate /  (update_size / (channels * (sample_size / 8))));
    6363        printf("Time to play half buffer: %ld us.\n", interval);
    6464        /* Initialize buffer. */
     
    8888
    8989                const size_t bytes =
    90                     fread(buffer_place, sizeof(uint8_t), half_buf, source);
     90                    fread(buffer_place, sizeof(uint8_t), update_size, source);
    9191                if (bytes == 0)
    9292                        break;
    93                 if (bytes < half_buf) {
    94                         bzero(buffer_place + bytes, half_buf - bytes);
     93                if (bytes < update_size) {
     94                        bzero(buffer_place + bytes, update_size - bytes);
    9595                }
    96                 if (buffer_place == buffer) {
    97                         buffer_place = buffer + half_buf;
    98                 } else {
     96                buffer_place += update_size;
     97
     98                if (buffer_place == buffer + size) {
    9999                        buffer_place = buffer;
    100100                }
Note: See TracChangeset for help on using the changeset viewer.