int AudioSourceDataPipe::Impl::allocateBuffer() noexcept { if (CXXPH_UNLIKELY(!initialized_)) return OSLMP_RESULT_ILLEGAL_STATE; if (buffer_pool_) return OSLMP_RESULT_SUCCESS; LOGD("allocateBuffer()"); const size_t cache_aligned_block_size = cache_aligned_block_size_; const size_t num_blocks = init_args_.num_buffer_items; // allocate memory pool cxxporthelper::aligned_memory<uint8_t> buffer_pool; buffer_pool.allocate(cache_aligned_block_size * num_blocks, CXXPH_PLATFORM_CACHE_LINE_SIZE); if (!buffer_pool) return OSLMP_RESULT_MEMORY_ALLOCATION_FAILED; // setup queue int result = setupQueues(init_args_, cache_aligned_block_size, &buffer_pool[0]); if (CXXPH_UNLIKELY(result != OSLMP_RESULT_SUCCESS)) { return result; } // update field buffer_pool_ = std::move(buffer_pool); return OSLMP_RESULT_SUCCESS; }
int StereoVolumeDataPipe::Impl::reset() noexcept { if (CXXPH_UNLIKELY(!initialized_)) return OSLMP_RESULT_ILLEGAL_STATE; return setupQueues(); }
int AudioCaptureDataPipe::Impl::reset() noexcept { if (CXXPH_UNLIKELY(!initialized_)) return OSLMP_RESULT_ILLEGAL_STATE; int result; if (buffer_pool_) { result = setupQueues(init_args_, cache_aligned_block_size_, &buffer_pool_[0]); } else { result = OSLMP_RESULT_SUCCESS; } return result; }
int StereoVolumeDataPipe::Impl::initialize() noexcept { // check state if (CXXPH_UNLIKELY(initialized_)) return OSLMP_RESULT_ILLEGAL_STATE; // setup queue int result = setupQueues(); if (result != OSLMP_RESULT_SUCCESS) return result; initialized_ = true; return OSLMP_RESULT_SUCCESS; }
int AudioSourceDataPipe::Impl::initialize(const initialize_args_t &args) noexcept { // check arguments if (!(args.num_buffer_items >= 2 && args.num_buffer_items <= MAX_BUFFER_ITEM_COUNT)) return OSLMP_RESULT_ILLEGAL_ARGUMENT; if (args.num_channels == 0) return OSLMP_RESULT_ILLEGAL_ARGUMENT; if (args.num_frames == 0) return OSLMP_RESULT_ILLEGAL_ARGUMENT; // check state if (initialized_) return OSLMP_RESULT_ILLEGAL_STATE; const size_t block_size = sizeof(float) * args.num_channels * args.num_frames; const size_t cache_aligned_block_size = ROUND_UP_TO_CACHE_LINE_SIZE(block_size); const size_t num_blocks = args.num_buffer_items; cxxporthelper::aligned_memory<uint8_t> buffer_pool; if (!args.deferred_buffer_alloc) { // allocate memory pool buffer_pool.allocate(cache_aligned_block_size * num_blocks, CXXPH_PLATFORM_CACHE_LINE_SIZE); if (!buffer_pool) return OSLMP_RESULT_MEMORY_ALLOCATION_FAILED; // setup queue int result = setupQueues(args, cache_aligned_block_size, &buffer_pool[0]); if (result != OSLMP_RESULT_SUCCESS) return result; } // update field buffer_pool_ = std::move(buffer_pool); init_args_ = args; cache_aligned_block_size_ = cache_aligned_block_size; initialized_ = true; last_consumer_tag_ = TAG_NONE; return OSLMP_RESULT_SUCCESS; }
bool setup() { // Initialize video if ( !setupVideo(pongInstance.videoDeviceName, VFRAME_WIDTH, VFRAME_HEIGHT)) { loge( "Failed to setup video" ); return false; } // Initialize MQs if ( !setupQueues() ) { loge( "Failed to setup queues" ); return false; } // No thread should be working right now keepWorking = false; log("setup completed."); return true; }