kopia lustrzana https://gitlab.com/eliggett/wfview
Some code tidying in udpserver/audiohandler
rodzic
c610edd371
commit
40d0c99964
|
@ -776,30 +776,16 @@ bool audioHandler::init(const quint8 bits, const quint8 channels, const quint16
|
||||||
this->radioSampleRate = samplerate;
|
this->radioSampleRate = samplerate;
|
||||||
this->radioChannels = channels;
|
this->radioChannels = channels;
|
||||||
|
|
||||||
//this->chunkSize = (INTERNAL_SAMPLE_RATE / 25) * (radioSampleBits / 8)/2;
|
|
||||||
|
|
||||||
// chunk size is always relative to Internal Sample Rate.
|
// chunk size is always relative to Internal Sample Rate.
|
||||||
this->chunkSize = (INTERNAL_SAMPLE_RATE / 25) * radioChannels;
|
this->chunkSize = (INTERNAL_SAMPLE_RATE / 25) * radioChannels;
|
||||||
|
|
||||||
qDebug(logAudio()) << "Audio chunkSize: " << this->chunkSize;
|
qDebug(logAudio()) << "Audio chunkSize: " << this->chunkSize;
|
||||||
|
|
||||||
int resample_error=0;
|
int resample_error=0;
|
||||||
if (isinput) {
|
|
||||||
resampler = wf_resampler_init(radioChannels, INTERNAL_SAMPLE_RATE, samplerate, resampleQuality, &resample_error);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
resampler = wf_resampler_init(radioChannels, samplerate, INTERNAL_SAMPLE_RATE, resampleQuality, &resample_error);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wf_resampler_get_ratio(resampler, &ratioNum, &ratioDen);
|
|
||||||
|
|
||||||
qDebug(logAudio()) << "wf_resampler_init() returned: " << resample_error << " ratioNum" << ratioNum << " ratioDen" << ratioDen << " input " << isinput;
|
|
||||||
|
|
||||||
qDebug(logAudio()) << "Got audio port name: " << port;
|
|
||||||
|
|
||||||
if (isInput) {
|
if (isInput) {
|
||||||
|
resampler = wf_resampler_init(radioChannels, INTERNAL_SAMPLE_RATE, samplerate, resampleQuality, &resample_error);
|
||||||
|
|
||||||
const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
||||||
for (const QAudioDeviceInfo& deviceInfo : deviceInfos) {
|
for (const QAudioDeviceInfo& deviceInfo : deviceInfos) {
|
||||||
if (deviceInfo.deviceName() == port) {
|
if (deviceInfo.deviceName() == port) {
|
||||||
|
@ -815,6 +801,8 @@ bool audioHandler::init(const quint8 bits, const quint8 channels, const quint16
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
resampler = wf_resampler_init(radioChannels, samplerate, INTERNAL_SAMPLE_RATE, resampleQuality, &resample_error);
|
||||||
|
|
||||||
const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||||
for (const QAudioDeviceInfo& deviceInfo : deviceInfos) {
|
for (const QAudioDeviceInfo& deviceInfo : deviceInfos) {
|
||||||
if (deviceInfo.deviceName() == port) {
|
if (deviceInfo.deviceName() == port) {
|
||||||
|
@ -828,7 +816,13 @@ bool audioHandler::init(const quint8 bits, const quint8 channels, const quint16
|
||||||
isInitialized = setDevice(QAudioDeviceInfo::defaultOutputDevice());
|
isInitialized = setDevice(QAudioDeviceInfo::defaultOutputDevice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isInitialized;
|
|
||||||
|
wf_resampler_get_ratio(resampler, &ratioNum, &ratioDen);
|
||||||
|
qDebug(logAudio()) << "wf_resampler_init() returned: " << resample_error << " ratioNum" << ratioNum << " ratioDen" << ratioDen << " input " << isinput;
|
||||||
|
|
||||||
|
qDebug(logAudio()) << "Got audio port name: " << port;
|
||||||
|
|
||||||
|
return isInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1086,11 +1086,13 @@ void udpServer::receiveAudioData(const audioPacket &d)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find all gaps in received packets and then send requests for them.
|
||||||
|
/// This will run every 100ms so out-of-sequence packets will not trigger a retransmit request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="c"></param>
|
||||||
void udpServer::sendRetransmitRequest(CLIENT *c)
|
void udpServer::sendRetransmitRequest(CLIENT *c)
|
||||||
{
|
{
|
||||||
// Find all gaps in received packets and then send requests for them.
|
|
||||||
// This will run every 100ms so out-of-sequence packets will not trigger a retransmit request.
|
|
||||||
|
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
|
|
||||||
|
@ -1174,8 +1176,12 @@ void udpServer::sendRetransmitRequest(CLIENT *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This function is passed a pointer to the list of connection objects and a pointer to the object itself
|
/// <summary>
|
||||||
// Needs to stop and delete all timers, remove the connection from the list and delete the connection.
|
/// This function is passed a pointer to the list of connection objects and a pointer to the object itself
|
||||||
|
/// Needs to stop and delete all timers, remove the connection from the list and delete the connection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="l"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
void udpServer::deleteConnection(QList<CLIENT*> *l, CLIENT* c)
|
void udpServer::deleteConnection(QList<CLIENT*> *l, CLIENT* c)
|
||||||
{
|
{
|
||||||
qDebug(logUdpServer()) << "Deleting connection to: " << c->ipAddress.toString() << ":" << QString::number(c->port);
|
qDebug(logUdpServer()) << "Deleting connection to: " << c->ipAddress.toString() << ":" << QString::number(c->port);
|
||||||
|
|
Ładowanie…
Reference in New Issue