// Spam 10+ different entries lots of times, to fill cache with high count // entries void spamLog3(uint64_t& time, int diff) { for (int i=0; i<100; ++i) { time += diff; LOGBT(warning, "Failed to talk to node 1", "Failed to send message to node 0x1: NOT CONNECTED"); time += diff; LOGBT(warning, "Failed to talk to node 2", "Failed to send message to node 0x2: NOT_READY"); time += diff; LOGBT(warning, "Failed to talk to node 3", "Failed to send message to node 0x3: BAAAH"); time += diff; LOGBT(warning, "Failed to talk to node 4", "Failed to send message to node 0x4: RPC FAILURE"); time += diff; LOGBT(warning, "Failed to talk to node 5", "Failed to send message to node 0x5: COSMIC RADIATION"); time += diff; LOGBT(warning, "Failed to talk to node 6", "Failed to send message to node 0x6: ITS SATURDAY"); time += diff; LOGBT(warning, "Failed to talk to node 7", "Failed to send message to node 0x7: Yeah, Right!!"); time += diff; LOGBT(error, "Failed to talk to node 8", "Failed to send message to node 0x8: NOT CONNECTED"); time += diff; LOGBT(info, "Failed to talk to node 9", "Failed to send message to node 0x9: NOT CONNECTED"); time += diff; LOGBT(warning, "Failed to talk to node 10", "Failed to send message to node 0xa: NOT CONNECTED"); } }
static int mtk_asoc_pcm_btcvsd_rx_new(struct snd_soc_pcm_runtime *rtd) { int ret = 0; LOGBT("%s\n", __func__); return ret; }
static int mtk_pcm_btcvsd_rx_silence(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { LOGBT("%s\n", __func__); return 0; /* do nothing */ }
void testThatEntriesWithHighCountIsKept(const std::string& file, uint64_t& timer) { std::cerr << "testThatEntriesWithHighCountIsKept ...\n"; timer = 10 * 1000000 + 4; LOGBM(info, "Starting up, using logfile %s", file.c_str()); timer = 100 * 1000000 + 4; LOGBT(warning, "Token", "message"); spamLog1(timer, 1); spamLog2(timer, 1); spamLog1(timer, 1); LOGB_FLUSH(); std::string result(readFile(file)); std::string expected(readFile("bufferedlogtest.highcountkept.log")); if (result != expected) { std::cerr << "Failed testThatEntriesWithHighCountIsKept\n"; system(("diff -u " + file + " bufferedlogtest.highcountkept.log") .c_str()); exit(EXIT_FAILURE); } unlink(file.c_str()); }
void testThatHighCountEntriesDontStarveOthers( const std::string& file, uint64_t& timer) { std::cerr << "testThatHighCountEntriesDontStarveOthers ...\n"; timer = 10 * 1000000 + 4; // Long time out, we don't want to rely on timeout to prevent starvation ns_log::BufferedLogger::logger.setMaxEntryAge(12000000); // Let counts count much, so they score high ns_log::BufferedLogger::logger.setCountFactor(100000); LOGBM(info, "Starting up, using logfile %s", file.c_str()); timer = 100 * 1000000; LOGBT(warning, "Token", "message"); spamLog3(timer, 1); spamLog1(timer, 1); LOGB_FLUSH(); std::string result(readFile(file)); std::string expected(readFile("bufferedlogtest.nostarve.log")); if (result != expected) { std::cerr << "Failed " << "testThatHighCountEntriesDontStarveOthers\n"; system(("diff -u " + file + " bufferedlogtest.nostarve.log").c_str()); exit(EXIT_FAILURE); } unlink(file.c_str()); }
void testThatEntriesExpire( const std::string& file, uint64_t& timer) { std::cerr << "testThatEntriesExpire ...\n"; // Test that we don't keep entries longer than max age timer = 10 * 1000000 + 4; // Time out after 120 seconds ns_log::BufferedLogger::logger.setMaxEntryAge(120); // Let counts count much, so they expire due to time instead ns_log::BufferedLogger::logger.setCountFactor(100000); LOGBM(info, "Starting up, using logfile %s", file.c_str()); timer = 100 * 1000000 + 4; LOGBT(warning, "Token", "message"); spamLog1(timer, 1); spamLog2(timer, 10 * 1000000); spamLog1(timer, 1); LOGB_FLUSH(); std::string result(readFile(file)); std::string expected(readFile("bufferedlogtest.expire.log")); if (result != expected) { std::cerr << "Failed " << "testThatEntriesExpire\n"; system(("diff -u " + file + " bufferedlogtest.expire.log").c_str()); exit(EXIT_FAILURE); } unlink(file.c_str()); }
void testThatEntriesWithHighCountsAreEventuallyRemoved( const std::string& file, uint64_t& timer) { std::cerr << "testThatEntriesWithHighCountsAreEventuallyRemoved ...\n"; // Same as above, just increase timer more between each log entry. // Should eventually throw out the entries with high count timer = 10 * 1000000 + 4; // Make sure we don't remove due to age. ns_log::BufferedLogger::logger.setMaxEntryAge(1000000); // Let each count, count for 5 seconds. ns_log::BufferedLogger::logger.setCountFactor(5); LOGBM(info, "Starting up, using logfile %s", file.c_str()); timer = 100 * 1000000 + 4; LOGBT(warning, "Token", "message"); spamLog1(timer, 1); spamLog2(timer, 10 * 1000000); spamLog1(timer, 1); LOGB_FLUSH(); std::string result(readFile(file)); std::string expected(readFile("bufferedlogtest.highcountexpire.log")); if (result != expected) { std::cerr << "Failed " << "testThatEntriesWithHighCountsAreEventuallyRemoved\n"; system(("diff -u " + file + " bufferedlogtest.highcountexpire.log") .c_str()); exit(EXIT_FAILURE); } unlink(file.c_str()); }
static void InquiryComplete() { { CriticalSectionHandler csh(&gBt.critSec); LOGBT("Discovery done\n"); setDiscoveryState(gBt.devices.size() + 1); } gBt.deviceCallback(); }
void spamLog2(uint64_t& time, int diff) { for (int i=0; i<100; ++i) { time += diff; std::ostringstream ost; ost << "Message " << i; LOGBT(info, ost.str(), "%s", ost.str().c_str()); } }
static snd_pcm_uframes_t mtk_pcm_btcvsd_rx_pointer(struct snd_pcm_substream *substream) { kal_uint32 byte = 0; kal_uint32 Frameidx = 0; unsigned long flags; /* struct snd_pcm_runtime *runtime = substream->runtime; */ LOGBT("%s\n", __func__); spin_lock_irqsave(&auddrv_btcvsd_rx_lock, flags); #if 0 /* kernel time testing */ do_gettimeofday(&begin_rx); diff_msec_rx = (begin_rx.tv_sec - prev_sec_rx) * 1000 + (begin_rx.tv_usec - prev_usec_rx) / 1000; LOGBT("%s, tv_sec=%d, tv_usec=%ld, diff_msec=%ld, prev_sec=%d, prev_usec=%ld\n", __func__, (int)(begin_rx.tv_sec), begin_rx.tv_usec, diff_msec_rx, prev_sec_rx, prev_usec_rx); prev_sec_rx = begin_rx.tv_sec; prev_usec_rx = begin_rx.tv_usec; /* calculate cheating byte */ byte = (diff_msec_rx * substream->runtime->rate * substream->runtime->channels / 1000); Frameidx = audio_bytes_to_frame(substream , byte); LOGBT("%s, ch=%d, rate=%d, byte=%d, Frameidx=%d\n", __func__, substream->runtime->channels, substream->runtime->rate, byte, Frameidx); #else /* get total bytes to copy */ /* Frameidx = audio_bytes_to_frame(substream , Afe_Block->u4DMAReadIdx); */ /* return Frameidx; */ byte = (btsco.pRX->iPacket_w & SCO_RX_PACKET_MASK)* (SCO_RX_PLC_SIZE + BTSCO_CVSD_PACKET_VALID_SIZE); Frameidx = audio_bytes_to_frame(substream , byte); #endif spin_unlock_irqrestore(&auddrv_btcvsd_rx_lock, flags); return Frameidx; }
static int mtk_pcm_btcvsd_rx_hw_free(struct snd_pcm_substream *substream) { LOGBT("%s\n", __func__); if (BT_CVSD_Mem.RX_btcvsd_dma_buf->area) return 0; else return snd_pcm_lib_free_pages(substream); return 0; }
static int mtk_pcm_btcvsd_rx_copy(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count) { /* get total bytes to copy */ char *Read_Data_Ptr = (char *)dst; count = audio_frame_to_bytes(substream , count); count = Align64ByteSize(count); AudDrv_btcvsd_read(Read_Data_Ptr, count); LOGBT("pcm_copy return\n"); return 0; }
static int mtk_pcm_btcvsd_rx_trigger(struct snd_pcm_substream *substream, int cmd) { LOGBT("%s\n", __func__); switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: return mtk_pcm_btcvsd_rx_start(substream); case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: return mtk_pcm_btcvsd_rx_stop(substream); } return -EINVAL; }
static void InquiryResult(BTDEVHDL dev_hdl) { BtDevice dev; BTUINT32 dev_class; BST(Btsdk_GetRemoteDeviceClass(dev_hdl, &dev_class)); BtSdkRemoteDevicePropertyStru props; BST(Btsdk_GetRemoteDeviceProperty(dev_hdl, &props)); byte nameBuf[256]; WORD len = sizeof(nameBuf); BST(Btsdk_GetRemoteDeviceName(dev_hdl, nameBuf, &len)); dev.name = (char*)nameBuf; BST(Btsdk_GetRemoteDeviceAddress(dev_hdl, dev.address.a)); { CriticalSectionHandler csh(&gBt.critSec); LOGBT("d%i: \"%s\" (%s)\n", gBt.devices.size(), dev.name.c_str(), btaddr2string(dev.addr)); gBt.devices.push_back(dev); } gBt.deviceCallback(); }
static int mtk_btcvsd_rx_remove(struct platform_device *pdev) { LOGBT("%s\n", __func__); snd_soc_unregister_platform(&pdev->dev); return 0; }
void spamLog1(uint64_t& time, int diff) { for (int i=0; i<100; ++i) { time += diff; LOGBT(warning, "Failed to send to node 4", "Failed to send message to node 4: NOT CONNECTED"); time += diff; LOGBT(warning, "Failed to send to node 4", "Failed to send message to node 4: NOT_READY"); time += diff; LOGBT(warning, "Failed to send to node 4", "Failed to send message to node 4: BAAAH"); time += diff; LOGBT(warning, "Failed to send to node 4", "Failed to send message to node 4: RPC FAILURE"); time += diff; LOGBT(warning, "Failed to send to node 4", "Failed to send message to node 4: COSMIC RADIATION"); time += diff; LOGBT(warning, "Failed to send to node 4", "Failed to send message to node 4: ITS SATURDAY"); time += diff; LOGBT(warning, "Failed to send to node 4", "Failed to send message to node 4: Yeah, Right!!"); time += diff; LOGBT(error, "Failed to send to node 4", "Failed to send message to node 4: NOT CONNECTED"); time += diff; LOGBT(spam, "Failed to send to node 4", "Failed to send message to node 4: NOT CONNECTED"); time += diff; LOGBT(warning, "Failed to send to node 4", "Failed to send message to node 4: NOT CONNECTED"); time += diff * 10; LOGBT(warning, "Failed to send to node 3", "Failed to send message to node 3: NOT CONNECTED"); } }