Last RString MSVC compiler error. Eliminate gotos to fix more MSVC compiler errors.

This commit is contained in:
Brian Phlipot
2022-10-03 16:21:19 -07:00
committed by teejusb
parent 0cc289fa1c
commit 95e55f5cdd
2 changed files with 21 additions and 29 deletions
+1 -1
View File
@@ -6059,7 +6059,7 @@ void ScreenEdit::HandleBGChangeChoice( BGChangeChoice c, const std::vector<int>
case global_movie_song_group_and_genre: case global_movie_song_group_and_genre:
{ {
BGChangeChoice row1 = (BGChangeChoice)(file1_song_bganimation + iAnswers[file1_type]); BGChangeChoice row1 = (BGChangeChoice)(file1_song_bganimation + iAnswers[file1_type]);
newChange.m_def.m_sFile1 = g_BackgroundChange.rows[row1].choices.empty() ? "" : g_BackgroundChange.rows[row1].choices[iAnswers[row1]]; newChange.m_def.m_sFile1 = g_BackgroundChange.rows[row1].choices.empty() ? RString("") : g_BackgroundChange.rows[row1].choices[iAnswers[row1]];
} }
break; break;
} }
+19 -27
View File
@@ -98,13 +98,12 @@ struct WinWdmFilter
~WinWdmFilter() ~WinWdmFilter()
{ {
for( size_t i = 0; i < m_apPins.size(); ++i ) m_apPins.clear();
delete m_apPins[i];
if( m_hHandle ) if( m_hHandle )
CloseHandle( m_hHandle ); CloseHandle( m_hHandle );
} }
WinWdmPin *CreatePin( unsigned long iPinId, RString &sError ); std::shared_ptr<WinWdmPin> CreatePin( unsigned long iPinId, RString &sError );
WinWdmPin *InstantiateRenderPin( WinWdmPin *InstantiateRenderPin(
DeviceSampleFormat &PreferredOutputSampleFormat, DeviceSampleFormat &PreferredOutputSampleFormat,
int &iPreferredOutputChannels, int &iPreferredOutputChannels,
@@ -115,7 +114,7 @@ struct WinWdmFilter
void Release(); void Release();
HANDLE m_hHandle; HANDLE m_hHandle;
std::vector<WinWdmPin *> m_apPins; std::vector<std::shared_ptr<WinWdmPin>> m_apPins;
RString m_sFilterName; RString m_sFilterName;
RString m_sFriendlyName; RString m_sFriendlyName;
int m_iUsageCount; int m_iUsageCount;
@@ -275,7 +274,7 @@ static bool WdmGetPinPropertyMulti(
* The pin object holds all the configuration information about the pin * The pin object holds all the configuration information about the pin
* before it is opened, and then the handle of the pin after is opened * before it is opened, and then the handle of the pin after is opened
*/ */
WinWdmPin *WinWdmFilter::CreatePin( unsigned long iPinId, RString &sError ) std::shared_ptr<WinWdmPin> WinWdmFilter::CreatePin( unsigned long iPinId, RString &sError )
{ {
{ {
/* Get the COMMUNICATION property */ /* Get the COMMUNICATION property */
@@ -370,14 +369,14 @@ WinWdmPin *WinWdmFilter::CreatePin( unsigned long iPinId, RString &sError )
} }
/* Allocate the new PIN object */ /* Allocate the new PIN object */
WinWdmPin *pPin = new WinWdmPin( this, iPinId ); auto pPin = std::make_shared<WinWdmPin>( this, iPinId );
/* Get DATARANGEs */ /* Get DATARANGEs */
KSMULTIPLE_ITEM *pDataRangesItem; KSMULTIPLE_ITEM *pDataRangesItem;
if( !WdmGetPinPropertyMulti(m_hHandle, iPinId, &KSPROPSETID_Pin, KSPROPERTY_PIN_DATARANGES, &pDataRangesItem, sError) ) if( !WdmGetPinPropertyMulti(m_hHandle, iPinId, &KSPROPSETID_Pin, KSPROPERTY_PIN_DATARANGES, &pDataRangesItem, sError) )
{ {
sError = "KSPROPERTY_PIN_DATARANGES: " + sError; sError = "KSPROPERTY_PIN_DATARANGES: " + sError;
goto error; return nullptr;
} }
KSDATARANGE* pDataRanges = (KSDATARANGE*) (pDataRangesItem + 1); KSDATARANGE* pDataRanges = (KSDATARANGE*) (pDataRangesItem + 1);
@@ -410,18 +409,13 @@ WinWdmPin *WinWdmFilter::CreatePin( unsigned long iPinId, RString &sError )
if( pPin->m_dataRangesItem.size() == 0 ) if( pPin->m_dataRangesItem.size() == 0 )
{ {
sError = "Pin has no supported audio data ranges"; sError = "Pin has no supported audio data ranges";
goto error; return nullptr;
} }
/* Success */ /* Success */
sError = ""; sError = "";
CHECKPOINT_M( "Pin created successfully" ); CHECKPOINT_M( "Pin created successfully" );
return pPin; return pPin;
error:
/* Error cleanup */
delete pPin;
return nullptr;
} }
/* If the pin handle is open, close it */ /* If the pin handle is open, close it */
@@ -555,8 +549,8 @@ WinWdmFilter *WinWdmFilter::Create( const RString &sFilterName, const RString &s
for( int iPinId = 0; iPinId < iNumPins; iPinId++ ) for( int iPinId = 0; iPinId < iNumPins; iPinId++ )
{ {
/* Create the pin with this Id */ /* Create the pin with this Id */
WinWdmPin *pNewPin = pFilter->CreatePin( iPinId, sError ); auto pNewPin = pFilter->CreatePin( iPinId, sError );
if( pNewPin != nullptr ) if( pNewPin )
pFilter->m_apPins.push_back( pNewPin ); pFilter->m_apPins.push_back( pNewPin );
} }
@@ -625,11 +619,11 @@ WinWdmPin *WinWdmFilter::InstantiateRenderPin( const WAVEFORMATEX *wfex, RString
{ {
for( size_t i = 0; i < m_apPins.size(); ++i ) for( size_t i = 0; i < m_apPins.size(); ++i )
{ {
WinWdmPin *pPin = m_apPins[i]; auto pPin = m_apPins[i];
if( pPin->Instantiate(wfex, sError) ) if( pPin->Instantiate(wfex, sError) )
{ {
sError = ""; sError = "";
return pPin; return pPin.get();
} }
} }
@@ -640,10 +634,10 @@ WinWdmPin *WinWdmFilter::InstantiateRenderPin( const WAVEFORMATEX *wfex, RString
template<typename T, typename U> template<typename T, typename U>
void MoveToBeginning( std::vector<T> &v, const U &item ) void MoveToBeginning( std::vector<T> &v, const U &item )
{ {
std::vector<T>::iterator it = find( v.begin(), v.end(), item ); auto it = find( v.begin(), v.end(), item );
if( it == v.end() ) if( it == v.end() )
return; return;
std::vector<T>::iterator next = it; auto next = it;
++next; ++next;
copy_backward( v.begin(), it, next ); copy_backward( v.begin(), it, next );
*v.begin() = item; *v.begin() = item;
@@ -721,7 +715,7 @@ WinWdmPin *WinWdmFilter::InstantiateRenderPin(
*/ */
std::vector<int> aSampleRates; std::vector<int> aSampleRates;
{ {
for (WinWdmPin *pPin : m_apPins) for (auto pPin : m_apPins)
{ {
for (KSDATARANGE_AUDIO const &range : pPin->m_dataRangesItem) for (KSDATARANGE_AUDIO const &range : pPin->m_dataRangesItem)
{ {
@@ -956,8 +950,10 @@ bool WinWdmStream::Open( WinWdmFilter *pFilter,
iPreferredSampleRate, iPreferredSampleRate,
sError ); sError );
if( m_pPlaybackPin == nullptr ) if (m_pPlaybackPin == nullptr) {
goto error; Close();
return false;
}
m_DeviceSampleFormat = PreferredOutputSampleFormat; m_DeviceSampleFormat = PreferredOutputSampleFormat;
m_iDeviceOutputChannels = iPreferredOutputChannels; m_iDeviceOutputChannels = iPreferredOutputChannels;
@@ -1012,10 +1008,6 @@ bool WinWdmStream::Open( WinWdmFilter *pFilter,
} }
return true; return true;
error:
Close();
return false;
} }
bool WinWdmStream::SubmitPacket( int iPacket, RString &sError ) bool WinWdmStream::SubmitPacket( int iPacket, RString &sError )
@@ -1287,7 +1279,7 @@ RString RageSoundDriver_WDMKS::Init()
const WinWdmFilter *pFilter = apFilters[i]; const WinWdmFilter *pFilter = apFilters[i];
LOG->Trace( "Device #%i: %s", i, pFilter->m_sFriendlyName.c_str() ); LOG->Trace( "Device #%i: %s", i, pFilter->m_sFriendlyName.c_str() );
int j = 0; int j = 0;
for (WinWdmPin *pPin : pFilter->m_apPins) for (auto pPin : pFilter->m_apPins)
{ {
LOG->Trace( " Pin %i", j++ ); LOG->Trace( " Pin %i", j++ );
for (KSDATARANGE_AUDIO const &range : pPin->m_dataRangesItem) for (KSDATARANGE_AUDIO const &range : pPin->m_dataRangesItem)