@@ -245,24 +245,24 @@ TEST_F (OpusAudioFormatFileTests, TestWriteAndReadRoundTrip)
245245 tempFile.deleteFile ();
246246 } };
247247
248- std::unique_ptr<FileOutputStream> outputStream = std::make_unique<FileOutputStream> (tempFile);
249- auto writer = format->createWriterFor (outputStream.get (), 48000 , 1 , 32 , {}, 0 );
250- ASSERT_NE (nullptr , writer);
251-
252248 const int numSamples = 960 * 3 ;
253249 AudioBuffer<float > buffer (1 , numSamples);
254250 auto * channelData = buffer.getWritePointer (0 );
255251 for (int sample = 0 ; sample < numSamples; ++sample)
256252 channelData[sample] = std::sin (2.0 * 3.14159 * 440.0 * sample / 48000.0 );
257253
258- const float * const * bufferData = buffer.getArrayOfReadPointers ();
259- EXPECT_TRUE (writer->write (bufferData, numSamples));
260- writer->flush ();
254+ {
255+ auto outputStream = std::make_unique<FileOutputStream> (tempFile);
256+ auto writer = format->createWriterFor (outputStream.release (), 48000 , 1 , 32 , {}, 0 );
257+ ASSERT_NE (nullptr , writer);
261258
262- outputStream.release ();
259+ const float * const * bufferData = buffer.getArrayOfReadPointers ();
260+ EXPECT_TRUE (writer->write (bufferData, numSamples));
261+ writer->flush ();
262+ }
263263
264- std::unique_ptr<FileInputStream> inputStream = std::make_unique<FileInputStream> (tempFile);
265- auto reader = format->createReaderFor (inputStream.get ());
264+ auto inputStream = std::make_unique<FileInputStream> (tempFile);
265+ auto reader = format->createReaderFor (inputStream.release ());
266266 ASSERT_NE (nullptr , reader);
267267
268268 EXPECT_DOUBLE_EQ (48000.0 , reader->sampleRate );
@@ -318,7 +318,5 @@ TEST_F (OpusAudioFormatFileTests, TestWriteAndReadRoundTrip)
318318 EXPECT_LT (rmsRatio, 1.6 );
319319 EXPECT_GT (peakRatio, 0.4 );
320320 EXPECT_LT (peakRatio, 1.6 );
321-
322- inputStream.release ();
323321}
324322#endif
0 commit comments