VirtualBox

Changeset 39875 in vbox


Ignore:
Timestamp:
Jan 25, 2012 3:32:55 PM (13 years ago)
Author:
vboxsync
Message:

Devices/Audio: fixed rounding error in noaudio driver output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/noaudio.c

    r35353 r39875  
    4646    int64_t now;
    4747    int64_t ticks;
    48     int64_t bytes;
     48    int64_t ticks_per_second;
    4949
    5050    live = audio_pcm_hw_get_live_out (&no->hw);
     
    5555    now = audio_get_clock ();
    5656    ticks = now - no->old_ticks;
    57     bytes = (ticks * hw->info.bytes_per_second) / audio_get_ticks_per_sec ();
    58     bytes = audio_MIN (bytes, INT_MAX);
    59     samples = bytes >> hw->info.shift;
     57
     58    ticks_per_second = audio_get_ticks_per_sec ();
     59    /* Minimize the rounding error: samples = int((ticks * freq) / ticks_per_second + 0.5). */
     60    samples = (2 * ticks * hw->info.freq + ticks_per_second) / ticks_per_second / 2;
    6061
    6162    no->old_ticks = now;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette