Skip to content

Commit

Permalink
Merge to master (#9)
Browse files Browse the repository at this point in the history
* Update python-build-test.yml

* Update python-publish.yml

* fix: time measure

* Update utils.py

* Update codec.cpp
  • Loading branch information
wyapx authored Apr 26, 2022
1 parent ad9eb95 commit 276e403
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/python-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
branches: [ master, dev ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package
name: Publish to pypi

on:
release:
Expand All @@ -17,7 +17,7 @@ jobs:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

Expand All @@ -39,6 +39,7 @@ jobs:
with:
fetch-depth: 0 # Optional, use if you use setuptools_scm
submodules: true # Optional, use if you have submodules

- name: Build SDist
run: pipx run build --sdist

Expand Down
2 changes: 1 addition & 1 deletion src/pysilk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def log(*content_args):
f.write(decode_file(source, to_wav=args.output == "wav"))
else:
print("Unknown operation:", i_suffix, "to", o_suffix)
log(f"done, {round(time.time() - st, 2)}ms used")
log(f"done, {round((time.time() - st) * 1000, 2)}ms used")
5 changes: 4 additions & 1 deletion src/pysilk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

def is_silk_data(raw: bytes) -> bool:
if len(raw) > 10:
if raw[:10] == b"\x02#!SILK_V3":
offset = 0
if raw[0] == 2:
offset = 1
if raw[offset:10] == b"#!SILK_V3":
return True
return False

Expand Down
11 changes: 8 additions & 3 deletions src/silk/codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,13 @@ silkDecode(unsigned char *silkData, int dataLen,
SKP_SILK_SDK_DecControlStruct DecControl;

/* Check Silk header */
if (strncmp((char *) psRead, "\x02#!SILK_V3", 0x0A) != 0)
goto failed;
if (psRead[0] == 0x02) {
if (strncmp((char *) psRead, "\x02#!SILK_V3", 0x0A) != 0)
goto failed;
} else {
if (strncmp((char *) psRead, "#!SILK_V3", 0x09) != 0)
goto failed;
}

psRead += 0x0A;

Expand Down Expand Up @@ -286,4 +291,4 @@ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************/
***********************************************************************/

0 comments on commit 276e403

Please sign in to comment.