diff --git a/client/decoder/flacDecoder.cpp b/client/decoder/flacDecoder.cpp index 94931a7f..169e36fd 100644 --- a/client/decoder/flacDecoder.cpp +++ b/client/decoder/flacDecoder.cpp @@ -113,7 +113,7 @@ FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, } else if (flacChunk != NULL) { - ((FlacDecoder*)client_data)->cacheInfo_.isCachedChunk_ = false; + static_cast(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(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(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, diff --git a/client/decoder/oggDecoder.cpp b/client/decoder/oggDecoder.cpp index 4a3d4c24..7039f691 100644 --- a/client/decoder/oggDecoder.cpp +++ b/client/decoder/oggDecoder.cpp @@ -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; diff --git a/client/player/openslPlayer.cpp b/client/player/openslPlayer.cpp index c5cbd057..541f0af6 100644 --- a/client/player/openslPlayer.cpp +++ b/client/player/openslPlayer.cpp @@ -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(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); diff --git a/client/player/openslPlayer.h b/client/player/openslPlayer.h index 8483f7dc..b0d7593b 100644 --- a/client/player/openslPlayer.h +++ b/client/player/openslPlayer.h @@ -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_; }; diff --git a/client/snapClient.cpp b/client/snapClient.cpp index ab691e23..88c1ee57 100644 --- a/client/snapClient.cpp +++ b/client/snapClient.cpp @@ -39,11 +39,10 @@ PcmDevice getPcmDevice(const std::string& soundcard) { #ifndef ANDROID vector 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; diff --git a/client/stream.h b/client/stream.h index 174d1f85..95b9272b 100644 --- a/client/stream.h +++ b/client/stream.h @@ -74,7 +74,6 @@ private: SampleFormat format_; - long lastTick_; chronos::usec sleep_; Queue> chunks_;