1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-17 08:01:12 +02:00

Applying patch from bug #766

This patch fixes the corrupted device names as 
documented by the bug report.
This commit is contained in:
lllucius@gmail.com
2014-12-06 05:05:21 +00:00
parent 71d8b0d8ec
commit 9317bbb3f7
6 changed files with 31 additions and 31 deletions

View File

@@ -494,14 +494,14 @@ void DeinitAudioIO()
wxString DeviceName(const PaDeviceInfo* info) wxString DeviceName(const PaDeviceInfo* info)
{ {
wxString infoName(info->name, wxConvLocal); wxString infoName = wxSafeConvertMB2WX(info->name);
return infoName; return infoName;
} }
wxString HostName(const PaDeviceInfo* info) wxString HostName(const PaDeviceInfo* info)
{ {
wxString hostapiName(Pa_GetHostApiInfo(info->hostApi)->name, wxConvLocal); wxString hostapiName = wxSafeConvertMB2WX(Pa_GetHostApiInfo(info->hostApi)->name);
return hostapiName; return hostapiName;
} }
@@ -727,7 +727,7 @@ wxArrayString AudioIO::GetInputSourceNames()
{ {
int numSources = Px_GetNumInputSources(mPortMixer); int numSources = Px_GetNumInputSources(mPortMixer);
for( int source = 0; source < numSources; source++ ) for( int source = 0; source < numSources; source++ )
deviceNames.Add(wxString(Px_GetInputSourceName(mPortMixer, source), wxConvLocal)); deviceNames.Add(wxString(wxSafeConvertMB2WX(Px_GetInputSourceName(mPortMixer, source))));
} }
else else
{ {
@@ -1568,10 +1568,10 @@ bool AudioIO::StartPortMidiStream()
const PmDeviceInfo *info = Pm_GetDeviceInfo(i); const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
if (!info) continue; if (!info) continue;
if (!info->output) continue; if (!info->output) continue;
wxString interf(info->interf, wxConvLocal); wxString interf = wxSafeConvertMB2WX((info->interf);
wxString name(info->name, wxConvLocal); wxString name = wxSafeConvertMB2WX(info->name);
interf.Append(wxT(": ")).Append(name); interf.Append(wxT(": ")).Append(name);
if (wxStrcmp(interf, playbackDeviceName) == 0) { if (wxStrcmp(interf, playbackDeviceName) == 0) {
playbackDevice = i; playbackDevice = i;
} }
} }
@@ -2379,7 +2379,7 @@ int AudioIO::getRecordSourceIndex(PxMixer *portMixer)
wxString sourceName = gPrefs->Read(wxT("/AudioIO/RecordingSource"), wxT("")); wxString sourceName = gPrefs->Read(wxT("/AudioIO/RecordingSource"), wxT(""));
int numSources = Px_GetNumInputSources(portMixer); int numSources = Px_GetNumInputSources(portMixer);
for (i = 0; i < numSources; i++) { for (i = 0; i < numSources; i++) {
if (sourceName == wxString(Px_GetInputSourceName(portMixer, i), wxConvLocal)) if (sourceName == wxString(wxSafeConvertMB2WX(Px_GetInputSourceName(portMixer, i))))
return i; return i;
} }
return -1; return -1;
@@ -2400,7 +2400,7 @@ int AudioIO::getPlayDevIndex(wxString devName)
for (hostNum = 0; hostNum < hostCnt; hostNum++) for (hostNum = 0; hostNum < hostCnt; hostNum++)
{ {
const PaHostApiInfo *hinfo = Pa_GetHostApiInfo(hostNum); const PaHostApiInfo *hinfo = Pa_GetHostApiInfo(hostNum);
if (hinfo && wxString(hinfo->name, wxConvLocal) == hostName) if (hinfo && wxString(wxSafeConvertMB2WX(hinfo->name)) == hostName)
{ {
for (PaDeviceIndex hostDevice = 0; hostDevice < hinfo->deviceCount; hostDevice++) for (PaDeviceIndex hostDevice = 0; hostDevice < hinfo->deviceCount; hostDevice++)
{ {
@@ -2453,7 +2453,7 @@ int AudioIO::getRecordDevIndex(wxString devName)
for (hostNum = 0; hostNum < hostCnt; hostNum++) for (hostNum = 0; hostNum < hostCnt; hostNum++)
{ {
const PaHostApiInfo *hinfo = Pa_GetHostApiInfo(hostNum); const PaHostApiInfo *hinfo = Pa_GetHostApiInfo(hostNum);
if (hinfo && wxString(hinfo->name, wxConvLocal) == hostName) if (hinfo && wxString(wxSafeConvertMB2WX(hinfo->name)) == hostName)
{ {
for (PaDeviceIndex hostDevice = 0; hostDevice < hinfo->deviceCount; hostDevice++) for (PaDeviceIndex hostDevice = 0; hostDevice < hinfo->deviceCount; hostDevice++)
{ {
@@ -2673,7 +2673,7 @@ wxString AudioIO::GetDeviceInfo()
cnt = Px_GetNumMixers(stream); cnt = Px_GetNumMixers(stream);
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
wxString name(Px_GetMixerName(stream, i), wxConvLocal); wxString name = wxSafeConvertMB2WX(Px_GetMixerName(stream, i));
s << i << wxT(" - ") << name << e; s << i << wxT(" - ") << name << e;
} }
@@ -2681,7 +2681,7 @@ wxString AudioIO::GetDeviceInfo()
s << wxT("Available recording sources:") << e; s << wxT("Available recording sources:") << e;
cnt = Px_GetNumInputSources(PortMixer); cnt = Px_GetNumInputSources(PortMixer);
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
wxString name(Px_GetInputSourceName(PortMixer, i), wxConvLocal); wxString name = wxSafeConvertMB2WX(Px_GetInputSourceName(PortMixer, i));
s << i << wxT(" - ") << name << e; s << i << wxT(" - ") << name << e;
} }
@@ -2689,7 +2689,7 @@ wxString AudioIO::GetDeviceInfo()
s << wxT("Available playback volumes:") << e; s << wxT("Available playback volumes:") << e;
cnt = Px_GetNumOutputVolumes(PortMixer); cnt = Px_GetNumOutputVolumes(PortMixer);
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
wxString name(Px_GetOutputVolumeName(PortMixer, i), wxConvLocal); wxString name = wxSafeConvertMB2WX(Px_GetOutputVolumeName(PortMixer, i));
s << i << wxT(" - ") << name << e; s << i << wxT(" - ") << name << e;
} }

View File

@@ -70,7 +70,7 @@ wxString MakeDeviceSourceString(const DeviceSourceMap *map)
wxString ret; wxString ret;
ret = map->deviceString; ret = map->deviceString;
if (map->totalSources > 1) if (map->totalSources > 1)
ret += wxString(": ", wxConvLocal) + map->sourceString; ret += wxT(": ") + map->sourceString;
return ret; return ret;
} }
@@ -120,8 +120,8 @@ static int DummyPaStreamCallback(
static void FillHostDeviceInfo(DeviceSourceMap *map, const PaDeviceInfo *info, int deviceIndex, int isInput) static void FillHostDeviceInfo(DeviceSourceMap *map, const PaDeviceInfo *info, int deviceIndex, int isInput)
{ {
wxString hostapiName(Pa_GetHostApiInfo(info->hostApi)->name, wxConvLocal); wxString hostapiName = wxSafeConvertMB2WX(Pa_GetHostApiInfo(info->hostApi)->name);
wxString infoName(info->name, wxConvLocal); wxString infoName = wxSafeConvertMB2WX(info->name);
map->deviceIndex = deviceIndex; map->deviceIndex = deviceIndex;
map->hostIndex = info->hostApi; map->hostIndex = info->hostApi;
@@ -166,7 +166,7 @@ static void AddSourcesFromStream(int deviceIndex, const PaDeviceInfo *info, std:
//open up a stream with the device so portmixer can get the info out of it. //open up a stream with the device so portmixer can get the info out of it.
for (i = 0; i < map.totalSources; i++) { for (i = 0; i < map.totalSources; i++) {
map.sourceIndex = i; map.sourceIndex = i;
map.sourceString = wxString(Px_GetInputSourceName(portMixer, i), wxConvLocal); map.sourceString = wxString(wxSafeConvertMB2WX(Px_GetInputSourceName(portMixer, i)));
maps->push_back(map); maps->push_back(map);
} }
} }
@@ -245,7 +245,7 @@ static void AddSources(int deviceIndex, int rate, std::vector<DeviceSourceMap> *
if(error) { if(error) {
wxLogDebug(wxT("PortAudio stream error creating device list: ") + wxLogDebug(wxT("PortAudio stream error creating device list: ") +
map.hostString + wxT(":") + map.deviceString + wxT(": ") + map.hostString + wxT(":") + map.deviceString + wxT(": ") +
wxString(Pa_GetErrorText( (PaError)error), wxConvLocal)); wxString(wxSafeConvertMB2WX(Pa_GetErrorText((PaError)error))));
} }
} }

View File

@@ -45,7 +45,7 @@ void Internat::Init()
// Save decimal point character // Save decimal point character
struct lconv * localeInfo = localeconv(); struct lconv * localeInfo = localeconv();
if (localeInfo) if (localeInfo)
mDecimalSeparator = wxString(localeInfo->decimal_point, wxConvLocal).GetChar(0); mDecimalSeparator = wxString(wxSafeConvertMB2WX(localeInfo->decimal_point)).GetChar(0);
// wxLogDebug(wxT("Decimal separator set to '%c'"), mDecimalSeparator); // wxLogDebug(wxT("Decimal separator set to '%c'"), mDecimalSeparator);

View File

@@ -92,7 +92,7 @@ void DevicePrefs::GetNamesAndLabels()
for (int i = 0; i < nDevices; i++) { for (int i = 0; i < nDevices; i++) {
const PaDeviceInfo *info = Pa_GetDeviceInfo(i); const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
if (info->maxOutputChannels > 0 || info->maxInputChannels > 0) { if (info->maxOutputChannels > 0 || info->maxInputChannels > 0) {
wxString name(Pa_GetHostApiInfo(info->hostApi)->name, wxConvLocal); wxString name = wxSafeConvertMB2WX(Pa_GetHostApiInfo(info->hostApi)->name);
if (mHostNames.Index(name) == wxNOT_FOUND) { if (mHostNames.Index(name) == wxNOT_FOUND) {
mHostNames.Add(name); mHostNames.Add(name);
mHostLabels.Add(name); mHostLabels.Add(name);
@@ -120,7 +120,7 @@ void DevicePrefs::PopulateOrExchange(ShuttleGui & S)
S.SetSizeHints(mHostNames); S.SetSizeHints(mHostNames);
S.AddPrompt(_("Using:")); S.AddPrompt(_("Using:"));
S.AddFixedText(wxString(Pa_GetVersionText(), wxConvLocal)); S.AddFixedText(wxString(wxSafeConvertMB2WX(Pa_GetVersionText())));
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }
@@ -169,7 +169,7 @@ void DevicePrefs::OnHost(wxCommandEvent & e)
wxString apiName = mHostNames[mHost->GetCurrentSelection()]; wxString apiName = mHostNames[mHost->GetCurrentSelection()];
int nHosts = Pa_GetHostApiCount(); int nHosts = Pa_GetHostApiCount();
for (int i = 0; i < nHosts; ++i) { for (int i = 0; i < nHosts; ++i) {
wxString name(Pa_GetHostApiInfo(i)->name, wxConvLocal); wxString name = wxSafeConvertMB2WX(Pa_GetHostApiInfo(i)->name);
if (name == apiName) { if (name == apiName) {
index = i; index = i;
break; break;
@@ -201,7 +201,7 @@ void DevicePrefs::OnHost(wxCommandEvent & e)
recDevice = mRecordDevice; recDevice = mRecordDevice;
if (this->mRecordSource != wxT("")) if (this->mRecordSource != wxT(""))
recDevice += wxString(": ", wxConvLocal) + mRecordSource; recDevice += wxT(": ") + mRecordSource;
mRecord->Clear(); mRecord->Clear();
for (i = 0; i < inMaps.size(); i++) { for (i = 0; i < inMaps.size(); i++) {

View File

@@ -100,7 +100,7 @@ void MidiIOPrefs::GetNamesAndLabels() {
for (int i = 0; i < nDevices; i++) { for (int i = 0; i < nDevices; i++) {
const PmDeviceInfo *info = Pm_GetDeviceInfo(i); const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
if (info->output || info->input) { //should always happen if (info->output || info->input) { //should always happen
wxString name(info->interf, wxConvLocal); wxString name = wxSafeConvertMB2WX(info->interf);
if (mHostNames.Index(name) == wxNOT_FOUND) { if (mHostNames.Index(name) == wxNOT_FOUND) {
mHostNames.Add(name); mHostNames.Add(name);
mHostLabels.Add(name); mHostLabels.Add(name);
@@ -195,9 +195,9 @@ void MidiIOPrefs::OnHost(wxCommandEvent & e)
for (int i = 0; i < nDevices; i++) { for (int i = 0; i < nDevices; i++) {
const PmDeviceInfo *info = Pm_GetDeviceInfo(i); const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
wxString interf(info->interf, wxConvLocal); wxString interf = wxSafeConvertMB2WX(info->interf);
if (itemAtIndex.IsSameAs(interf)) { if (itemAtIndex.IsSameAs(interf)) {
wxString name(info->name, wxConvLocal); wxString name = wxSafeConvertMB2WX(info->name);
wxString device = wxString::Format(wxT("%s: %s"), wxString device = wxString::Format(wxT("%s: %s"),
interf.c_str(), interf.c_str(),
name.c_str()); name.c_str());
@@ -259,16 +259,16 @@ bool MidiIOPrefs::Apply()
if (info) { if (info) {
gPrefs->Write(wxT("/MidiIO/PlaybackDevice"), gPrefs->Write(wxT("/MidiIO/PlaybackDevice"),
wxString::Format(wxT("%s: %s"), wxString::Format(wxT("%s: %s"),
wxString(info->interf, wxConvLocal).c_str(), wxString(wxSafeConvertMB2WX(info->interf)).c_str(),
wxString(info->name, wxConvLocal).c_str())); wxString(wxSafeConvertMB2WX(info->name)).c_str()));
} }
#ifdef EXPERIMENTAL_MIDI_IN #ifdef EXPERIMENTAL_MIDI_IN
info = (const PmDeviceInfo *) mRecord->GetClientData(mRecord->GetSelection()); info = (const PmDeviceInfo *) mRecord->GetClientData(mRecord->GetSelection());
if (info) { if (info) {
gPrefs->Write(wxT("/MidiIO/RecordingDevice"), gPrefs->Write(wxT("/MidiIO/RecordingDevice"),
wxString::Format(wxT("%s: %s"), wxString::Format(wxT("%s: %s"),
wxString(info->interf, wxConvLocal).c_str(), wxString(wxSafeConvertMB2WX(info->interf)).c_str(),
wxString(info->name, wxConvLocal).c_str())); wxString(wxSafeConvertMB2WX(info->name)).c_str()));
} }
#endif #endif
return gPrefs->Flush(); return gPrefs->Flush();

View File

@@ -255,7 +255,7 @@ void DeviceToolBar::UpdatePrefs()
if (sourceName == wxT("")) if (sourceName == wxT(""))
desc = devName; desc = devName;
else else
desc = devName + wxString(": ", wxConvLocal) + sourceName; desc = devName + wxT(": ") + sourceName;
if (mInput->GetStringSelection() != desc && if (mInput->GetStringSelection() != desc &&
mInput->FindString(desc) != wxNOT_FOUND) { mInput->FindString(desc) != wxNOT_FOUND) {
@@ -285,7 +285,7 @@ void DeviceToolBar::UpdatePrefs()
if (sourceName == wxT("")) if (sourceName == wxT(""))
desc = devName; desc = devName;
else else
desc = devName + wxString(": ", wxConvLocal) + sourceName; desc = devName + wxT(": ") + sourceName;
if (mOutput->GetStringSelection() != desc && if (mOutput->GetStringSelection() != desc &&
mOutput->FindString(desc) != wxNOT_FOUND) { mOutput->FindString(desc) != wxNOT_FOUND) {