@@ -2163,9 +2163,6 @@ static void mic_driver_microphone_handle_init(retro_microphone_t *microphone,
21632163 unsigned microphone_sample_rate = settings -> uints .microphone_sample_rate ;
21642164 microphone -> microphone_context = NULL ;
21652165 microphone -> flags = MICROPHONE_FLAG_ACTIVE ;
2166- microphone -> sample_buffer = NULL ;
2167- microphone -> sample_buffer_length = 0 ;
2168-
21692166 microphone -> requested_params .rate = params ? params -> rate : microphone_sample_rate ;
21702167 microphone -> actual_params .rate = 0 ;
21712168 /* We don't set the actual parameters until we actually open the mic.
@@ -2195,13 +2192,6 @@ static void mic_driver_microphone_handle_free(retro_microphone_t *microphone, bo
21952192 microphone -> microphone_context = NULL ;
21962193 }
21972194
2198- if (microphone -> sample_buffer )
2199- {
2200- memalign_free (microphone -> sample_buffer );
2201- microphone -> sample_buffer = NULL ;
2202- microphone -> sample_buffer_length = 0 ;
2203- }
2204-
22052195 if (microphone -> outgoing_samples )
22062196 {
22072197 fifo_free (microphone -> outgoing_samples );
@@ -2236,6 +2226,9 @@ bool microphone_driver_init_internal(void *settings_data)
22362226 if (!settings -> bools .microphone_enable )
22372227 {
22382228 mic_st -> flags &= ~MICROPHONE_DRIVER_FLAG_ACTIVE ;
2229+ /* Ensure microphone struct is clean to prevent crashes on deinit
2230+ * if there was stale data from a previous session */
2231+ memset (& mic_st -> microphone , 0 , sizeof (mic_st -> microphone ));
22392232 return false;
22402233 }
22412234
@@ -2329,13 +2322,6 @@ static bool mic_driver_open_mic_internal(retro_microphone_t* microphone)
23292322 if (!microphone || !mic_driver || !(mic_st -> flags & MICROPHONE_DRIVER_FLAG_ACTIVE ))
23302323 return false;
23312324
2332- microphone -> sample_buffer_length = max_samples * sizeof (int16_t );
2333- microphone -> sample_buffer =
2334- (int16_t * )memalign_alloc (64 , microphone -> sample_buffer_length );
2335-
2336- if (!microphone -> sample_buffer )
2337- goto error ;
2338-
23392325 microphone -> outgoing_samples = fifo_new (max_samples * sizeof (int16_t ));
23402326 if (!microphone -> outgoing_samples )
23412327 goto error ;
0 commit comments