-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
945 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
Authors and copyright holders of this package in no particular order. By adding | ||
yourself to this list you agree to license your contributions under the | ||
relevant license (see the LICENSE file). | ||
All code and content in this project is Copyright © 2015-2022 Go Opus Authors | ||
|
||
Go Opus Authors and copyright holders of this package are listed below, in no | ||
particular order. By adding yourself to this list you agree to license your | ||
contributions under the relevant license (see the LICENSE file). | ||
|
||
Hraban Luyat <[email protected]> | ||
Dejian Xu <[email protected]> | ||
Tobias Wellnitz <[email protected]> | ||
Elinor Natanzon <[email protected]> | ||
Victor Gaydov <[email protected]> | ||
Randy Reddig <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
// Copyright © 2015, 2016 Authors (see AUTHORS file) | ||
// +build !nolibopusfile | ||
|
||
// Copyright © Go Opus Authors (see AUTHORS file) | ||
// | ||
// License for use of this code is detailed in the LICENSE file | ||
|
||
// Allocate callback struct in C to ensure it's not managed by the Go GC. This | ||
// plays nice with the CGo rules and avoids any confusion. | ||
|
||
#include <opusfile.h> | ||
#include <stdint.h> | ||
|
||
// Defined in Go. Uses the same signature as Go, no need for proxy function. | ||
int go_readcallback(void *p, unsigned char *buf, int nbytes); | ||
|
||
// Allocated once, never moved. Pointer to this is safe for passing around | ||
// between Go and C. | ||
struct OpusFileCallbacks callbacks = { | ||
static struct OpusFileCallbacks callbacks = { | ||
.read = go_readcallback, | ||
}; | ||
|
||
// Proxy function for op_open_callbacks, because it takes a void * context but | ||
// we want to pass it non-pointer data, namely an arbitrary uintptr_t | ||
// value. This is legal C, but go test -race (-d=checkptr) complains anyway. So | ||
// we have this wrapper function to shush it. | ||
// https://groups.google.com/g/golang-nuts/c/995uZyRPKlU | ||
OggOpusFile * | ||
my_open_callbacks(uintptr_t p, int *error) | ||
{ | ||
return op_open_callbacks((void *)p, &callbacks, NULL, 0, error); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.