mirror of https://github.com/stella-emu/stella.git
Remove unnecessary code, don't spam if audio is disabled.
This commit is contained in:
parent
176507cb46
commit
47bbdb679e
|
@ -21,10 +21,9 @@ using std::mutex;
|
|||
using std::lock_guard;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
AudioQueue::AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo, uInt16 sampleRate)
|
||||
AudioQueue::AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo)
|
||||
: myFragmentSize(fragmentSize),
|
||||
myIsStereo(isStereo),
|
||||
mySampleRate(sampleRate),
|
||||
myFragmentQueue(capacity),
|
||||
myAllFragments(capacity + 2),
|
||||
mySize(0),
|
||||
|
@ -70,12 +69,6 @@ uInt32 AudioQueue::fragmentSize() const
|
|||
return myFragmentSize;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 AudioQueue::sampleRate() const
|
||||
{
|
||||
return mySampleRate;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Int16* AudioQueue::enqueue(Int16* fragment)
|
||||
{
|
||||
|
@ -101,7 +94,7 @@ Int16* AudioQueue::enqueue(Int16* fragment)
|
|||
if (mySize < capacity) mySize++;
|
||||
else {
|
||||
myNextFragment = (myNextFragment + 1) % capacity;
|
||||
(cerr << "audio buffer overflow\n").flush();
|
||||
if (!myIgnoreOverflows) (cerr << "audio buffer overflow\n").flush();
|
||||
}
|
||||
|
||||
return newFragment;
|
||||
|
@ -141,3 +134,9 @@ void AudioQueue::closeSink(Int16* fragment)
|
|||
if (!myFirstFragmentForDequeue)
|
||||
myFirstFragmentForDequeue = fragment;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void AudioQueue::ignoreOverflows(bool shouldIgnoreOverflows)
|
||||
{
|
||||
myIgnoreOverflows = shouldIgnoreOverflows;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class AudioQueue
|
|||
@param isStereo Whether samples are stereo or mono.
|
||||
@param sampleRate The sample rate. This is not used, but can be queried.
|
||||
*/
|
||||
AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo, uInt16 sampleRate);
|
||||
AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo);
|
||||
|
||||
/**
|
||||
Capacity getter.
|
||||
|
@ -67,11 +67,6 @@ class AudioQueue
|
|||
*/
|
||||
uInt32 fragmentSize() const;
|
||||
|
||||
/**
|
||||
Sample rate getter.
|
||||
*/
|
||||
uInt16 sampleRate() const;
|
||||
|
||||
/**
|
||||
Enqueue a new fragment and get a new fragmen to fill.
|
||||
|
||||
|
@ -96,6 +91,11 @@ class AudioQueue
|
|||
*/
|
||||
void closeSink(Int16* fragment);
|
||||
|
||||
/**
|
||||
Should we ignore overflows?
|
||||
*/
|
||||
void ignoreOverflows(bool shouldIgnoreOverflows);
|
||||
|
||||
private:
|
||||
|
||||
// The size of an individual fragment (in stereo / mono samples)
|
||||
|
@ -104,9 +104,6 @@ class AudioQueue
|
|||
// Are we using stereo samples?
|
||||
bool myIsStereo;
|
||||
|
||||
// The sample rate
|
||||
uInt16 mySampleRate;
|
||||
|
||||
// The fragment queue
|
||||
vector<Int16*> myFragmentQueue;
|
||||
|
||||
|
@ -130,6 +127,9 @@ class AudioQueue
|
|||
// The first (empty) dequeue call replaces the returned fragment with this fragment.
|
||||
Int16* myFirstFragmentForDequeue;
|
||||
|
||||
// Log overflows?
|
||||
bool myIgnoreOverflows;
|
||||
|
||||
private:
|
||||
|
||||
AudioQueue() = delete;
|
||||
|
|
|
@ -98,6 +98,7 @@ SoundSDL2::~SoundSDL2()
|
|||
void SoundSDL2::setEnabled(bool state)
|
||||
{
|
||||
myAudioSettings.setEnabled(state);
|
||||
if (myAudioQueue) myAudioQueue->ignoreOverflows(!state);
|
||||
|
||||
myOSystem.logMessage(state ? "SoundSDL2::setEnabled(true)" :
|
||||
"SoundSDL2::setEnabled(false)", 2);
|
||||
|
@ -112,6 +113,7 @@ void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue,
|
|||
myOSystem.logMessage("SoundSDL2::open started ...", 2);
|
||||
mute(true);
|
||||
|
||||
audioQueue->ignoreOverflows(!myAudioSettings.enabled());
|
||||
if(!myAudioSettings.enabled())
|
||||
{
|
||||
myOSystem.logMessage("Sound disabled\n", 1);
|
||||
|
@ -251,7 +253,7 @@ void SoundSDL2::initResampler()
|
|||
};
|
||||
|
||||
Resampler::Format formatFrom =
|
||||
Resampler::Format(myAudioQueue->sampleRate(), myAudioQueue->fragmentSize(), myAudioQueue->isStereo());
|
||||
Resampler::Format(myEmulationTiming->audioSampleRate(), myAudioQueue->fragmentSize(), myAudioQueue->isStereo());
|
||||
Resampler::Format formatTo =
|
||||
Resampler::Format(myHardwareSpec.freq, myHardwareSpec.samples, myHardwareSpec.channels > 1);
|
||||
|
||||
|
|
|
@ -725,8 +725,7 @@ void Console::createAudioQueue()
|
|||
myAudioQueue = make_shared<AudioQueue>(
|
||||
myEmulationTiming.audioFragmentSize(),
|
||||
myEmulationTiming.audioQueueCapacity(),
|
||||
myProperties.get(Cartridge_Sound) == "STEREO",
|
||||
myEmulationTiming.audioSampleRate()
|
||||
myProperties.get(Cartridge_Sound) == "STEREO"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue