Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/audio/hound/audio_data.c

    r38d150e r33b8d024  
    3636#include <macros.h>
    3737#include <stdlib.h>
     38#include <str.h>
    3839
    3940#include "audio_data.h"
     
    5051    pcm_format_t format)
    5152{
    52         audio_data_t *adata = malloc(sizeof(audio_data_t));
     53        audio_data_t *adata = malloc(sizeof(audio_data_t) + size);
    5354        if (adata) {
    5455                unsigned overflow = size % pcm_format_frame_size(&format);
     
    5657                        log_warning("Data not a multiple of frame size, "
    5758                            "clipping.");
    58 
    59                 adata->data = data;
     59                uint8_t *d = ((uint8_t *)adata) + offsetof(audio_data_t, data);
     60                memcpy(d, data, size);
    6061                adata->size = size - overflow;
    6162                adata->format = format;
     
    8687        atomic_count_t refc = atomic_predec(&adata->refcount);
    8788        if (refc == 0) {
    88                 free(adata->data);
    8989                free(adata);
    9090        }
     
    213213 * @return Error code.
    214214 */
    215 int audio_pipe_push(audio_pipe_t *pipe, audio_data_t *data)
     215errno_t audio_pipe_push(audio_pipe_t *pipe, audio_data_t *data)
    216216{
    217217        assert(pipe);
     
    260260 * @param size Target buffer size.
    261261 * @param format Target data format.
    262  * @return Size of the target buffer used, Error code on failure.
    263  */
    264 ssize_t audio_pipe_mix_data(audio_pipe_t *pipe, void *data,
     262 * @return Size of the target buffer used.
     263 */
     264size_t audio_pipe_mix_data(audio_pipe_t *pipe, void *data,
    265265    size_t size, const pcm_format_t *f)
    266266{
Note: See TracChangeset for help on using the changeset viewer.