Changeset 190

Show
Ignore:
Timestamp:
01/16/08 13:28:21 (4 years ago)
Author:
ath
Message:

Add new buffer flags.

Location:
fm_server/trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • fm_server/trunk/src/fm_buffer.c

    r32 r190  
    11/* 
    22 *  FreeMix - sound server 
    3  *  Copyright (C) 2004 Alberto Botti <ath9@libero.it> 
     3 *  Copyright (C) 2004-2008 Alberto Botti <alberto.botti@yoda2000.net> 
    44 * 
    55 *  This program is free software; you can redistribute it and/or modify 
     
    1919 * 
    2020 *  fm_buffer.c - object used to store and pass around audio data 
    21  * 
    2221 */ 
    2322 
     
    3534FmBuffer * 
    3635fm_buffer_new                           (guint          n_samples, 
    37                                         /* FmSamplesType        type,*/ 
    38 /*                                       FmSamplesInterleaving interleaving,*/ 
    3936                                         guint          n_channels) 
    4037{ 
     
    4946        buffer = g_new0 (FmBuffer, 1); 
    5047        buffer->data = g_malloc0 (size_bytes); 
     48        buffer->discont = FALSE; 
     49        buffer->silence = FALSE; 
    5150         
    5251        for (i = 0; i < n_channels; i++) 
     
    5958         
    6059        buffer->requested_samples = 0; 
     60 
     61        buffer->timestamp = 0; 
     62        buffer->duration = 0; 
    6163         
    6264        return buffer; 
     
    9193 
    9294        memset (buffer->data, 0, samples_to_bytes(buffer->allocated_samples, buffer->n_channels)); 
     95        FM_BUFFER_USED_SAMPLES (buffer) = FM_BUFFER_REQUESTED (buffer); 
     96        buffer->silence = TRUE; 
    9397} 
    9498 
     
    108112                        buffer->channel_data[l][i] = *(data++); 
    109113} 
     114 
     115 
     116void 
     117fm_buffer_reset_flags                   (FmBuffer       *buffer) 
     118{ 
     119        buffer->discont = FALSE; 
     120        buffer->silence = FALSE; 
     121        buffer->timestamp = 0; 
     122        buffer->duration = 0;    
     123} 
  • fm_server/trunk/src/fm_buffer.h

    r186 r190  
    11/* 
    22 *  FreeMix - sound server 
    3  *  Copyright (C) 2004 Alberto Botti <ath9@libero.it> 
     3 *  Copyright (C) 2004-2008 Alberto Botti <alberto.botti@yoda2000.net> 
    44 * 
    55 *  This program is free software; you can redistribute it and/or modify 
     
    1919 * 
    2020 *  fm_buffer.h - object used to store and pass around audio data 
    21  * 
    2221 */ 
    2322 
    2423 
    2524typedef struct _FmBuffer FmBuffer; 
    26  
    27 //#define MAX_SAMPLES 1024              // ? 
    2825 
    2926 
     
    4340        gfloat          *data; 
    4441        gfloat *        channel_data[FM_CHANNELS_LAST]; 
     42        gboolean        discont;                // the buffer is a start of a discontinuous section 
     43        gboolean        silence;                // the whole buffer contains silence 
    4544         
    4645        guint           n_channels; 
     
    4847        guint           allocated_samples; 
    4948        guint           used_samples; 
     49 
    5050        guint           requested_samples; 
    5151 
    52         guint64         timestamp; 
     52        guint64         timestamp;              // real timestamp from start of the song 
     53        guint64         duration;               // real duration of AUDIO (not silence) in the buffer  
    5354}; 
    5455 
     
    7576                                         guint          n_samples); 
    7677 
     78void 
     79fm_buffer_reset_flags                   (FmBuffer       *buffer); 
     80 
     81 
    7782#define FM_BUFFER_DATA(x) (x)->data 
    7883#define FM_BUFFER_CHANNEL_DATA(x,y) (x)->channel_data[(y)] 
     84#define FM_BUFFER_DISCONT(x) (x)->discont 
    7985 
    8086#define FM_BUFFER_ALLOCATED_SAMPLES(x) (x)->allocated_samples 
     
    8692 
    8793#define FM_BUFFER_TIMESTAMP(x) (x)->timestamp 
     94#define FM_BUFFER_DURATION(x) (x)->duration