aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Input/in_flac/FLACFileCallbacks.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/Input/in_flac/FLACFileCallbacks.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/Plugins/Input/in_flac/FLACFileCallbacks.cpp')
-rw-r--r--Src/Plugins/Input/in_flac/FLACFileCallbacks.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/Src/Plugins/Input/in_flac/FLACFileCallbacks.cpp b/Src/Plugins/Input/in_flac/FLACFileCallbacks.cpp
new file mode 100644
index 00000000..23a53b91
--- /dev/null
+++ b/Src/Plugins/Input/in_flac/FLACFileCallbacks.cpp
@@ -0,0 +1,57 @@
+#include "FLACFileCallbacks.h"
+
+
+FLAC__StreamDecoderReadStatus FLAC_NXFile_Read(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
+{
+ nx_file_t file = FLAC_GetFile(client_data);
+ size_t bytes_to_read = *bytes;
+ size_t bytes_read=0;
+ ns_error_t ret = NXFileRead(file, buffer, bytes_to_read, &bytes_read);
+ *bytes = bytes_read;
+
+ if (ret == NErr_EndOfFile)
+ return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
+
+ if (ret != NErr_Success)
+ return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
+
+ return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
+}
+
+FLAC__StreamDecoderSeekStatus FLAC_NXFile_Seek(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
+{
+ nx_file_t file = FLAC_GetFile(client_data);
+ if (NXFileSeek(file, absolute_byte_offset) == NErr_Success)
+ return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
+ else
+ return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
+}
+
+FLAC__StreamDecoderTellStatus FLAC_NXFile_Tell(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
+{
+ nx_file_t file = FLAC_GetFile(client_data);
+
+ if (NXFileTell(file, absolute_byte_offset) == NErr_Success)
+ return FLAC__STREAM_DECODER_TELL_STATUS_OK;
+ else
+ return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
+}
+
+FLAC__StreamDecoderLengthStatus FLAC_NXFile_Length(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
+{
+ nx_file_t file = FLAC_GetFile(client_data);
+
+ if (NXFileLength(file, stream_length) == NErr_Success)
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
+ else
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
+}
+
+FLAC__bool FLAC_NXFile_EOF(const FLAC__StreamDecoder *decoder, void *client_data)
+{
+ nx_file_t file = FLAC_GetFile(client_data);
+ if (NXFileEndOfFile(file) == NErr_False)
+ return false;
+ else
+ return true;
+}