V2 llaudio merge
This commit is contained in:
@@ -222,31 +222,61 @@ BOOL LLVorbisDecodeState::initDecode()
|
|||||||
S32 sample_count = ov_pcm_total(&mVF, -1);
|
S32 sample_count = ov_pcm_total(&mVF, -1);
|
||||||
size_t size_guess = (size_t)sample_count;
|
size_t size_guess = (size_t)sample_count;
|
||||||
vorbis_info* vi = ov_info(&mVF, -1);
|
vorbis_info* vi = ov_info(&mVF, -1);
|
||||||
size_guess *= vi->channels;
|
size_guess *= (vi? vi->channels : 1);
|
||||||
size_guess *= 2;
|
size_guess *= 2;
|
||||||
size_guess += 2048;
|
size_guess += 2048;
|
||||||
|
|
||||||
bool abort_decode = false;
|
bool abort_decode = false;
|
||||||
|
|
||||||
|
if (vi)
|
||||||
|
{
|
||||||
|
if( vi->channels < 1 || vi->channels > LLVORBIS_CLIP_MAX_CHANNELS )
|
||||||
|
{
|
||||||
|
abort_decode = true;
|
||||||
|
llwarns << "Bad channel count: " << vi->channels << llendl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // !vi
|
||||||
|
{
|
||||||
|
abort_decode = true;
|
||||||
|
llwarns << "No default bitstream found" << llendl;
|
||||||
|
}
|
||||||
// <edit>
|
// <edit>
|
||||||
// This magic value is equivilent to 150MiB of data.
|
// This magic value is equivilent to 150MiB of data.
|
||||||
// Prevents griffers from utilizin a huge xbox sound the size of god to instafry the viewer
|
// Prevents griffers from utilizin a huge xbox sound the size of god to instafry the viewer
|
||||||
if(size_guess >= 157286400)
|
if(size_guess >= 157286400)
|
||||||
{
|
{
|
||||||
llwarns << "Bad sound caught by zmagic" << llendl;
|
llwarns << "Bad sound caught by zmagic" << llendl;
|
||||||
abort_decode = true;
|
abort_decode = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
else /* </edit> */if( vi->channels < 1 || vi->channels > LLVORBIS_CLIP_MAX_CHANNELS )
|
{
|
||||||
|
// </edit>
|
||||||
|
//Much more restrictive than zmagic. Perhaps make toggleable.
|
||||||
|
if( (size_t)sample_count > LLVORBIS_CLIP_REJECT_SAMPLES ||
|
||||||
|
(size_t)sample_count <= 0)
|
||||||
{
|
{
|
||||||
abort_decode = true;
|
abort_decode = true;
|
||||||
llwarns << "Bad channel count: " << vi->channels << llendl;
|
llwarns << "Illegal sample count: " << sample_count << llendl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( size_guess > LLVORBIS_CLIP_REJECT_SIZE ||
|
||||||
|
size_guess < 0)
|
||||||
|
{
|
||||||
|
abort_decode = true;
|
||||||
|
llwarns << "Illegal sample size: " << size_guess << llendl;
|
||||||
|
}
|
||||||
|
// <edit>
|
||||||
|
}
|
||||||
|
// </edit>
|
||||||
if( abort_decode )
|
if( abort_decode )
|
||||||
{
|
{
|
||||||
llwarns << "Canceling initDecode. Bad asset: " << mUUID << llendl;
|
llwarns << "Canceling initDecode. Bad asset: " << mUUID << llendl;
|
||||||
llwarns << "Bad asset encoded by: " << ov_comment(&mVF,-1)->vendor << llendl;
|
vorbis_comment* comment = ov_comment(&mVF,-1);
|
||||||
|
if (comment && comment->vendor)
|
||||||
|
{
|
||||||
|
llwarns << "Bad asset encoded by: " << comment->vendor << llendl;
|
||||||
|
}
|
||||||
delete mInFilep;
|
delete mInFilep;
|
||||||
mInFilep = NULL;
|
mInFilep = NULL;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|||||||
@@ -104,7 +104,11 @@ void LLAudioEngine::setDefaults()
|
|||||||
}
|
}
|
||||||
|
|
||||||
mMasterGain = 1.f;
|
mMasterGain = 1.f;
|
||||||
mInternalGain = 0.f;
|
// Setting mInternalGain to an out of range value fixes the issue reported in STORM-830.
|
||||||
|
// There is an edge case in setMasterGain during startup which prevents setInternalGain from
|
||||||
|
// being called if the master volume setting and mInternalGain both equal 0, so using -1 forces
|
||||||
|
// the if statement in setMasterGain to execute when the viewer starts up.
|
||||||
|
mInternalGain = -1.f;
|
||||||
mNextWindUpdate = 0.f;
|
mNextWindUpdate = 0.f;
|
||||||
|
|
||||||
mStreamingAudioImpl = NULL;
|
mStreamingAudioImpl = NULL;
|
||||||
@@ -204,12 +208,12 @@ void LLAudioEngine::updateInternetStream()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
int LLAudioEngine::isInternetStreamPlaying()
|
LLAudioEngine::LLAudioPlayState LLAudioEngine::isInternetStreamPlaying()
|
||||||
{
|
{
|
||||||
if (mStreamingAudioImpl)
|
if (mStreamingAudioImpl)
|
||||||
return mStreamingAudioImpl->isPlaying();
|
return (LLAudioEngine::LLAudioPlayState) mStreamingAudioImpl->isPlaying();
|
||||||
|
|
||||||
return 0; // Stopped
|
return LLAudioEngine::AUDIO_STOPPED; // Stopped
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -594,7 +598,7 @@ LLAudioBuffer * LLAudioEngine::getFreeBuffer()
|
|||||||
|
|
||||||
if (buffer_id >= 0)
|
if (buffer_id >= 0)
|
||||||
{
|
{
|
||||||
llinfos << "Taking over unused buffer " << buffer_id << llendl;
|
lldebugs << "Taking over unused buffer " << buffer_id << llendl;
|
||||||
//llinfos << "Flushing unused buffer!" << llendl;
|
//llinfos << "Flushing unused buffer!" << llendl;
|
||||||
mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL;
|
mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL;
|
||||||
delete mBuffers[buffer_id];
|
delete mBuffers[buffer_id];
|
||||||
@@ -1627,6 +1631,10 @@ bool LLAudioSource::hasPendingPreloads() const
|
|||||||
LLAudioData *adp = iter->second;
|
LLAudioData *adp = iter->second;
|
||||||
// note: a bad UUID will forever be !hasDecodedData()
|
// note: a bad UUID will forever be !hasDecodedData()
|
||||||
// but also !hasValidData(), hence the check for hasValidData()
|
// but also !hasValidData(), hence the check for hasValidData()
|
||||||
|
if (!adp)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!adp->hasDecodedData() && adp->hasValidData())
|
if (!adp->hasDecodedData() && adp->hasValidData())
|
||||||
{
|
{
|
||||||
// This source is still waiting for a preload
|
// This source is still waiting for a preload
|
||||||
|
|||||||
@@ -91,6 +91,15 @@ public:
|
|||||||
AUDIO_TYPE_COUNT = 4 // last
|
AUDIO_TYPE_COUNT = 4 // last
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum LLAudioPlayState
|
||||||
|
{
|
||||||
|
// isInternetStreamPlaying() returns an *int*, with
|
||||||
|
// 0 = stopped, 1 = playing, 2 = paused.
|
||||||
|
AUDIO_STOPPED = 0,
|
||||||
|
AUDIO_PLAYING = 1,
|
||||||
|
AUDIO_PAUSED = 2
|
||||||
|
};
|
||||||
|
|
||||||
LLAudioEngine();
|
LLAudioEngine();
|
||||||
virtual ~LLAudioEngine();
|
virtual ~LLAudioEngine();
|
||||||
|
|
||||||
@@ -161,7 +170,7 @@ public:
|
|||||||
void stopInternetStream();
|
void stopInternetStream();
|
||||||
void pauseInternetStream(int pause);
|
void pauseInternetStream(int pause);
|
||||||
void updateInternetStream(); // expected to be called often
|
void updateInternetStream(); // expected to be called often
|
||||||
int isInternetStreamPlaying();
|
LLAudioPlayState isInternetStreamPlaying();
|
||||||
// use a value from 0.0 to 1.0, inclusive
|
// use a value from 0.0 to 1.0, inclusive
|
||||||
void setInternetStreamGain(F32 vol);
|
void setInternetStreamGain(F32 vol);
|
||||||
std::string getInternetStreamURL();
|
std::string getInternetStreamURL();
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata)
|
|||||||
bool audio_ok = false;
|
bool audio_ok = false;
|
||||||
|
|
||||||
if (!audio_ok)
|
if (!audio_ok)
|
||||||
|
{
|
||||||
if (NULL == getenv("LL_BAD_FMOD_ESD")) /*Flawfinder: ignore*/
|
if (NULL == getenv("LL_BAD_FMOD_ESD")) /*Flawfinder: ignore*/
|
||||||
{
|
{
|
||||||
LL_DEBUGS("AppInit") << "Trying ESD audio output..." << LL_ENDL;
|
LL_DEBUGS("AppInit") << "Trying ESD audio output..." << LL_ENDL;
|
||||||
@@ -147,8 +148,9 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata)
|
|||||||
} else {
|
} else {
|
||||||
LL_DEBUGS("AppInit") << "ESD audio output SKIPPED" << LL_ENDL;
|
LL_DEBUGS("AppInit") << "ESD audio output SKIPPED" << LL_ENDL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!audio_ok)
|
if (!audio_ok)
|
||||||
|
{
|
||||||
if (NULL == getenv("LL_BAD_FMOD_OSS")) /*Flawfinder: ignore*/
|
if (NULL == getenv("LL_BAD_FMOD_OSS")) /*Flawfinder: ignore*/
|
||||||
{
|
{
|
||||||
LL_DEBUGS("AppInit") << "Trying OSS audio output..." << LL_ENDL;
|
LL_DEBUGS("AppInit") << "Trying OSS audio output..." << LL_ENDL;
|
||||||
@@ -164,8 +166,9 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata)
|
|||||||
} else {
|
} else {
|
||||||
LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL;
|
LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!audio_ok)
|
if (!audio_ok)
|
||||||
|
{
|
||||||
if (NULL == getenv("LL_BAD_FMOD_ALSA")) /*Flawfinder: ignore*/
|
if (NULL == getenv("LL_BAD_FMOD_ALSA")) /*Flawfinder: ignore*/
|
||||||
{
|
{
|
||||||
LL_DEBUGS("AppInit") << "Trying ALSA audio output..." << LL_ENDL;
|
LL_DEBUGS("AppInit") << "Trying ALSA audio output..." << LL_ENDL;
|
||||||
@@ -181,7 +184,7 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata)
|
|||||||
} else {
|
} else {
|
||||||
LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL;
|
LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!audio_ok)
|
if (!audio_ok)
|
||||||
{
|
{
|
||||||
LL_WARNS("AppInit") << "Overall audio init failure." << LL_ENDL;
|
LL_WARNS("AppInit") << "Overall audio init failure." << LL_ENDL;
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ void LLStreamingAudio_FMOD::update()
|
|||||||
break;
|
break;
|
||||||
case -3:
|
case -3:
|
||||||
// failed to open, file not found, perhaps
|
// failed to open, file not found, perhaps
|
||||||
llwarns << "InternetSteam - failed to open" << llendl;
|
llwarns << "InternetStream - failed to open" << llendl;
|
||||||
stop();
|
stop();
|
||||||
return;
|
return;
|
||||||
case -4:
|
case -4:
|
||||||
@@ -271,7 +271,7 @@ void LLStreamingAudio_FMOD::setGain(F32 vol)
|
|||||||
|
|
||||||
if (mFMODInternetStreamChannel != -1)
|
if (mFMODInternetStreamChannel != -1)
|
||||||
{
|
{
|
||||||
vol = llclamp(vol, 0.f, 1.f);
|
vol = llclamp(vol * vol, 0.f, 1.f);
|
||||||
int vol_int = llround(vol * 255.f);
|
int vol_int = llround(vol * 255.f);
|
||||||
FSOUND_SetVolumeAbsolute(mFMODInternetStreamChannel, vol_int);
|
FSOUND_SetVolumeAbsolute(mFMODInternetStreamChannel, vol_int);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,13 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro
|
|||||||
+ ((U32) wav_header[5] << 8)
|
+ ((U32) wav_header[5] << 8)
|
||||||
+ wav_header[4];
|
+ wav_header[4];
|
||||||
|
|
||||||
|
if (chunk_length > physical_file_size - file_pos - 4)
|
||||||
|
{
|
||||||
|
infile.close();
|
||||||
|
error_msg = "SoundFileInvalidChunkSize";
|
||||||
|
return(LLVORBISENC_CHUNK_SIZE_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
// llinfos << "chunk found: '" << wav_header[0] << wav_header[1] << wav_header[2] << wav_header[3] << "'" << llendl;
|
// llinfos << "chunk found: '" << wav_header[0] << wav_header[1] << wav_header[2] << wav_header[3] << "'" << llendl;
|
||||||
|
|
||||||
if (!(strncmp((char *)&(wav_header[0]),"fmt ",4)))
|
if (!(strncmp((char *)&(wav_header[0]),"fmt ",4)))
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ const S32 LLVORBISENC_MULTICHANNEL_ERR = 7; // can't do stereo
|
|||||||
const S32 LLVORBISENC_UNSUPPORTED_SAMPLE_RATE = 8; // unsupported sample rate
|
const S32 LLVORBISENC_UNSUPPORTED_SAMPLE_RATE = 8; // unsupported sample rate
|
||||||
const S32 LLVORBISENC_UNSUPPORTED_WORD_SIZE = 9; // unsupported word size
|
const S32 LLVORBISENC_UNSUPPORTED_WORD_SIZE = 9; // unsupported word size
|
||||||
const S32 LLVORBISENC_CLIP_TOO_LONG = 10; // source file is too long
|
const S32 LLVORBISENC_CLIP_TOO_LONG = 10; // source file is too long
|
||||||
|
const S32 LLVORBISENC_CHUNK_SIZE_ERR = 11; // chunk size is wrong
|
||||||
|
|
||||||
const F32 LLVORBIS_CLIP_MAX_TIME = 10.0f;
|
const F32 LLVORBIS_CLIP_MAX_TIME = 10.0f;
|
||||||
const U8 LLVORBIS_CLIP_MAX_CHANNELS = 2;
|
const U8 LLVORBIS_CLIP_MAX_CHANNELS = 2;
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ public:
|
|||||||
mY1(0.0f),
|
mY1(0.0f),
|
||||||
mCurrentGain(0.f),
|
mCurrentGain(0.f),
|
||||||
mCurrentFreq(100.f),
|
mCurrentFreq(100.f),
|
||||||
mCurrentPanGainR(0.5f)
|
mCurrentPanGainR(0.5f),
|
||||||
|
mLastSample(0.f)
|
||||||
{
|
{
|
||||||
mSamplePeriod = (F32)mSubSamples / (F32)mInputSamplingRate;
|
mSamplePeriod = (F32)mSubSamples / (F32)mInputSamplingRate;
|
||||||
mB2 = expf(-F_TWO_PI * mFilterBandWidth * mSamplePeriod);
|
mB2 = expf(-F_TWO_PI * mFilterBandWidth * mSamplePeriod);
|
||||||
|
|||||||
@@ -1454,6 +1454,14 @@ Could not find 'data' chunk in WAV header:
|
|||||||
[FILE]
|
[FILE]
|
||||||
</notification>
|
</notification>
|
||||||
|
|
||||||
|
<notification
|
||||||
|
icon="alertmodal.tga"
|
||||||
|
name="SoundFileInvalidChunkSize"
|
||||||
|
type="alertmodal">
|
||||||
|
Wrong chunk size in WAV file:
|
||||||
|
[FILE]
|
||||||
|
</notification>
|
||||||
|
|
||||||
<notification
|
<notification
|
||||||
icon="alertmodal.tga"
|
icon="alertmodal.tga"
|
||||||
name="SoundFileInvalidTooLong"
|
name="SoundFileInvalidTooLong"
|
||||||
|
|||||||
Reference in New Issue
Block a user