2017-02-01 19:54:22 +01:00
|
|
|
#
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2009, 2010, 2011
|
|
|
|
* Jan van Katwijk (J.vanKatwijk@gmail.com)
|
2017-08-02 13:13:21 +02:00
|
|
|
* Lazy Chair Computing
|
2017-02-01 19:54:22 +01:00
|
|
|
*
|
2017-04-02 15:27:15 +02:00
|
|
|
* This file is part of the main program for the DAB library
|
2017-02-01 19:54:22 +01:00
|
|
|
*
|
2017-04-02 15:27:15 +02:00
|
|
|
* DAB library is free software; you can redistribute it and/or modify
|
2017-02-01 19:54:22 +01:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2017-04-02 15:27:15 +02:00
|
|
|
* DAB library is distributed in the hope that it will be useful,
|
2017-02-01 19:54:22 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-04-02 15:27:15 +02:00
|
|
|
* along with DAB library; if not, write to the Free Software
|
2017-02-01 19:54:22 +01:00
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-04-02 15:27:15 +02:00
|
|
|
#ifndef __AUDIO_SINK__
|
|
|
|
#define __AUDIO_SINK__
|
2017-02-01 19:54:22 +01:00
|
|
|
#include <portaudio.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "audio-base.h"
|
|
|
|
#include "ringbuffer.h"
|
2017-02-01 21:15:56 +01:00
|
|
|
#include <string>
|
2017-02-01 19:54:22 +01:00
|
|
|
|
|
|
|
class audioSink : public audioBase {
|
|
|
|
public:
|
2017-02-01 21:15:56 +01:00
|
|
|
audioSink (int16_t, std::string, bool *);
|
2017-02-01 19:54:22 +01:00
|
|
|
~audioSink (void);
|
|
|
|
void stop (void);
|
|
|
|
void restart (void);
|
2017-02-01 21:15:56 +01:00
|
|
|
bool selectDevice (const std::string);
|
2017-02-01 19:54:22 +01:00
|
|
|
bool selectDefaultDevice (void);
|
|
|
|
private:
|
|
|
|
int16_t numberofDevices (void);
|
|
|
|
const char *outputChannelwithRate (int16_t, int32_t);
|
|
|
|
int16_t invalidDevice (void);
|
|
|
|
bool isValidDevice (int16_t);
|
|
|
|
int32_t cardRate (void);
|
|
|
|
|
|
|
|
bool OutputrateIsSupported (int16_t, int32_t);
|
|
|
|
void audioOutput (float *, int32_t);
|
|
|
|
int32_t CardRate;
|
|
|
|
int16_t latency;
|
|
|
|
int32_t size;
|
|
|
|
bool portAudio;
|
|
|
|
bool writerRunning;
|
|
|
|
int16_t numofDevices;
|
|
|
|
int paCallbackReturn;
|
|
|
|
int16_t bufSize;
|
|
|
|
PaStream *ostream;
|
|
|
|
RingBuffer<float> *_O_Buffer;
|
|
|
|
PaStreamParameters outputParameters;
|
|
|
|
|
|
|
|
int16_t *outTable;
|
|
|
|
protected:
|
|
|
|
static int paCallback_o (const void *input,
|
|
|
|
void *output,
|
|
|
|
unsigned long framesperBuffer,
|
|
|
|
const PaStreamCallbackTimeInfo *timeInfo,
|
|
|
|
PaStreamCallbackFlags statusFlags,
|
|
|
|
void *userData);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|