blob: 76194b65615d3261d588dcbbbf24c0cc20ab699b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright 2005-2016 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#ifndef MUMBLE_MUMBLE_AUDIOOUTPUTSAMPLE_H_
#define MUMBLE_MUMBLE_AUDIOOUTPUTSAMPLE_H_
#include <sndfile.h>
#include <speex/speex_resampler.h>
#include <QtCore/QObject>
#include <QtCore/QFile>
#include "AudioOutputUser.h"
class SoundFile : public QObject {
private:
Q_OBJECT
Q_DISABLE_COPY(SoundFile)
protected:
SNDFILE *sfFile;
SF_INFO siInfo;
QFile qfFile;
static sf_count_t vio_get_filelen(void *user_data);
static sf_count_t vio_seek(sf_count_t offset, int whence, void *user_data);
static sf_count_t vio_read(void *ptr, sf_count_t count, void *user_data);
static sf_count_t vio_write(const void *ptr, sf_count_t count, void *user_data);
static sf_count_t vio_tell(void *user_data);
public:
SoundFile(const QString &fname);
~SoundFile();
int channels() const;
int samplerate() const;
int error() const ;
QString strError() const;
bool isOpen() const;
sf_count_t seek(sf_count_t frames, int whence);
sf_count_t read(float *ptr, sf_count_t items);
};
class AudioOutputSample : public AudioOutputUser {
private:
Q_OBJECT
Q_DISABLE_COPY(AudioOutputSample)
protected:
unsigned int iLastConsume;
unsigned int iBufferFilled;
unsigned int iOutSampleRate;
SpeexResamplerState *srs;
SoundFile *sfHandle;
bool bLoop;
bool bEof;
signals:
void playbackFinished();
public:
static SoundFile* loadSndfile(const QString &filename);
static QString browseForSndfile(QString defaultpath=QString());
virtual bool needSamples(unsigned int snum) Q_DECL_OVERRIDE;
AudioOutputSample(const QString &name, SoundFile *psndfile, bool repeat, unsigned int freq);
~AudioOutputSample() Q_DECL_OVERRIDE;
};
#endif // AUDIOOUTPUTSAMPLE_H_
|