blob: 6be2d0cdc75b3d8d63fb1d3592d4b9f118a6259a (
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
68
69
70
|
// Copyright 2011-2021 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 <QtCore/QFile>
#include <QtCore/QObject>
#include <sndfile.h>
#include <speex/speex_resampler.h>
#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 prepareSampleBuffer(unsigned int frameCount) Q_DECL_OVERRIDE;
AudioOutputSample(const QString &name, SoundFile *psndfile, bool repeat, unsigned int freq,
unsigned int bufferSize);
~AudioOutputSample() Q_DECL_OVERRIDE;
};
#endif // AUDIOOUTPUTSAMPLE_H_
|