mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-22 13:36:18 +02:00
fixed cppcheck warnings
This commit is contained in:
parent
08c35ccc62
commit
0c87becca0
6 changed files with 17 additions and 17 deletions
|
@ -113,7 +113,7 @@ FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder,
|
|||
}
|
||||
else if (flacChunk != NULL)
|
||||
{
|
||||
((FlacDecoder*)client_data)->cacheInfo_.isCachedChunk_ = false;
|
||||
static_cast<FlacDecoder*>(client_data)->cacheInfo_.isCachedChunk_ = false;
|
||||
if (*bytes > flacChunk->payloadSize)
|
||||
*bytes = flacChunk->payloadSize;
|
||||
|
||||
|
@ -155,8 +155,9 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder
|
|||
//TODO: hard coded to 2 channels, 16 bit
|
||||
size_t bytes = frame->header.blocksize * 4;
|
||||
|
||||
if (((FlacDecoder*)client_data)->cacheInfo_.isCachedChunk_)
|
||||
((FlacDecoder*)client_data)->cacheInfo_.cachedBlocks_ += frame->header.blocksize;
|
||||
FlacDecoder* flacDecoder = static_cast<FlacDecoder*>(client_data);
|
||||
if (flacDecoder->cacheInfo_.isCachedChunk_)
|
||||
flacDecoder->cacheInfo_.cachedBlocks_ += frame->header.blocksize;
|
||||
|
||||
pcmChunk->payload = (char*)realloc(pcmChunk->payload, pcmChunk->payloadSize + bytes);
|
||||
|
||||
|
@ -178,7 +179,7 @@ void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMet
|
|||
/* print some stats */
|
||||
if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO)
|
||||
{
|
||||
((FlacDecoder*)client_data)->cacheInfo_.sampleRate_ = metadata->data.stream_info.sample_rate;
|
||||
static_cast<FlacDecoder*>(client_data)->cacheInfo_.sampleRate_ = metadata->data.stream_info.sample_rate;
|
||||
sampleFormat.setFormat(
|
||||
metadata->data.stream_info.sample_rate,
|
||||
metadata->data.stream_info.bits_per_sample,
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
using namespace std;
|
||||
|
||||
|
||||
OggDecoder::OggDecoder() : Decoder(), buffer(NULL)
|
||||
OggDecoder::OggDecoder() : Decoder(), buffer(NULL), bytes(0)
|
||||
{
|
||||
ogg_sync_init(&oy); /* Now we can read pages */
|
||||
convsize = 4096;
|
||||
|
|
|
@ -35,13 +35,14 @@ using namespace std;
|
|||
// and then render the next. Hopefully it's okay to spend time in this callback after having enqueued.
|
||||
static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
|
||||
{
|
||||
OpenslPlayer* player = (OpenslPlayer*)context;
|
||||
OpenslPlayer* player = static_cast<OpenslPlayer*>(context);
|
||||
player->playerCallback(bq);
|
||||
}
|
||||
|
||||
|
||||
|
||||
OpenslPlayer::OpenslPlayer(const PcmDevice& pcmDevice, Stream* stream) : Player(pcmDevice, stream), pubStream_(stream), bqPlayerObject(NULL), curBuffer(0)
|
||||
OpenslPlayer::OpenslPlayer(const PcmDevice& pcmDevice, Stream* stream) :
|
||||
Player(pcmDevice, stream), pubStream_(stream), bqPlayerObject(NULL), curBuffer(0), frames_(0), buff_size(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -212,10 +213,11 @@ void OpenslPlayer::initOpensl()
|
|||
|
||||
SLAndroidConfigurationItf playerConfig;
|
||||
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_ANDROIDCONFIGURATION, &playerConfig);
|
||||
assert(SL_RESULT_SUCCESS == result);
|
||||
SLint32 streamType = SL_ANDROID_STREAM_MEDIA;
|
||||
// SLint32 streamType = SL_ANDROID_STREAM_VOICE;
|
||||
result = (*playerConfig)->SetConfiguration(playerConfig, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
|
||||
|
||||
assert(SL_RESULT_SUCCESS == result);
|
||||
result = (*bqPlayerObject)->Realize(bqPlayerObject, SL_BOOLEAN_FALSE);
|
||||
assert(SL_RESULT_SUCCESS == result);
|
||||
result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAY, &bqPlayerPlay);
|
||||
|
|
|
@ -41,11 +41,6 @@ public:
|
|||
|
||||
void playerCallback(SLAndroidSimpleBufferQueueItf bq);
|
||||
|
||||
public:
|
||||
size_t frames_;
|
||||
size_t buff_size;
|
||||
Stream* pubStream_;
|
||||
|
||||
protected:
|
||||
void initOpensl();
|
||||
void uninitOpensl();
|
||||
|
@ -65,8 +60,12 @@ protected:
|
|||
SLVolumeItf bqPlayerVolume;
|
||||
|
||||
// Double buffering.
|
||||
char *buffer[2];
|
||||
int curBuffer;
|
||||
char *buffer[2];
|
||||
|
||||
size_t frames_;
|
||||
size_t buff_size;
|
||||
Stream* pubStream_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -39,11 +39,10 @@ PcmDevice getPcmDevice(const std::string& soundcard)
|
|||
{
|
||||
#ifndef ANDROID
|
||||
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
|
||||
int soundcardIdx = -1;
|
||||
|
||||
try
|
||||
{
|
||||
soundcardIdx = std::stoi(soundcard);
|
||||
int soundcardIdx = std::stoi(soundcard);
|
||||
for (auto dev: pcmDevices)
|
||||
if (dev.idx == soundcardIdx)
|
||||
return dev;
|
||||
|
|
|
@ -74,7 +74,6 @@ private:
|
|||
|
||||
SampleFormat format_;
|
||||
|
||||
long lastTick_;
|
||||
chronos::usec sleep_;
|
||||
|
||||
Queue<std::shared_ptr<msg::PcmChunk>> chunks_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue