Skip to content

Commit

Permalink
Renamed audio ports: Pa to PortAudio and Rt to RtAudio #1216 (#1223)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg68 authored Oct 16, 2022
1 parent 4305b0f commit 3a86122
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Renamed audio ports: Pa to PortAudio and Rt to RtAudio https://github.com/GrandOrgue/grandorgue/issues/1216
- Fixed size of the Organ Selection Dialog https://github.com/GrandOrgue/grandorgue/issues/1215
- Fixed generals buttons behaviour with the crescendo in add mode https://github.com/GrandOrgue/grandorgue/issues/1209
- Fixed an empty stop set to a general combination https://github.com/GrandOrgue/grandorgue/issues/1212
Expand Down
8 changes: 6 additions & 2 deletions src/grandorgue/sound/ports/GOSoundPortFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ GOSoundPort *GOSoundPortFactory::create(
wxString subsysName = parser.nextComp();
unsigned short subsysMask; // possible subsystems matching with the name

if (subsysName == GOSoundPortaudioPort::PORT_NAME)
if (
subsysName == GOSoundPortaudioPort::PORT_NAME
|| subsysName == GOSoundPortaudioPort::PORT_NAME_OLD)
subsysMask = SUBSYS_PA_BIT;
else if (subsysName == GOSoundRtPort::PORT_NAME)
else if (
subsysName == GOSoundRtPort::PORT_NAME
|| subsysName == GOSoundRtPort::PORT_NAME_OLD)
subsysMask = SUBSYS_RT_BIT;
else if (subsysName == GOSoundJackPort::PORT_NAME)
subsysMask = SUBSYS_JACK_BIT;
Expand Down
14 changes: 10 additions & 4 deletions src/grandorgue/sound/ports/GOSoundPortaudioPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

#include <wx/intl.h>

const wxString GOSoundPortaudioPort::PORT_NAME = wxT("Pa");
const wxString GOSoundPortaudioPort::PORT_NAME = wxT("PortAudio");
const wxString GOSoundPortaudioPort::PORT_NAME_OLD = wxT("Pa");

wxString GOSoundPortaudioPort::getLastError(PaError error) {
const char *errText = NULL;
Expand Down Expand Up @@ -37,11 +38,15 @@ GOSoundPortaudioPort::GOSoundPortaudioPort(GOSound *sound, wxString name)

GOSoundPortaudioPort::~GOSoundPortaudioPort() { Close(); }

wxString GOSoundPortaudioPort::getName(unsigned index) {
wxString compose_device_name(const wxString &prefix, unsigned index) {
const PaDeviceInfo *info = Pa_GetDeviceInfo(index);
const PaHostApiInfo *api = Pa_GetHostApiInfo(info->hostApi);
return GOSoundPortFactory::getInstance().ComposeDeviceName(
PORT_NAME, wxString::FromAscii(api->name), wxString(info->name));
prefix, wxString::FromAscii(api->name), wxString(info->name));
}

wxString GOSoundPortaudioPort::getName(unsigned index) {
return compose_device_name(PORT_NAME, index);
}

void GOSoundPortaudioPort::Open() {
Expand Down Expand Up @@ -148,7 +153,8 @@ GOSoundPort *GOSoundPortaudioPort::create(

if (
devName == name || devName + GOPortFactory::c_NameDelim == name
|| get_oldstyle_name(i) == name)
|| get_oldstyle_name(i) == name
|| compose_device_name(PORT_NAME_OLD, i) == name)
return new GOSoundPortaudioPort(sound, devName);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/grandorgue/sound/ports/GOSoundPortaudioPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class GOSoundPortaudioPort : public GOSoundPort {

public:
static const wxString PORT_NAME;
static const wxString PORT_NAME_OLD;

GOSoundPortaudioPort(GOSound *sound, wxString name);
virtual ~GOSoundPortaudioPort();
Expand Down
20 changes: 15 additions & 5 deletions src/grandorgue/sound/ports/GOSoundRtPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

#include "GOSoundPortFactory.h"

const wxString GOSoundRtPort::PORT_NAME = wxT("Rt");
const wxString GOSoundRtPort::PORT_NAME = wxT("RtAudio");
const wxString GOSoundRtPort::PORT_NAME_OLD = wxT("Rt");

GOSoundRtPort::GOSoundRtPort(GOSound *sound, RtAudio *rtApi, wxString name)
: GOSoundPort(sound, name), m_rtApi(rtApi), m_nBuffers(0) {}
Expand Down Expand Up @@ -139,7 +140,8 @@ int GOSoundRtPort::Callback(
return 1;
}

wxString GOSoundRtPort::getName(RtAudio *rt_api, unsigned index) {
wxString compose_device_name(
const wxString &prefix, RtAudio *rt_api, unsigned index) {
wxString apiName = RtAudio::getApiName(rt_api->getCurrentApi());
wxString devName;

Expand All @@ -152,7 +154,11 @@ wxString GOSoundRtPort::getName(RtAudio *rt_api, unsigned index) {
devName = wxString::Format(_("<unknown> %d"), index);
}
return GOSoundPortFactory::getInstance().ComposeDeviceName(
PORT_NAME, apiName, devName);
prefix, apiName, devName);
}

wxString GOSoundRtPort::getName(RtAudio *rt_api, unsigned index) {
return compose_device_name(PORT_NAME, rt_api, index);
}

wxString get_oldstyle_name(RtAudio::Api api, RtAudio *rt_api, unsigned index) {
Expand Down Expand Up @@ -225,7 +231,10 @@ GOSoundPort *GOSoundRtPort::create(
try {
GOSoundPortFactory::NameParser parser(name);
const wxString subsysName = parser.nextComp();
wxString apiName = subsysName == PORT_NAME ? parser.nextComp() : wxT("");
wxString apiName
= (subsysName == PORT_NAME || subsysName == PORT_NAME_OLD)
? parser.nextComp()
: wxT("");

std::vector<RtAudio::Api> rtaudio_apis;
RtAudio::getCompiledApi(rtaudio_apis);
Expand All @@ -248,7 +257,8 @@ GOSoundPort *GOSoundRtPort::create(

if (
devName == name || devName + GOPortFactory::c_NameDelim == name
|| (apiName.IsEmpty() && get_oldstyle_name(apiIndex, rtApi, i) == name)) {
|| (apiName.IsEmpty() && get_oldstyle_name(apiIndex, rtApi, i) == name)
|| compose_device_name(PORT_NAME_OLD, rtApi, i) == name) {
port = new GOSoundRtPort(sound, rtApi, devName);
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/grandorgue/sound/ports/GOSoundRtPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class GOSoundRtPort : public GOSoundPort {

public:
static const wxString PORT_NAME;
static const wxString PORT_NAME_OLD;

// rtApi to be deleted in the destructor
GOSoundRtPort(GOSound *sound, RtAudio *rtApi, wxString name);
Expand Down

0 comments on commit 3a86122

Please sign in to comment.