{"action":"created","issue":{"url":"https://api.github.com/repos/muhku/FreeStreamer/issues/231","labels_url":"https://api.github.com/repos/muhku/FreeStreamer/issues/231/labels{/name}","comments_url":"https://api.github.com/repos/muhku/FreeStreamer/issues/231/comments","events_url":"https://api.github.com/repos/muhku/FreeStreamer/issues/231/events","html_url":"https://github.com/muhku/FreeStreamer/issues/231","id":122896287,"number":231,"title":"some  deficiency   ，i hope  i can  learn more about it   here, thanks","user":{"login":"zhangshijian","id":12208334,"avatar_url":"https://avatars.githubusercontent.com/u/12208334?v=3","gravatar_id":"","url":"https://api.github.com/users/zhangshijian","html_url":"https://github.com/zhangshijian","followers_url":"https://api.github.com/users/zhangshijian/followers","following_url":"https://api.github.com/users/zhangshijian/following{/other_user}","gists_url":"https://api.github.com/users/zhangshijian/gists{/gist_id}","starred_url":"https://api.github.com/users/zhangshijian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhangshijian/subscriptions","organizations_url":"https://api.github.com/users/zhangshijian/orgs","repos_url":"https://api.github.com/users/zhangshijian/repos","events_url":"https://api.github.com/users/zhangshijian/events{/privacy}","received_events_url":"https://api.github.com/users/zhangshijian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-18T07:25:30Z","updated_at":"2015-12-18T07:29:42Z","closed_at":null,"body":"Hi，muhku,  FreeStream  is so great。  I admired you  so much  ,  But  i  rencently  use it   , i find some deficiency  .   I was a beginner,  And  Describe the problem is not clear，forgive me。(my  english is not good).    \r\nwhen i  use   seekToPosition:       \r\n\r\nlog it : \r\n\r\nvoid Audio_Stream::seekToOffset(float offset)\r\n{\r\n    if (state() != PLAYING) {\r\n        // Do not allow seeking if we are not currently playing the stream\r\n        // This allows a previous seek to be completed\r\n        return;\r\n    }\r\n    \r\n    m_inputStream->setScheduledInRunLoop(false);\r\n    \r\n    // Close the audio queue so that it won't ask any more data\r\n    closeAudioQueue();\r\n    \r\n    setState(SEEKING);\r\n    \r\n    Input_Stream_Position position = streamPositionForOffset(offset);\r\n    \r\n    if (position.start == 0 && position.end == 0) {\r\n        closeAndSignalError(AS_ERR_NETWORK, CFSTR(\"Failed to retrieve seeking position\"));\r\n        return;\r\n    }\r\n    \r\n    UInt64 originalContentLength = m_contentLength;\r\n    \r\n    const float duration = durationInSeconds();\r\n    const double packetDuration = m_srcFormat.mFramesPerPacket / m_srcFormat.mSampleRate;\r\n    \r\n    printf(\"22222222222222\\t\");\r\n    \r\n    if (packetDuration > 0) {\r\n        UInt32 ioFlags = 0;\r\n        SInt64 packetAlignedByteOffset;\r\n        SInt64 seekPacket = floor((duration * offset) / packetDuration);\r\n        \r\n        m_packetIdentifier = seekPacket;\r\n        \r\n        OSStatus err = AudioFileStreamSeek(m_audioFileStream, seekPacket, &packetAlignedByteOffset, &ioFlags);\r\n        if (!err) {\r\n            position.start = packetAlignedByteOffset + m_dataOffset;\r\n            \r\n            printf(\"111111111111111\\t\");\r\n            \r\n        } else {\r\n            closeAndSignalError(AS_ERR_NETWORK, CFSTR(\"Failed to calculate seeking position\"));\r\n            return;\r\n        }\r\n    } else {\r\n        closeAndSignalError(AS_ERR_NETWORK, CFSTR(\"Failed to calculate seeking position\"));\r\n        return;\r\n    }\r\n    \r\n    Stream_Configuration *config = Stream_Configuration::configuration();\r\n    \r\n    // Do a cache lookup if we can find the seeked packet from the cache and no need to\r\n    // open the stream from the new position\r\n    bool foundCachedPacket = false;\r\n    queued_packet_t *seekPacket = 0;\r\n    \r\n    if (config->seekingFromCacheEnabled) {\r\n        queued_packet_t *cur = m_queuedHead;\r\n        while (cur) {\r\n            if (cur->identifier == m_packetIdentifier) {\r\n                foundCachedPacket = true;\r\n                seekPacket = cur;\r\n                break;\r\n            }\r\n            \r\n            queued_packet_t *tmp = cur->next;\r\n            cur = tmp;\r\n        }\r\n    } else {\r\n        AS_TRACE(\"Seeking from cache disabled\\n\");\r\n    }\r\n    \r\n    if (!foundCachedPacket) {\r\n        AS_TRACE(\"Seeked packet not found from cache, reopening the input stream\\n\");\r\n        \r\n        // Close but keep the stream parser running\r\n        close(false);\r\n        \r\n        m_bytesReceived = 0;\r\n        m_bounceCount = 0;\r\n        m_firstBufferingTime = 0;\r\n        m_bitrateBufferIndex = 0;\r\n        m_initializationError = noErr;\r\n        m_converterRunOutOfData = false;\r\n        m_discontinuity = true;\r\n\r\n        bool success = m_inputStream->open(position);\r\n        \r\n        if (success) {\r\n            setSeekOffset(offset);\r\n            setContentLength(originalContentLength);\r\n            \r\n            m_inputStreamRunning = true;\r\n\r\n        } else {\r\n            closeAndSignalError(AS_ERR_OPEN, CFSTR(\"Input stream open error\"));\r\n            return;\r\n        }\r\n    } else {\r\n        AS_TRACE(\"Seeked packet found from cache!\\n\");\r\n        \r\n        // Found the packet from the cache, let's use the cache directly.\r\n        \r\n        m_playPacket    = seekPacket;\r\n        m_discontinuity = true;\r\n        \r\n        setSeekOffset(offset);\r\n    }\r\n    \r\n    audioQueue()->init();\r\n    \r\n    setState(BUFFERING);\r\n    \r\n    m_inputStream->setScheduledInRunLoop(true);\r\n}\r\n\r\nthe  console   printf   ：\"22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t22222222222222\t111111111111111\t  ...... \"      Has been circulating。    i  dont  konw  why   , please   help me   thanks  !"},"comment":{"url":"https://api.github.com/repos/muhku/FreeStreamer/issues/comments/165700978","html_url":"https://github.com/muhku/FreeStreamer/issues/231#issuecomment-165700978","issue_url":"https://api.github.com/repos/muhku/FreeStreamer/issues/231","id":165700978,"user":{"login":"zhangshijian","id":12208334,"avatar_url":"https://avatars.githubusercontent.com/u/12208334?v=3","gravatar_id":"","url":"https://api.github.com/users/zhangshijian","html_url":"https://github.com/zhangshijian","followers_url":"https://api.github.com/users/zhangshijian/followers","following_url":"https://api.github.com/users/zhangshijian/following{/other_user}","gists_url":"https://api.github.com/users/zhangshijian/gists{/gist_id}","starred_url":"https://api.github.com/users/zhangshijian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhangshijian/subscriptions","organizations_url":"https://api.github.com/users/zhangshijian/orgs","repos_url":"https://api.github.com/users/zhangshijian/repos","events_url":"https://api.github.com/users/zhangshijian/events{/privacy}","received_events_url":"https://api.github.com/users/zhangshijian/received_events","type":"User","site_admin":false},"created_at":"2015-12-18T07:29:42Z","updated_at":"2015-12-18T07:29:42Z","body":"if  FreeStream  work well  ， it  will   Run the method once，  but   sometime   will be  circulating。  "}}