Skip to content

Commit

Permalink
Expose plgAudioSys::GetFriendlyDeviceName to Python.
Browse files Browse the repository at this point in the history
Due to limited space in the options GUI, I was already needing to do
this in the Python code. Now that we need it in C++ for CoreAudio, it's
best to rely only on a single implementation.
  • Loading branch information
Hoikas committed Jan 28, 2020
1 parent a92334b commit 3fb4da9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/Plasma/FeatureLib/pfPython/pyAudioControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ std::vector<ST::string> pyAudioControl::GetPlaybackDevices() const
return plgAudioSys::GetPlaybackDevices();
}

ST::string pyAudioControl::GetFriendlyDeviceName(const ST::string& deviceName) const
{
return plgAudioSys::GetFriendlyDeviceName(deviceName);
}

void pyAudioControl::SetCaptureDevice(const ST::string& device)
{
plgAudioSys::SetCaptureDevice(device);
Expand Down
2 changes: 2 additions & 0 deletions Sources/Plasma/FeatureLib/pfPython/pyAudioControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class pyAudioControl

std::vector<ST::string> GetPlaybackDevices() const;

ST::string GetFriendlyDeviceName(const ST::string& deviceName) const;


//------------------------

Expand Down
11 changes: 11 additions & 0 deletions Sources/Plasma/FeatureLib/pfPython/pyAudioControlGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,16 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptAudioControl, getPlaybackDevices)
return tup;
}

PYTHON_METHOD_DEFINITION(ptAudioControl, getFriendlyDeviceName, args)
{
PyObject* devicename;
if (!PyArg_ParseTuple(args, "O", &devicename) || !PyString_CheckEx(devicename)) {
PyErr_SetString(PyExc_TypeError, "getFriendlyDeviceName expects a string");
PYTHON_RETURN_ERROR;
}
return PyUnicode_FromSTString(self->fThis->GetFriendlyDeviceName(PyString_AsStringEx(devicename)));
}

PYTHON_METHOD_DEFINITION(ptAudioControl, setCaptureDevice, args)
{
PyObject* devicename;
Expand Down Expand Up @@ -436,6 +446,7 @@ PYTHON_START_METHODS_TABLE(ptAudioControl)
PYTHON_METHOD(ptAudioControl, setPlaybackDevice, "Params: devicename,restart\nSets audio system output device by name, and optionally restarts it"),
PYTHON_METHOD(ptAudioControl, getPlaybackDevice, "Gets the name for the device being used by the audio system"),
PYTHON_METHOD_NOARGS(ptAudioControl, getPlaybackDevices, "Gets the names of all available audio playback devices"),
PYTHON_METHOD(ptAudioControl, getFriendlyDeviceName, "Params: devicename\nReturns the provided device name without any OpenAL prefixes applied"),

PYTHON_METHOD_NOARGS(ptAudioControl, canSetMicLevel, "Can the microphone level be set? Returns 1 if true otherwise returns 0."),
PYTHON_METHOD(ptAudioControl, setMicLevel, "Params: level\nSets the microphone recording level (0.0 to 1.0)."),
Expand Down

0 comments on commit 3fb4da9

Please sign in to comment.