Skip to content

Commit

Permalink
blah (squish this later)
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaMorphic committed Nov 23, 2023
1 parent 98f654f commit c006a99
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 34 deletions.
6 changes: 5 additions & 1 deletion src/mumble/AudioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void AudioOutput::prepareOutputBuffers(unsigned int frameCount, QList< AudioOutp
QList< AudioOutputBuffer * > *qlDel) {
// Get the users that are currently talking (and are thus serving as an audio source)
QMultiHash< const ClientUser *, AudioOutputBuffer * >::const_iterator it = qmOutputs.constBegin();
while (it != qmOutputs.constEnd()) {
for (int i = 0; i < qmOutputs.count(); i++) {
AudioOutputBuffer *buffer = it.value();
if (!buffer->prepareSampleBuffer(frameCount)) {
qlDel->append(buffer);
Expand Down Expand Up @@ -810,3 +810,7 @@ unsigned int AudioOutput::getMixerFreq() const {
void AudioOutput::setBufferSize(unsigned int bufferSize) {
iBufferSize = bufferSize;
}

bool AudioOutput::supportsTransportRecording() const {
return false;
}
2 changes: 2 additions & 0 deletions src/mumble/AudioOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ private slots:
void removeToken(AudioOutputToken &);
void removeUser(const ClientUser *);

virtual bool supportsTransportRecording() const;

signals:
/// Signal emitted whenever an audio source has been fetched
///
Expand Down
2 changes: 1 addition & 1 deletion src/mumble/EnumStringConversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
PROCESS(Settings::RecordingMode, RecordingMixdown, "Mixdown") \
PROCESS(Settings::RecordingMode, RecordingMultichannel, "Multichannel") \
PROCESS(Settings::RecordingMode, RecordingMultichannelAndTransport, "MultichannelAndTransport") \
PROCESS(Settings::RecordingMode, RecordingTransportStandalone, "MultichannelAndTransport")
PROCESS(Settings::RecordingMode, RecordingTransportStandalone, "TransportStandalone")

#define SEARCH_USER_ACTION_VALUES \
PROCESS(Search::SearchDialog::UserAction, NONE, "None") \
Expand Down
39 changes: 8 additions & 31 deletions src/mumble/JackAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,14 +980,13 @@ bool JackAudioOutput::unregisterPorts() {
}
}

for (auto port : userPorts.values()) {
if (!port) {
for (auto port : userPorts) {
if (!port.second) {
continue;
}

if (!jas->unregisterPort(port)) {
qWarning("JackAudioOutput: unable to unregister port named \"%s\"",
userPorts.key(port).toStdString().c_str());
if (!jas->unregisterPort(port.second)) {
qWarning("JackAudioOutput: unable to unregister port named \"%s\"", port.first.toStdString().c_str());
ret = false;
}
}
Expand Down Expand Up @@ -1102,9 +1101,6 @@ void JackAudioOutput::prepareOutputBuffers(unsigned int frameCount, QList< Audio
recorder = Global::get().sh->recorder;
}

// Keep track of ports we've filled the audio of.
QList< jack_port_t * > qlPortsYetToFill(userPorts.values());

// Register user ports based on who is currently present in qmOutputs and route their audio to JACK.
// Don't care if users get removed for now. TODO: maybe at some point we do.
QMultiHash< const ClientUser *, AudioOutputBuffer * >::const_iterator it = qmOutputs.constBegin();
Expand Down Expand Up @@ -1135,33 +1131,10 @@ void JackAudioOutput::prepareOutputBuffers(unsigned int frameCount, QList< Audio
}

if (audio->prepareSampleBuffer(frameCount)) {
qlPortsYetToFill.removeOne(userPorts[qsPortName]);
qlMix->append(audio);

auto outputBuffer = (float *) jas->getPortBuffer(userPorts[qsPortName], frameCount);
if (audio->bStereo) {
// Mix down stereo to mono. TODO: stereo record support
// frame: for a stereo stream, the [LR] pair inside ...[LR]LRLRLR.... is a frame
for (unsigned int i = 0; i < frameCount; ++i) {
outputBuffer[i] = (audio->pfBuffer[2 * i] / 2.0 + audio->pfBuffer[2 * i + 1] / 2.0);
}
} else {
for (unsigned int i = 0; i < frameCount; ++i) {
outputBuffer[i] = audio->pfBuffer[i];
}
}
} else {
qlDel->append(audio);
}

++it;
}

for (auto port : qlPortsYetToFill) {
if (port) {
auto outputBuffer = jas->getPortBuffer(port, frameCount);
memset(outputBuffer, 0, sizeof(float) * frameCount);
}
}
}

Expand Down Expand Up @@ -1237,4 +1210,8 @@ void JackAudioOutput::run() {
} while (bReady);
}

bool JackAudioOutput::supportsTransportRecording() const {
return true;
}

#undef RESOLVE
7 changes: 6 additions & 1 deletion src/mumble/JackAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef MUMBLE_MUMBLE_JACKAUDIO_H_
#define MUMBLE_MUMBLE_JACKAUDIO_H_

#include <map>

#include "AudioInput.h"
#include "AudioOutput.h"

Expand All @@ -28,7 +30,7 @@ struct jack_ringbuffer_data_t {
};

typedef QVector< jack_port_t * > JackPorts;
typedef QHash< QString, jack_port_t * > JackNamedPorts;
typedef std::map< QString, jack_port_t * > JackNamedPorts;
typedef QVector< jack_default_audio_sample_t * > JackBuffers;
typedef QVector< jack_ringbuffer_t * > JackRingBuffers;

Expand Down Expand Up @@ -166,6 +168,7 @@ class JackAudioOutput : public AudioOutput {
JackNamedPorts userPorts;
JackBuffers outputBuffers;
jack_ringbuffer_t *buffer;

void prepareOutputBuffers(unsigned int frameCount, QList< AudioOutputBuffer * > *qlMix,
QList< AudioOutputBuffer * > *qlDel) override;

Expand All @@ -181,6 +184,8 @@ class JackAudioOutput : public AudioOutput {
bool disconnectPorts();

void run() Q_DECL_OVERRIDE;
bool supportsTransportRecording() const Q_DECL_OVERRIDE;

JackAudioOutput();
~JackAudioOutput() Q_DECL_OVERRIDE;
};
Expand Down
16 changes: 16 additions & 0 deletions src/mumble/VoiceRecorderDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ VoiceRecorderDialog::VoiceRecorderDialog(QWidget *p) : QDialog(p), qtTimer(new Q
qleTargetDirectory->setText(Global::get().s.qsRecordingPath);
qleFilename->setText(Global::get().s.qsRecordingFile);

guardTransportRecording();

qrbDownmix->setChecked(Global::get().s.rmRecordingMode == Settings::RecordingMixdown);
qrbMultichannel->setChecked(Global::get().s.rmRecordingMode == Settings::RecordingMultichannel);
qrbMultichannelAndTransport->setChecked(Global::get().s.rmRecordingMode
Expand Down Expand Up @@ -78,6 +80,18 @@ VoiceRecorderDialog::~VoiceRecorderDialog() {
reset();
}

void VoiceRecorderDialog::guardTransportRecording() {
bool aoSupportsTransport = Global::get().ao->supportsTransportRecording();
if (aoSupportsTransport) {
qrbMultichannelAndTransport->setEnabled(true);
qrbTransportStandalone->setEnabled(true);
} else {
qrbMultichannelAndTransport->setDisabled(true);
qrbTransportStandalone->setDisabled(true);
Global::get().s.rmRecordingMode = Settings::RecordingMixdown;
}
}

void VoiceRecorderDialog::closeEvent(QCloseEvent *evt) {
if (Global::get().sh) {
VoiceRecorderPtr recorder(Global::get().sh->recorder);
Expand Down Expand Up @@ -290,6 +304,8 @@ void VoiceRecorderDialog::reset(bool resettimer) {
qgbMode->setEnabled(true);
qgbOutput->setDisabled(qrbTransportStandalone->isChecked());

guardTransportRecording();

if (resettimer)
qlTime->setText(QLatin1String("00:00:00"));
}
Expand Down
2 changes: 2 additions & 0 deletions src/mumble/VoiceRecorderDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class VoiceRecorderDialog : public QDialog, private Ui::VoiceRecorderDialog {

QTimer *qtTimer;

void guardTransportRecording();

public:
explicit VoiceRecorderDialog(QWidget *p = nullptr);
~VoiceRecorderDialog() Q_DECL_OVERRIDE;
Expand Down

0 comments on commit c006a99

Please sign in to comment.