Ignore:
Timestamp:
2013-04-10T19:08:09Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8a7d78cc
Parents:
a8e87da
Message:

libpcm: comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/pcm/include/pcm/sample_format.h

    ra8e87da rb1dfe13  
    4040#include <time.h>
    4141
     42/** Known and supported PCM sample formats */
    4243typedef enum {
    4344        PCM_SAMPLE_UINT8,
     
    6364} pcm_sample_format_t;
    6465
     66/**
     67 * Query if the format uses signed values.
     68 * @param format PCM sample format.
     69 * @return True if the format uses signed values, false otherwise.
     70 */
    6571static inline bool pcm_sample_format_is_signed(pcm_sample_format_t format)
    6672{
     
    9197}
    9298
     99/**
     100 * Query byte-size of samples.
     101 * @param format PCM sample format.
     102 * @return Size in bytes of a single sample.
     103 */
    93104static inline size_t pcm_sample_format_size(pcm_sample_format_t format)
    94105{
     
    122133}
    123134
     135/**
     136 * Query sie of the entire frame.
     137 * @param channels Number of samples in every frame.
     138 * @param format PCM sample format.
     139 * @return Size in bytes.
     140 */
    124141static inline size_t pcm_sample_format_frame_size(unsigned channels,
    125142    pcm_sample_format_t format)
     
    128145}
    129146
     147/**
     148 * Count number of frames that fit into a buffer (even incomplete frames).
     149 * @param size Size of the buffer.
     150 * @param channels Number of samples in every frame.
     151 * @param format PCM sample format.
     152 * @return Number of frames (even incomplete).
     153 */
    130154static inline size_t pcm_sample_format_size_to_frames(size_t size,
    131155    unsigned channels, pcm_sample_format_t format)
     
    135159}
    136160
     161/**
     162 * Convert byte size to time.
     163 * @param size Size of the buffer.
     164 * @param sample_rate Samples per second.
     165 * @param channels Number of samples in every frame.
     166 * @param format PCM sample format.
     167 * @return Number of useconds of audio data.
     168 */
    137169static inline useconds_t pcm_sample_format_size_to_usec(size_t size,
    138170    unsigned sample_rate, unsigned channels, pcm_sample_format_t format)
    139171{
    140         const long long frames =
     172        const unsigned long long frames =
    141173            pcm_sample_format_size_to_frames(size, channels, format);
    142174        return (frames * 1000000ULL) / sample_rate;
    143175}
    144176
     177/**
     178 * Get readable name of a sample format.
     179 * @param format PCM sample format.
     180 * @return Valid string representation.
     181 */
    145182static inline const char * pcm_sample_format_str(pcm_sample_format_t format)
    146183{
Note: See TracChangeset for help on using the changeset viewer.