Changeset b1dfe13 in mainline


Ignore:
Timestamp:
2013-04-10T19:08:09Z (11 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

Location:
uspace/lib/pcm
Files:
3 edited

Legend:

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

    ra8e87da rb1dfe13  
    4141#include <pcm/sample_format.h>
    4242
     43/** Linear PCM audio parameters */
    4344typedef struct {
    4445        unsigned channels;
     
    5051extern const pcm_format_t AUDIO_FORMAT_ANY;
    5152
     53/**
     54 * Frame size helper function.
     55 * @param a pointer to a PCM format structure.
     56 * @return Size in bytes.
     57 */
    5258static inline size_t pcm_format_frame_size(const pcm_format_t *a)
    5359{
     
    5561}
    5662
     63/**
     64 * Convert byte size to frame count.
     65 * @param size Byte-size.
     66 * @param a pointer to a PCM format structure.
     67 * @return Frame count.
     68 */
    5769static inline size_t pcm_format_size_to_frames(size_t size,
    5870    const pcm_format_t *a)
     
    6274}
    6375
    64 static inline suseconds_t pcm_format_size_to_usec(size_t size,
     76/**
     77 * Convert byte size to audio playback time.
     78 * @param size Byte-size.
     79 * @param a pointer to a PCM format structure.
     80 * @return Number of microseconds.
     81 */
     82static inline useconds_t pcm_format_size_to_usec(size_t size,
    6583    const pcm_format_t *a)
    6684{
     
    7088
    7189bool pcm_format_same(const pcm_format_t *a, const pcm_format_t* b);
     90
     91/**
     92 * Helper function, compares with ANY metaformat.
     93 * @param f pointer to format structure.
     94 * @return True if @p f points to ANY format, false otherwise.
     95 */
    7296static inline bool pcm_format_is_any(const pcm_format_t *f)
    7397{
  • 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{
  • uspace/lib/pcm/src/format.c

    ra8e87da rb1dfe13  
    7575#define to(x, type, endian) (float)(host2 ## type ## _ ## endian(x))
    7676
     77/** Default linear PCM format */
    7778const pcm_format_t AUDIO_FORMAT_DEFAULT = {
    7879        .channels = 2,
     
    8182        };
    8283
     84/** Special ANY PCM format.
     85 * This format is used if the real format is no know or important.
     86 */
    8387const pcm_format_t AUDIO_FORMAT_ANY = {
    8488        .channels = 0,
Note: See TracChangeset for help on using the changeset viewer.