3
Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
Boston, MA 02111-1307, USA.
21
#ifndef _AKODE_AUDIOFRAME_H
22
#define _AKODE_AUDIOFRAME_H
25
#include "audioconfiguration.h"
29
#define AKODE_POS_UNKNOWN -1
30
#define AKODE_POS_EOF -2
31
#define AKODE_POS_ERROR -3
33
//! The internal audio format
36
* AudioFrames are used through-out akodelib as the mean of audiotransport.
37
* It derives from AudioConfiguration because it caries its own interpretation
40
struct AudioFrame : public AudioConfiguration {
42
AudioFrame() : length(0), max(0), data(0) {};
43
~AudioFrame() { freeSpace(); }
45
* Reserves space in the frame for atleast \a iLength samples of the
46
* configuration \a config.
48
void reserveSpace(const AudioConfiguration *config, long iLength) {
49
reserveSpace(config->channels, iLength, config->sample_width);
50
sample_rate = config->sample_rate;
51
channel_config = config->channel_config;
52
surround_config = config->surround_config;
54
void reserveSpace(uint8_t iChannels, long iLength, int8_t iWidth) {
55
if ( data != 0 && channels == iChannels &&
56
max >= iLength && sample_width == iWidth)
63
length = max = iLength;
64
sample_width = iWidth;
65
data = new int8_t*[channels+1];
66
int bytes = (sample_width+7) / 8;
67
if (bytes > 2) bytes = 4;
68
if (bytes < 0) bytes = 4;
69
for(int i=0; i<iChannels; i++)
70
data[i] = new int8_t[length*bytes];
74
* Frees the space allocated for the buffer.
92
* The current position in stream (measured in milliseconds)
97
* The length of the frame in samples.
101
* The maximum number of samples currently reserved in the frame.
105
* The buffer is accessed according sample-width
106
* 1-8bit: int8_t, 9-16bit: int16_t, 17-32bit: int32_t