Lines Matching refs:stream

579         // FIXME: Open a stream without an IOHandle
585 returnIn(res, stream, suggestedConfig)));
590 ASSERT_TRUE(stream != nullptr);
594 ASSERT_TRUE(stream == nullptr);
596 // Could not open stream with config, try again with the
600 returnIn(res, stream, suggestedConfigRetry)));
603 ASSERT_TRUE(stream != nullptr);
615 return stream->close();
621 ASSERT_OK(stream->close());
628 sp<Stream> stream;
731 * thus use this macro do duplicate tests for Input and Output stream */
744 "Check that the stream frame count == the one it was opened with",
745 ASSERT_EQ(audioConfig.frameCount, extract(stream->getFrameCount())))
749 "Check that the stream sample rate == the one it was opened with",
750 stream->getSampleRate())
754 "Check that the stream channel mask == the one it was opened with",
755 stream->getChannelMask())
758 "Check that the stream format == the one it was opened with",
759 ASSERT_EQ(audioConfig.format, extract(stream->getFormat())))
763 "Check that the stream frame size == the one it was opened with",
764 ASSERT_GT(extract(stream->getFrameSize()), 0U))
767 "Check that the stream buffer size== the one it was opened with",
768 ASSERT_GE(extract(stream->getBufferSize()),
769 extract(stream->getFrameSize())));
772 static void testCapabilityGetter(const string& name, IStream* stream,
777 ASSERT_OK((stream->*capablityGetter)(returnIn(capabilities)));
795 ASSERT_OK((stream->*setter)(capability));
796 ASSERT_EQ(capability, extract((stream->*getter)()));
801 "Check that the stream sample rate is declared as supported",
802 testCapabilityGetter("getSupportedSampleRate", stream.get(),
803 extract(stream->getSampleRate()),
809 "Check that the stream channel mask is declared as supported",
810 testCapabilityGetter("getSupportedChannelMask", stream.get(),
811 extract(stream->getChannelMask()),
817 "Check that the stream format is declared as supported",
818 testCapabilityGetter("getSupportedFormat", stream.get(),
819 extract(stream->getFormat()),
823 static void testGetDevice(IStream* stream, AudioDevice expectedDevice) {
827 auto ret = stream->getDevice();
836 "Check that the stream device == the one it was opened with",
839 : testGetDevice(stream.get(), address.device))
841 static void testSetDevice(IStream* stream, const DeviceAddress& address) {
846 EXPECT_OK(stream->setDevice(otherAddress));
848 ASSERT_OK(stream->setDevice(address)); // Go back to the original value
853 "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
855 : testSetDevice(stream.get(), address))
857 static void testGetAudioProperties(IStream* stream) {
861 stream->getAudioProperties(returnIn(sampleRateHz, mask, format));
866 "Check that the stream audio properties == the ones it was opened with",
867 testGetAudioProperties(stream.get()))
869 static void testConnectedState(IStream* stream) {
876 ASSERT_OK(stream->setConnectedState(address, true));
877 ASSERT_OK(stream->setConnectedState(address, false));
881 "Check that the stream can be notified of device connection and "
883 testConnectedState(stream.get()))
889 stream->setHwAvSync(666)))
894 static void checkGetNoParameter(IStream* stream, hidl_vec<hidl_string> keys,
898 ASSERT_OK(stream->getParameters(keys, returnIn(res, parameters)));
912 checkGetNoParameter(stream.get(), {} /* keys */, {Result::OK}))
916 checkGetNoParameter(stream.get(),
922 ASSERT_RESULT(Result::OK, stream->setParameters({})))
931 stream->setParameters({{"non existing key", "0"}})))
934 "Check that a stream can dump its state without error",
936 return stream->debugDump(handle);
940 "Check that the stream dump doesn't crash on invalid arguments",
941 ASSERT_OK(stream->debugDump(hidl_handle())))
948 ASSERT_RESULT(Result::INVALID_ARGUMENTS, stream->addEffect(666)))
952 stream->removeEffect(666)))
960 TEST_IO_STREAM(standby, "Make sure the stream can be put in stanby",
961 ASSERT_OK(stream->standby())) // can not fail
967 "Starting a mmaped stream before mapping it should fail",
968 ASSERT_RESULT(invalidStateOrNotSupported, stream->start()))
971 "Stopping a mmaped stream before mapping it should fail",
972 ASSERT_RESULT(invalidStateOrNotSupported, stream->stop()))
975 "Get a stream Mmap position before mapping it should fail",
976 ASSERT_RESULT(invalidStateOrNotSupported, stream->stop()))
978 TEST_IO_STREAM(close, "Make sure a stream can be closed",
980 TEST_IO_STREAM(closeTwice, "Make sure a stream can not be closed twice",
986 static void testCreateTooBigMmapBuffer(IStream* stream) {
993 ASSERT_OK(stream->createMmapBuffer(minSizeFrames, returnIn(res, info)));
998 testCreateTooBigMmapBuffer(stream.get()))
1000 static void testGetMmapPositionOfNonMmapedStream(IStream* stream) {
1003 ASSERT_OK(stream->getMmapPosition(returnIn(res, position)));
1009 "Retrieving the mmap position of a non mmaped stream should fail",
1010 testGetMmapPositionOfNonMmapedStream(stream.get()))
1018 "Retrieving the audio source of an input stream should always succeed");
1020 ASSERT_OK(stream->getAudioSource(returnIn(res, source)));
1054 doc::test("The gain of an input stream should only be set between [0,1]");
1056 [this](float volume) { return stream->setGain(volume); },
1060 static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize,
1064 ASSERT_OK(stream->prepareForReading(
1072 "Preparing a stream for reading with a 0 sized buffer should fail");
1073 testPrepareForReading(stream.get(), 0, 0);
1078 "Preparing a stream for reading with a 2^32 sized buffer should fail");
1079 testPrepareForReading(stream.get(), 1,
1085 "Preparing a stream for reading with a overflowing sized buffer should "
1088 testPrepareForReading(stream.get(), uintMax, uintMax);
1093 "The number of frames lost on a never started stream should be 0");
1094 auto ret = stream->getInputFramesLost();
1102 "The capture position of a non prepared stream should not be "
1106 ASSERT_OK(stream->getCapturePosition(returnIn(res, frames, time)));
1116 auto result = stream->getLatency();
1124 [this](float volume) { return stream->setVolume(volume, volume); },
1128 static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize,
1132 ASSERT_OK(stream->prepareForWriting(
1140 "Preparing a stream for writing with a 0 sized buffer should fail");
1141 testPrepareForWriting(stream.get(), 0, 0);
1146 "Preparing a stream for writing with a 2^32 sized buffer should fail");
1147 testPrepareForWriting(stream.get(), 1,
1153 "Preparing a stream for writing with a overflowing sized buffer should "
1156 testPrepareForWriting(stream.get(), uintMax, uintMax);
1160 Capability(IStreamOut* stream) {
1161 EXPECT_OK(stream->supportsPauseAndResume(returnIn(pause, resume)));
1162 auto ret = stream->supportsDrain();
1176 Capability(stream.get());
1193 doc::test("A new stream render position should be 0 or INVALID_STATE");
1195 ASSERT_OK(stream->getRenderPosition(returnIn(res, dspFrames)));
1204 doc::test("A new stream next write timestamp should be 0 or INVALID_STATE");
1206 ASSERT_OK(stream->getNextWriteTimestamp(returnIn(res, timestampUs)));
1214 /** Stub implementation of out stream callback. */
1221 static bool isAsyncModeSupported(IStreamOut* stream) {
1222 auto res = stream->setCallback(new MockOutCallbacks);
1223 stream->clearCallback(); // try to restore the no callback state, ignore
1234 if (!isAsyncModeSupported(stream.get())) {
1235 doc::partialTest("The stream does not support async operations");
1238 ASSERT_OK(stream->setCallback(new MockOutCallbacks));
1239 ASSERT_OK(stream->setCallback(new MockOutCallbacks));
1246 if (!isAsyncModeSupported(stream.get())) {
1247 doc::partialTest("The stream does not support async operations");
1251 ASSERT_OK(stream->setCallback(new MockOutCallbacks));
1252 ASSERT_OK(stream->clearCallback());
1257 "If supported, a stream should fail to resume if not previously "
1259 if (!Capability(stream.get()).resume) {
1260 doc::partialTest("The output stream does not support resume");
1263 ASSERT_RESULT(Result::INVALID_STATE, stream->resume());
1268 "If supported, a stream should fail to pause if not previously "
1270 if (!Capability(stream.get()).pause) {
1271 doc::partialTest("The output stream does not support pause");
1274 ASSERT_RESULT(Result::INVALID_STATE, stream->resume());
1277 static void testDrain(IStreamOut* stream, AudioDrain type) {
1278 if (!Capability(stream).drain) {
1279 doc::partialTest("The output stream does not support drain");
1282 ASSERT_RESULT(Result::OK, stream->drain(type));
1286 doc::test("If supported, a stream should always succeed to drain");
1287 testDrain(stream.get(), AudioDrain::ALL);
1291 doc::test("If supported, a stream should always succeed to drain");
1292 testDrain(stream.get(), AudioDrain::EARLY_NOTIFY);
1296 doc::test("If supported, a stream should always succeed to flush");
1297 auto ret = stream->flush();
1308 "If supported, a stream should always succeed to retrieve the "
1312 ASSERT_OK(stream->getPresentationPosition(returnIn(res, frames, mesureTS)));
1320 // As the stream has never written a frame yet,