Changeset ea6c838 in mainline for uspace/lib/pcm


Ignore:
Timestamp:
2012-07-17T08:26:49Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6bba8f
Parents:
950110ee
Message:

Create libpcm.

Move pcm related functions and definitions there.
Make other stuff use this library.
Rename most of it on the way.

Location:
uspace/lib/pcm
Files:
1 added
3 moved

Legend:

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

    r950110ee rea6c838  
    3434 */
    3535
    36 #ifndef AUDIO_FORMAT_H_
    37 #define AUDIO_FORMAT_H_
     36#ifndef PCM_FORMAT_H_
     37#define PCM_FORMAT_H_
    3838
    3939#include <assert.h>
    4040#include <bool.h>
    41 #include <pcm_sample_format.h>
    42 
     41#include <pcm/sample_format.h>
    4342
    4443typedef struct {
     
    4645        unsigned sampling_rate;
    4746        pcm_sample_format_t sample_format;
    48 } audio_format_t;
     47} pcm_format_t;
    4948
    50 static const audio_format_t AUDIO_FORMAT_DEFAULT = {
     49static const pcm_format_t AUDIO_FORMAT_DEFAULT = {
    5150        .channels = 2,
    5251        .sampling_rate = 44100,
     
    5453        };
    5554
    56 static const audio_format_t AUDIO_FORMAT_ANY = {
     55static const pcm_format_t AUDIO_FORMAT_ANY = {
    5756        .channels = 0,
    5857        .sampling_rate = 0,
     
    6059        };
    6160
    62 
    63 static inline size_t audio_format_frame_size(const audio_format_t *a)
     61static inline size_t pcm_format_frame_size(const pcm_format_t *a)
    6462{
    6563        return a->channels * pcm_sample_format_size(a->sample_format);
    6664}
    6765
    68 bool audio_format_same(const audio_format_t *a, const audio_format_t* b);
    69 static inline bool audio_format_is_any(const audio_format_t *f)
     66bool pcm_format_same(const pcm_format_t *a, const pcm_format_t* b);
     67static inline bool pcm_format_is_any(const pcm_format_t *f)
    7068{
    71         return audio_format_same(f, &AUDIO_FORMAT_ANY);
     69        return pcm_format_same(f, &AUDIO_FORMAT_ANY);
    7270}
    73 int audio_format_convert_and_mix(void *dst, size_t dst_size, const void *src,
    74     size_t src_size, const audio_format_t *sf, const audio_format_t *df);
    75 int audio_format_mix(void *dst, const void *src, size_t size, const audio_format_t *f);
    76 int audio_format_convert(audio_format_t a, void* srca, size_t sizea,
    77     audio_format_t b, void* srcb, size_t *sizeb);
     71int pcm_format_convert_and_mix(void *dst, size_t dst_size, const void *src,
     72    size_t src_size, const pcm_format_t *sf, const pcm_format_t *df);
     73int pcm_format_mix(void *dst, const void *src, size_t size, const pcm_format_t *f);
     74int pcm_format_convert(pcm_format_t a, void* srca, size_t sizea,
     75    pcm_format_t b, void* srcb, size_t *sizeb);
    7876
    7977#endif
  • uspace/lib/pcm/src/format.c

    r950110ee rea6c838  
    4040#include <stdio.h>
    4141
    42 #include "audio_format.h"
     42#include "format.h"
    4343
    4444#define uint8_t_le2host(x) (x)
     
    7676
    7777static float get_normalized_sample(const void *buffer, size_t size,
    78     unsigned frame, unsigned channel, const audio_format_t *f);
    79 
    80 bool audio_format_same(const audio_format_t *a, const audio_format_t* b)
     78    unsigned frame, unsigned channel, const pcm_format_t *f);
     79
     80bool pcm_format_same(const pcm_format_t *a, const pcm_format_t* b)
    8181{
    8282        assert(a);
     
    8888}
    8989
    90 int audio_format_mix(void *dst, const void *src, size_t size, const audio_format_t *f)
    91 {
    92         return audio_format_convert_and_mix(dst, size, src, size, f, f);
    93 }
    94 int audio_format_convert_and_mix(void *dst, size_t dst_size, const void *src,
    95     size_t src_size, const audio_format_t *sf, const audio_format_t *df)
     90int pcm_format_mix(void *dst, const void *src, size_t size, const pcm_format_t *f)
     91{
     92        return pcm_format_convert_and_mix(dst, size, src, size, f, f);
     93}
     94int pcm_format_convert_and_mix(void *dst, size_t dst_size, const void *src,
     95    size_t src_size, const pcm_format_t *sf, const pcm_format_t *df)
    9696{
    9797        if (!dst || !src || !sf || !df)
    9898                return EINVAL;
    99         const size_t src_frame_size = audio_format_frame_size(sf);
     99        const size_t src_frame_size = pcm_format_frame_size(sf);
    100100        if ((src_size % src_frame_size) != 0)
    101101                return EINVAL;
    102102
    103         const size_t dst_frame_size = audio_format_frame_size(df);
     103        const size_t dst_frame_size = pcm_format_frame_size(df);
    104104        if ((src_size % dst_frame_size) != 0)
    105105                return EINVAL;
     
    170170/** Converts all sample formats to float <-1,1> */
    171171static float get_normalized_sample(const void *buffer, size_t size,
    172     unsigned frame, unsigned channel, const audio_format_t *f)
     172    unsigned frame, unsigned channel, const pcm_format_t *f)
    173173{
    174174        assert(f);
Note: See TracChangeset for help on using the changeset viewer.