Update bass streaming test to include opus as well
This commit is contained in:
		
							parent
							
								
									1fc6c85568
								
							
						
					
					
						commit
						ba47b5d35e
					
				@ -4,4 +4,4 @@ find_package(Catch2 REQUIRED)
 | 
			
		||||
add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp test_bass.cpp ../include/aopacket.h ../src/aopacket.cpp)
 | 
			
		||||
target_include_directories(test PRIVATE ../include)
 | 
			
		||||
target_link_directories(test PRIVATE ../lib)
 | 
			
		||||
target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass)
 | 
			
		||||
target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass bassopus)
 | 
			
		||||
 | 
			
		||||
@ -5,16 +5,26 @@
 | 
			
		||||
#include <QString>
 | 
			
		||||
 | 
			
		||||
#include "bass.h"
 | 
			
		||||
#include "bassopus.h"
 | 
			
		||||
 | 
			
		||||
TEST_CASE("BASS URL streaming", "[bass]") {
 | 
			
		||||
  // Sample
 | 
			
		||||
  QString url = "https://raw.githubusercontent.com/skyedeving/aocharedit/master/Attorney%20Online%20Character%20Editor/Resources/about.mp3";
 | 
			
		||||
 | 
			
		||||
  // initialize
 | 
			
		||||
  BASS_Init(-1, 44100, 0, 0, nullptr);
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
  HSTREAM stream = BASS_StreamCreateURL(url.toWStdString().c_str(), 0, BASS_STREAM_STATUS, nullptr, 0);
 | 
			
		||||
#else
 | 
			
		||||
  HSTREAM stream = BASS_StreamCreateURL(url.toStdString().c_str(), 0, BASS_STREAM_STATUS, nullptr, 0);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  // create stream from url
 | 
			
		||||
  HSTREAM stream;
 | 
			
		||||
  unsigned int flags = BASS_STREAM_AUTOFREE | BASS_STREAM_STATUS;
 | 
			
		||||
  if (url.endsWith(".opus")) {
 | 
			
		||||
    stream = BASS_OPUS_StreamCreateURL(url.toStdString().c_str(), 0, flags, nullptr, 0);
 | 
			
		||||
  }
 | 
			
		||||
  else {
 | 
			
		||||
    stream = BASS_StreamCreateURL(url.toStdString().c_str(), 0, flags, nullptr, 0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Log http status
 | 
			
		||||
  const char *tags = BASS_ChannelGetTags(stream, BASS_TAG_HTTP);
 | 
			
		||||
  if (tags) {
 | 
			
		||||
    while(*tags) {
 | 
			
		||||
@ -22,7 +32,9 @@ TEST_CASE("BASS URL streaming", "[bass]") {
 | 
			
		||||
      tags += strlen(tags) + 1;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Test
 | 
			
		||||
  REQUIRE(stream != 0);
 | 
			
		||||
  REQUIRE(BASS_ChannelPlay(stream, TRUE) == TRUE);
 | 
			
		||||
  // while (BASS_ChannelIsActive(stream) != BASS_ACTIVE_STOPPED);
 | 
			
		||||
  // while (BASS_ChannelIsActive(stream) != BASS_ACTIVE_STOPPED); // block test to listen
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user